diff -u --recursive --new-file v2.4.9/linux/CREDITS linux/CREDITS
--- v2.4.9/linux/CREDITS	Mon Aug 27 12:41:37 2001
+++ linux/CREDITS	Sun Sep  9 10:43:02 2001
@@ -400,13 +400,12 @@
 S: USA
 
 N: Peter Braam
-E: braam@cs.cmu.edu
-W: http://coda.cs.cmu.edu/~braam
-D: Coda Filesystem
-S: Dept of Computer Science
-S: 5000 Forbes Avenue
-S: Pittsburgh, Pennsylvania 15213
-S: USA
+E: braam@clusterfs.com
+W: http://www.clusterfs.com/
+D: Coda & InterMezzo filesystems
+S: 181 McNeil
+S: Canmore, AB
+S: Canada, T1W 2R9
 
 N: Ryan Bradetich
 E: rbradetich@uswest.net
@@ -535,6 +534,12 @@
 S: Stanford, California 94305
 S: USA
 
+N: Randolph Chung
+E: tausq@debian.org
+D: Linux/PA-RISC hacker
+S: Fremont, CA 94538
+S: USA
+
 N: Juan Jose Ciarlante
 W: http://juanjox.kernelnotes.org/
 E: jjciarla@raiz.uncu.edu.ar
@@ -633,10 +638,11 @@
 S: USA
 
 N: Frank Davis
+E: fdavis@si.rr.com
 E: fdavis112@juno.com
 D: Various kernel patches
 S: 8 Lakeview Terr.
-S: Kerhonskon, NY 12446
+S: Kerhonkson, NY 12446
 S: USA
 
 N: Wayne Davison
@@ -714,7 +720,7 @@
 N: Oleg Drokin
 E: green@ccssu.crimea.ua
 W: http://www.ccssu.crimea.ua/~green
-D: Cleaning up sound drivers.
+D: Cleaning up sound drivers, SA1100 Watchdog.
 S: Skvoznoy per., 14a
 S: Evpatoria
 S: Crimea
diff -u --recursive --new-file v2.4.9/linux/Documentation/00-INDEX linux/Documentation/00-INDEX
--- v2.4.9/linux/Documentation/00-INDEX	Thu Feb  8 16:32:44 2001
+++ linux/Documentation/00-INDEX	Mon Aug 27 07:44:15 2001
@@ -5,6 +5,11 @@
 Please try and keep the descriptions small enough to fit on one line.
 							 Thanks -- Paul G.
 
+Following translations are available on the WWW:
+
+   - Japanese, maintained by the JF Project (JF@linux.or.jp), at
+     http://www.linux.or.jp/JF/
+
 00-INDEX
 	- this file.
 BUG-HUNTING
diff -u --recursive --new-file v2.4.9/linux/Documentation/CodingStyle linux/Documentation/CodingStyle
--- v2.4.9/linux/Documentation/CodingStyle	Wed Sep 29 13:59:12 1999
+++ linux/Documentation/CodingStyle	Sun Sep  9 16:40:43 2001
@@ -233,3 +233,34 @@
 stable. All options that are known to trash data (experimental write-
 support for file-systems, for instance) should be denoted (DANGEROUS), other
 Experimental options should be denoted (EXPERIMENTAL).
+
+
+		Chapter 8: Data structures
+
+Data structures that have visibility outside the single-threaded
+environment they are created and destroyed in should always have
+reference counts.  In the kernel, garbage collection doesn't exist (and
+outside the kernel garbage collection is slow and inefficient), which
+means that you absolutely _have_ to reference count all your uses. 
+
+Reference counting means that you can avoid locking, and allows multiple
+users to have access to the data structure in parallel - and not having
+to worry about the structure suddenly going away from under them just
+because they slept or did something else for a while. 
+
+Note that locking is _not_ a replacement for reference counting. 
+Locking is used to keep data structures coherent, while reference
+counting is a memory management technique.  Usually both are needed, and
+they are not to be confused with each other.
+
+Many data structures can indeed have two levels of reference counting,
+when there are users of different "classes".  The subclass count counts
+the number of subclass users, and decrements the global count just once
+when the subclass count goes to zero.
+
+Examples of this kind of "multi-reference-counting" can be found in
+memory management ("struct mm_struct": mm_users and mm_count), and in
+filesystem code ("struct super_block": s_count and s_active).
+
+Remember: if another thread can find your data structure, and you don't
+have a reference count on it, you almost certainly have a bug.
diff -u --recursive --new-file v2.4.9/linux/Documentation/Configure.help linux/Documentation/Configure.help
--- v2.4.9/linux/Documentation/Configure.help	Mon Aug 27 12:41:37 2001
+++ linux/Documentation/Configure.help	Sat Sep  8 12:39:33 2001
@@ -1746,6 +1746,36 @@
   similar) CPU, R4xx0 might be a safe bet.
   If the resulting Kernel does not work try to recompile with R3000.
 
+CPU type
+CONFIG_CPU_VR41XX
+  The options selects support for the NEC VR41xx series of processors.
+  Only choose this option if you have one of these processors as a
+  kernel built with this option will not run on any other type of
+  processor or vice versa.
+
+CPU feature configuration
+CONFIG_CPU_ADVANCED
+  Saying yes here allows you to select support for various features your
+  CPU may or may not have.  Most people should say N here.
+
+ll and sc instructions
+CONFIG_CPU_HAS_LLSC
+  Say Y here if your CPU has the ll and sc instructions.  Say Y here for
+  better performance, N if you don't know.  You must say Y here for
+  multiprocessor machines.
+
+lld and scd instructions
+CONFIG_CPU_HAS_LLDSCD
+  Say Y here if your CPU has the lld and scd instructions, the 64-bit
+  equivalents of ll and sc.  Say Y here for better performance, N if
+  you don't know.  You must say Y here for multiprocessor machines.
+
+Support for writebuffer flushing
+CONFIG_CPU_HAS_WB
+  Say N here for slightly better performance.  You must say Y here for
+  machines which require flushing of write buffers in software.  Saying
+  Y is the safe option; N may result in kernel malfunction and crashes.
+
 Support for large 64-bit configurations
 CONFIG_MIPS_INSANE_LARGE
   MIPS R10000 does support a 44 bit / 16TB address space as opposed to
@@ -11478,6 +11508,45 @@
   The module will be called pegasus.o. If you want to compile it as a
   module, say M here and read Documentation/modules.txt.
 
+CONFIG_USB_KAWETH
+  Say Y here if you want to use one of the following 10Mbps only
+  USB Ethernet adapters based on the KLSI KL5KUSB101B chipset:
+       3Com 3C19250
+       ADS USB-10BT
+       ATEN USB Ethernet
+       ASANTE USB To Ethernet Adapter
+       AOX Endpoints USB Ethernet
+       Correga K.K.
+       D-Link DSB-650C and DU-E10
+       Entrega / Portgear E45
+       I-O DATA USB-ET/T
+       Jaton USB Ethernet Device Adapter
+       Kingston Technology USB Ethernet Adapter
+       Linksys USB10T
+       Mobility USB-Ethernet Adapter
+        NetGear EA-101
+       Peracom Enet and Enet2
+       Portsmith Express Ethernet Adapter
+       Shark Pocket Adapter
+       SMC 2202USB
+       Sony Vaio port extender
+
+  This driver is likely to work with most 10Mbps only USB Ethernet
+  adapters, including some "no brand" devices. It does NOT work on
+  SmartBridges smartNIC or on Belkin F5U111 devices - you should use
+  the CATC NetMate driver for those. If you are not sure which one
+  you need, select both, and the correct one should be selected for
+  you.
+
+  This driver makes the adapter appear as a normal Ethernet interface,
+  typically on eth0, if it is the only ethernet device, or perhaps on
+  eth1, if you have a PCI or ISA ethernet card installed.
+
+  This code 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 kaweth.o. If you want to compile it as a
+  module, say M here and read <file:Documentation/modules.txt>.
+
 USB CATC NetMate-based Ethernet device support
 CONFIG_USB_CATC
   Say Y if you want to use one of the following 10Mbps USB Ethernet
@@ -11532,6 +11601,20 @@
   Say Y here in order to have the USB Mass Storage code generate
   verbose debugging messages.
 
+ISD-200 USB/ATA driver
+CONFIG_USB_STORAGE_ISD200
+  Say Y here if you want to use USB Mass Store devices based
+  on the In-Systems Design ISD-200 USB/ATA bridge.
+
+  Some of the products that use this chip are:
+
+    - Archos Jukebox 6000
+    - ISD SmartCable for Storage
+    - Taiwan Skymaster CD530U/DEL-0241 IDE bridge
+    - Sony CRX10U CD-R/RW drive
+    - CyQ've CQ8060A CDRW drive
+    - Planex eXtreme Drive RX-25HU USB-IDE cable (not model RX-25U)
+
 USS720 parport driver
 CONFIG_USB_USS720
   This driver is for USB parallel port adapters that use the Lucent
@@ -11604,18 +11687,22 @@
   The module will be called dabusb.o. If you want to compile it as a
   module, say M here and read Documentation/modules.txt.
 
-PLUSB driver
-CONFIG_USB_PLUSB
-  A driver for the Prolific PL-2302 USB-to-USB network device. This
-  'USB cable' connects two hosts via a point-to-point network with
-  bandwidth of 5 Mbit/s. Configure this driver after connecting the
-  USB cable via ifconfig plusb0 10.0.0.1 pointopoint 10.0.0.2 (and
-  vice versa on the other host).
+Host-to-Host USB networking
+CONFIG_USB_USBNET
+  This driver supports network links over USB with USB "Network"
+  or "data transfer" cables, often used to network laptops to PCs.
+  Such cables have chips from suppliers such as NetChip and Prolific.
+  Intelligent USB devices could also use this approach to provide
+  Internet access, using standard USB cabling.
+
+  These links will have names like "usb0", "usb1", etc.  They act
+  like two-node Ethernets, so you can use 802.1d Ethernet Bridging
+  (CONFIG_BRIDGE) to simplify your network routing.
 
-  This code is also available as a module ( = code which can be
+  This code is also available as a kernel module (code which can be
   inserted in and removed from the running kernel whenever you want).
-  The module will be called plusb.o. If you want to compile it as a
-  module, say M here and read Documentation/modules.txt.
+  The module will be called usbnet.o. If you want to compile it as a
+  module, say M here and read <file:Documentation/modules.txt>.
 
 USB Diamond Rio500 support
 CONFIG_USB_RIO500
@@ -15754,6 +15841,14 @@
   better 32 MB RAM to avoid excessive linking time. This is only
   useful for kernel hackers. If unsure, say N.
 
+Run uncached
+CONFIG_MIPS_UNCACHED
+  If you say Y here there kernel will disable all CPU caches.  This will
+  reduce the system's performance dramatically but can help finding
+  otherwise hard to track bugs.  It can also useful if you're doing
+  hardware debugging with a logic analyzer and need to see all traffic
+  on the bus.
+
 Magic System Request Key support
 CONFIG_MAGIC_SYSRQ
   If you say Y here, you will have some control over the system even
@@ -16960,12 +17055,12 @@
 
 Motorola MPC8260 CPM support
 CONFIG_8260
-   The MPC8260 CPM (Communications Processor Module) is a typically
-   embedded CPU made by Motorola.  Selecting this option means that
-   you wish to build a kernel for a machine with specifically an 8260
-   for a CPU.
+  The MPC8260 CPM (Communications Processor Module) is a typical
+  embedded CPU made by Motorola. Selecting this option means that you
+  wish to build a kernel for a machine with specifically an 8260 for
+  a CPU.
 
-   If in doubt, say N.
+  If in doubt, say N.
 
 Workarounds for PPC601 bugs
 CONFIG_PPC601_SYNC_FIX
@@ -16983,11 +17078,190 @@
 CONFIG_ALL_PPC
   Linux currently supports several different kinds of PowerPC-based
   machines: Apple Power Macintoshes and clones (such as the Motorola
-  Starmax series), PReP (PowerPC Reference Platform) machines such as
-  the Motorola PowerStack, CHRP (Common Hardware Reference Platform), 
-  the embedded MBX boards from Motorola and many others. Currently, 
-  the default option is to build a kernel which works on the first 
-  three.  Support for other machines is currently incomplete.
+  Starmax series), PReP (PowerPC Reference Platform) machines (such
+  as the Motorola PowerStacks, Motorola cPCI/VME embedded systems,
+  and some IBM RS/6000 systems), CHRP (Common Hardware Reference
+  Platform), and several embedded PowerPC systems containing 4xx, 6xx,
+  7xx, 8xx, 74xx, and 82xx processors.  Currently, the default option
+  is to build a kernel which works on the first three. 
+
+Embedded 8xx Board Type
+CONFIG_RPXLITE
+  RPX-Lite:
+    Embedded Planet RPX Lite
+
+  RPX-Classic:
+    Embedded Planet RPX Classic Low-fat.
+
+  BSE-IP: 
+    Bright Star Engineering ip-Engine.
+
+  TQM823L:
+  TQM850L:
+  TQM855L:
+  TQM860L:
+    MPC8xx based family of mini modules, half credit card size,
+    up to 64 MB of RAM, 8 MB Flash, (Fast) Ethernet, 2 x serial ports,
+    2 x CAN bus interface, ...
+      Manufacturer: TQ Components, www.tq-group.de
+      Date of Release: October (?) 1999
+      End of Life: not yet :-)
+      URL:
+      - module: http://www.denx.de/PDF/TQM8xxLHWM201.pdf
+      - starter kit: http://www.denx.de/PDF/STK8xxLHWM201.pdf
+      - images: http://www.denx.de/embedded-ppc-en.html
+
+  FPS850L:
+    FingerPrint Sensor System (based on TQM850L)
+      Manufacturer: IKENDI AG, http://www.ikendi.com/
+      Date of Release: November 1999
+      End of life: end 2000 ?
+      URL: see TQM850L
+
+  SPD823TS:
+    MPC823 based board used in the "Tele Server" product
+    Manufacturer: Speech Design, http://www.speech-design.de/
+    Date of Release: Mid 2000 (?)
+    End of life: -
+    URL: http://www.speech-design.de/
+         select "English", then "Teleteam Solutions", then "TeleServer"
+
+  IVMS8:
+    MPC860 based board used in the "Integrated Voice Mail System",
+    Small Version (8 voice channels)
+    Manufacturer: Speech Design, http://www.speech-design.de/
+    Date of Release: December 2000 (?)
+    End of life: -
+    URL: http://www.speech-design.de/
+
+  IVML24:
+    MPC860 based board used in the "Integrated Voice Mail System", 
+    Large Version (24 voice channels)
+    Manufacturer: Speech Design, http://www.speech-design.de/
+    Date of Release: March 2001  (?)
+    End of life: -
+    URL: http://www.speech-design.de/
+
+  SM850:
+    Service Module (based on TQM850L)
+    Manufacturer: Dependable Computer Systems, http://www.decomsys.com/
+    Date of Release: end 2000 (?)
+    End of life: mid 2001 (?)
+    URL: http://www.tz-mikroelektronik.de/ServiceModule/index.html
+
+  HERMES:
+    Hermes-Pro ISDN/LAN router with integrated 8 x hub
+    Manufacturer: Multidata Gesellschaft für Datentechnik und Informatik
+      http://www.multidata.de/
+    Date of Release: 2000 (?)
+    End of life: -
+    URL: http://www.multidata.de/english/products/hpro.htm
+
+  IP860:	
+    VMEBus IP (Industry Pack) carrier board with MPC860
+    Manufacturer: MicroSys GmbH, http://www.microsys.de/
+    Date of Release: ?
+    End of life: -
+    URL: http://www.microsys.de/html/ip860.html
+
+  PCU_E:
+    PCU = Peripheral Controller Unit, Extended
+    Manufacturer: Siemens AG, ICN (Information and Communication Networks)
+    	http://www.siemens.de/page/1,3771,224315-1-999_2_226207-0,00.html
+    Date of Release: April 2001
+    End of life: August 2001
+    URL: n. a.
+
+Embedded 82xx Board Type
+CONFIG_EST8260
+  EST8260: Wind River System, Inc. EST SBC8260
+
+  TQM8260:
+    MPC8260 based module, little larger than credit card,
+    up to 128 MB global + 64 MB local RAM, 32 MB Flash,
+    32 kB EEPROM, 256 kB L@ Cache, 10baseT + 100baseT Ethernet,
+    2 x serial ports, ...
+      Manufacturer: TQ Components, www.tq-group.de
+      Date of Release: June 2001
+      End of Life: not yet :-)
+      URL: http://www.denx.de/PDF/TQM82xx_SPEC_Rev005.pdf
+
+  PM826:
+    Modular system with MPC8260 CPU
+    Manufacturer: MicroSys GmbH, http://www.microsys.de/
+    Date of Release: mid 2001
+    End of life: -
+    URL: http://www.microsys.de/html/pm826.html
+
+  CU824:
+    VMEBus Board with PCI extension with MPC8240 CPU
+    Manufacturer: MicroSys GmbH, http://www.microsys.de/
+    Date of Release: early 2001 (?)
+    End of life: -
+    URL: http://www.microsys.de/html/cu824.html
+
+AltiVec Kernel Support
+CONFIG_ALTIVEC
+  This option enables kernel support for the Altivec extensions to the
+  PowerPC processor. The kernel currently supports saving and restoring
+  altivec registers, and turning on the 'altivec enable' bit so user
+  processes can execute altivec instructions.
+
+  This option is only usefully if you have a processor that supports 
+  altivec (G4, otherwise known as 74xx series), but does not have
+  any affect on a non-altivec cpu (it does, however add code to the
+  kernel).
+
+  If in doubt, say Y here.
+
+Thermal Management Support
+CONFIG_TAU
+  G3 and G4 processors have an on-chip temperature sensor called the
+  'Thermal Assist Unit (TAU)', which, in theory, can measure the on-die
+  temperature within 2-4 degrees celcius. This option shows the current
+  on-die temperature in /proc/cpuinfo if the cpu supports it.
+
+  Unfortunately, on some chip revisions, this sensor is very inaccurate
+  and in some cases, does not work at all, so don't assume the cpu
+  temp is actually what /proc/cpuinfo says it is.
+
+Interrupt driven TAU driver
+CONFIG_TAU_INT
+  The TAU supports an interrupt driven mode which causes an interrupt
+  whenever the temperature goes out of range. This is the fastest way
+  to get notified the temp has exceeded a range. With this option off,
+  a timer is used to re-check the temperature periodically.
+
+  However, on some cpus it appears that the TAU interrupt hardware
+  is buggy and can cause a situation which would lead unexplained hard
+  lockups.
+
+  Unless you are extending the TAU driver, or enjoy kernel/hardware
+  debugging, leave this option off.
+
+Average high and low temp
+CONFIG_TAU_AVERAGE
+  The TAU hardware can compare the temperature to an upper and lower bound.
+  The default behavior is to show both the upper and lower bound in 
+  /proc/cpuinfo. If the range is large, the temperature is either changing
+  a lot, or the TAU hardware is broken (likely on some G4's). If the range
+  is small (around 4 degrees), the temperature is relatively stable.
+
+Support for CUDA based PowerMacs
+CONFIG_ADB_CUDA
+  This provides support for CUDA based Power Macintosh systems.  This
+  includes most OldWorld PowerMacs, the first generation iMacs, the
+  Blue&White G3 and the Yikes G4 (PCI Graphics).  All later models
+  should use CONFIG_ADB_PMU instead.
+
+  If unsure say Y.
+
+Support for PMU based PowerMacs
+CONFIG_ADB_PMU
+  This provides support for PMU based Power Macintosh systems.  This
+  includes all PowerBooks and all AGP-based machines.
+  
+  If unsure say Y.
 
 Power management support for PowerBooks
 CONFIG_PMAC_PBOOK
@@ -17004,13 +17278,6 @@
   You may also want to compile the dma sound driver as a module and
   have it autoloaded. The act of removing the module shuts down the
   sound hardware for more power savings.
-
-Mac-on-Linux support
-CONFIG_MOL
-  This option enables low-level support for Mac-on-Linux.
-  MOL lets you run MacOS and Linux simultaneously. Please
-  visit <http://www.maconlinux.org> for more information.
-  If unsure, say Y.
 
 ADB raw keycode support
 CONFIG_MAC_ADBKEYCODES
diff -u --recursive --new-file v2.4.9/linux/Documentation/DocBook/Makefile linux/Documentation/DocBook/Makefile
--- v2.4.9/linux/Documentation/DocBook/Makefile	Wed Jul 25 17:10:16 2001
+++ linux/Documentation/DocBook/Makefile	Fri Sep  7 18:15:17 2001
@@ -24,10 +24,10 @@
 html:	$(HTML)
 
 %.eps: %.fig
-	-fig2dev -Leps $< $@
+	fig2dev -Leps $< $@
 
 %.jpeg: %.fig
-	-fig2dev -Ljpeg $< $@
+	fig2dev -Ljpeg $< $@
 
 %.sgml: %.c
 	echo "<programlisting>" > $@
@@ -129,7 +129,7 @@
 		$(PERL) $(TOPDIR)/scripts/split-man $(TOPDIR)/Documentation/man
 
 parportbook: $(JPG-parportbook)
-parportbook.ps: $(EPS-parportbook)
+parportbook.ps parportbook.pdf: $(EPS-parportbook)
 parportbook.sgml: parportbook.tmpl $(TOPDIR)/drivers/parport/init.c
 	$(TOPDIR)/scripts/docgen $(TOPDIR)/drivers/parport/init.c <$< >$@
 
diff -u --recursive --new-file v2.4.9/linux/Documentation/DocBook/kernel-api.tmpl linux/Documentation/DocBook/kernel-api.tmpl
--- v2.4.9/linux/Documentation/DocBook/kernel-api.tmpl	Thu May 24 15:14:08 2001
+++ linux/Documentation/DocBook/kernel-api.tmpl	Sun Sep  9 12:00:55 2001
@@ -187,6 +187,11 @@
 !Edrivers/block/ll_rw_blk.c
   </chapter>
 
+  <chapter id="part">
+     <title>Partition Handling</title>
+!Edrivers/block/genhd.c
+  </chapter>
+
   <chapter id="miscdev">
      <title>Miscellaneous Devices</title>
 !Edrivers/char/misc.c
diff -u --recursive --new-file v2.4.9/linux/Documentation/DocBook/parportbook.tmpl linux/Documentation/DocBook/parportbook.tmpl
--- v2.4.9/linux/Documentation/DocBook/parportbook.tmpl	Sun Aug 12 13:27:58 2001
+++ linux/Documentation/DocBook/parportbook.tmpl	Fri Sep  7 18:15:17 2001
@@ -1654,6 +1654,16 @@
 
       </listitem></varlistentry>
 
+     <varlistentry><term><constant>PPGETMODE</constant></term>
+      <listitem>
+
+       <para>
+	Retrieves the current IEEE 1284 mode to use for
+	<function>read</function> and <function>write</function>.
+       </para>
+
+      </listitem></varlistentry>
+
      <varlistentry><term><constant>PPGETTIME</constant></term>
       <listitem>
 
@@ -1681,6 +1691,36 @@
 	should be a pointer to a <structname>struct
 	timeval</structname>.
        </para>
+
+      </listitem></varlistentry>
+
+     <varlistentry><term><constant>PPGETMODES</constant></term>
+      <listitem>
+
+       <para>
+	Retrieves the capabilities of the hardware (i.e. the
+	<structfield>modes</structfield> field of the
+	<structname>parport</structname> structure).
+       </para>
+
+      </listitem></varlistentry>
+
+     <varlistentry><term><constant>PPSETFLAGS</constant></term>
+      <listitem>
+
+       <para>
+	Sets flags on the <literal>ppdev</literal> device which can
+	affect future I/O operations.  Available flags are:
+       </para>
+
+       <itemizedlist spacing=compact>
+	<listitem><para>
+	  <constant>PP_FASTWRITE</constant></para></listitem>
+	<listitem><para>
+	  <constant>PP_FASTREAD</constant></para></listitem>
+	<listitem><para>
+	  <constant>PP_W91284PIC</constant></para></listitem>
+       </itemizedlist>
 
       </listitem></varlistentry>
 
diff -u --recursive --new-file v2.4.9/linux/Documentation/DocBook/procfs-guide.tmpl linux/Documentation/DocBook/procfs-guide.tmpl
--- v2.4.9/linux/Documentation/DocBook/procfs-guide.tmpl	Tue Jul  3 17:08:18 2001
+++ linux/Documentation/DocBook/procfs-guide.tmpl	Sat Sep  8 12:20:25 2001
@@ -207,7 +207,7 @@
         will return <constant>NULL</constant>. <xref
         linkend="userland"> describes how to do something useful with
         regular files.
-      <para>
+      </para>
 
       <para>
         Note that it is specifically supported that you can pass a
@@ -577,7 +577,7 @@
         the <structfield>owner</structfield> field in the
         <structname>struct proc_dir_entry</structname> to
         <constant>THIS_MODULE</constant>.
-      <para>
+      </para>
 
       <programlisting>
 struct proc_dir_entry* entry;
diff -u --recursive --new-file v2.4.9/linux/Documentation/arm/SA1100/Assabet linux/Documentation/arm/SA1100/Assabet
--- v2.4.9/linux/Documentation/arm/SA1100/Assabet	Fri May 12 11:21:20 2000
+++ linux/Documentation/arm/SA1100/Assabet	Fri Sep  7 09:28:38 2001
@@ -9,38 +9,268 @@
 http://www.cs.cmu.edu/~wearable/software/assabet.html
 
 
-To build the kernel:
+Building the kernel
+-------------------
+
+To build the kernel with current defaults:
 
 	make assabet_config
-	make config
-	[accept all defaults]
+	make oldconfig
 	make dep
 	make zImage
 
-Typically, you'll need angelboot to load the kernel.
-The following angelboot.opt file should be used:
+The resulting kernel image should be available in linux/arch/arm/boot/zImage.
+
+
+Installing a bootloader
+-----------------------
+
+A couple of bootloaders able to boot Linux on Assabet are available:
+
+BLOB (http://www.lart.tudelft.nl/lartware/blob/)
+
+   BLOB is a bootloader used within the LART project.  Some contributed
+   patches were merged into BLOB to add support for Assabet.
+
+Compaq's Bootldr + John Dorsey's patch for Assabet support
+(http://www.handhelds.org/Compaq/bootldr.html)
+(http://www.wearablegroup.org/software/bootldr/)
+
+   Bootldr is the bootloader developed by Compaq for the iPAQ Pocket PC.
+   John Dorsey has produced add-on patches to add support for Assabet and
+   the JFFS filesystem.
+
+RedBoot (http://sources.redhat.com/redboot/)
+
+   RedBoot is a bootloader developed by Red Hat based on the eCos RTOS
+   hardware abstraction layer.  It supports Assabet amongst many other
+   hardware platforms.
+
+RedBoot is currently the recommended choice since it's the only one to have
+networking support, and is the most actively maintained.
+
+Brief examples on how to boot Linux with RedBoot are shown below.  But first
+you need to have RedBoot installed in your flash memory.  A known to work
+precompiled RedBoot binary is available from the following location:
+
+ftp://ftp.netwinder.org/users/n/nico/
+ftp://ftp.arm.linux.org.uk/pub/linux/arm/people/nico/
+ftp://ftp.handhelds.org/pub/linux/arm/sa-1100-patches/
+
+Look for redboot-assabet*.tgz.  Some installation infos are provided in
+redboot-assabet*.txt.
+
+
+Initial RedBoot configuration
+-----------------------------
+
+The commands used here are explained in The RedBoot User's Guide available
+on-line at http://sources.redhat.com/ecos/docs-latest/redboot/redboot.html.
+Please refer to it for explanations.
+
+If you have a CF network card (my Assabet kit contained a CF+ LP-E from
+Socket Communications Inc.), you should strongly consider using it for TFTP
+file transfers.  You must insert it before RedBoot runs since it can't detect
+it dynamically.
+
+To initialize the flash directory:
+
+	fis init -f
+
+To initialize the non-volatile settings, like whether you want to use BOOTP or
+a static IP address, etc, use this command:
+
+	fconfig -i
+
+
+Writing a kernel image into flash
+---------------------------------
+
+First, the kernel image must be loaded into RAM.  If you have the zImage file
+available on a TFTP server:
+
+	load zImage -r -b 0x100000
+
+If you rather want to use Y-Modem upload over the serial port:
+
+	load -m ymodem -r -b 0x100000
+
+To write it to flash:
+
+	fis create "Linux kernel" -b 0x100000 -l 0xc0000
+
+
+Booting the kernel
+------------------
+
+The kernel still requires a filesystem to boot.  A ramdisk image can be loaded
+as follows:
+
+	load ramdisk_image.gz -r -b 0x800000
+
+Again, Y-Modem upload can be used instead of TFTP by replacing the file name
+by '-y ymodem'.
+
+Now the kernel can be retrieved from flash like this:
+
+	fis load "Linux kernel"
+
+or loaded as described previously.  To boot the kernel:
+
+	exec -b 0x100000 -l 0xc0000
+
+The ramdisk image could be stored into flash as well, but there are better
+solutions for on-flash filesystems as mentioned below.
+
+
+Using JFFS2
+-----------
+
+Using JFFS2 (the Second Journaling Flash File System) is probably the most
+convenient way to store a writable filesystem into flash.  JFFS2 is used in
+conjunction with the MTD layer which is responsible for low-level flash
+management.  More information on the Linux MTD can be found on-line at:
+http://www.linux-mtd.infradead.org/.  A JFFS howto with some infos about
+creating JFFS/JFFS2 images is available from the same site.
+
+For instance, a sample JFFS2 image can be retrieved from the same FTP sites
+mentioned below for the precompiled RedBoot image.
+
+To load this file:
+
+	load sample_img.jffs2 -r -b 0x100000
+
+The result should look like:
+
+RedBoot> load sample_img.jffs2 -r -b 0x100000
+Raw file loaded 0x00100000-0x00377424
+
+Now we must know the size of the unallocated flash:
+
+	fis free
+
+Result:
+
+RedBoot> fis free
+  0x500E0000 .. 0x503C0000
+
+The values above may be different depending on the size of the filesystem and
+the type of flash.  See their usage below as an example and take care of
+substituting yours appropriately.
+
+We must determine some values:
+
+size of unallocated flash:	0x503c0000 - 0x500e0000 = 0x2e0000
+size of the filesystem image:	0x00377424 - 0x00100000 = 0x277424
+
+We want to fit the filesystem image of course, but we also want to give it all
+the remaining flash space as well.  To write it:
+
+	fis unlock -f 0x500E0000 -l 0x2e0000
+	fis erase -f 0x500E0000 -l 0x2e0000
+	fis write -b 0x100000 -l 0x277424 -f 0x500E0000
+	fis create "JFFS2" -n -f 0x500E0000 -l 0x2e0000
+
+Now the filesystem is associated to a MTD "partition" once Linux has discovered
+what they are in the boot process.  From Redboot, the 'fis list' command
+displays them:
+
+RedBoot> fis list
+Name              FLASH addr  Mem addr    Length      Entry point
+RedBoot           0x50000000  0x50000000  0x00020000  0x00000000
+RedBoot config    0x503C0000  0x503C0000  0x00020000  0x00000000
+FIS directory     0x503E0000  0x503E0000  0x00020000  0x00000000
+Linux kernel      0x50020000  0x00100000  0x000C0000  0x00000000
+JFFS2             0x500E0000  0x500E0000  0x002E0000  0x00000000
+
+However Linux should display something like:
+
+SA1100 flash: probing 32-bit flash bus
+SA1100 flash: Found 2 x16 devices at 0x0 in 32-bit mode
+Using RedBoot partition definition
+Creating 5 MTD partitions on "SA1100 flash":
+0x00000000-0x00020000 : "RedBoot"
+0x00020000-0x000e0000 : "Linux kernel"
+0x000e0000-0x003c0000 : "JFFS2"
+0x003c0000-0x003e0000 : "RedBoot config"
+0x003e0000-0x00400000 : "FIS directory"
+
+What's important here is the position of the partition we are interested in,
+which is the third one.  Within Linux, this correspond to /dev/mtdblock2.
+Therefore to boot Linux with the kernel and its root filesystem in flash, we
+need this RedBoot command:
+
+	fis load "Linux kernel"
+	exec -b 0x100000 -l 0xc0000 -c "root=/dev/mtdblock2"
+
+Of course other filesystems than JFFS might be used, like cramfs for example.
+You might want to boot with a root filesystem over NFS, etc.  It is also
+possible, and sometimes more convenient, to flash a filesystem directly from
+within Linux while booted from a ramdisk or NFS.  The Linux MTD repository has
+many tools to deal with flash memory as well, to erase it for example.  JFFS2
+can then be mounted directly on a freshly erased partition and files can be
+copied over directly.  Etc...
+
+
+RedBoot scripting
+-----------------
+
+All the commands above aren't so useful if they have to be typed in every
+time the Assabet is rebooted.  Therefore it's possible to automatize the boot
+process using RedBoot's scripting capability.
+
+For example, I use this to boot Linux with both the kernel and the ramdisk
+images retrieved from a TFTP server on the network:
+
+RedBoot> fconfig
+Run script at boot: false true
+Boot script:
+Enter script, terminate with empty line
+>> load zImage -r -b 0x100000
+>> load ramdisk_ks.gz -r -b 0x800000
+>> exec -b 0x100000 -l 0xc0000
+>>
+Boot script timeout (1000ms resolution): 3
+Use BOOTP for network configuration: true
+GDB connection port: 9000
+Network debug at boot time: false
+Update RedBoot non-volatile configuration - are you sure (y/n)? y
+
+Then, rebooting the Assabet is just a matter of waiting for the login prompt.
+
+
+
+Nicolas Pitre
+nico@cam.org
+June 12, 2001
+
+
+Status of peripherals in -rmk tree
+----------------------------------
+
+Assabet:
+ Serial ports:
+  Radio:	TX, RX, CTS, DSR, DCD, RI
+  COM:		TX, RX, CTS, DSR, DCD, RTS, DTR, PM
+  I2C:		TX, RX
+  L3:		No
+
+ Video:
+  LCD:		PM
+  Video out:	Not fully
+  Touchscreen:	No
+
+ Audio:
+  Codec:	No
+  POTS:		No
+
+ Other:
+  PCMCIA:	Yes
+  USB:		No
 
------ begin angelboot.opt -----
-base 0xc0008000
-entry 0xc0008000
-r0 0x00000000
-r1 0x00000019
-device /dev/ttyS1
-options "9600 8N1"
-baud 115200
-otherfile ramdisk_img.gz
-otherbase 0xc0800000
-exec minicom
------ end angelboot.opt -----
-
-Then load the kernel and ramdisk with:
-
-	angelboot -f angelboot.opt zImage
-
-Here it is assumed that your Assabet is connected to ttyS1 and that
-minicom is preconfigured with /dev/ttyS1, 9600 baud, 8N1, no flow control
-by default.
+Neponset:
+ Serial ports:
+  COM1,2:	TX, RX, CTS, DSR, DCD, RTS, DTR
 
-This is work in progress...
+More stuff can be found in the -np (Nicolas Pitre's) tree.
 
-Please send any patches to nico@cam.org.
diff -u --recursive --new-file v2.4.9/linux/Documentation/arm/SA1100/DMA linux/Documentation/arm/SA1100/DMA
--- v2.4.9/linux/Documentation/arm/SA1100/DMA	Wed Dec 31 16:00:00 1969
+++ linux/Documentation/arm/SA1100/DMA	Fri Sep  7 09:28:38 2001
@@ -0,0 +1,248 @@
+Support functions for the SA11x0 internal DMA channels
+======================================================
+
+Nicolas Pitre <nico@cam.org>
+Last updated: 2001/07/15
+
+
+The DMA controller consists of six independent DMA channels. Each channel
+can be configured to service any of the serial controllers. Two channels
+are required to service a full-duplex serial controller. The DMA
+controller is intended to relieve the processor of the interrupt overhead
+in servicing these ports with programmed I/ O.
+
+If desired, any or all peripherals (except the UDC) may be serviced with
+programmed I/ O instead of DMA. Each peripheral is capable of requesting
+processor service through its own interrupt lines or through a DMA
+request.
+
+A set of functions is provided to support drivers working with DMA buffers
+through a generic interface for (wishfully) all DMA usages.  Those
+functions will take care of buffer queueing and splitting, DMA register
+management, interrupt handling, etc.
+
+
+SA11x0 DMA API
+--------------
+
+Here is the description for the DMA API.
+
+
+int sa1100_request_dma( dmach_t *channel, const char *device_id,
+			dma_device_t device );
+
+This function will search for a free DMA channel and returns the channel
+number in '*channel'.  'device_id' should point to a string identifying
+the DMA usage or device (mainly for /proc).  'device' is the SA11x0
+peripheral's ports.  Note that reading from a port and writing to the
+same port are actually considered as two different streams requiring
+two DMA channels with their own device type.  All possible dma_device_t
+are defined in include/asm-arm/arch-sa1100/dma.h.  If no channel is
+available, or if the desired device is already in use by another DMA
+channel, then an error code is returned.  This function must be called
+before any other DMA calls.
+
+
+int sa1100_dma_queue_buffer( dmach_t channel, void *buf_id,
+                             dma_addr_t data, int size );
+
+This function enqueue the specified buffer for DMA processing.  The buffer
+will be transmitted or filled with incoming data depending on the channel
+configuration made through sa1100_dma_set_device().  If the queue is
+empty, DMA starts immediately on the given buffer.
+
+Arguments are:
+
+dmach_t channel:	the channel number.
+void *buf_id:		a buffer identification known by the caller.
+dma_addr_t data:	the buffer's physical address.
+int size:		the buffer size in bytes.
+
+Note here the dma_addr_t which is not the same as the virtual address as
+returned by kmalloc() and friends.  The DMA controller must be given a
+physical address to a buffer which is not cached bye the CPU data cache.
+To get such address, the DMA mapping functions (see
+Documentation/DMA-mapping.txt) are recommended.  The only relevant
+functions are pci_alloc_consistent(), pci_map_single() and their unmap
+counterparts.  The PCI dev argument is NULL of course.
+
+There is no restriction on the buffer size.  The DMA code will split it up
+internally to acommodate the DMA controller as needed.  If the buffer
+can't be enqueued the appropriate error code is returned.
+
+
+int sa1100_dma_set_callback( dmach_t channel, dma_callback_t cb );
+
+As soon as the DMa completes with a buffer, a callback function is used to
+notify the driver which would have registered one.  The callback function
+is prototyped as:
+
+void dma_callback( void *buf_id, int size );
+
+The 'buf_id' argument is the buffer identifier as passed to
+sa1100_dma_queue_buffer().  The 'size' argument is the number of bytes the
+DMA processed (should be the same as the buffer size).
+
+Note that this callback function is called while in interrupt context.
+So it has to be small and efficient while posponing more complex
+processing to a bottom-half function or similar.  All
+restrictions for interrupt handlers still apply.
+
+
+int sa1100_dma_get_current( dmach_t channel, void **buf_id,
+                            dma_addr_t *addr );
+
+This returns the buffer ID and the DMA address pointer within the buffer
+currently being processed.  If no such buffer is currently processed, an
+error code is returned.  This is useful for mmap()'ed buffers like in
+audio drivers.
+
+
+int sa1100_dma_stop( dmach_t channel );
+
+This call stops any DMA transfer on the given channel.
+
+
+int sa1100_dma_resume( dmach_t channel );
+
+This call resumes a DMA transfer which would have been stopped through
+sa1100_dma_stop().
+
+
+int sa1100_dma_flush_all( dmach_t channel );
+
+This completely flushes all queued buffers and on-going DMA transfers on a
+given channel.  The next enqueued buffer following this call will be
+processed right away.
+
+
+int sa1100_dma_set_spin( dmach_t channel, dma_addr_t addr, int size );
+
+Because there is at least one device out there that uses its receive
+signal for its transmit clock reference, we need a mecanism to make the
+DMA "spin" on a certain buffer for when there is no more actual buffer to
+process.  The 'addr' argument is the physical memory address to use, and
+the 'size' argument determines the spin DMA chunk.  This size can't be
+larger than 8191 (if so, it is clamped to 4096).  When the size is 0,
+the spin function is turned off.
+
+When activated, DMA will "spin" until there is any buffer in the queue.
+The current DMA chunk will terminate before a newly queued buffer is
+processed.  The spin buffer will only be reused when there is no more
+acctual buffer to process.
+
+It is important not to choose a too small 'size' value since it will
+greatly increase the interrupt load required to restart the spin.  Since
+this feature will typically be used on transmit DMAs, and because a buffer
+full of zeros is probably the best thing to spin out, the 'addr' argument
+may well be used with FLUSH_BASE_PHYS for which no allocation nor memory
+bus request are needed.
+
+The spinning DMA is affected by sa1100_dma_stop() and sa1100_dma_resume()
+but not bu sa1100_dma_flush_all().
+
+
+void sa1100_free_dma( dmach_t channel );
+
+This clears all activities on a given DMA channel and releases it for
+future requests.
+
+
+Buffer allocation
+-----------------
+
+Like mentionned above, it is the driver's responsibility to allocate, free
+and keep track of buffer space with dma_addr_t type addresses. However the
+driver must not change the state of any buffer after it has been sent to
+sa1100-dma_queue_buffer().  When that function has been called, the buffer
+becomes the DMA's ownership until one of these events occur:
+
+- The callback function is called by the DMA code with a buffer ID to
+  indicate that DMA processing terminated on that buffer.  Then the
+  driver owns the buffer again.
+- The sa1100-dma_flush_all() function is called by the driver at which
+  point *all* queued buffers are owned by the driver again.
+- The sa1100-free_dma() does the same as sa1100-dma_flush_all().
+
+This doesn't mean that you can't change the content of a queued buffer in
+conjonction with the usage of pci_map_consistent() and
+sa1100_dma_get_current()... but then you must be sure you know what you're
+doing (this doesn't work with pci_map_single()).
+
+
+Examples
+--------
+
+A real example of audio ring buffers is implemented in the
+drivers/sound/sa1100-audio.c driver.  The SA1110 USB client and the
+SA11x0 FIR drivers are also using this interface to implement packetized
+DMA.
+
+A transmit DMA for network packets could look like this (largely simplified):
+
+struct sk_buff *tx_ring_skb[RING_SIZE];
+dma_addr_t      tx_ring_dma[RING_SIZE];
+int cur_tx;
+...
+
+transmit function:
+
+	tx_ring_skb[cur_tx] = skb;
+	tx_ring_dma[cur_tx] = pci_map_single(NULL, skb->data, skb->len,
+	                                     PCI_DMA_TODEVICE);
+	sa1100_dma_queue_buffer(channel, (void*)cur_tx,
+	                        tx_ring_dma[cur_tx], skb->len);
+	cur_tx++; cur_tx %= RING_SIZE;
+	...
+
+and the callback function:
+
+void tx_done_callback( void *buf_id, int size ) {
+	int done_tx = (int) buf_id;
+	struct sk_buff *skb = tx_ring_skb[done_tx];
+	pci_unmap_single(NULL, tx_ring_dma[done_tx], skb->len,
+	                 PCI_DMA_TODEVICE);
+	stats.tx_packets++;
+	stats.tx_bytes += size;
+	dev_kfree_skb_irq(skb);
+	tx_ring_skb[done_tx] = NULL;
+}
+
+
+For drivers expecting variable length packets i.e. USB client, it is
+necessary to register the appropriate IRQ to be notified when the receiver
+is idle, the packet is complete, etc.  We could use one buffer at a time
+with its ID being the virtual address of the buffer.
+
+Then the sequence:
+
+	/* be sure DMA won't continue under our feet */
+	sa1100_dma_stop(channel);
+	/* get the actual DMA length */
+	sa1100_get_current(channel, &data, &dma_ptr);
+	/* acquire ownership for the buffer */
+	sa1100_dma_flush_all(channel);
+	/* unmap the DMA buffer (actually doing cache coherency on ARM) */
+	pci_unmap_single (NULL, dma_addr, MAX_PKT_SIZE, PCI_DMA_FROMDEVICE);
+	/* get remaining bytes from the fifo */
+	ptr = data + dma_ptr - dma_addr;
+	while (fifo_not_empty)
+		*ptr++ = get_byte_from_fifo;
+	/* feed another free buffer for the next packet */
+	dma_addr2 = pci_map_single(NULL, data2, MAX_PKT_SIZE,
+					PCI_DMA_FROMDEVICE);
+	sa1100_dma_queue_buffer(channel, data2, dma_addr2, MAX_PKT_SIZE);
+	/* process the current packet */
+	...
+
+might do the trick.  This looks a bit ugly but that's a starting point for
+improvements.
+
+
+TODO
+----
+
+- Create kernel-doc comments in the source to document the API and
+  let the documentation be generated automatically.
+
+
diff -u --recursive --new-file v2.4.9/linux/Documentation/arm/SA1100/FreeBird linux/Documentation/arm/SA1100/FreeBird
--- v2.4.9/linux/Documentation/arm/SA1100/FreeBird	Wed Dec 31 16:00:00 1969
+++ linux/Documentation/arm/SA1100/FreeBird	Fri Sep  7 09:28:38 2001
@@ -0,0 +1,21 @@
+Freebird-1.1 is produced by Legned(C) ,Inc.
+(http://www.legend.com.cn)
+and software/linux mainatined by Coventive(C),Inc.
+(http://www.coventive.com)
+
+Based on the Nicolas's strongarm kernel tree.
+
+===============================================================
+Maintainer:
+
+Chester Kuo <chester@coventive.com>
+	    <chester@linux.org.tw>
+
+Author :
+Tim wu <timwu@coventive.com>
+CIH <cih@coventive.com>
+Eric Peng <ericpeng@coventive.com>
+Jeff Lee <jeff_lee@coventive.com>
+Allen Cheng
+Tony Liu <tonyliu@coventive.com>
+
diff -u --recursive --new-file v2.4.9/linux/Documentation/arm/SA1100/GraphicsClient linux/Documentation/arm/SA1100/GraphicsClient
--- v2.4.9/linux/Documentation/arm/SA1100/GraphicsClient	Mon Nov 27 17:07:59 2000
+++ linux/Documentation/arm/SA1100/GraphicsClient	Fri Sep  7 09:28:38 2001
@@ -1,15 +1,18 @@
-ADS GraphicsClient/ThinClient Single Board Computer
+ADS GraphicsClient Plus Single Board Computer
 
 For more details, contact Applied Data Systems or see
-http://www.flatpanels.com/products.html
+http://www.applieddata.net/products.html
 
 The original Linux support for this product has been provided by 
-Nicolas Pitre <nico@cam.org>.
+Nicolas Pitre <nico@cam.org>. Continued development work by
+Woojung Huh <whuh@applieddata.net>
 
 It's currently possible to mount a root filesystem via NFS providing a
-complete Linux environment.  Otherwise a ramdisk image may be used.  Use
-'make graphicsclient_config' before any 'make config'.  This will set up
-defaults for GraphicsClient/ThinClient support.
+complete Linux environment.  Otherwise a ramdisk image may be used.  The
+board supports MTD/JFFS, so you could also mount something on there.
+
+Use 'make graphicsclient_config' before any 'make config'.  This will set up
+defaults for GraphicsClient Plus support.
 
 The kernel zImage is linked to be loaded and executed at 0xc0200000.  
 Also the following registers should have the specified values upon entry:
@@ -17,8 +20,18 @@
 	r0 = 0
 	r1 = 29	(this is the GraphicsClient architecture number)
 
-Here is a tipical angel.opt option file if the kernel is loaded through
-the Angel Debug Monitor:
+Linux can  be used with the ADS BootLoader that ships with the
+newer rev boards. See their documentation on how to load Linux.
+Angel is not available for the GraphicsClient Plus AFAIK.
+
+There is a  board known as just the GraphicsClient that ADS used to
+produce but has end of lifed. This code will not work on the older
+board with the ADS bootloader, but should still work with Angel,
+as outlined below.  In any case, if you're planning on deploying
+something en masse, you should probably get the newer board.
+
+If using Angel on the older boards, here is a typical angel.opt option file
+if the kernel is loaded through the Angel Debug Monitor:
 
 ----- begin angelboot.opt -----
 base 0xc0200000
@@ -26,7 +39,7 @@
 r0 0x00000000
 r1 0x0000001d
 device /dev/ttyS1
-options "9600 8N1"
+options "38400 8N1"
 baud 115200
 #otherfile ramdisk.gz
 #otherbase 0xc0800000
@@ -39,7 +52,7 @@
 	angelboot -f angelboot.opt zImage
 
 Here it is assumed that the board is connected to ttyS1 on your PC
-and that minicom is preconfigured with /dev/ttyS1, 9600 baud, 8N1, no flow
+and that minicom is preconfigured with /dev/ttyS1, 38400 baud, 8N1, no flow
 control by default.
 
 If any other bootloader is used, ensure it accomplish the same, especially
@@ -47,19 +60,39 @@
 
 
 Supported peripherals:
-- SA1100 LCD frame buffer (only 8bpp yet)
-- on-board SMC 92C94 ethernet NIC
+- SA1100 LCD frame buffer (8/16bpp...sort of)
+- on-board SMC 92C96 ethernet NIC
 - SA1100 serial port
-- flash memory access
+- flash memory access (MTD/JFFS)
 - pcmcia
-- possibly UCB1200 audio (not tested yet)
+- touchscreen(ucb1200)
+- ps/2 keyboard
+- console on LCD screen
+- serial ports (ttyS[0-2])
+  - ttyS0 is default for serial console
+- Smart I/O (ADC, keypad, digital inputs, etc)
+  See http://www.applieddata.com/developers/linux for IOCTL documentation
+  and example user space code. ps/2 keybd is multiplexed through this driver
 
 To do:
-- touchscreen driver
-- 16bpp frame buffer support
-- extra (external) serial port driver
-- some console keyboard support (maybe IR?)
+- UCB1200 audio with new ucb_generic layer
 - everything else!  :-)
+
+Notes:
+
+- The flash on board is divided into 3 partitions.  mtd0 is where
+  the ADS boot ROM and zImage is stored.  It's been marked as
+  read-only to keep you from blasting over the bootloader. :)  mtd1 is
+  for the ramdisk.gz image.  mtd2 is user flash space and can be
+  utilized for either JFFS or if you're feeling crazy, running ext2
+  on top of it. If you're not using the ADS bootloader, you're
+  welcome to blast over the mtd1 partition also.
+
+- 16bpp mode requires a different cable than what ships with the board.
+  Contact ADS or look through the manual to wire your own. Currently,
+  if you compile with 16bit mode support and switch into a lower bpp
+  mode, the timing is off so the image is corrupted.  This will be
+  fixed soon.
 
 Any contribution can be sent to nico@cam.org and will be greatly welcome!
 
diff -u --recursive --new-file v2.4.9/linux/Documentation/arm/SA1100/HUW_WEBPANEL linux/Documentation/arm/SA1100/HUW_WEBPANEL
--- v2.4.9/linux/Documentation/arm/SA1100/HUW_WEBPANEL	Wed Dec 31 16:00:00 1969
+++ linux/Documentation/arm/SA1100/HUW_WEBPANEL	Fri Sep  7 09:28:38 2001
@@ -0,0 +1,18 @@
+The HUW_WEBPANEL is a product of the german company Hoeft & Wessel AG
+
+If you want more information, please visit
+http://www.hoeft-wessel.de
+
+To build the kernel:
+	make huw_webpanel_config
+	make oldconfig
+	[accept all defaults]
+	make dep
+	make zImage
+
+Mostly of the work is done by:
+Roman Jordan         jor@hoeft-wessel.de
+Christoph Schulz    schu@hoeft-wessel.de
+
+2000/12/18/
+
diff -u --recursive --new-file v2.4.9/linux/Documentation/arm/SA1100/Itsy linux/Documentation/arm/SA1100/Itsy
--- v2.4.9/linux/Documentation/arm/SA1100/Itsy	Wed Oct 20 16:29:07 1999
+++ linux/Documentation/arm/SA1100/Itsy	Fri Sep  7 09:28:38 2001
@@ -2,11 +2,38 @@
 Research Center in Palo Alto, CA. The Itsy project is one of several
 research projects at Compaq that are related to pocket computing.
 
-Itsy support has yet to be fully integrated in this kernel.  Linux 2.0.x
-support is available though.
-
 For more information, see:
 
 	http://www.research.digital.com/wrl/itsy/index.html
 
+Notes on initial 2.4 Itsy support (8/27/2000) :
+The port was done on an Itsy version 1.5 machine with a daughtercard with
+64 Meg of DRAM and 32 Meg of Flash. The initial work includes support for
+serial console (to see what you're doing).  No other devices have been
+enabled.
+
+To build, do a "make menuconfig" (or xmenuconfig) and select Itsy support.
+Disable Flash and LCD support. and then do a make dep and a make zImage.
+Finally, you will need to cd to arch/arm/boot/tools and execute a make there
+to build the params-itsy program used to boot the kernel.
+
+In order to install the port of 2.4 to the itsy, You will need to set the
+configuration parameters in the monitor as follows:
+Arg 1:0x08340000, Arg2: 0xC0000000, Arg3:18 (0x12), Arg4:0
+Make sure the start-routine address is set to 0x00060000.
+
+Next, flash the params-itsy program to 0x00060000 ("p 1 0x00060000" in the
+flash menu)  Flash the kernel in arch/arm/boot/zImage into 0x08340000
+("p 1 0x00340000").  Finally flash an initial ramdisk into 0xC8000000
+("p 2 0x0")  We used ramdisk-2-30.gz from the 0.11 version directory on
+handhelds.org.
+
+The serial connection we established was at:
+ 8-bit data, no parity, 1 stop bit(s), 115200.00 b/s. in the monitor, in the
+params-itsy program, and in the kernel itself.  This can be changed, but
+not easily. The monitor parameters are easily changed, the params program
+setup is assembly outl's, and the kernel is a configuration item specific to
+the itsy. (i.e. grep for CONFIG_SA1100_ITSY and you'll find where it is.)
+
 
+This should get you a properly booting 2.4 kernel on the itsy.
diff -u --recursive --new-file v2.4.9/linux/Documentation/arm/SA1100/PCMCIA linux/Documentation/arm/SA1100/PCMCIA
--- v2.4.9/linux/Documentation/arm/SA1100/PCMCIA	Wed Dec 31 16:00:00 1969
+++ linux/Documentation/arm/SA1100/PCMCIA	Fri Sep  7 09:28:38 2001
@@ -0,0 +1,374 @@
+Kernel Low-Level PCMCIA Interface Documentation
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+John G Dorsey <john+@cs.cmu.edu>
+Updated: 30 June, 2000
+
+
+Note: this interface has not been finalized!
+See also: http://www.cs.cmu.edu/~wearable/software/pcmcia-arm.html
+
+
+Introduction
+
+Early versions of PCMCIA Card Services for StrongARM were designed to
+permit a single socket driver to run on a variety of SA-1100 boards by
+using a userland configuration process. During the conversion to the 2.3
+kernel series, all of the configuration has moved into sub-drivers in the
+kernel proper (see linux/drivers/pcmcia/sa1100*). This document describes
+the low-level interface between those sub-drivers and the sa1100 socket
+driver module.
+
+Presently, there are six operations which must be provided by the
+board-specific code. Only functions whose implementation is likely to
+differ across board designs are required at this level. Some examples
+include:
+
+  - configuring card detect lines to generate interrupts
+  - sensing the legal voltage levels for inserted cards
+  - asserting the reset signal for a card
+
+Functions which are assumed to be the same across all designs are
+performed within the generic socket driver itself. Some examples of these
+kinds of operations include:
+
+  - configuring memory access times based on the core clock frequency
+  - reads/writes on memory, byte swizzling, ...
+
+The current implementation allows the specific per-board set of low-level
+operations to be determined at run time. For each specific board, the
+following structure should be filled in:
+
+  struct pcmcia_low_level {
+    int (*init)(struct pcmcia_init *);
+    int (*shutdown)(void);
+    int (*socket_state)(struct pcmcia_state_array *);
+    int (*get_irq_info)(struct pcmcia_irq_info *);
+    int (*configure_socket)(const struct pcmcia_configure *);
+  };
+
+The component functions are described in detail below. Using the
+machine_is_*() tests, the pointer `pcmcia_low_level' should be assigned to
+the location of the table for your board.
+
+
+0. init(struct pcmcia_init *init)
+
+This operation has three responsibilities:
+
+  - perform any board-specific initialization tasks
+  - associate the given handler with any interrupt-generating signals
+    such as card detection, or battery voltage detection
+  - set up any necessary edge detection for card ready signals
+
+Argument passing for this operation is implemented by the following
+structure:
+
+  struct pcmcia_init {
+    void (*handler)(int irq, void *dev, struct pt_regs *regs);
+    struct pcmcia_maps *maps;
+  };
+
+Here, `handler' is provided by the socket driver, and `maps' must be
+modified if the default mapping isn't appropriate. This operation should
+return one of two values:
+
+  - the highest-numbered socket available, plus one
+  - a negative number, indicating an error in configuration
+
+Note that the former case is _not_ the same as "the number of sockets
+available." In particular, if your design uses SA-1100 slot "one" but
+not slot "zero," you MUST report "2" to the socket driver.
+
+
+1. shutdown(void)
+
+This operation takes no arguments, and will be called during cleanup for
+the socket driver module. Any state associated with the socket controller,
+including allocated data structures, reserved IRQs, etc. should be
+released in this routine.
+
+The return value for this operation is not examined.
+
+
+2. socket_state(struct pcmcia_state_array *state_array)
+
+This operation will be invoked from the interrupt handler which was set up
+in the earlier call to init(). Note, however, that it should not include
+any side effects which would be inappropriate if the operation were to
+occur when no interrupt is pending. (An extra invocation of this operation
+currently takes place to initialize state in the socket driver.)
+
+Argument passing for this operation is handled by a structure which
+contains an array of the following type:
+
+  struct pcmcia_state {
+    unsigned detect: 1,
+              ready: 1,
+               bvd1: 1,
+               bvd2: 1,
+             wrprot: 1,
+              vs_3v: 1,
+              vs_Xv: 1;
+  };
+
+Upon return from the operation, a struct pcmcia_state should be filled in
+for each socket available in the hardware. For every array element (up to
+`size' in the struct pcmcia_state_saarray) which does not correspond to an
+available socket, zero the element bits. (This includes element [0] if
+socket zero is not used.)
+
+Regardless of how the various signals are routed to the SA-1100, the bits
+in struct pcmcia_state always have the following semantics:
+
+  detect - 1 if a card is fully inserted, 0 otherwise
+  ready  - 1 if the card ready signal is asserted, 0 otherwise
+  bvd1   - the value of the Battery Voltage Detect 1 signal
+  bvd2   - the value of the Battery Voltage Detect 2 signal
+  wrprot - 1 if the card is write-protected, 0 otherwise
+  vs_3v  - 1 if the card must be operated at 3.3V, 0 otherwise
+  vs_Xv  - 1 if the card must be operated at X.XV, 0 otherwise
+
+A note about the BVD signals: if your board does not make both lines
+directly observable to the processor, just return reasonable values. The
+standard interpretation of the BVD signals is:
+
+  BVD1  BVD2
+
+   0     x    battery is dead
+   1     0    battery warning
+   1     1    battery ok
+
+Regarding the voltage sense flags (vs_3v, vs_Xv), these bits should be set
+based on a sampling of the Voltage Sense pins, if available. The standard
+interpretation of the VS signals (for a "low-voltage" socket) is:
+
+  VS1   VS2
+
+   0     0    X.XV, else 3.3V, else none
+   0     1    3.3V, else none
+   1     0    X.XV, else none
+   1     1    5V, else none
+
+More information about the BVD and VS conventions is available in chapter
+5 of "PCMCIA System Architecture," 2nd ed., by Don Anderson.
+
+This operation should return 1 if an IRQ is actually pending for the
+socket controller, 0 if no IRQ is pending (but no error condition exists,
+such as an undersized state array), or -1 on any error.
+
+
+3. get_irq_info(struct pcmcia_irq_info *info)
+
+This operation obtains the IRQ assignment which is legal for the given
+socket. An argument of the following type is passed:
+
+  struct pcmcia_irq_info {
+    unsigned int sock;
+    unsigned int irq ;
+  };
+
+The `sock' field contains the socket index being queried. The `irq' field
+should contain the IRQ number corresponding to the card ready signal from
+the device.
+
+This operation should return 0 on success, or -1 on any error.
+
+
+4. configure_socket(const struct pcmcia_configure *configure)
+
+This operation allows the caller to apply power to the socket, issue a
+reset, or enable various outputs. The argument is of the following type:
+
+  struct pcmcia_configure {
+    unsigned sock: 8,
+              vcc: 8,
+              vpp: 8,
+           output: 1,
+          speaker: 1,
+            reset: 1;
+  };
+
+The `sock' field contains the index of the socket to be configured. The
+`vcc' and `vpp' fields contain the voltages to be applied for Vcc and Vpp,
+respectively, in units of 0.1V. (Note that vpp==120 indicates that
+programming voltage should be applied.)
+
+The two output enables, `output' and `speaker', refer to the card data
+signal enable and the card speaker enable, respectively. The `reset' bit,
+when set, indicates that the card reset should be asserted.
+
+This operation should return 0 on success, or -1 on any error.
+
+
+Board-Specific Notes
+
+The following information is known about various SA-11x0 board designs
+which may be used as reference while adding support to the kernel.
+
+
+Carnegie Mellon Itsy/Cue (http://www.cs.cmu.edu/~wearable/itsy/)
+
+  Itsy Chip Select 3 (CS3) Interface
+  ("ITSY MEMORY/PCMCIA ADD-ON BOARD with BATTERY and CHARGER CIRCUITRY,"
+   memo dated 5-20-99, from Tim Manns to Richard Martin, et. al)
+
+  Read:
+    ABVD2    (SS)D0          A slot, Battery Voltage Detect
+    ABVD1    (SS)D1
+    AVSS2    (SS)D2          A slot, Voltage Sense
+    AVSS1    (SS)D3
+    GND      (SS)D4
+    GND      (SS)D5
+    GND      (SS)D6
+    GND      (SS)D7
+  
+    BBVD2    (SS)D8          B slot, Battery Voltage Detect
+    BBVD1    (SS)D9
+    BVSS2    (SS)D10         B slot, Voltage Sense
+    BVSS1    (SS)D11
+    GND      (SS)D12
+    GND      (SS)D13
+    GND      (SS)D14
+    GND      (SS)D15
+  
+  Write:
+    (SS)D0   A_VPP_VCC       LTC1472 VPPEN1
+    (SS)D1   A_VPP_PGM       LTC1472 VPPEN0
+    (SS)D2   A_VCC_3         LTC1472 VCCEN0
+    (SS)D3   A_VCC_5         LTC1472 VCCEN1
+    (SS)D4   RESET (A SLOT)
+    (SS)D5   GND
+    (SS)D6   GND
+    (SS)D7   GND
+ 
+    (SS)D8   B_VPP_VCC       LTC1472 VPPEN1
+    (SS)D9   B_VPP_PGM       LTC1472 VPPEN0
+    (SS)D10  B_VCC_3         LTC1472 VCCEN0
+    (SS)D11  B_VCC_5         LTC1472 VCCEN1
+    (SS)D12  RESET (B SLOT)
+    (SS)D13  GND
+    (SS)D14  GND
+    (SS)D15  GND
+ 
+  GPIO pin assignments are as follows: (from schematics)
+ 
+    GPIO 10                  Slot 0 Card Detect
+    GPIO 11                  Slot 1 Card Detect
+    GPIO 12                  Slot 0 Ready/Interrupt
+    GPIO 13                  Slot 1 Ready/Interrupt
+
+
+
+Intel SA-1100 Multimedia Board (http://developer.intel.com/design/strong/)
+
+  CPLD Registers
+  SA-1100 Multimedia Development Board with Companion SA-1101 Development
+    Board User's Guide, p.4-42
+
+  This SA-1100/1101 development package uses only one GPIO pin (24) to
+  signal changes in card status, and requires software to inspect a
+  PCMCIA status register to determine the source.
+
+  Read: (PCMCIA Power Sense Register - 0x19400000)
+    S0VS1           0        Slot 0 voltage sense
+    S0VS2           1
+    S0BVD1          2        Slot 0 battery voltage sense
+    S0BVD2          3
+    S1VS1           4        Slot 1 voltage sense
+    S1VS2           5
+    S1BVD1          6        Slot 1 battery voltage sense
+    S1BVD2          7
+
+  Read/Write: (PCMCIA Power Control Register - 0x19400002)
+    S0VPP0          0        Slot 0 Vpp
+    S0VPP1          1
+    S0VCC0          2        Slot 0 Vcc
+    S0VCC1          3
+    S1VPP0          4        Slot 1 Vpp
+    S1VPP1          5
+    S1VCC0          6        Slot 1 Vcc
+    S1VCC1          7
+
+  Read: (PCMCIA Status Register - 0x19400004)
+    S0CD1           0        Slot 0 Card Detect 1
+    S0RDY           1        Slot 0 Ready/Interrupt
+    S0STSCHG        2        Slot 0 Status Change
+    S0Reset         3        Slot 0 Reset (RW)
+    S1CD1           4        Slot 1 Card Detect 1
+    S1RDY           5        Slot 1 Ready/Interrupt
+    S1STSCHG        6        Slot 1 Status Change
+    S1Reset         7        Slot 1 Reset (RW)
+
+
+
+Intel SA-1100 Evaluation Platform (http://developer.intel.com/design/strong/)
+
+  Brutus I/O Pins and Chipselect Register
+  pcmcia-brutus.c, by Ivo Clarysse
+  (What's the official reference for this info?)
+
+  This SA-1100 development board uses more GPIO pins than say, the Itsy
+  or the SA-1100/1101 multimedia package. The pin assignments are as
+  follows:
+
+    GPIO 2                   Slot 0 Battery Voltage Detect 1
+    GPIO 3                   Slot 0 Ready/Interrupt
+    GPIO 4                   Slot 0 Card Detect
+    GPIO 5                   Slot 1 Battery Voltage Detect 1
+    GPIO 6                   Slot 1 Ready/Interrupt
+    GPIO 7                   Slot 1 Card Detect
+
+  Like the Itsy, Brutus uses a chipselect register in static memory
+  bank 3 for the other signals, such as voltage sense or reset:
+
+  Read:
+    P0_VS1          8        Slot 0 Voltage Sense
+    P0_VS2          9
+    P0_STSCHG      10        Slot 0 Status Change
+    P1_VS1         12        Slot 1 Voltage Sense
+    P1_VS2         13
+    P1_STSCHG      14        Slot 1 Status Change
+
+  Read/Write:
+    P0_            16        Slot 0 MAX1600EAI control line
+    P0_            17        Slot 0 MAX1600EAI control line
+    P0_            18        Slot 0 MAX1600EAI control line
+    P0_            19        Slot 0 MAX1600EAI control line
+    P0_            20        Slot 0 12V
+    P0_            21        Slot 0 Vpp to Vcc (CONFIRM?)
+    P0_            22        Slot 0 enable fan-out drivers & xcvrs
+    P0_SW_RST      23        Slot 0 Reset
+    P1_            24        Slot 1 MAX1600EAI control line
+    P1_            25        Slot 1 MAX1600EAI control line
+    P1_            26        Slot 1 MAX1600EAI control line
+    P1_            27        Slot 1 MAX1600EAI control line
+    P1_            28        Slot 1 12V
+    P1_            29        Slot 1 Vpp to Vcc (CONFIRM?)
+    P1_            30        Slot 1 enable fan-out drivers & xcvrs
+    P1_SW_RST      31        Slot 1 Reset
+
+  For each slot, the bits labelled "MAX1600EAI" should (apparently)
+  be written with the value 0101 for Vcc 3.3V, and 1001 for Vcc 5V.
+
+
+
+Intel SA-1110 Development Platform (http://developer.intel.com/design/strong/)
+
+  GPIO Pin Descriptions and Board Control Register
+  SA-1110 Microprocessor Development Board User's Guide, p.4-7, 4-10
+
+  The Assabet board contains only a single Compact Flash slot,
+  attached to slot 1 on the SA-1110. Card detect, ready, and BVD
+  signals are routed through GPIO, with power and reset placed in a
+  control register. Note that the CF bus must be enabled before use.
+
+    GPIO 21                  Slot 1 Compact Flash interrupt
+    GPIO 22                  Slot 1 card detect (CD1 NOR CD2)
+    GPIO 24                  Slot 1 Battery Voltage Detect 2
+    GPIO 25                  Slot 1 Battery Voltage Detect 1
+
+  Write-only: (Board Control Register - 0x12000000)
+    CF_PWR          0        CF bus power (3.3V)
+    CF_RST          1        CF reset
+    CF_Bus_On       7        CF bus enable
+
diff -u --recursive --new-file v2.4.9/linux/Documentation/arm/SA1100/Pangolin linux/Documentation/arm/SA1100/Pangolin
--- v2.4.9/linux/Documentation/arm/SA1100/Pangolin	Mon Nov 27 17:07:59 2000
+++ linux/Documentation/arm/SA1100/Pangolin	Fri Sep  7 09:28:38 2001
@@ -1,25 +1,20 @@
-Pangolin is a StrongARM 1110-based evaluation  platform produced
-by Dialogue Technoloy (http://www.dialogue.com.tw/).
+Pangolin is a StrongARM 1110-based evaluation platform produced
+by Dialogue Technology (http://www.dialogue.com.tw/).
 It has EISA slots for ease of configuration with SDRAM/Flash
 memory card, USB/Serial/Audio card, Compact Flash card,
 and TFT-LCD card.
-This platform is currently under development.
 
 To compile for Pangolin, you must issue the following commands:
 
 	make pangolin_config
-	make config
-	[accept all defaults]
+	make oldconfig
 	make dep
 	make zImage
 
 Supported peripherals:
-- SA1110 serial port
+- SA1110 serial port (UART1/UART2/UART3)
 - flash memory access
-
-Testing:
-- pcmcia driver
-- sound driver
-
-To do:
-- MQ-200 driver
+- compact flash driver
+- UDA1341 sound driver
+- SA1100 LCD controller for 800x600 16bpp TFT-LCD
+- MQ-200 driver for 800x600 16bpp TFT-LCD
diff -u --recursive --new-file v2.4.9/linux/Documentation/arm/SA1100/Yopy linux/Documentation/arm/SA1100/Yopy
--- v2.4.9/linux/Documentation/arm/SA1100/Yopy	Wed Dec 31 16:00:00 1969
+++ linux/Documentation/arm/SA1100/Yopy	Fri Sep  7 09:28:38 2001
@@ -0,0 +1,2 @@
+See http://www.yopydeveloper.org for more.
+
diff -u --recursive --new-file v2.4.9/linux/Documentation/arm/SA1100/nanoEngine linux/Documentation/arm/SA1100/nanoEngine
--- v2.4.9/linux/Documentation/arm/SA1100/nanoEngine	Sun Aug 13 09:58:24 2000
+++ linux/Documentation/arm/SA1100/nanoEngine	Fri Sep  7 09:28:38 2001
@@ -4,6 +4,8 @@
 "nanoEngine" is a SA1110 based single board computer from 
 Bright Star Engineering Inc.  See www.brightstareng.com/arm
 for more info.
+(Ref: Stuart Adams <sja@brightstareng.com>)
 
-Ref: Stuart Adams <sja@brightstareng.com>
+Also visit Larry Doolittle's "Linux for the nanoEngine" site:
+http://recycle.lbl.gov/~ldoolitt/bse/
 
diff -u --recursive --new-file v2.4.9/linux/Documentation/arm/SA1100/serial_UART linux/Documentation/arm/SA1100/serial_UART
--- v2.4.9/linux/Documentation/arm/SA1100/serial_UART	Mon Nov 27 17:07:59 2000
+++ linux/Documentation/arm/SA1100/serial_UART	Fri Sep  7 09:28:38 2001
@@ -1,5 +1,4 @@
-The SA1100 serial port finally had its major/minor numbers officially 
-assigned:
+The SA1100 serial port had its major/minor numbers officially assigned:
 
 > Date: Sun, 24 Sep 2000 21:40:27 -0700
 > From: H. Peter Anvin <hpa@transmeta.com>
@@ -25,7 +24,7 @@
 >                   7 = /dev/cusa2                Callout device for ttySA2
 >
 
-So, if you're not using devfs, you must create those inodes in /dev
+If you're not using devfs, you must create those inodes in /dev
 on the root filesystem used by your SA1100-based device:
 
 	mknod ttySA0 c 204 5
@@ -35,31 +34,14 @@
 	mknod cusa1 c 205 6
 	mknod cusa2 c 205 7
 
-Note that the old incorrect use of /dev/ttyS0 in order to use the serial port 
-won't work anymore.  This device node is reserved to the conventionnal 16x50
-UART which may appear on devices like PCMCIA modem, etc.
-
-In addition to the creation of the appropriate device nodes above, you must
-ensure your user space applications make use of the correct device name.
-The classic example is the content of the /etc/inittab where you might have 
-a getty process started on ttyS0.  In this case you have two choices:
-
-1- replace occurences of ttyS0 with ttySA0, ttyS1 with ttySA1, etc.
-
-2- in the occurence of 'ttyS0', you may consider replacing it with 'console'.
-   as in "T0:12345:respawn:/sbin/getty -L console 9600 vt100"
-
-(don't forget to add 'ttySA0', 'console', or the appropriate tty name 
- in /etc/securetty for root to be allowed to login as well.)
-
-The use of /dev/console has the advantage of being independent of the real
-serial device used.  The kernel automatically forward all operations on
-/dev/console to the apropriate serial device.  The nature of the console may
-also be modified with a kernel command line parameter (see
-Documentation/serial-console.txt for the details).  Of course, 
-/dev/console must have been created as a char device with major 5 minor 1.
-
-Using /dev/console is also compatible with older kernels that used /dev/ttyS0.
-Therefore it is handy for ramdisk images which are targetted for different
-StrongARM platforms and older kernels.
+In addition to the creation of the appropriate device nodes above, you
+must ensure your user space applications make use of the correct device
+name. The classic example is the content of the /etc/inittab file where
+you might have a getty process started on ttyS0.  In this case:
+
+- replace occurences of ttyS0 with ttySA0, ttyS1 with ttySA1, etc.
+
+- don't forget to add 'ttySA0', 'console', or the appropriate tty name
+  in /etc/securetty for root to be allowed to login as well.
+
 
diff -u --recursive --new-file v2.4.9/linux/Documentation/fb/README-sstfb.txt linux/Documentation/fb/README-sstfb.txt
--- v2.4.9/linux/Documentation/fb/README-sstfb.txt	Wed Dec 31 16:00:00 1969
+++ linux/Documentation/fb/README-sstfb.txt	Fri Sep  7 09:28:38 2001
@@ -0,0 +1,167 @@
+
+Introduction
+
+	  This is a frame buffer device driver for 3dfx' Voodoo Graphics 
+	(aka voodoo 1, aka sst1) and Voodoo² (aka Voodoo 2, aka CVG) based 
+	video boards. It's highly experimental code, but is guaranteed to work
+	on my computer, with my "Maxi Gamer 3D" and "Maxi Gamer 3d²" boards,
+	and with me "between chair and keyboard". Some people tested other
+	combinations and it seems that it works.
+	  The main page is located at <http://sstfb.sourceforge.net>, and if
+	you want the latest version, check out the CVS, as the driver is a work
+	in progress, i feel incomfortable with releasing tarballs of something
+	not completely working...Don't worry, it's still more than useable
+	(I eat my own dog food)
+
+	  Please read the Bug section, and report any success or failure to me
+	(Ghozlane Toumi <gtoumi@messel.emse.fr>).
+	  BTW, If you have only one monitor , and you don't feel like playing
+	with the vga passthrou cable, I can only suggest borrowing a screen
+	somewhere... 
+
+
+Installation 
+
+	  This driver (should) work on ix86, with any 2.2.x kernel (tested
+	with x = 19) and "recent" 2.4.x kernel, as a module or compiled in.
+	  You can apply the patches found in sstfb/kernel/*-2.{2|4}.x.patch,
+	and copy sstfb.c to linux/drivers/video/, or apply a single patch, 
+	sstfb/patch-2.{2|4}.x-sstfb-yymmdd to your linux source tree.
+
+	  Then configure your kernel as usual: choose "m" or "y" to 3Dfx Voodoo
+	Graphics in section "console". Compile, install, have fun... and please
+	drop me a report :)
+
+
+Module Usage
+	
+	Warnings.
+	# You should read completely this section before issuing any command.
+	# If you have only one monitor to play with, once you insmod the
+	  module, the 3dfx takes control of the output, so you'll have to
+	  plug the monitor to the "normal" video board in order to issue
+	  the commands, or you can blindly use sst_dbg_vgapass
+          in the tools directory (See Tools). The latest option is pass the
+	  parameter vgapass=1 when insmodding the driver. (See Kernel/Modules
+	  Options)
+
+	Module insertion:
+	# insmod sstfb.o
+	  you should see some strange output frome the board: 
+	  a big blue square, a green and a red small squares and a vertical
+	  white rectangle. why ? the function's name is self explanatory :
+	  "sstfb_test()"...
+	  (if you don't have a second monitor, you'll have to plug your monitor
+	  directely to the 2D videocard to see what you're typing)
+	# con2fb /dev/fbx /dev/ttyx
+	  bind a tty to the new frame buffer. if you already have a frame
+	  buffer driver, the voodoo fb will likely be /dev/fb1. if not, 
+	  the device will be /dev/fb0. You can check this by doing a 
+	  cat /proc/fb. You can find a copy of con2fb in tools/ directory.
+	  if you don't have another fb device, this step is superfluous,
+	  as the console subsystem automagicaly binds ttys to the fb.
+	# switch to the virtual console you just mapped. "tadaaa" ...
+
+	Module removal:
+	# con2fb /dev/fbx /dev/ttyx
+	  bind the tty to the old frame buffer so the module can be removed.
+	  (how does it work with vgacon ? short answer : it doesn't work)
+	# rmmod sstfb
+
+
+Kernel/Modules Options
+
+	You can pass some otions to sstfb module, and via the kernel command
+	line when the driver is compiled in :
+	for module : insmod sstfb.o option1=value1 option2=value2 ...
+	in kernel :  video=sstfb:option1,option2:value2,option3 ...
+	
+	sstfb supports the folowing options :
+	module		kernel		description
+
+	vgapass=1	vgapass		enable or disable VGA passthrou cable
+	vgapass=0	vganopass	when enabled, the monitor will
+					get the signal from the VGA board
+					and not from the voodoo. default nopass
+
+	mem=x		mem:x		force frame buffer memory in MiB
+					allowed values: 1, 2, 4. default detect
+
+	inverse=1	inverse		suposed to enable inverse console.
+					doesn't work ...
+
+	clipping=1	clipping	enable or disable clipping . with
+	clipping=0	noclipping	clipping enabled, all offscreen reads
+					and writes are disgarded. default:
+					enable clipping.
+
+	gfxclk=x	gfxclk:x	force graphic clock frequency (in MHz)
+					becarefull with this option .
+					default is 50Mhz for voodoo1, 75MHz
+					for voodoo2. Be carefull, this one is
+					dangerous. default=auto
+
+	slowpci=0	slowpci		enable or disable fast PCI read/writes
+	slowpci=1	fastpci		default : fastpci
+
+	dev=x		dev:x		attach the driver to device number x
+					0 is the first compatible board (in 
+					lspci order)
+
+Tools
+
+	These tools are mostly for debugging purposes, but you can 
+	find some of these interesting :
+	 - con2fb , maps a tty to a fbramebuffer .
+		con2fb /dev/fb1 /dev/tty5
+	 - sst_dbg_vgapass , changes vga passthrou. You have to recompile the
+	driver with SST_DEBUG and SST_DEBUG_IOCTL set to 1
+		sst_dbg_vgapass /dev/fb1 1 (enables vga cable)
+		sst_dbg_vgapass /dev/fb1 0 (disables vga cable)
+	 - glide_reset , resets the voodoo using glide
+		use this after rmmoding sstfb, if the module refuses to
+		reinsert .
+
+Bugs
+
+	- DO NOT use glide while the sstfb module is in, you'll most likely
+	hang your computer.
+	- if you see some artefacts (pixels not cleaning and stuff like that), 
+	try turning off clipping (clipping=0)
+	- the driver don't detect the 4Mb frame buffer voodoos, it seems that
+	the 2 last Mbs wrap around. looking into that .
+	- The driver is 16 bpp only, 24/32 won't work.
+	- The driver is not your_favorite_toy-safe. this includes SMP...
+          [Actually from inspection it seems to be safe - Alan]
+	- when using XFree86 FBdev (X over fbdev) you may see strange color
+	patterns at the border of your windows (the pixels loose the lowest
+	byte -> basicaly the blue component nd some of the green) . I'm unable
+	to reproduce this with XFree86-3.3, but one of the testers has this
+	problem with XFree86-4. I don't know yet if this is the drivers fault
+	or X's (most likely the driver, of course).
+	- I didn't really test changing the palette, so you may find some weird
+	things when playing with that.
+	- Sometimes the driver will not recognise the DAC , and the
+        initialisation will fail. this is specificaly true for
+	voodoo 2 boards , but it should be solved in recent versions. please
+	contact me .
+	- the 24/32 is not likely to work anytime soon , knowing that the
+	hardware does ... unusual thigs in 24/32 bpp
+
+Todo
+
+	- Get rid of the previous paragraph.
+	- Buy more coffee.
+	- test/port to other arch.
+	- try to add panning using tweeks with front and back buffer .
+	- try to implement accel en voodoo2 , this board can actualy do a 
+	  lot in 2D even if it was sold as a 3D only board ...
+
+ghoz.
+
+-- 
+Ghozlane Toumi <gtoumi@messel.emse.fr>
+
+
+$Date: 2001/08/29 00:21:11 $
+http://sstfb.sourceforge.net/README
diff -u --recursive --new-file v2.4.9/linux/Documentation/filesystems/ntfs.txt linux/Documentation/filesystems/ntfs.txt
--- v2.4.9/linux/Documentation/filesystems/ntfs.txt	Mon Aug 27 12:41:37 2001
+++ linux/Documentation/filesystems/ntfs.txt	Tue Sep 11 17:02:46 2001
@@ -64,6 +64,25 @@
 			Be careful not to write anything to them or you could
 			crash the kernel and/or corrupt your file system!
 
+mft_zone_multiplier=	Set the MFT zone multiplier for the volume (this
+			setting is not persistent across mounts and can be
+			changed from mount to mount but cannot be changed on
+			remount). Values of 1 to 4 are allowed, 1 being the
+			default. The MFT zone multiplier determines how much
+			space is reserved for the MFT on the volume. If all
+			other space is used up, then the MFT zone will be
+			shrunk dynamically, so this has no impact on the
+			amount of free space. However, it can have an impact
+			on performance by affecting fragmentation of the MFT.
+			In general use the default. If you have a lot of small
+			files then use a higher value. The values have the
+			following meaning:
+			      Value	     MFT zone size (% of volume size)
+				1		12.5%
+				2		25%
+				3		37.5%
+				4		50%
+
 Known bugs and (mis-)features
 =============================
 
@@ -71,10 +90,6 @@
   use it, get the Linux-NTFS tools and use the ntfsfix utility after
   dismounting a partition you wrote to.
 
-- Use the show_sys_files mount option which should make things work generally
-  better. (It results in both the short and long file names being shown as well
-  as the sytem files.)
-
 - Writing of extension records is not supported properly.
 
 Please send bug reports/comments/feed back/abuse to the Linux-NTFS development
@@ -82,6 +97,96 @@
 
 ChangeLog
 =========
+
+NTFS 1.1.19:
+	- Fixed ntfs_getdir_unsorted(), ntfs_readdir() and ntfs_printcb() to
+	  cope with arbitrary cluster sizes. Very important for Win2k+. Also,
+	  make them detect directories which are too large and truncate the
+	  enumeration pretending end of directory was reached. Detect more
+	  error conditions and overflows. All this fixes the problem where the
+	  driver could end up in an infinite loop under certain circumstances.
+	- Fixed potential memory leaks in Unicode conversion functions and
+	  setup correct NULL return values.
+
+NTFS 1.1.18:
+
+	- Enhanced & bug fixed cluster deallocation (race fixes, etc.)
+	- Complete rewrite of cluster allocation, now race free.
+	- Fixed several bugs in the attribute modification codepaths.
+	- Hopefully fixed bug where the first sectors of some people's
+	  partitions would be overwritten by the mft. And in general fixed up
+	  mft extension code a bit (still incomplete though).
+	- Introduce splice_runlist() to allow generic splicing of two run
+	  lists into one.
+	- MFT zone is now implemented. [Stage 2 of 3; only lack dynamic
+	  growing of mft zone but that is AFAIK not even done by Windows, and
+	  the overhead would be so large that it is probably not worth doing
+	  at all, so Stage 3 might never happen...]
+	- Complete rewrite of $MFT extension and ntfs inode allocation code.
+	- Made the NTFS driver initialization string show the compile options
+	  used (i.e. whether read-only or read-write, whether a module, and
+	  whether with debug support).
+	- Modify ntfs_fill_mft_header() to set all fields and to accept more
+	  arguments.
+	- Get rid of superfluous add_mft_header().
+	- Get rid of some unused code.
+	- Fixed several bugs in and generally cleaned up ntfs_readdir,
+	  ntfs_getdir_unsorted(), and ntfs_printcb. Now they spew out huge
+	  amounts of debug output if debugging is enabled. This will be
+	  removed once I know that this works for everyone.
+	- ntfs_readdir now shows hidden files. The only files that are now
+	  hidden are the first 16 inodes (i.e. the hard coded system files),
+	  which is consistent with Windows NT4. Using the show_sys_files mount
+	  option, these files are then shown, too.
+	- Fixed the displaying of the "." and ".." directories. We still cannot
+	  cope with more than 65536 files in a directory index block which is
+	  not a problem and we now cannot cope with more than 32766 directory
+	  index blocks which should not be a problem unless you have a
+	  directory with an insanely large number of files in it. The exact
+	  number depends on the length of the file names of the directory
+	  entries and on the size of the dircetory index blocks.
+	- Fixed all problems with the last file in a directory (e.g. the last
+	  file should no longer disappear and tab completion should work). If
+	  there are still disappearing files or any other problems with the
+	  last file in a directory, please report them! Thanks.
+	- Rewrote ntfs_extend_attr() to use the new cluster allocator and the
+	  freshly introduced splice_runlists() function. This simplified
+	  ntfs_extend_attr() a lot which in turn seems to have removed one or
+	  more bugs from it.
+	- Probably other things I have forgotten... (-;
+	- Removed dollar signs from the names in the system file enumeration.
+	  Apparently gcc doesn't support dollar signs on PPC architecture.
+	  (Andrzej Krzysztofowicz)
+
+NTFS 1.1.17:
+
+	- Fixed system file handling. No longer need to use show_sys_files
+	  option for driver to work fine. System files are now always treated
+	  the same, but without the option, they are made invisible to
+	  directory listings. As a result system files can once again be opened
+	  even without the show_sys_files option. This is important for the
+	  statfs system call to work properly, for example.
+	- Implemented MFT zone including mount parameter to tune it (just like
+	  in Windows via the registry, only we make it per mount rather than
+	  global for the whole driver, so we are better but we have no way of
+	  storing the value as we don't have a registry so either specify on
+	  each mount or put it in /etc/fstab). [Stage 1 of 3, mount parameter
+	  handling.]
+	- Fixed fixup functions to handle corruption cases and to return error
+	  codes to the caller.
+	- Made fixup functions apply hotfixes where sensible. [Stage 1 of 2+,
+	  in memory only.]
+	- Fixed ommission of "NTFS: " string in ntfs_error() output.
+	- Fixed stupid if statement bug in unistr.c. Thanks to Yann E. Morin
+	  for spotting it. 
+	- Get rid of all uses of max and min macros. This actually allowed for
+	  optimizing the code in several places so it was a Good Thing(TM).
+	- Make ntfs use generic_file_open to enforce the O_LARGEFILE flag.
+	- Detect encrypted files and refuse to access them (return EACCES
+	  error code to user space).
+	- Fix handling of encrypted & compressed files so that an encrypted
+	  file no longer is considered to be compressed (this was causing
+	  kernel segmentation faults).
 
 NTFS 1.1.16:
 
diff -u --recursive --new-file v2.4.9/linux/Documentation/ide.txt linux/Documentation/ide.txt
--- v2.4.9/linux/Documentation/ide.txt	Sat Feb 26 20:32:12 2000
+++ linux/Documentation/ide.txt	Fri Sep  7 09:28:38 2001
@@ -314,7 +314,7 @@
  "ide0=ht6560b"		: probe/support HT6560B interface
  "ide0=cmd640_vlb"	: *REQUIRED* for VLB cards with the CMD640 chip
 			  (not for PCI -- automatically detected)
- "ide0=qd6580"		: probe/support qd6580 interface
+ "ide0=qd65xx"		: probe/support qd65xx interface
  "ide0=ali14xx"		: probe/support ali14xx chipsets (ALI M1439/M1445)
  "ide0=umc8672"		: probe/support umc8672 chipsets
 
diff -u --recursive --new-file v2.4.9/linux/Documentation/input/cs461x.txt linux/Documentation/input/cs461x.txt
--- v2.4.9/linux/Documentation/input/cs461x.txt	Wed Dec 31 16:00:00 1969
+++ linux/Documentation/input/cs461x.txt	Wed Sep 12 15:34:06 2001
@@ -0,0 +1,45 @@
+Preface.
+
+This is a new low-level driver to support analog joystick attached to
+Crystal SoundFusion CS4610/CS4612/CS4615. This code is based upon 
+Vortex/Solo drivers as an example of decoration style, and ALSA
+0.5.8a kernel drivers as an chipset documentation and samples.
+
+This version does not have cooked mode support; the basic code 
+is present here, but have not tested completely. The button analysis 
+is completed in this mode, but the axis movement is not. 
+
+Raw mode works fine with analog joystick front-end driver and cs461x
+driver as a backend. I've tested this driver with CS4610, 4-axis and 
+4-button joystick; I mean the jstest utility. Also I've tried to
+play in xracer game using joystick, and the result is better than
+keyboard only mode.
+
+The sensitivity and calibrate quality have not been tested; the two
+reasons are performed: the same hardware cannot work under Win95 (blue 
+screen in VJOYD); I have no documentation on my chip; and the existing 
+behavior in my case was not raised the requirement of joystick calibration. 
+So the driver have no code to perform hardware related calibration.
+
+The patch contains minor changes of Config.in and Makefile files. All
+needed code have been moved to one separate file cs461x.c like ns558.c
+This driver have the basic support for PCI devices only; there is no
+ISA or PnP ISA cards supported. AFAIK the ns558 have support for Crystal 
+ISA and PnP ISA series.
+
+The driver works witn ALSA drivers simultaneously. For exmple, the xracer
+uses joystick as input device and PCM device as sound output in one time.
+There are no sound or input collisions detected. The source code have
+comments about them; but I've found the joystick can be initialized 
+separately of ALSA modules. So, you canm use only one joystick driver
+without ALSA drivers. The ALSA drivers are not needed to compile or
+run this driver.
+
+There are no debug information print have been placed in source, and no
+specific options required to work this driver. The found chipset parameters
+are printed via printk(KERN_INFO "..."), see the /var/log/messages to
+inspect cs461x: prefixed messages to determine possible card detection 
+errors.
+
+Regards,
+Viktor
diff -u --recursive --new-file v2.4.9/linux/Documentation/input/ff.txt linux/Documentation/input/ff.txt
--- v2.4.9/linux/Documentation/input/ff.txt	Wed Dec 31 16:00:00 1969
+++ linux/Documentation/input/ff.txt	Wed Sep 12 15:34:06 2001
@@ -0,0 +1,194 @@
+Force feedback for Linux.
+By Johann Deneux <deneux@ifrance.com> on 2001/04/22.
+
+----------------------------------------------------------------------------
+
+0. Introduction
+~~~~~~~~~~~~~~~
+This document describes how to use force feedback devices under Linux. The
+goal is not to support these devices as if they were simple input-only devices
+(as it is already the case), but to really enable the rendering of force
+effects.
+At the moment, only I-Force devices are supported, and not officially. That
+means I had to find out how the protocol works on my own. Of course, the
+information I managed to grasp is far from being complete, and I can not
+guarranty that this driver will work for you.
+This document only describes the force feedback part of the driver for I-Force
+devices. Please read joystick.txt before reading further this document.
+
+2. Instructions to the user
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Here are instructions on how to compile and use the driver. In fact, this
+driver is the normal iforce.o, input.o and evdev.o drivers written by Vojtech
+Pavlik, plus additions to support force feedback.
+
+Before you start, let me WARN you that some devices shake violently during the
+initialisation phase. This happens for example with my "AVB Top Shot Pegasus".
+To stop this annoying behaviour, move you joystick to its limits. Anyway, you
+should keep a hand on your device, in order to avoid it to brake down if
+something goes wrong.
+
+At the kernel's compilation:
+	- Enable IForce/Serial
+	- Enable Event interface
+
+Compile the modules, install them.
+
+You also need inputattach.
+
+You then need to insert the modules into the following order:
+% modprobe joydev
+% modprobe serport
+% modprobe iforce
+% modprobe evdev
+% ./inputattach -ifor $2 &	# Only for serial
+For convenience, you may use the shell script named "ff" available from
+the cvs tree of the Linux Console Project at sourceforge. You can also
+retrieve it from http://www.esil.univ-mrs.fr/~jdeneux/projects/ff/.
+If you are using USB, you don't need the inputattach step.
+
+Please check that you have all the /dev/input entries needed:
+cd /dev
+rm js*
+mkdir input
+mknod input/js0 c 13 0
+mknod input/js1 c 13 1
+mknod input/js2 c 13 2
+mknod input/js3 c 13 3
+ln -s input/js0 js0
+ln -s input/js1 js1
+ln -s input/js2 js2
+ln -s input/js3 js3
+
+mknod input/event0 c 13 64
+mknod input/event1 c 13 65
+mknod input/event2 c 13 66
+mknod input/event3 c 13 67
+
+2.1 Does it work ?
+~~~~~~~~~~~~~~~~~~
+There is an utility called fftest that will allow you to test the driver.
+% fftest /dev/eventXX
+
+3. Instructions to the developper
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  All interactions are done using the event API. That is, you can use ioctl()
+and write() on /dev/input/eventXX.
+  This information is subject to change.
+
+3.1 Querying device capabilities
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#include <linux/input.h>
+#include <sys/ioctl.h>
+
+int ioctl(int file_descriptor, int request, unsigned long *features);
+
+"request" must be EVIOCGBIT(EV_FF, sizeof(unsigned long))
+
+Returns the features supported by the device. features is a bitfield with the
+following bits:
+- FF_X		has an X axis (should allways be the case)
+- FF_Y		has an Y axis (usually not the case for wheels)
+- FF_CONSTANT	can render constant force effects
+- FF_PERIODIC	can render periodic effects (sine, ramp, square...)
+- FF_SPRING	can simulate the presence of a spring
+- FF_FRICTION	can simulate friction (aka drag, damper effect...)
+- FF_RUMBLE	rumble effects (normally the only effect supported by rumble
+		pads)
+- 8 bits from FF_N_EFFECTS_0 containing the number of effects that can be
+		simultaneously played.
+
+3.2 Uploading effects to the device
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#include <linux/input.h>
+#include <sys/ioctl.h>
+ 
+int ioctl(int file_descriptor, int request, struct ff_effect *effect);
+
+"request" must be EVIOCSFF.
+
+"effect" points to a structure describing the effect to upload. The effect is
+uploaded, but not played.
+The content of effect may be modified. In particular, its field "id" is set
+to the unique id assigned by the driver. This data is required for performing
+some operations (removing an effect, controlling the playback).
+See <linux/input.h> for a description of the ff_effect stuct.
+
+3.3 Removing an effect from the device
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+int ioctl(int fd, EVIOCRMFF, effect.id);
+
+This makes room for new effects in the device's memory. Please note this won't
+stop the effect if it was playing.
+
+3.4 Controlling the playback of effects
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Control of playing is done with write(). Below is an example:
+
+#include <linux/input.h>
+#include <unistd.h>
+
+	struct input_event play;
+	struct input_event stop;
+	struct ff_effect effect;
+	int fd;
+...
+	fd = open("/dev/input/eventXX", O_RDWR);
+...
+	/* Play three times */
+	play.type = EV_FF;
+	play.code = effect.id;
+	play.value = 3;
+	
+	write(fd, (const void*) &play, sizeof(play));
+...
+	/* Stop an effect */
+	stop.type = EV_FF;
+	stop.code = effect.id;
+	stop.value = 0;
+	
+	write(fd, (const void*) &play, sizeof(stop));
+
+3.5 Setting the gain
+~~~~~~~~~~~~~~~~~~~~
+Not all devices have the same strength. Therefore, users should set a gain
+factor depending on how strong they want effects to be. This setting is
+persistent accross access to the driver, so you should not care about it if
+you are writing games, as another utility probably already set this for you.
+
+/* Set the gain of the device
+int gain;		/* between 0 and 100 */
+struct input_event ie;	/* structure used to communicate with the driver */
+
+ie.type = EV_FF;
+ie.code = FF_GAIN;
+ie.value = 0xFFFFUL * gain / 100;
+
+if (write(fd, &ie, sizeof(ie)) == -1)
+	perror("set gain");
+
+3.6 Enabling/Disabling autocenter
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The autocenter feature quite disturbs the rendering of effects in my opinion,
+and I think it should be an effect, which computation depends on the game
+type. But you can enable it if you want.
+
+int autocenter;		/* between 0 and 100 */
+struct input_event ie;
+
+ie.type = EV_FF;
+ie.code = FF_AUTOCENTER;
+ie.value = 0xFFFFUL * autocenter / 100;
+
+if (write(fd, &ie, sizeof(ie)) == -1)
+	perror("set auto-center");
+
+A value of 0 means "no auto-center".
+
+3.7 Dynamic update of an effect
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+This consists in changing some parameters of an effect while it's playing. The
+driver currently does not support that. You still have the brute-force method,
+which consists in erasing the effect and uploading the updated version. It
+actually works pretty well. You don't need to stop-and-start the effect.
+
diff -u --recursive --new-file v2.4.9/linux/Documentation/input/gameport-programming.txt linux/Documentation/input/gameport-programming.txt
--- v2.4.9/linux/Documentation/input/gameport-programming.txt	Wed Dec 31 16:00:00 1969
+++ linux/Documentation/input/gameport-programming.txt	Wed Sep 12 15:34:06 2001
@@ -0,0 +1,189 @@
+$Id: gameport-programming.txt,v 1.3 2001/04/24 13:51:37 vojtech Exp $
+
+Programming gameport drivers
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+1. A basic classic gameport
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+If the gameport doesn't provide more than the inb()/outb() functionality,
+the code needed to register it with the joystick drivers is simple:
+
+	struct gameport gameport;
+
+	gameport.io = MY_IO_ADDRESS;
+	gameport_register_port(&gameport);
+
+Make sure struct gameport is initialized to 0 in all other fields. The
+gameport generic code will take care of the rest.
+
+If your hardware supports more than one io address, and your driver can
+choose which one program the hardware to, starting from the more exotic
+addresses is preferred, because the likelyhood of clashing with the standard
+0x201 address is smaller.
+
+Eg. if your driver supports addresses 0x200, 0x208, 0x210 and 0x218, then
+0x218 would be the address of first choice.
+
+If your hardware supports a gameport address that is not mapped to ISA io
+space (is above 0x1000), use that one, and don't map the ISA mirror.
+
+Also, always request_region() on the whole io space occupied by the
+gameport. Although only one ioport is really used, the gameport usually
+occupies from one to sixteen addresses in the io space.
+
+Please also consider enabling the gameport on the card in the ->open()
+callback if the io is mapped to ISA space - this way it'll occupy the io
+space only when something really is using it. Disable it again in the
+->close() callback. You also can select the io address in the ->open()
+callback, so that it doesn't fail if some of the possible addresses are
+already occupied by other gameports.
+
+2. Memory mapped gameport
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+When a gameport can be accessed through MMIO, this way is preferred, because
+it is faster, allowing more reads per second. Registering such a gameport
+isn't as easy as a basic IO one, but not so much complex:
+
+	struct gameport gameport;
+
+	void my_trigger(struct gameport *gameport)
+	{
+		my_mmio = 0xff;
+	}
+
+	unsigned char my_read(struct gameport *gameport)
+	{
+		return my_mmio;	
+	}
+
+	gameport.read = my_read;
+	gameport.trigger = my_trigger;
+	gameport_register_port(&gameport);
+
+3. Cooked mode gameport
+~~~~~~~~~~~~~~~~~~~~~~~
+
+There are gameports that can report the axis values as numbers, that means
+the driver doesn't have to measure them the old way - an ADC is built into
+the gameport. To register a cooked gameport:
+
+	struct gameport gameport;
+
+	int my_cooked_read(struct gameport *gameport, int *axes, int *buttons)
+	{
+		int i;
+
+		for (i = 0; i < 4; i++)
+			axes[i] = my_mmio[i];
+		buttons[i] = my_mmio[4];
+	}
+
+	int my_open(struct gameport *gameport, int mode)
+	{
+		return -(mode != GAMEPORT_MODE_COOKED);
+	}
+
+	gameport.cooked_read = my_cooked_read;
+	gameport.open = my_open;
+	gameport.fuzz = 8;
+	gameport_register_port(&gameport);
+
+The only confusing thing here is the fuzz value. Best determined by
+experimentation, it is the amount of noise in the ADC data. Perfect
+gameports can set this to zero, most common have fuzz between 8 and 32.
+See analog.c and input.c for handling of fuzz - the fuzz value determines
+the size of a gaussian filter window that is used to eliminate the noise
+in the data.
+
+4. More complex gameports
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Gameports can support both raw and cooked modes. In that case combine either
+examples 1+2 or 1+3. Gameports can support internal calibration - see below,
+and also lightning.c and analog.c on how that works. If your driver supports
+more than one gameport instance simultaneously, use the ->private member of
+the gameport struct to point to your data.
+
+5. Unregistering a gameport
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Simple:
+
+gameport_unregister_port(&gameport);
+
+6. The gameport structure
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+struct gameport {
+
+	void *private;
+
+A private pointer for free use in the gameport driver. (Not the joystick
+driver!)
+
+	int number;
+
+Number assigned to the gameport when registered. Informational purpose only.
+
+	int io;
+
+I/O address for use with raw mode. You have to either set this, or ->read()
+to some value if your gameport supports raw mode.
+
+	int speed;
+
+Raw mode speed of the gameport reads in thousands of reads per second.
+
+	int fuzz;
+
+If the gameport supports cooked mode, this should be set to a value that
+represents the amount of noise in the data. See section 3.
+
+	void (*trigger)(struct gameport *);
+
+Trigger. This function should trigger the ns558 oneshots. If set to NULL,
+outb(0xff, io) will be used.
+
+	unsigned char (*read)(struct gameport *);
+
+Read the buttons and ns558 oneshot bits. If set to NULL, inb(io) will be
+used instead.
+
+	int (*cooked_read)(struct gameport *, int *axes, int *buttons);	
+
+If the gameport supports cooked mode, it should point this to its cooked
+read function. It should fill axes[0..3] with four values of the joystick axes
+and buttons[0] with four bits representing the buttons.
+
+	int (*calibrate)(struct gameport *, int *axes, int *max); 
+
+Function for calibrating the ADC hardware. When called, axes[0..3] should be
+pre-filled by cooked data by the caller, max[0..3] should be pre-filled with
+expected maximums for each axis. The calibrate() function should set the
+sensitivity of the ADC hardware so that the maximums fit in its range and
+recompute the axes[] values to match the new sensitivity or re-read them from
+the hardware so that they give valid values. 
+
+	int (*open)(struct gameport *, int mode);
+
+Open() serves two purposes. First a driver either opens the port in raw or
+in cooked mode, the open() callback can decide which modes are supported.
+Second, resource allocation can happen here. The port can also be enabled
+here. Prior to this call, other fields of the gameport struct (namely the io
+member) need not to be valid.
+
+	void (*close)(struct gameport *);
+
+Close() should free the resources allocated by open, possibly disabling the
+gameport.
+
+	struct gameport_dev *dev;
+	struct gameport *next;
+
+For internal use by the gameport layer.
+
+};
+
+Enjoy!
diff -u --recursive --new-file v2.4.9/linux/Documentation/input/input-programming.txt linux/Documentation/input/input-programming.txt
--- v2.4.9/linux/Documentation/input/input-programming.txt	Wed Dec 31 16:00:00 1969
+++ linux/Documentation/input/input-programming.txt	Wed Sep 12 15:34:06 2001
@@ -0,0 +1,271 @@
+$Id: input-programming.txt,v 1.4 2001/05/04 09:47:14 vojtech Exp $
+
+Programming input drivers
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+1. Creating an input device driver
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+1.0 The simplest example
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+Here comes a very simple example of an input device driver. The device has
+just one button and the button is accessible at i/o port BUTTON_PORT. When
+pressed or released a BUTTON_IRQ happens. The driver could look like:
+
+#include <linux/input.h>
+#include <linux/module.h>
+#include <linux/init.h>
+
+#include <asm/irq.h>
+#include <asm/io.h>
+
+static void button_interrupt(int irq, void *dummy, struct pt_regs *fp)
+{
+	input_report_key(&button_dev, BTN_1, inb(BUTTON_PORT) & 1);
+}
+
+static int __init button_init(void)
+{
+	if (request_irq(BUTTON_IRQ, button_interrupt, 0, "button", NULL)) {
+                printk(KERN_ERR "button.c: Can't allocate irq %d\n", button_irq);
+                return -EBUSY;
+        }
+	
+	button_dev.evbit[0] = BIT(EV_KEY);
+	button_dev.keybit[LONG(BTN_0)] = BIT(BTN_0);
+	
+	input_register_device(&button_dev);
+}
+
+static void __exit button_exit(void)
+{
+        input_unregister_device(&button_dev);
+	free_irq(BUTTON_IRQ, button_interrupt);
+}
+
+module_init(button_init);
+module_exit(button_exit);
+
+1.1 What the example does
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+First it has to include the <linux/input.h> file, which interfaces to the
+input subsystem. This provides all the definitions needed.
+
+In the _init function, which is called either upon module load or when
+booting the kernel, it grabs the required resources (it should also check
+for the presence of the device).
+
+Then it sets the input bitfields. This way the device driver tells the other
+parts of the input systems what it is - what events can be generated or
+accepted by this input device. Our example device can only generate EV_KEY type
+events, and from those only BTN_0 event code. Thus we only set these two
+bits. We could have used
+
+	set_bit(EV_KEY, button_dev.evbit);
+	set_bit(BTN_0, button_dev.keybit);
+
+as well, but with more than single bits the first approach tends to be
+shorter. 
+
+Then the example driver registers the input device structure by calling
+
+	input_register_device(&button_dev);
+
+This adds the button_dev structure to linked lists of the input driver and
+calls device handler modules _connect functions to tell them a new input
+device has appeared. Because the _connect functions may call kmalloc(,
+GFP_KERNEL), which can sleep, input_register_device() must not be called
+from an interrupt or with a spinlock held.
+
+While in use, the only used function of the driver is
+
+	button_interrupt()
+
+which upon every interrupt from the button checks its state and reports it
+via the 
+
+	input_report_btn()
+
+call to the input system. There is no need to check whether the interrupt
+routine isn't reporting two same value events (press, press for example) to
+the input system, because the input_report_* functions check that
+themselves.
+
+1.2 dev->open() and dev->close()
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+In case the driver has to repeatedly poll the device, because it doesn't
+have an interrupt coming from it and the polling is too expensive to be done
+all the time, or if the device uses a valuable resource (eg. interrupt), it
+can use the open and close callback to know when it can stop polling or
+release the interrupt and when it must resume polling or grab the interrupt
+again. To do that, we would add this to our example driver:
+
+int button_used = 0;
+
+static int button_open(struct input_dev *dev)
+{
+        if (button_used++)
+                return 0;
+
+	if (request_irq(BUTTON_IRQ, button_interrupt, 0, "button", NULL)) {
+                printk(KERN_ERR "button.c: Can't allocate irq %d\n", button_irq);
+                button_used--;
+                return -EBUSY;
+        }
+
+        return 0;
+}
+
+static void button_close(struct input_dev *dev)
+{
+        if (!--button_used)
+                free_irq(IRQ_AMIGA_VERTB, button_interrupt);
+}
+
+static int __init button_init(void)
+{
+	...
+	button_dev.open = button_open;
+	button_dev.close = button_close;
+	...
+}
+
+Note the button_used variable - we have to track how many times the open
+function was called to know when exactly our device stops being used.
+
+The open() callback should return a 0 in case of succes or any nonzero value
+in case of failure. The close() callback (which is void) must always succeed.
+
+1.3 Basic event types
+~~~~~~~~~~~~~~~~~~~~~
+
+The most simple event type is EV_KEY, which is used for keys and buttons.
+It's reported to the input system via:
+
+	input_report_key(struct input_dev *dev, int code, int value)
+
+See linux/input.h for the allowable values of code (from 0 to KEY_MAX).
+Value is interpreted as a truth value, ie any nonzero value means key
+pressed, zero value means key released. The input code generates events only
+in case the value is different from before.
+
+In addition to EV_KEY, there are two more basic event types: EV_REL and
+EV_ABS. They are used for relative and absolute values supplied by the
+device. A relative value may be for example a mouse movement in the X axis.
+The mouse reports it as a relative difference from the last position,
+because it doesn't have any absolute coordinate system to work in. Absolute
+events are namely for joysticks and digitizers - devices that do work in an
+absolute coordinate systems.
+
+Having the device report EV_REL buttons is as simple as with EV_KEY, simply
+set the corresponding bits and call the
+
+	input_report_rel(struct input_dev *dev, int code, int value)
+
+function. Events are generated only for nonzero value. 
+
+However EV_ABS requires a little special care. Before calling
+input_register_devices, you have to fill additional fields in the input_dev
+struct for each absolute axis your device has. If our button device had also
+the ABS_X axis:
+
+	button_dev.absmin[ABS_X] = 0;
+	button_dev.absmax[ABS_X] = 255;
+	button_dev.absfuzz[ABS_X] = 4;
+	button_dev.absflat[ABS_X] = 8;
+
+This setting would be appropriate for a joystick X axis, with the minimum of
+0, maximum of 255 (which the joystick *must* be able to reach, no problem if
+it sometimes reports more, but it must be able to always reach the min and
+max values), with noise in the data up to +- 4, and with a center flat
+position of size 8.
+
+If you don't need absfuzz and absflat, you can set them to zero, which mean
+that the thing is precise and always returns to exactly the center position
+(if it has any).
+
+1.4 The void *private field
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This field in the input structure can be used to point to any private data
+structures in the input device driver, in case the driver handles more than
+one device. You'll need it in the open and close callbacks.
+
+1.5 NBITS(), LONG(), BIT()
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+These three macros frin input.h help some bitfield computations:
+
+	NBITS(x) - returns the length of a bitfield array in longs for x bits
+	LONG(x)  - returns the index in the array in longs for bit x
+	BIT(x)   - returns the indes in a long for bit x
+
+1.6 The number, id* and name fields
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The dev->number is assigned by the input system to the input device when it
+is registered. It has no use except for identifying the device to the user
+in system messages.
+
+The dev->name should be set before registering the input device by the input
+device driver. It's a string like 'Generic button device' containing an
+user friendly name of the device.
+
+The id* fields contain the bus ID (PCI, USB, ...), vendor ID and device ID
+of the device. The bus IDs are defined in input.h. The vendor and device ids
+are defined in pci_ids.h, usb_ids.h and similar include files. These fields
+should be set by the input device driver before registering it.
+
+The idtype field can be used for specific information for the input device
+driver.
+
+The id and name fields can be passed to userland via the evdev interface.
+
+1.7 The keycode, keycodemax, keycodesize fields
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+These two fields will be used for any inpur devices that report their data
+as scancodes. If not all scancodes can be known by autodetection, they may
+need to be set by userland utilities. The keycode array then is an array
+used to map from scancodes to input system keycodes. The keycode max will
+contain the size of the array and keycodesize the size of each entry in it
+(in bytes).
+
+1.8 Key autorepeat
+~~~~~~~~~~~~~~~~~~
+
+... is simple. It is handled by the input.c module. Hardware autorepeat is
+not used, because it's not present in many devices and even where it is
+present, it is broken sometimes (at keyboards: Toshiba notebooks). To enable
+autorepeat for your device, just set EV_REP in dev->evbit. All will be
+handled by the input system.
+
+1.9 Other event types, handling output events
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The other event types up to now are:
+
+EV_LED - used for the keyboad LEDs.
+EV_SND - used for keyboard beeps.
+
+They are very similar to for example key events, but they go in the other
+direction - from the system to the input device driver. If your input device
+driver can handle these events, it has to set the respective bits in evbit,
+*and* also the callback routine:
+
+	button_dev.event = button_event;
+
+int button_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
+{
+	if (type == EV_SND && code == EV_BELL) {
+		outb(value, BUTTON_BELL);
+		return 0;
+	}
+	return -1;
+}
+
+This callback routine can be called from an interrupt or a BH (although that
+isn't a rule), and thus must not sleep, and must not take too long to finish.
diff -u --recursive --new-file v2.4.9/linux/Documentation/input/input.txt linux/Documentation/input/input.txt
--- v2.4.9/linux/Documentation/input/input.txt	Wed Dec 31 16:00:00 1969
+++ linux/Documentation/input/input.txt	Wed Sep 12 15:34:06 2001
@@ -0,0 +1,297 @@
+			  Linux Input drivers v1.0
+	       (c) 1999-2001 Vojtech Pavlik <vojtech@suse.cz>
+			     Sponsored by SuSE
+	    $Id: input.txt,v 1.5 2001/06/06 11:05:33 vojtech Exp $
+----------------------------------------------------------------------------
+
+0. Disclaimer
+~~~~~~~~~~~~~
+  This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option)
+any later version.
+
+  This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+more details.
+
+  You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc., 59
+Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+  Should you need to contact me, the author, you can do so either by e-mail
+- mail your message to <vojtech@suse.cz>, or by paper mail: Vojtech Pavlik,
+Simunkova 1594, Prague 8, 182 00 Czech Republic
+
+  For your convenience, the GNU General Public License version 2 is included
+in the package: See the file COPYING.
+
+1. Introduction
+~~~~~~~~~~~~~~~
+  This is a collection of drivers that is designed to support all input
+devices under Linux. However, in the current kernels, although it's
+possibilities are much bigger, it's limited to USB devices only. This is
+also why it resides in the drivers/usb subdirectory.
+
+  The center of the input drivers is the input.o module, which must be
+loaded before any other of the input modules - it serves as a way of
+communication between two groups of modules:
+
+1.1 Device drivers
+~~~~~~~~~~~~~~~~~~
+  These modules talk to the hardware (for example via USB), and provide
+events (keystrokes, mouse movements) to the input.o module.
+
+1.2 Event handlers
+~~~~~~~~~~~~~~~~~~
+  These modules get events from input.o and pass them where needed via
+various interfaces - keystrokes to the kernel, mouse movements via a
+simulated PS/2 interface to GPM and X and so on.
+
+2. Simple Usage
+~~~~~~~~~~~~~~~
+  For the most usual configuration, with one USB mouse and one USB keyboard,
+you'll have to load the following modules (or have them built in to the
+kernel):
+
+	input.o
+	mousedev.o
+	keybdev.o
+	usbcore.o
+	usb-[uo]hci.o
+	hid.o
+
+  After this, the USB keyboard will work straight away, and the USB mouse
+will be available as a character device on major 13, minor 63:
+
+	crw-r--r--   1 root     root      13,  63 Mar 28 22:45 mice
+
+  This device, has to be created, unless you use devfs, in which case it's
+created automatically. The commands to do that are:
+
+	cd /dev
+	mkdir input
+	mknod input/mice c 13 63
+
+  After that you have to point GPM (the textmode mouse cut&paste tool) and
+XFree to this device to use it - GPM should be called like:
+
+	gpm -t ps2 -m /dev/input/mice
+
+  And in X:
+
+	Section "Pointer"
+	    Protocol    "ImPS/2"
+	    Device      "/dev/input/mice"
+	    ZAxisMapping 4 5
+	EndSection
+
+  When you do all of the above, you can use your USB mouse and keyboard.
+
+3. Detailed Description
+~~~~~~~~~~~~~~~~~~~~~~~
+3.1 Device drivers
+~~~~~~~~~~~~~~~~~~
+  Device drivers are the modules that generate events. The events are
+however not useful without being handled, so you also will need to use some
+of the modules from section 3.2.
+
+3.1.1 hid.c
+~~~~~~~~~~~
+  Hid.c is the largest and most complex driver of the whole suite. It
+handles all HID devices, and because there is a very wide variety of them,
+and because the USB HID specification isn't simple, it needs to be this big.
+
+  Currently, it handles USB mice, joysticks, gamepads, steering wheels
+keyboards, trackballs and digitizers.
+
+ However, USB uses HID also for monitor controls, speaker controls, UPSs,
+LCDs and many other purposes.
+
+ The monitor and speaker controls should be easy to add to the hid/input
+interface, but for the UPSs and LCDs it doesn't make much sense. For this,
+the hiddev interface was designed. See Documentation/usb/hiddev.txt
+for more information about it.
+
+  The usage of the hid.o module is very simple, it takes no parameters,
+detects everything automatically and when a HID device is inserted, it
+detects it appropriately.
+
+  However, because the devices vary wildly, you might happen to have a
+device that doesn't work well. In that case #define DEBUG at the beginning
+of hid.c and send me the syslog traces.
+
+3.1.2 usbmouse.c
+~~~~~~~~~~~~~~~~
+  For embedded systems, for mice with broken HID descriptors and just any
+other use when the big hid.c wouldn't be a good choice, there is the
+usbmouse.c driver. It handles USB mice only. It uses a simpler HIDBP
+protocol. This also means the mice must support this simpler protocol. Not
+all do. If you don't have any strong reason to use this module, use hid.c
+instead.
+
+3.1.3 usbkbd.c
+~~~~~~~~~~~~~~
+  Much like usbmouse.c, this module talks to keyboards with a simpplified
+HIDBP protocol. It's smaller, but doesn't support any extra special keys.
+Use hid.c instead if there isn't any special reason to use this.
+
+3.1.4 wacom.c
+~~~~~~~~~~~~~
+  This is a driver for Wacom Graphire and Intuos tablets. Not for Wacom
+PenPartner, that one is handled by the HID driver. Although the Intuos and
+Graphire tablets claim that they are HID tablets as well, they are not and
+thus need this specific driver.
+
+3.1.5 iforce.c
+~~~~~~~~~~~~~~~
+  A driver for I-Force joysticks and wheels, both over USB and RS232. 
+It includes ForceFeedback support now, even though Immersion Corp. considers
+the protocol a trade secret and won't disclose a word about it.
+
+3.2 Event handlers
+~~~~~~~~~~~~~~~~~~
+  Event handlers distrubite the events from the devices to userland and
+kernel, as needed.
+
+3.2.1 keybdev.c
+~~~~~~~~~~~~~~~
+  Keybdev is currently a rather ugly hack that translates the input events
+into architecture-specific keyboard raw mode (Xlated AT Set2 on x86), and
+passes them into the handle_scancode function of the keyboard.c module. This
+works well enough on all architectures that keybdev can generate rawmode on,
+other architectures can be added to it.
+
+  The right way would be to pass the events to keyboard.c directly, best if
+keyboard.c would itself be an event handler. This is done in the input
+patch, available on the webpage mentioned below.
+
+3.2.2 mousedev.c
+~~~~~~~~~~~~~~~~
+  Mousedev is also a hack to make programs that use mouse input work. It
+takes events from either mice or digitizers/tablets and makes a PS/2-style
+(a la /dev/psaux) mouse device available to the userland. Ideally, the
+programs could use a more reasonable interface, for example evdev.c
+
+  Mousedev devices in /dev/input (as shown above) are:
+
+	crw-r--r--   1 root     root      13,  32 Mar 28 22:45 mouse0
+	crw-r--r--   1 root     root      13,  33 Mar 29 00:41 mouse1
+	crw-r--r--   1 root     root      13,  34 Mar 29 00:41 mouse2
+	crw-r--r--   1 root     root      13,  35 Apr  1 10:50 mouse3
+	...
+	...
+	crw-r--r--   1 root     root      13,  62 Apr  1 10:50 mouse30
+	crw-r--r--   1 root     root      13,  63 Apr  1 10:50 mice
+
+Each 'mouse' device is assigned to a single mouse or digitizer, except the last
+one - 'mice'. This single character device is shared by all mice and
+digitizers, and even if none are connected, the device is present.  This is
+useful for hotplugging USB mice, so that programs can open the device even when
+no mice are present.
+
+  CONFIG_INPUT_MOUSEDEV_SCREEN_[XY] in the kernel configuration are the size
+of your screen (in pixels) in XFree86. This is needed if you want to use
+your digitizer in X, because it's movement is sent to X via a virtual PS/2
+mouse and thus needs to be scaled accordingly. These values won't be used if
+you use a mouse only.
+
+  Mousedev will generate either PS/2, ImPS/2 (Microsoft IntelliMouse) or
+ExplorerPS/2 (IntelliMouse Explorer) protocols, depending on what the program
+reading the data wishes. You can set GPM and X to any of these. You'll need
+ImPS/2 if you want to make use of a wheel on a USB mouse and ExplorerPS/2 if you
+want to use extra (up to 5) buttons. 
+
+3.2.3 joydev.c
+~~~~~~~~~~~~~~
+  Joydev implements v0.x and v1.x Linux joystick api, much like
+drivers/char/joystick/joystick.c used to in earlier versions. See
+joystick-api.txt in the Documentation subdirectory for details.  As soon as
+any joystick is connected, it can be accessed in /dev/input on:
+
+	crw-r--r--   1 root     root      13,   0 Apr  1 10:50 js0
+	crw-r--r--   1 root     root      13,   1 Apr  1 10:50 js1
+	crw-r--r--   1 root     root      13,   2 Apr  1 10:50 js2
+	crw-r--r--   1 root     root      13,   3 Apr  1 10:50 js3
+	...
+
+And so on up to js31.
+
+3.2.4 evdev.c
+~~~~~~~~~~~~~
+  Evdev is the generic input event interface. It passes the events generated
+in the kernel straight to the program, with timestamps. The API is still
+evolving, but should be useable now. It's described in section 5.
+
+  This should be the way for GPM and X to get keyboard and mouse mouse
+events. It allows for multihead in X without any specific multihead kernel
+support. The event codes are the same on all architectures and are hardware
+independent.
+
+  The devices are in /dev/input:
+
+	crw-r--r--   1 root     root      13,  64 Apr  1 10:49 event0
+	crw-r--r--   1 root     root      13,  65 Apr  1 10:50 event1
+	crw-r--r--   1 root     root      13,  66 Apr  1 10:50 event2
+	crw-r--r--   1 root     root      13,  67 Apr  1 10:50 event3
+	...
+
+3. Contacts
+~~~~~~~~~~~
+  This effort has it's home page at:
+
+	http://www.suse.cz/development/input/
+
+You'll find both the latest HID driver and the complete Input driver there
+as well as information how to access the CVS repository for latest revisions
+of the drivers.
+
+  There is also a mailing list for this:
+
+	majordomo@atrey.karlin.mff.cuni.cz
+
+Send "subscribe linux-input" to subscribe to it.
+
+4. Verifying if it works
+~~~~~~~~~~~~~~~~~~~~~~~~
+  Typing a couple keys on the keyboard should be enough to check that a USB
+keyboard works and is correctly connected to the kernel keyboard driver.
+
+  Doing a cat /dev/input/mouse0 (c, 13, 32) will verify that a mouse is also
+emulated, characters should appear if you move it.
+
+  You can test the joystick emulation with the 'jstest' utility, available
+in the joystick package (see Documentation/joystick.txt).
+
+  You can test the event devics with the 'evtest' utitily available on the
+input driver homepage (see the URL above).
+
+5. Event interface
+~~~~~~~~~~~~~~~~~~
+  Should you want to add event device support into any application (X, gpm,
+svgalib ...) I <vojtech@suse.cz> will be happy to provide you any help I
+can. Here goes a description of the current state of things, which is going
+to be extended, but not changed incompatibly as time goes:
+
+  You can use blocking and nonblocking reads, also select() on the
+/dev/input/eventX devices, and you'll always get a whole number of input
+events on a read. Their layout is:
+
+struct input_event {
+	struct timeval time;
+	unsigned short type;
+	unsigned short code;
+	unsigned int value;
+};
+
+  'time' is the timestamp, it returns the time at which the event happened.
+Type is for example EV_REL for relative momement, REL_KEY for a keypress or
+release. More types are defined in include/linux/input.h.
+
+  'code' is event code, for example REL_X or KEY_BACKSPACE, again a complete
+list is in include/linux/input.h.
+
+  'value' is the value the event carries. Either a relative change for
+EV_REL, absolute new value for EV_ABS (joysticks ...), or 0 for EV_KEY for
+release, 1 for keypress and 2 for autorepeat.
diff -u --recursive --new-file v2.4.9/linux/Documentation/input/joystick-api.txt linux/Documentation/input/joystick-api.txt
--- v2.4.9/linux/Documentation/input/joystick-api.txt	Wed Dec 31 16:00:00 1969
+++ linux/Documentation/input/joystick-api.txt	Wed Sep 12 15:34:06 2001
@@ -0,0 +1,316 @@
+		      Joystick API Documentation                -*-Text-*-
+
+		        Ragnar Hojland Espinosa
+			  <ragnar@macula.net>
+
+			      7 Aug 1998
+
+	$Id: joystick-api.txt,v 1.2 2001/05/08 21:21:23 vojtech Exp $
+
+1. Initialization
+~~~~~~~~~~~~~~~~~
+
+Open the joystick device following the usual semantics (that is, with open).
+Since the driver now reports events instead of polling for changes,
+immediately after the open it will issue a series of synthetic events
+(JS_EVENT_INIT) that you can read to check the initial state of the
+joystick.
+
+By default, the device is opened in blocking mode.
+
+	int fd = open ("/dev/js0", O_RDONLY);
+
+
+2. Event Reading
+~~~~~~~~~~~~~~~~
+
+	struct js_event e;
+	read (fd, &e, sizeof(struct js_event));
+
+where js_event is defined as
+
+	struct js_event {
+		__u32 time;     /* event timestamp in milliseconds */
+		__s16 value;    /* value */
+		__u8 type;      /* event type */
+		__u8 number;    /* axis/button number */
+	};
+
+If the read is successful, it will return sizeof(struct js_event), unless
+you wanted to read more than one event per read as described in section 3.1.
+
+
+2.1 js_event.type
+~~~~~~~~~~~~~~~~~
+
+The possible values of ``type'' are
+
+	#define JS_EVENT_BUTTON         0x01    /* button pressed/released */
+	#define JS_EVENT_AXIS           0x02    /* joystick moved */
+	#define JS_EVENT_INIT           0x80    /* initial state of device */
+
+As mentioned above, the driver will issue synthetic JS_EVENT_INIT ORed
+events on open. That is, if it's issuing a INIT BUTTON event, the
+current type value will be
+
+	int type = JS_EVENT_BUTTON | JS_EVENT_INIT;	/* 0x81 */
+
+If you choose not to differentiate between synthetic or real events
+you can turn off the JS_EVENT_INIT bits
+
+	type &= ~JS_EVENT_INIT;				/* 0x01 */
+
+
+2.2 js_event.number
+~~~~~~~~~~~~~~~~~~~
+
+The values of ``number'' correspond to the axis or button that
+generated the event. Note that they carry separate numeration (that
+is, you have both an axis 0 and a button 0). Generally,
+
+			number
+	1st Axis X	0
+	1st Axis Y	1
+	2nd Axis X	2
+	2nd Axis Y	3
+	...and so on
+
+Hats vary from one joystick type to another. Some can be moved in 8
+directions, some only in 4, The driver, however, always reports a hat as two
+independent axis, even if the hardware doesn't allow independent movement.
+
+
+2.3 js_event.value
+~~~~~~~~~~~~~~~~~~
+
+For an axis, ``value'' is a signed integer between -32767 and +32767
+representing the position of the joystick along that axis. If you
+don't read a 0 when the joystick is `dead', or if it doesn't span the
+full range, you should recalibrate it (with, for example, jscal).
+
+For a button, ``value'' for a press button event is 1 and for a release
+button event is 0.
+
+Though this
+
+	if (js_event.type == JS_EVENT_BUTTON) {
+		buttons_state ^= (1 << js_event.number);
+	}
+
+may work well if you handle JS_EVENT_INIT events separately,
+
+	if ((js_event.type & ~JS_EVENT_INIT) == JS_EVENT_BUTTON) {
+		if (js_event.value)
+	        	buttons_state |= (1 << js_event.number);
+	   	else
+	      		buttons_state &= ~(1 << js_event.number);
+	}
+
+is much safer since it can't lose sync with the driver. As you would
+have to write a separate handler for JS_EVENT_INIT events in the first
+snippet, this ends up being shorter.
+
+
+2.4 js_event.time
+~~~~~~~~~~~~~~~~~
+
+The time an event was generated is stored in ``js_event.time''. It's a time
+in milliseconds since ... well, since sometime in the past.  This eases the
+task of detecting double clicks, figuring out if movement of axis and button
+presses happened at the same time, and similar.
+
+
+3. Reading
+~~~~~~~~~~
+
+If you open the device in blocking mode, a read will block (that is,
+wait) forever until an event is generated and effectively read. There
+are two alternatives if you can't afford to wait forever (which is,
+admittedly, a long time;)
+
+	a) use select to wait until there's data to be read on fd, or
+	   until it timeouts. There's a good example on the select(2)
+	   man page.
+
+	b) open the device in non-blocking mode (O_NONBLOCK)
+
+
+3.1 O_NONBLOCK
+~~~~~~~~~~~~~~
+
+If read returns -1 when reading in O_NONBLOCK mode, this isn't
+necessarily a "real" error (check errno(3)); it can just mean there
+are no events pending to be read on the driver queue. You should read
+all events on the queue (that is, until you get a -1).
+
+For example,
+
+	while (1) {
+		while (read (fd, &e, sizeof(struct js_event)) > 0) {
+	        	process_event (e);
+	   	}
+	   	/* EAGAIN is returned when the queue is empty */
+	   	if (errno != EAGAIN) {
+	      		/* error */
+	   	}
+	   	/* do something interesting with processed events */
+	}
+
+One reason for emptying the queue is that if it gets full you'll start
+missing events since the queue is finite, and older events will get
+overwritten.
+
+The other reason is that you want to know all what happened, and not
+delay the processing till later.
+
+Why can get the queue full? Because you don't empty the queue as
+mentioned, or because too much time elapses from one read to another
+and too many events to store in the queue get generated. Note that
+high system load may contribute to space those reads even more.
+
+If time between reads is enough to fill the queue and loose an event,
+the driver will switch to startup mode and next time you read it,
+synthetic events (JS_EVENT_INIT) will be generated to inform you of
+the actual state of the joystick.
+
+[As for version 1.2.8, the queue is circular and able to hold 64
+ events. You can increment this size bumping up JS_BUFF_SIZE in
+ joystick.h and recompiling the driver.]
+
+
+In the above code, you might as well want to read more than one event
+at a time using the typical read(2) functionality. For that, you would
+replace the read above with something like
+
+	struct js_event mybuffer[0xff];
+	int i = read (fd, mybuffer, sizeof(struct mybuffer));
+
+In this case, read would return -1 if the queue was empty, or some
+other value in which the number of events read would be i /
+sizeof(js_event)  Again, if the buffer was full, it's a good idea to
+process the events and keep reading it until you empty the driver queue.
+
+
+4. IOCTLs
+~~~~~~~~~
+
+The joystick driver defines the following ioctl(2) operations.
+
+				/* function			3rd arg  */
+	#define JSIOCGAXES	/* get number of axes		char	 */
+	#define JSIOCGBUTTONS	/* get number of buttons	char	 */
+	#define JSIOCGVERSION	/* get driver version		int	 */
+	#define JSIOCGNAME(len) /* get identifier string	char	 */
+	#define JSIOCSCORR	/* set correction values	&js_corr */
+	#define JSIOCGCORR	/* get correction values	&js_corr */
+
+For example, to read the number of axes
+
+	char number_of_axes;
+	ioctl (fd, JSIOCGAXES, &number_of_axes);
+
+
+4.1 JSIOGCVERSION
+~~~~~~~~~~~~~~~~~
+
+JSIOGCVERSION is a good way to check in run-time whether the running
+driver is 1.0+ and supports the event interface. If it is not, the
+IOCTL will fail. For a compile-time decision, you can test the
+JS_VERSION symbol
+
+	#ifdef JS_VERSION
+	#if JS_VERSION > 0xsomething
+
+
+4.2 JSIOCGNAME
+~~~~~~~~~~~~~~
+
+JSIOCGNAME(len) allows you to get the name string of the joystick - the same
+as is being printed at boot time. The 'len' argument is the length of the
+buffer provided by the application asking for the name. It is used to avoid
+possible overrun should the name be too long.
+
+	char name[128];
+	if (ioctl(fd, JSIOCGNAME(sizeof(name)), name) < 0)
+		strncpy(name, "Unknown", sizeof(name));
+	printf("Name: %s\n", name);
+
+
+4.3 JSIOC[SG]CORR
+~~~~~~~~~~~~~~~~~
+
+For usage on JSIOC[SG]CORR I suggest you to look into jscal.c  They are
+not needed in a normal program, only in joystick calibration software
+such as jscal or kcmjoy. These IOCTLs and data types aren't considered
+to be in the stable part of the API, and therefore may change without
+warning in following releases of the driver.
+
+Both JSIOCSCORR and JSIOCGCORR expect &js_corr to be able to hold
+information for all axis. That is, struct js_corr corr[MAX_AXIS];
+
+struct js_corr is defined as
+
+	struct js_corr {
+		__s32 coef[8];
+		__u16 prec;
+		__u16 type;
+	};
+
+and ``type''
+
+	#define JS_CORR_NONE            0x00    /* returns raw values */
+	#define JS_CORR_BROKEN          0x01    /* broken line */
+
+
+5. Backward compatibility
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The 0.x joystick driver API is quite limited and its usage is deprecated.
+The driver offers backward compatibility, though. Here's a quick summary:
+
+	struct JS_DATA_TYPE js;
+	while (1) {
+		if (read (fd, &js, JS_RETURN) != JS_RETURN) {
+	      		/* error */
+	   	}
+	   	usleep (1000);
+	}
+
+As you can figure out from the example, the read returns immediately,
+with the actual state of the joystick.
+
+	struct JS_DATA_TYPE {
+		int buttons;    /* immediate button state */
+		int x;          /* immediate x axis value */
+		int y;          /* immediate y axis value */
+	};
+
+and JS_RETURN is defined as
+
+	#define JS_RETURN       sizeof(struct JS_DATA_TYPE)
+
+To test the state of the buttons,
+
+	first_button_state  = js.buttons & 1;
+	second_button_state = js.buttons & 2;
+
+The axis values do not have a defined range in the original 0.x driver,
+except for that the values are non-negative. The 1.2.8+ drivers use a
+fixed range for reporting the values, 1 being the minimum, 128 the
+center, and 255 maximum value.
+
+The v0.8.0.2 driver also had an interface for 'digital joysticks', (now
+called Multisystem joysticks in this driver), under /dev/djsX. This driver
+doesn't try to be compatible with that interface.
+
+
+6. Final Notes
+~~~~~~~~~~~~~~
+
+____/|	Comments, additions, and specially corrections are welcome.
+\ o.O|	Documentation valid for at least version 1.2.8 of the joystick
+ =(_)=	driver and as usual, the ultimate source for documentation is
+   U	to "Use The Source Luke" or, at your convenience, Vojtech ;)
+
+					- Ragnar
+EOF
diff -u --recursive --new-file v2.4.9/linux/Documentation/input/joystick-parport.txt linux/Documentation/input/joystick-parport.txt
--- v2.4.9/linux/Documentation/input/joystick-parport.txt	Wed Dec 31 16:00:00 1969
+++ linux/Documentation/input/joystick-parport.txt	Wed Sep 12 15:34:06 2001
@@ -0,0 +1,533 @@
+		    Linux Joystick parport drivers v2.0
+	       (c) 1998-2000 Vojtech Pavlik <vojtech@suse.cz>
+	       (c) 1998 Andree Borrmann <a.borrmann@tu-bs.de>
+			     Sponsored by SuSE
+	$Id: joystick-parport.txt,v 1.5 2001/05/15 06:41:00 vojtech Exp $
+----------------------------------------------------------------------------
+
+0. Disclaimer
+~~~~~~~~~~~~~
+  Any information in this file is provided as-is, without any guarantee that
+it will be true. So, use it at your own risk. The possible damages that can
+happen include burning your parallel port, and/or the sticks and joystick
+and maybe even more. Like when a lightning kills you it is not our problem.
+
+1. Intro
+~~~~~~~~
+  The joystick parport drivers are used for joysticks and gamepads not
+originally designed for PCs and other computers Linux runs on. Because of
+that, PCs usually lack the right ports to connect these devices to. Parallel
+port, because of its ability to change single bits at will, and providing
+both output and input bits is the most suitable port on the PC for
+connecting such devices.
+
+2. Devices supported
+~~~~~~~~~~~~~~~~~~~~
+  Many console and 8-bit computer gamepads and joysticks are supported. The
+following subsections discuss usage of each.
+
+2.1 NES and SNES
+~~~~~~~~~~~~~~~~
+  The Nintendo Entertainment System and Super Nintendo Entertainment System
+gamepads are widely available, and easy to get. Also, they are quite easy to
+connect to a PC, and don't need much processing speed (108 us for NES and
+165 us for SNES, compared to about 1000 us for PC gamepads) to communicate
+with them.
+
+  All NES and SNES use the same synchronous serial protocol, clocked from
+the computer's side (and thus timing insensitive). To allow up to 5 NES
+and/or SNES gamepads connected to the parallel port at once, the output
+lines of the parallel port are shared, while one of 5 available input lines
+is assigned to each gamepad.
+
+  This protocol is handled by the gamecon.c driver, so that's the one
+you'll use for NES and SNES gamepads.
+
+  The main problem with PC parallel ports is that they don't have +5V power
+source on any of their pins. So, if you want a reliable source of power
+for your pads, use either keyboard or joystick port, and make a pass-through
+cable. You can also pull the power directly from the power supply (the red
+wire is +5V).
+
+  If you want to use the parallel port only, you can take the power is from
+some data pin. For most gamepad and parport implementations only one pin is
+needed, and I'd recommend pin 9 for that, the highest data bit. On the other
+hand, if you are not planning to use anything else than NES / SNES on the
+port, anything between and including pin 4 and pin 9 will work.
+
+(pin 9) -----> Power
+
+  Unfortunately, there are pads that need a lot more of power, and parallel
+ports that can't give much current through the data pins. If this is your
+case, you'll need to use diodes (as a prevention of destroying your parallel
+port), and combine the currents of two or more data bits together.
+
+	   Diodes
+(pin 9) ----|>|-------+------> Power
+		      |
+(pin 8) ----|>|-------+
+		      |
+(pin 7) ----|>|-------+
+		      |
+ <and so on>          :
+		      |
+(pin 4) ----|>|-------+
+
+  Ground is quite easy. On PC's parallel port the ground is on any of the
+pins from pin 18 to pin 25. So use any pin of these you like for the ground.
+
+(pin 18) -----> Ground
+
+  NES and SNES pads have two input bits, Clock and Latch, which drive the
+serial transfer. These are connected to pins 2 and 3 of the parallel port,
+respectively.
+
+(pin 2) -----> Clock
+(pin 3) -----> Latch
+
+  And the last thing is the NES / SNES data wire. Only that isn't shared and
+each pad needs its own data pin. The parallel port pins are:
+
+(pin 10) -----> Pad 1 data
+(pin 11) -----> Pad 2 data
+(pin 12) -----> Pad 3 data
+(pin 13) -----> Pad 4 data
+(pin 15) -----> Pad 5 data
+
+  Note that pin 14 is not used, since it is not an input pin on the parallel
+port.
+
+  This is everything you need on the PC's side of the connection, now on to
+the gamepads side. The NES and SNES have different connectors. Also, there
+are quite a lot of NES clones, and because Nintendo used proprietary
+connectors for their machines, the cloners couldn't and used standard D-Cannon
+connectors. Anyway, if you've got a gamepad, and it has buttons A, B, Turbo
+A, Turbo B, Select and Start, and is connected through 5 wires, then it is
+either a NES or NES clone and will work with this connection. SNES gamepads
+also use 5 wires, but have more buttons. They will work as well, of course.
+
+Pinout for NES gamepads                 Pinout for SNES gamepads
+
+	   +----> Power                   +-----------------------\
+	   |                            7 | o  o  o  o |  x  x  o  | 1
+ 5 +---------+  7                         +-----------------------/
+   | x  x  o   \                            |  |  |  |          |
+   | o  o  o  o |                           |  |  |  |          +-> Ground
+ 4 +------------+ 1                         |  |  |  +------------> Data
+     |  |  |  |                             |  |  +---------------> Latch
+     |  |  |  +-> Ground                    |  +------------------> Clock
+     |  |  +----> Clock                     +---------------------> Power
+     |  +-------> Latch
+     +----------> Data
+
+Pinout for NES clone (db9) gamepads     Pinout for NES clone (db15) gamepads
+
+	+---------> Clock                    +-----------------> Data
+	| +-------> Latch                    |             +---> Ground
+	| | +-----> Data                     |             |
+	| | |                              ___________________
+    _____________                        8 \ o x x x x x x o / 1
+  5 \ x o o o x / 1                         \ o x x o x x o /
+     \ x o x o /                          15 `~~~~~~~~~~~~~' 9
+    9 `~~~~~~~' 6                             |     |     |
+	 |   |                                |     |     +----> Clock
+	 |   +----> Power                     |     +----------> Latch
+	 +--------> Ground                    +----------------> Power
+
+2.2 Multisystem joysticks
+~~~~~~~~~~~~~~~~~~~~~~~~~
+  In the era of 8-bit machines, there was something like de-facto standard
+for joystick ports. They were all digital, and all used D-Cannon 9 pin
+connectors (db9). Because of that, a single joystick could be used without
+hassle on Atari (130, 800XE, 800XL, 2600, 7200), Amiga, Commodore C64,
+Amstrad CPC, Sinclair ZX Spectrum and many other machines. That's why these
+joysticks are called "Multisystem".
+
+  Now their pinout:
+
+      +---------> Right
+      | +-------> Left
+      | | +-----> Down
+      | | | +---> Up
+      | | | |
+  _____________
+5 \ x o o o o / 1
+   \ x o x o /
+  9 `~~~~~~~' 6
+       |   |
+       |   +----> Button
+       +--------> Ground
+
+  However, as time passed, extensions to this standard developed, and these
+were not compatible with each other:
+
+
+	Atari 130, 800/XL/XE		   MSX
+
+					 +-----------> Power
+      +---------> Right                  | +---------> Right
+      | +-------> Left                   | | +-------> Left
+      | | +-----> Down                   | | | +-----> Down
+      | | | +---> Up                     | | | | +---> Up
+      | | | |                            | | | | |
+  _____________                        _____________
+5 \ x o o o o / 1                    5 \ o o o o o / 1
+   \ x o o o /                          \ o o o o /
+  9 `~~~~~~~' 6                        9 `~~~~~~~' 6
+       | | |                              | | | |
+       | | +----> Button                  | | | +----> Button 1
+       | +------> Power                   | | +------> Button 2
+       +--------> Ground                  | +--------> Output 3
+					  +----------> Ground
+
+	Amstrad CPC			   Commodore C64
+
+					 +-----------> Analog Y
+      +---------> Right                  | +---------> Right
+      | +-------> Left                   | | +-------> Left
+      | | +-----> Down                   | | | +-----> Down
+      | | | +---> Up                     | | | | +---> Up
+      | | | |                            | | | | |
+  _____________                        _____________
+5 \ x o o o o / 1                    5 \ o o o o o / 1
+   \ x o o o /                          \ o o o o /
+  9 `~~~~~~~' 6                        9 `~~~~~~~' 6
+       | | |                              | | | |
+       | | +----> Button 1                | | | +----> Button
+       | +------> Button 2                | | +------> Power
+       +--------> Ground                  | +--------> Ground
+					  +----------> Analog X
+
+	Sinclair Spectrum +2A/+3           Amiga 1200
+                                     
+    +-----------> Up                     +-----------> Button 3
+    | +---------> Fire                   | +---------> Right
+    | |                                  | | +-------> Left
+    | |   +-----> Ground                 | | | +-----> Down
+    | |   |                              | | | | +---> Up
+    | |   |                              | | | | |
+  _____________                        _____________
+5 \ o o x o x / 1                    5 \ o o o o o / 1
+   \ o o o o /                          \ o o o o /
+  9 `~~~~~~~' 6                        9 `~~~~~~~' 6
+     | | | |                              | | | |
+     | | | +----> Right                   | | | +----> Button 1
+     | | +------> Left                    | | +------> Power
+     | +--------> Ground                  | +--------> Ground
+     +----------> Down                    +----------> Button 2
+
+  And there were many others.
+
+2.2.1 Multisystem joysticks using db9.c
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  For the Multisystem joysticks, and their derivatives, the db9.c driver
+was written. It allows only one joystick / gamepad per parallel port, but
+the interface is easy to build and works with almost anything.
+
+  For the basic 1-button Multisystem joystick you connect its wires to the
+parallel port like this:
+
+(pin  1) -----> Power
+(pin 18) -----> Ground
+
+(pin  2) -----> Up
+(pin  3) -----> Down
+(pin  4) -----> Left
+(pin  5) -----> Right
+(pin  6) -----> Button 1
+
+  However, if the joystick is switch based (eg. clicks when you move it),
+you might or might not, depending on your parallel port, need 10 kOhm pullup
+resistors on each of the direction and button signals, like this:
+
+(pin 2) ------------+------> Up
+	  Resistor  |
+(pin 1) --[10kOhm]--+
+
+  Try without, and if it doesn't work, add them. For TTL based joysticks /
+gamepads the pullups are not needed.
+
+  For joysticks with two buttons you connect the second button to pin 7 on
+the parallel port.
+
+(pin 7) -----> Button 2
+
+  And that's it.
+
+  On a side note, if you have already built a different adapter for use with
+the digital joystick driver 0.8.0.2, this is also supported by the db9.c
+driver, as device type 8. (See section 3.2)
+
+2.2.2 Multisystem joysticks using gamecon.c
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  For some people just one joystick per parallel port is not enough, and/or
+want to use them on one parallel port together with NES/SNES/PSX pads. This is
+possible using the gamecon.c. It supports up to 5 devices of the above types,
+including 1 and 2 buttons Multisystem joysticks.
+
+  However, there is nothing for free. To allow more sticks to be used at
+once, you need the sticks to be purely switch based (that is non-TTL), and
+not to need power. Just a plain simple six switches inside. If your
+joystick can do more (eg. turbofire) you'll need to disable it totally first
+if you want to use gamecon.c.
+
+  Also, the connection is a bit more complex. You'll need a bunch of diodes,
+and one pullup resistor. First, you connect the Directions and the button
+the same as for db9, however with the diodes inbetween.
+
+	    Diodes
+(pin 2) -----|<|----> Up
+(pin 3) -----|<|----> Down
+(pin 4) -----|<|----> Left
+(pin 5) -----|<|----> Right
+(pin 6) -----|<|----> Button 1
+
+  For two button sticks you also connect the other button.
+
+(pin 7) -----|<|----> Button 2
+
+  And finally, you connect the Ground wire of the joystick, like done in
+this little schematic to Power and Data on the parallel port, as described
+for the NES / SNES pads in section 2.1 of this file - that is, one data pin
+for each joystick. The power source is shared.
+
+Data    ------------+-----> Ground
+	  Resistor  |
+Power   --[10kOhm]--+
+
+  And that's all, here we go!
+
+2.2.3 Multisystem joysticks using turbografx.c
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  The TurboGraFX interface, designed by
+
+	Steffen Schwenke <schwenke@burg-halle.de>
+
+  allows up to 7 Multisystem joysticks connected to the parallel port. In
+Steffen's version, there is support for up to 5 buttons per joystick.  However,
+since this doesn't work reliably on all parallel ports, the turbografx.c driver
+supports only one button per joystick. For more information on how to build the
+interface, see
+
+	http://www2.burg-halle.de/~schwenke/parport.html
+
+2.3 Sony Playstation
+~~~~~~~~~~~~~~~~~~~~
+
+  The PSX controller is supported by the gamecon.c. Pinout of the PSX
+controller (compatible with DirectPadPro):
+
+  +---------+---------+---------+
+9 | o  o  o | o  o  o | o  o  o | 1               parallel
+   \________|_________|________/                  port pins
+    |  |      |  |  |   |
+    |  |      |  |  |   +-------->  Clock    ---  (4)
+    |  |      |  |  +------------>  Select   ---  (3)
+    |  |      |  +--------------->  Power    ---  (5-9)
+    |  |      +------------------>  Ground   ---  (18-25)
+    |  +------------------------->  Command  ---  (2)
+    +---------------------------->  Data     ---  (one of 10,11,12,13,15)
+
+  The driver supports these controllers:
+
+ * Standard PSX Pad
+ * NegCon PSX Pad
+ * Analog PSX Pad (red mode)
+ * Analog PSX Pad (green mode)
+ * PSX Rumble Pad
+
+2.4 Sega
+~~~~~~~~
+  All the Sega controllers are more or less based on the standard 2-button
+Multisystem joystick. However, since they don't use switches and use TTL
+logic, the only driver usable with them is the db9.c driver.
+
+2.4.1 Sega Master System
+~~~~~~~~~~~~~~~~~~~~~~~~
+  The SMS gamepads are almost exactly the same as normal 2-button
+Multisystem joysticks. Set the driver to Multi2 mode, use the corresponding
+parallel port pins, and the following schematic:
+
+    +-----------> Power
+    | +---------> Right
+    | | +-------> Left
+    | | | +-----> Down
+    | | | | +---> Up
+    | | | | |
+  _____________
+5 \ o o o o o / 1
+   \ o o x o /
+  9 `~~~~~~~' 6
+     | |   |
+     | |   +----> Button 1
+     | +--------> Ground
+     +----------> Button 2
+
+2.4.2 Sega Genesis aka MegaDrive
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  The Sega Genesis (in Europe sold as Sega MegaDrive) pads are an extension
+to the Sega Master System pads. They use more buttons (3+1, 5+1, 6+1).  Use
+the following schematic:
+
+    +-----------> Power
+    | +---------> Right
+    | | +-------> Left
+    | | | +-----> Down
+    | | | | +---> Up
+    | | | | |
+  _____________
+5 \ o o o o o / 1
+   \ o o o o /
+  9 `~~~~~~~' 6
+     | | | |
+     | | | +----> Button 1
+     | | +------> Select
+     | +--------> Ground
+     +----------> Button 2
+
+  The Select pin goes to pin 14 on the parallel port.
+
+(pin 14) -----> Select
+
+  The rest is the same as for Multi2 joysticks using db9.c
+
+2.4.3 Sega Saturn
+~~~~~~~~~~~~~~~~~
+  Sega Saturn has eight buttons, and to transfer that, without hacks like
+Genesis 6 pads use, it needs one more select pin. Anyway, it is still
+handled by the db9.c driver. Its pinout is very different from anything
+else.  Use this schematic:
+
+    +-----------> Select 1
+    | +---------> Power
+    | | +-------> Up
+    | | | +-----> Down
+    | | | | +---> Ground
+    | | | | |
+  _____________
+5 \ o o o o o / 1
+   \ o o o o /
+  9 `~~~~~~~' 6
+     | | | |
+     | | | +----> Select 2
+     | | +------> Right
+     | +--------> Left
+     +----------> Power
+
+  Select 1 is pin 14 on the parallel port, Select 2 is pin 16 on the
+parallel port.
+
+(pin 14) -----> Select 1
+(pin 16) -----> Select 2
+
+  The other pins (Up, Down, Right, Left, Power, Ground) are the same as for
+Multi joysticks using db9.c
+
+3. The drivers
+~~~~~~~~~~~~~~
+  There are three drivers for the parallel port interfaces. Each, as
+described above, allows to connect a different group of joysticks and pads.
+Here are described their command lines:
+
+3.1 gamecon.c
+~~~~~~~~~~~~~
+  Using gamecon.c you can connect up to five devices to one parallel port. It
+uses the following kernel/module command line:
+
+	gc=port,pad1,pad2,pad3,pad4,pad5
+
+  Where 'port' the number of the parport interface (eg. 0 for parport0).
+
+  And 'pad1' to 'pad5' are pad types connected to different data input pins
+(10,11,12,13,15), as described in section 2.1 of this file.
+
+  The types are:
+
+	Type | Joystick/Pad
+	--------------------
+	  0  | None
+	  1  | SNES pad
+	  2  | NES pad
+	  4  | Multisystem 1-button joystick
+	  5  | Multisystem 2-button joystick
+	  6  | N64 pad
+	  7  | Sony PSX controller
+
+  The exact type of the PSX controller type is autoprobed, so you must have
+your controller plugged in before initializing.
+
+  Should you want to use more than one of parallel ports at once, you can use
+gc_2 and gc_3 as additional command line parameters for two more parallel
+ports.
+
+3.2 db9.c
+~~~~~~~~~
+  Apart from making an interface, there is nothing difficult on using the
+db9.c driver. It uses the following kernel/module command line:
+
+	db9=port,type
+
+  Where 'port' is the number of the parport interface (eg. 0 for parport0).
+
+  Caveat here: This driver only works on bidirectional parallel ports. If
+your parallel port is recent enough, you should have no trouble with this.
+Old parallel ports may not have this feature.
+
+  'Type' is the type of joystick or pad attached:
+
+	Type | Joystick/Pad
+	--------------------
+	  0  | None
+	  1  | Multisystem 1-button joystick
+	  2  | Multisystem 2-button joystick
+	  3  | Genesis pad (3+1 buttons)
+	  5  | Genesis pad (5+1 buttons)
+	  6  | Genesis pad (6+2 buttons)
+	  7  | Saturn pad (8 buttons)
+	  8  | Multisystem 1-button joystick (v0.8.0.2 pin-out)
+	  9  | Two Multisystem 1-button joysticks (v0.8.0.2 pin-out) 
+	 10  | Amiga CD32 pad
+
+  Should you want to use more than one of these joysticks/pads at once, you
+can use db9_2 and db9_3 as additional command line parameters for two
+more joysticks/pads.
+
+3.3 turbografx.c
+~~~~~~~~~~~~~~~~
+  The turbografx.c driver uses a very simple kernel/module command line:
+
+	tgfx=port,js1,js2,js3,js4,js5,js6,js7
+
+  Where 'port' is the number of the parport interface (eg. 0 for parport0).
+
+  'jsX' is the number of buttons the Multisystem joysticks connected to the
+interface ports 1-7 have. For a standard multisystem joystick, this is 1.
+
+  Should you want to use more than one of these interfaces at once, you can
+use tgfx_2 and tgfx_3 as additional command line parameters for two more
+interfaces.
+
+3.4 PC parallel port pinout
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		  .----------------------------------------.
+   At the PC:     \ 13 12 11 10  9  8  7  6  5  4  3  2  1 /
+                   \  25 24 23 22 21 20 19 18 17 16 15 14 /
+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+	  Pin | Name    | Description
+	~~~~~~|~~~~~~~~~|~~~~~~~~~~
+	    1 | /STROBE | Strobe
+	  2-9 | D0-D7   | Data Bit 0-7
+	   10 | /ACK    | Acknowledge
+	   11 | BUSY    | Busy
+	   12 | PE      | Paper End
+	   13 | SELIN   | Select In
+	   14 | /AUTOFD | Autofeed
+	   15 | /ERROR  | Error
+	   16 | /INIT   | Initialize
+	   17 | /SEL    | Select
+	18-25 | GND     | Signal Ground
+
+3.5 End
+~~~~~~~
+  That's all, folks! Have fun!
diff -u --recursive --new-file v2.4.9/linux/Documentation/input/joystick.txt linux/Documentation/input/joystick.txt
--- v2.4.9/linux/Documentation/input/joystick.txt	Wed Dec 31 16:00:00 1969
+++ linux/Documentation/input/joystick.txt	Wed Sep 12 15:34:06 2001
@@ -0,0 +1,583 @@
+		       Linux Joystick driver v2.0.0
+	       (c) 1996-2000 Vojtech Pavlik <vojtech@suse.cz>
+			     Sponsored by SuSE
+	   $Id: joystick.txt,v 1.6 2001/06/05 09:57:01 vojtech Exp $
+----------------------------------------------------------------------------
+
+0. Disclaimer
+~~~~~~~~~~~~~
+  This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option)
+any later version.
+
+  This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+more details.
+
+  You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc., 59
+Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+  Should you need to contact me, the author, you can do so either by e-mail
+- mail your message to <vojtech@suse.cz>, or by paper mail: Vojtech Pavlik,
+Ucitelska 1576, Prague 8, 182 00 Czech Republic
+
+  For your convenience, the GNU General Public License version 2 is included
+in the package: See the file COPYING.
+
+1. Intro
+~~~~~~~~
+  The joystick driver for Linux provides support for a variety of joysticks
+and similar devices. It is based on a larger project aiming to support all
+input devices in Linux.
+
+  Should you encounter any problems while using the driver, or joysticks
+this driver can't make complete use of, I'm very interested in hearing about
+them. Bug reports and success stories are also welcome.
+
+  The input project website is at:
+
+	http://www.suse.cz/development/input/
+	http://atrey.karlin.mff.cuni.cz/~vojtech/input/
+
+  There is also a mailing list for the driver at:
+
+	listproc@atrey.karlin.mff.cuni.cz
+
+send "subscribe linux-joystick Your Name" to subscribe to it.
+
+2. Usage
+~~~~~~~~
+  For basic usage you just choose the right options in kernel config and
+you should be set.
+
+2.1 inpututils
+~~~~~~~~~~~~~~
+For testing and other purposes (for example serial devices), a set of
+utilities is available at the abovementioned website. I suggest you download
+and install it before going on.
+
+2.2 Device nodes
+~~~~~~~~~~~~~~~~
+For applications to be able to use the joysticks, in you don't use devfs,
+you'll have to manually create these nodes in /dev:
+
+cd /dev
+rm js*
+mkdir input
+mknod input/js0 c 13 0
+mknod input/js1 c 13 1
+mknod input/js2 c 13 2
+mknod input/js3 c 13 3
+ln -s input/js0 js0
+ln -s input/js1 js1
+ln -s input/js2 js2
+ln -s input/js3 js3
+
+For testing with inpututils it's also convenient to create these:
+
+mknod input/event0 c 13 64
+mknod input/event1 c 13 65
+mknod input/event2 c 13 66
+mknod input/event3 c 13 67
+
+2.4 Modules needed 
+~~~~~~~~~~~~~~~~~~
+  For all joystick drivers to function, you'll need the userland interface
+module in kernel, either loaded or compiled in:
+
+	modprobe joydev
+
+  For gameport joysticks, you'll have to load the gameport driver as well;
+
+	modprobe ns558
+
+  And for serial port joysticks, you'll need the serial input line
+discipline module loaded and the inputattach utility started:
+
+	modprobe serport
+	inputattach -xxx /dev/tts/X &
+
+  In addition to that, you'll need the joystick driver module itself, most
+usually you'll have an analog joystick:
+
+	modprobe analog
+	
+  For automatic module loading, something like this might work - tailor to
+your needs:
+
+	alias tty-ldisc-2 serport
+	alias char-major-13 input
+	above input joydev ns558 analog
+	options analog js=gameport
+
+2.5 Verifying that it works
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  For testing the joystick driver functionality, there is the jstest
+program in the utilities package. You run it by typing:
+
+	jstest /dev/js0
+
+  And it should show a line with the joystick values, which update as you
+move the stick, and press its buttons. The axes should all be zero when the
+joystick is in the center position. They should not jitter by themselves to
+other close values, and they also should be steady in any other position of
+the stick. They should have the full range from -32767 to 32767. If all this
+is met, then it's all fine, and you can play the games. :)
+
+  If it's not, then there might be a problem. Try to calibrate the joystick,
+and if it still doesn't work, read the drivers section of this file, the
+troubleshooting section, and the FAQ.
+
+2.6. Calibration
+~~~~~~~~~~~~~~~~
+  For most joysticks you won't need any manual calibration, since the
+joystick should be autocalibrated by the driver automagically. However, with
+some analog joysticks, that either do not use linear resistors, or if you
+want better precision, you can use the jscal program
+
+	jscal -c /dev/js0
+
+ included in the joystick package to set better correction coefficients than
+what the driver would choose itself.
+
+  After calibrating the joystick you can verify if you like the new
+calibration using the jstest command, and if you do, you then can save the
+correction coefficients into a file
+
+	jscal -p /dev/js0 > /etc/joystick.cal
+
+  And add a line to your rc script executing that file
+
+	source /etc/joystick.cal
+
+  This way, after the next reboot your joystick will remain calibrated. You
+can also add the jscal -p line to your shutdown script.
+
+
+3. HW specific driver information
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+In this section each of the separate hardware specific drivers is described.
+
+3.1 Analog joysticks
+~~~~~~~~~~~~~~~~~~~~
+  The analog.c uses the standard analog inputs of the gameport, and thus
+supports all standard joysticks and gamepads. It uses a very advanced
+routine for this, allowing for data precision that can't be found on any
+other system.
+
+  It also supports extensions like additional hats and buttons compatible
+with CH Flightstick Pro, ThrustMaster FCS or 6 and 8 button gamepads. Saitek
+Cyborg 'digital' joysticks are also supported by this driver, because
+they're basically souped up CHF sticks.
+
+  However the only types that can be autodetected are:
+
+* 2-axis, 4-button joystick
+* 3-axis, 4-button joystick
+* 4-axis, 4-button joystick
+* Saitek Cyborg 'digital' joysticks
+
+  For other joystick types (more/less axes, hats, and buttons) support
+you'll need to specify the types either on the kernel command line or on the
+module command line, when inserting analog.o into the kernel. The
+parameters are:
+
+	js=type,type,type,....
+
+  'type' is type of the joystick from the table below, defining joysticks
+present on gameports in the system, starting with gameport0, second 'type'
+entry defining joystick on gameport1 and so on.
+
+	Type     | Meaning
+	-----------------------------------
+	none     | No analog joystick on that port
+	auto     | Autodetect joystick
+	2btn     | 2-button n-axis joystick
+	y-joy    | Two 2-button 2-axis joysticks on an Y-cable
+	y-pad    | Two 2-button 2-axis gamepads on an Y-cable
+	fcs      | Thrustmaster FCS compatible joystick
+	chf      | Joystick with a CH Flightstick compatible hat
+	fullchf  | CH Flightstick compatible with two hats and 6 buttons
+	gamepad  | 4/6-button n-axis gamepad
+	gamepad8 | 8-button 2-axis gamepad
+
+  In case your joystick doesn't fit in any of the above categories, you can
+specify the type as a number by combining the bits in the table below. This
+is not recommended unless you really know what are you doing. It's not
+dangerous, but not simple either.
+
+	Bit | Meaning
+	--------------------------
+	 0  | Axis X1
+	 1  | Axis Y1
+	 2  | Axis X2
+	 3  | Axis Y2
+	 4  | Button A
+	 5  | Button B
+	 6  | Button C
+	 7  | Button D
+	 8  | CHF Buttons X and Y
+	 9  | CHF Hat 1
+	10  | CHF Hat 2
+	11  | FCS Hat
+	12  | Pad Button X
+	13  | Pad Button Y
+	14  | Pad Button U
+	15  | Pad Button V
+	16  | Saitek F1-F4 Buttons
+	17  | Saitek Digital Mode
+	19  | GamePad
+	20  | Joy2 Axis X1
+	21  | Joy2 Axis Y1
+	22  | Joy2 Axis X2
+	23  | Joy2 Axis Y2
+	24  | Joy2 Button A
+	25  | Joy2 Button B
+	26  | Joy2 Button C
+	27  | Joy2 Button D
+	31  | Joy2 GamePad
+
+3.2 Microsoft SideWinder joysticks
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  Microsoft 'Digital Overdrive' protocol is supported by the sidewinder.c
+module. All currently supported joysticks:
+
+* Microsoft SideWinder 3D Pro
+* Microsoft SideWinder Force Feedback Pro
+* Microsoft SideWinder Force Feedback Wheel
+* Microsoft SideWinder FreeStyle Pro 
+* Microsoft SideWinder GamePad (up to four, chained)
+* Microsoft SideWinder Precision Pro 
+* Microsoft SideWinder Precision Pro USB 
+
+  are autodetected, and thus no module parameters are needed.
+
+  There is one caveat with the 3D Pro. There are 9 buttons reported,
+although the joystick has only 8. The 9th button is the mode switch on the
+rear side of the joystick. However, moving it, you'll reset the joystick,
+and make it unresponsive for about a one third of a second. Furthermore, the
+joystick will also re-center itself, taking the position it was in during
+this time as a new center position. Use it if you want, but think first.
+
+  The SideWinder Standard is not a digital joystick, and thus is supported
+by the analog driver described above. 
+
+3.3 Logitech ADI devices
+~~~~~~~~~~~~~~~~~~~~~~~~
+  Logitech ADI protocol is supported by the adi.c module. It should support
+any Logitech device using this protocol. This includes, but is not limited
+to:
+
+* Logitech CyberMan 2
+* Logitech ThunderPad Digital
+* Logitech WingMan Extreme Digital
+* Logitech WingMan Formula
+* Logitech WingMan Interceptor
+* Logitech WingMan GamePad
+* Logitech WingMan GamePad USB
+* Logitech WingMan GamePad Extreme
+* Logitech WingMan Extreme Digital 3D
+
+  ADI devices are autodetected, and the driver supports up to two (any
+combination of) devices on a single gameport, using an Y-cable or chained
+together.
+
+  Logitech WingMan Joystick, Logitech WingMan Attack, Logitech WingMan
+Extreme and Logitech WingMan ThunderPad are not digital joysticks and are
+handled by the analog driver described above. Logitech WingMan Warrior and
+Logitech Magellan are supported by serial drivers described below.  Logitech
+WingMan Force and Logitech WingMan Formula Force are supported by the
+I-Force driver described below. Logitech CyberMan is not supported yet.
+
+3.4 Gravis GrIP
+~~~~~~~~~~~~~~~
+  Gravis GrIP protocol is supported by the grip.c module. It currently
+supports:
+
+* Gravis GamePad Pro
+* Gravis BlackHawk Digital
+* Gravis Xterminator
+* Gravis Xterminator DualControl
+
+  All these devices are autodetected, and you can even use any combination
+of up to two of these pads either chained together or using an Y-cable on a
+single gameport.
+
+GrIP MultiPort isn't supported yet. Gravis Stinger is a serial device and is
+supported by the stinger driver. Other Gravis joysticks are supported by the
+analog driver.
+
+3.5 FPGaming A3D and MadCatz A3D
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  The Assassin 3D protocol created by FPGaming, is used both by FPGaming
+themselves and is licensed to MadCatz. A3D devices are supported by the
+a3d.c module. It currently supports:
+
+* FPGaming Assassin 3D
+* MadCatz Panther
+* MadCatz Panther XL
+
+  All these devices are autodetected. Because the Assassin 3D and the Panther
+allow connecting analog joysticks to them, you'll need to load the analog
+driver as well to handle the attached joysticks.
+
+  The trackball should work with USB mousedev module as a normal mouse. See
+the USB documentation for how to setup an USB mouse.
+
+3.6 ThrustMaster DirectConnect (BSP)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  The TM DirectConnect (BSP) protocol is supported by the tmdc.c
+module. This includes, but is not limited to:
+
+* ThrustMaster Millenium 3D Inceptor
+* ThrustMaster 3D Rage Pad
+* ThrustMaster Fusion Digital Game Pad
+
+  Devices not directly supported, but hopefully working are:
+
+* ThrustMaster FragMaster
+* ThrustMaster Attack Throttle
+
+  If you have one of these, contact me.
+
+  TMDC devices are autodetected, and thus no parameters to the module
+are needed. Up to two TMDC devices can be connected to one gameport, using
+an Y-cable.
+
+3.7 Creative Labs Blaster
+~~~~~~~~~~~~~~~~~~~~~~~~~
+  The Blaster protocol is supported by the cobra.c module. It supports only
+the:
+
+* Creative Blaster GamePad Cobra
+
+  Up to two of these can be used on a single gameport, using an Y-cable.
+
+3.8 Genius Digital joysticks 
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  The Genius digitally communicating joysticks are supported by the gf2k.c
+module. This includes:
+
+* Genius Flight2000 F-23 joystick 
+* Genius Flight2000 F-31 joystick 
+* Genius G-09D gamepad
+
+  Other Genius digital joysticks are not supported yet, but support can be
+added fairly easily.
+
+3.9 InterAct Digital joysticks
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  The InterAct digitally communicating joysticks are supported by the
+interact.c module. This includes:
+
+* InterAct HammerHead/FX gamepad
+* InterAct ProPad8 gamepad 
+
+  Other InterAct digital joysticks are not supported yet, but support can be 
+added fairly easily.
+
+3.10 PDPI Lightning 4 gamecards
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  PDPI Lightning 4 gamecards are supported by the lightning.c module.
+Once the module is loaded, the analog driver can be used to handle the
+joysticks. Digitally communicating joystick will work only on port 0, while
+using Y-cables, you can connect up to 8 analog joysticks to a single L4
+card, 16 in case you have two in your system.
+
+3.11 Trident 4DWave / Aureal Vortex
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  Soundcards with a Trident 4DWave DX/NX or Aureal Vortex/Vortex2 chipsets
+provide an "Enhanced Game Port" mode where the soundcard handles polling the
+joystick.  This mode is supported by the pcigame.c module. Once loaded the
+analog driver can use the enhanced features of these gameports..
+
+3.13 Crystal SoundFusion
+~~~~~~~~~~~~~~~~~~~~~~~~
+  Soundcards with Crystal SoundFusion chipsets provide an "Enhanced Game
+Port", much like the 4DWave or Vortex above. This, and also the normal mode
+for the port of the SoundFusion is supported by the cs461x.c module.
+
+3.14 SoundBlaster Live!
+~~~~~~~~~~~~~~~~~~~~~~~~
+  The Live! has a special PCI gameport, which, although it doesn't provide
+any "Enhanced" stuff like 4DWave and friends, is quite a bit faster than
+it's ISA counterparts. It also requires special support, hence the
+emu10k1-gp.c module for it instead of the normal ns558.c one.
+
+3.15 SoundBlaster 64 and 128 - ES1370 and ES1371, ESS Solo1 and S3 SonicVibes
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  These PCI soundcards have specific gameports. They are handled by the
+sound drivers themselves. Make sure you select gameport support in the
+joystick menu and sound card support in the sound menu for your appropriate
+card.
+
+3.16 Amiga
+~~~~~~~~~~
+  Amiga joysticks, connected to an Amiga, are supported by the amijoy.c
+driver. Since they can't be autodetected, the driver has a command line.
+
+	amijoy=a,b
+
+  a and b define the joysticks connected to the JOY0DAT and JOY1DAT ports of
+the Amiga.
+
+	Value | Joystick type
+	---------------------
+	  0   | None
+	  1   | 1-button digital joystick
+
+  No more joystick types are supported now, but that should change in the
+future if I get an Amiga in the reach of my fingers.
+
+3.17 Game console and 8-bit pads and joysticks
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+See joystick-parport.txt for more info.
+
+3.18 SpaceTec/LabTec devices
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  SpaceTec serial devices communicate using the SpaceWare protocol. It is
+supported by the spaceorb.c and spaceball.c drivers. The devices currently
+supported by spaceorb.c are:
+
+* SpaceTec SpaceBall Avenger
+* SpaceTec SpaceOrb 360
+
+Devices currently supported by spaceball.c are:
+
+* SpaceTec SpaceBall 4000 FLX
+
+  In addition to having the spaceorb/spaceball and serport modules in the
+kernel, you also need to attach a serial port to it. to do that, run the
+inputattach program:
+
+	inputattach --spaceorb /dev/tts/x &
+or
+	inputattach --spaceball /dev/tts/x &
+
+where /dev/tts/x is the serial port which the device is connected to. After
+doing this, the device will be reported and will start working.
+
+  There is one caveat with the SpaceOrb. The button #6, the on the bottom
+side of the orb, although reported as an ordinary button, causes internal
+recentering of the spaceorb, moving the zero point to the position in which
+the ball is at the moment of pressing the button. So, think first before
+you bind it to some other function.
+
+SpaceTec SpaceBall 2003 FLX and 3003 FLX are not supported yet. 
+
+3.19 Logitech SWIFT devices
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  The SWIFT serial protocol is supported by the warrior.c module. It
+currently supports only the:
+
+* Logitech WingMan Warrior
+
+but in the future, Logitech CyberMan (the original one, not CM2) could be
+supported as well. To use the module, you need to run inputattach after you
+insert/compile the module into your kernel:
+
+	inputattach --warrior /dev/tts/x &
+
+/dev/tts/x is the serial port your Warrior is attached to.
+
+3.20 Magellan / Space Mouse
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  The Magellan (or Space Mouse), manufactured by LogiCad3d (formerly Space
+Systems), for many other companies (Logitech, HP, ...) is supported by the
+joy-magellan module. It currently supports only the:
+
+* Magellan 3D
+* Space Mouse
+
+models, the additional buttons on the 'Plus' versions are not supported yet.
+
+  To use it, you need to attach the serial port to the driver using the
+
+	inputattach --magellan /dev/tts/x &
+
+command. After that the Magellan will be detected, initialized, will beep,
+and the /dev/input/jsX device should become usable.
+
+3.21 I-Force devices 
+~~~~~~~~~~~~~~~~~~~~
+  All I-Force devices are supported by the iforce.c module. This includes:
+
+* AVB Mag Turbo Force
+* AVB Top Shot Pegasus
+* Logitech WingMan Force
+* Logitech WingMan Force 3D
+* Logitech WingMan Force Wheel 
+* Logitech WingMan Strike Force 3D
+* Guillemot Race Leader Force Feedback
+
+  To use it, you need to attach the serial port to the driver using the
+
+	inputattach --iforce /dev/tts/x &
+
+command. After that the I-Force device will be detected, and the
+/dev/input/jsX device should become usable.
+
+  In case you're using the device via the USB port, the inputattach command
+isn't needed.
+
+  The I-Force driver now supports force feedback via the event interface.
+
+3.22 Gravis Stinger gamepad 
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  The Gravis Stinger serial port gamepad, designed for use with laptop
+computers, is supported by the stinger.c module. To use it, attach the
+serial port to the driver using:
+
+        inputattach --stinger /dev/tty/x &
+
+where x is the number of the serial port.
+
+4. Troubleshooting
+~~~~~~~~~~~~~~~~~~
+  There is quite a high probability that you run into some problems. For
+testing whether the driver works, if in doubt, use the jstest utility in
+some of its modes. The most useful modes are "normal" - for the 1.x
+interface, and "old" for the "0.x" interface. You run it by typing:
+
+	jstest --normal /dev/input/js0
+	jstest --old    /dev/input/js0
+
+  Additionally you can do a test with the evtest utility:
+
+	evtest /dev/input/event0
+
+  Oh, and read the FAQ! :)
+
+5. FAQ
+~~~~~~
+Q: Running 'jstest /dev/js0' results in "File not found" error. What's the
+   cause?
+A: The device files don't exist. Create them (see section 2.2).
+
+Q: Is it possible to connect my old Atari/Commodore/Amiga/console joystick
+   or pad that uses a 9-pin D-type cannon connector to the serial port of my
+   PC?
+A: Yes, it is possible, but it'll burn your serial port or the pad. It
+   won't work, of course.
+
+Q: My joystick doesn't work with Quake / Quake 2. What's the cause?
+A: Quake / Quake 2 don't support joystick. Use joy2key to simulate keypresses
+   for them.
+
+6. Programming Interface
+~~~~~~~~~~~~~~~~~~~~~~~~
+  The 1.0 driver uses a new, event based approach to the joystick driver.
+Instead of the user program polling for the joystick values, the joystick
+driver now reports only any changes of its state. See joystick-api.txt,
+joystick.h and jstest.c included in the joystick package for more
+information. The joystick device can be used in either blocking or
+nonblocking mode and supports select() calls.
+
+  For backward compatibility the old (v0.x) interface is still included.
+Any call to the joystick driver using the old interface will return values
+that are compatible to the old interface.  This interface is still limited
+to 2 axes, and applications using it usually decode only 2 buttons, although
+the driver provides up to 32.
diff -u --recursive --new-file v2.4.9/linux/Documentation/isdn/README linux/Documentation/isdn/README
--- v2.4.9/linux/Documentation/isdn/README	Sun Aug 13 10:05:32 2000
+++ linux/Documentation/isdn/README	Sun Sep  9 10:52:35 2001
@@ -276,6 +276,8 @@
                                       1 = Add CPN to RING message on
                             Bit 1:    0 = Add CPN to FCON message off
                                       1 = Add CPN to FCON message on
+                            Bit 2:    0 = Add CDN to RING/FCON message off
+                                      1 = Add CDN to RING/FCON message on
 
   Last but not least a (at the moment fairly primitive) device to request
   the line-status (/dev/isdninfo) is made available.
diff -u --recursive --new-file v2.4.9/linux/Documentation/joystick-api.txt linux/Documentation/joystick-api.txt
--- v2.4.9/linux/Documentation/joystick-api.txt	Fri Apr  6 10:42:48 2001
+++ linux/Documentation/joystick-api.txt	Wed Dec 31 16:00:00 1969
@@ -1,315 +0,0 @@
-		      Joystick API Documentation                -*-Text-*-
-
-		        Ragnar Hojland Espinosa
-		          <ragnar@macula.net>
-
-			      7 Aug 1998
-
-
-1. Initialization
-~~~~~~~~~~~~~~~~~
-
-Open the joystick device following the usual semantics (that is, with open).
-Since the driver now reports events instead of polling for changes,
-immediately after the open it will issue a series of synthetic events
-(JS_EVENT_INIT) that you can read to check the initial state of the
-joystick.
-
-By default, the device is opened in blocking mode.
-
-	int fd = open ("/dev/js0", O_RDONLY);
-
-
-2. Event Reading
-~~~~~~~~~~~~~~~~
-
-	struct js_event e;
-	read (fd, &e, sizeof(struct js_event));
-
-where js_event is defined as
-
-	struct js_event {
-		__u32 time;     /* event timestamp in milliseconds */
-		__s16 value;    /* value */
-		__u8 type;      /* event type */
-		__u8 number;    /* axis/button number */
-	};
-
-If the read is successful, it will return sizeof(struct js_event), unless
-you wanted to read more than one event per read as described in section 3.1.
-
-
-2.1 js_event.type
-~~~~~~~~~~~~~~~~~
-
-The possible values of ``type'' are
-
-	#define JS_EVENT_BUTTON         0x01    /* button pressed/released */
-	#define JS_EVENT_AXIS           0x02    /* joystick moved */
-	#define JS_EVENT_INIT           0x80    /* initial state of device */
-
-As mentioned above, the driver will issue synthetic JS_EVENT_INIT ORed
-events on open. That is, if it's issuing a INIT BUTTON event, the
-current type value will be
-
-	int type = JS_EVENT_BUTTON | JS_EVENT_INIT;	/* 0x81 */
-
-If you choose not to differentiate between synthetic or real events
-you can turn off the JS_EVENT_INIT bits
-
-	type &= ~JS_EVENT_INIT;				/* 0x01 */
-
-
-2.2 js_event.number
-~~~~~~~~~~~~~~~~~~~
-
-The values of ``number'' correspond to the axis or button that
-generated the event. Note that they carry separate numeration (that
-is, you have both an axis 0 and a button 0). Generally,
-
-			number
-	1st Axis X	0
-	1st Axis Y	1
-	2nd Axis X	2
-	2nd Axis Y	3
-	...and so on
-
-Hats vary from one joystick type to another. Some can be moved in 8
-directions, some only in 4, The driver, however, always reports a hat as two
-independent axis, even if the hardware doesn't allow independent movement.
-
-
-2.3 js_event.value
-~~~~~~~~~~~~~~~~~~
-
-For an axis, ``value'' is a signed integer between -32767 and +32767
-representing the position of the joystick along that axis. If you
-don't read a 0 when the joystick is `dead', or if it doesn't span the
-full range, you should recalibrate it (with, for example, jscal).
-
-For a button, ``value'' for a press button event is 1 and for a release
-button event is 0.
-
-Though this
-
-	if (js_event.type == JS_EVENT_BUTTON) {
-		buttons_state ^= (1 << js_event.number);
-	}
-
-may work well if you handle JS_EVENT_INIT events separately,
-
-	if ((js_event.type & ~JS_EVENT_INIT) == JS_EVENT_BUTTON) {
-		if (js_event.value)
-	        	buttons_state |= (1 << js_event.number);
-	   	else
-	      		buttons_state &= ~(1 << js_event.number);
-	}
-
-is much safer since it can't lose sync with the driver. As you would
-have to write a separate handler for JS_EVENT_INIT events in the first
-snippet, this ends up being shorter.
-
-
-2.4 js_event.time
-~~~~~~~~~~~~~~~~~
-
-The time an event was generated is stored in ``js_event.time''. It's a time
-in milliseconds since ... well, since sometime in the past.  This eases the
-task of detecting double clicks, figuring out if movement of axis and button
-presses happened at the same time, and similar.
-
-
-3. Reading
-~~~~~~~~~~
-
-If you open the device in blocking mode, a read will block (that is,
-wait) forever until an event is generated and effectively read. There
-are two alternatives if you can't afford to wait forever (which is,
-admittedly, a long time;)
-
-	a) use select to wait until there's data to be read on fd, or
-	   until it timeouts. There's a good example on the select(2)
-	   man page.
-
-	b) open the device in non-blocking mode (O_NONBLOCK)
-
-
-3.1 O_NONBLOCK
-~~~~~~~~~~~~~~
-
-If read returns -1 when reading in O_NONBLOCK mode, this isn't
-necessarily a "real" error (check errno(3)); it can just mean there
-are no events pending to be read on the driver queue. You should read
-all events on the queue (that is, until you get a -1).
-
-For example,
-
-	while (1) {
-		while (read (fd, &e, sizeof(struct js_event)) > 0) {
-	        	process_event (e);
-	   	}
-	   	/* EAGAIN is returned when the queue is empty */
-	   	if (errno != EAGAIN) {
-	      		/* error */
-	   	}
-	   	/* do something interesting with processed events */
-	}
-
-One reason for emptying the queue is that if it gets full you'll start
-missing events since the queue is finite, and older events will get
-overwritten.
-
-The other reason is that you want to know all what happened, and not
-delay the processing till later.
-
-Why can get the queue full? Because you don't empty the queue as
-mentioned, or because too much time elapses from one read to another
-and too many events to store in the queue get generated. Note that
-high system load may contribute to space those reads even more.
-
-If time between reads is enough to fill the queue and loose an event,
-the driver will switch to startup mode and next time you read it,
-synthetic events (JS_EVENT_INIT) will be generated to inform you of
-the actual state of the joystick.
-
-[As for version 1.2.8, the queue is circular and able to hold 64
- events. You can increment this size bumping up JS_BUFF_SIZE in
- joystick.h and recompiling the driver.]
-
-
-In the above code, you might as well want to read more than one event
-at a time using the typical read(2) functionality. For that, you would
-replace the read above with something like
-
-	struct js_event mybuffer[0xff];
-	int i = read (fd, mybuffer, sizeof(struct mybuffer));
-
-In this case, read would return -1 if the queue was empty, or some
-other value in which the number of events read would be i /
-sizeof(js_event)  Again, if the buffer was full, it's a good idea to
-process the events and keep reading it until you empty the driver queue.
-
-
-4. IOCTLs
-~~~~~~~~~
-
-The joystick driver defines the following ioctl(2) operations.
-
-				/* function			3rd arg  */
-	#define JSIOCGAXES	/* get number of axes		char	 */
-	#define JSIOCGBUTTONS	/* get number of buttons	char	 */
-	#define JSIOCGVERSION	/* get driver version		int	 */
-	#define JSIOCGNAME(len) /* get identifier string	char	 */
-	#define JSIOCSCORR	/* set correction values	&js_corr */
-	#define JSIOCGCORR	/* get correction values	&js_corr */
-
-For example, to read the number of axes
-
-	char number_of_axes;
-	ioctl (fd, JSIOCGAXES, &number_of_axes);
-
-
-4.1 JSIOGCVERSION
-~~~~~~~~~~~~~~~~~
-
-JSIOGCVERSION is a good way to check in run-time whether the running
-driver is 1.0+ and supports the event interface. If it is not, the
-IOCTL will fail. For a compile-time decision, you can test the
-JS_VERSION symbol
-
-	#ifdef JS_VERSION
-	#if JS_VERSION > 0xsomething
-
-
-4.2 JSIOCGNAME
-~~~~~~~~~~~~~~
-
-JSIOCGNAME(len) allows you to get the name string of the joystick - the same
-as is being printed at boot time. The 'len' argument is the length of the
-buffer provided by the application asking for the name. It is used to avoid
-possible overrun should the name be too long.
-
-	char name[128];
-	if (ioctl(fd, JSIOCGNAME(sizeof(name)), name) < 0)
-		strncpy(name, "Unknown", sizeof(name));
-	printf("Name: %s\n", name);
-
-
-4.3 JSIOC[SG]CORR
-~~~~~~~~~~~~~~~~~
-
-For usage on JSIOC[SG]CORR I suggest you to look into jscal.c  They are
-not needed in a normal program, only in joystick calibration software
-such as jscal or kcmjoy. These IOCTLs and data types aren't considered
-to be in the stable part of the API, and therefore may change without
-warning in following releases of the driver.
-
-Both JSIOCSCORR and JSIOCGCORR expect &js_corr to be able to hold
-information for all axis. That is, struct js_corr corr[MAX_AXIS];
-
-struct js_corr is defined as
-
-	struct js_corr {
-		__s32 coef[8];
-		__u16 prec;
-		__u16 type;
-	};
-
-and ``type''
-
-	#define JS_CORR_NONE            0x00    /* returns raw values */
-	#define JS_CORR_BROKEN          0x01    /* broken line */
-
-
-5. Backward compatibility
-~~~~~~~~~~~~~~~~~~~~~~~~~
-
-The 0.x joystick driver API is quite limited and its usage is deprecated.
-The driver offers backward compatibility, though. Here's a quick summary:
-
-	struct JS_DATA_TYPE js;
-	while (1) {
-		if (read (fd, &js, JS_RETURN) != JS_RETURN) {
-	      		/* error */
-	   	}
-	   	usleep (1000);
-	}
-
-As you can figure out from the example, the read returns immediately,
-with the actual state of the joystick.
-
-	struct JS_DATA_TYPE {
-		int buttons;    /* immediate button state */
-		int x;          /* immediate x axis value */
-		int y;          /* immediate y axis value */
-	};
-
-and JS_RETURN is defined as
-
-	#define JS_RETURN       sizeof(struct JS_DATA_TYPE)
-
-To test the state of the buttons,
-
-	first_button_state  = js.buttons & 1;
-	second_button_state = js.buttons & 2;
-
-The axis values do not have a defined range in the original 0.x driver,
-except for that the values are non-negative. The 1.2.8+ drivers use a
-fixed range for reporting the values, 1 being the minimum, 128 the
-center, and 255 maximum value.
-
-The v0.8.0.2 driver also had an interface for 'digital joysticks', (now
-called Multisystem joysticks in this driver), under /dev/djsX. This driver
-doesn't try to be compatible with that interface.
-
-
-6. Final Notes
-~~~~~~~~~~~~~~
-
-____/|	Comments, additions, and specially corrections are welcome.
-\ o.O|	Documentation valid for at least version 1.2.8 of the joystick
- =(_)=	driver and as usual, the ultimate source for documentation is
-   U	to "Use The Source Luke" or, at your convenience, Vojtech ;)
-
-					- Ragnar
-EOF
diff -u --recursive --new-file v2.4.9/linux/Documentation/joystick-parport.txt linux/Documentation/joystick-parport.txt
--- v2.4.9/linux/Documentation/joystick-parport.txt	Fri Jul 28 12:50:51 2000
+++ linux/Documentation/joystick-parport.txt	Wed Dec 31 16:00:00 1969
@@ -1,521 +0,0 @@
-		    Linux Joystick parport drivers v2.0
-	       (c) 1998-2000 Vojtech Pavlik <vojtech@suse.cz>
-	       (c) 1998 Andree Borrmann <a.borrmann@tu-bs.de>
-			     Sponsored by SuSE
-----------------------------------------------------------------------------
-
-0. Disclaimer
-~~~~~~~~~~~~~
-  Any information in this file is provided as-is, without any guarantee that
-it will be true. So, use it at your own risk. The possible damages that can
-happen include burning your parallel port, and/or the sticks and joystick
-and maybe even more. Like when a lightning kills you it is not our problem.
-
-1. Intro
-~~~~~~~~
-  The joystick parport drivers are used for joysticks and gamepads not
-originally designed for PCs and other computers Linux runs on. Because of
-that, PCs usually lack the right ports to connect these devices to. Parallel
-port, because of its ability to change single bits at will, and providing
-both output and input bits is the most suitable port on the PC for
-connecting such devices.
-
-2. Devices supported
-~~~~~~~~~~~~~~~~~~~~
-  Many console and 8-bit computer gamepads and joysticks are supported. The
-following subsections discuss usage of each.
-
-2.1 NES and SNES
-~~~~~~~~~~~~~~~~
-  The Nintendo Entertainment System and Super Nintendo Entertainment System
-gamepads are widely available, and easy to get. Also, they are quite easy to
-connect to a PC, and don't need much processing speed (108 us for NES and
-165 us for SNES, compared to about 1000 us for PC gamepads) to communicate
-with them.
-
-  All NES and SNES use the same synchronous serial protocol, clocked from
-the computer's side (and thus timing insensitive). To allow up to 5 NES
-and/or SNES gamepads connected to the parallel port at once, the output
-lines of the parallel port are shared, while one of 5 available input lines
-is assigned to each gamepad.
-
-  This protocol is handled by the gamecon.c driver, so that's the one
-you'll use for NES and SNES gamepads.
-
-  The main problem with PC parallel ports is that they don't have +5V power
-source on any of their pins. So, if you want a reliable source of power
-for your pads, use either keyboard or joystick port, and make a pass-through
-cable. You can also pull the power directly from the power supply (the red
-wire is +5V).
-
-  If you want to use the parallel port only, you can take the power is from
-some data pin. For most gamepad and parport implementations only one pin is
-needed, and I'd recommend pin 9 for that, the highest data bit. On the other
-hand, if you are not planning to use anything else than NES / SNES on the
-port, anything between and including pin 4 and pin 9 will work.
-
-(pin 9) -----> Power
-
-  Unfortunately, there are pads that need a lot more of power, and parallel
-ports that can't give much current through the data pins. If this is your
-case, you'll need to use diodes (as a prevention of destroying your parallel
-port), and combine the currents of two or more data bits together.
-
-	   Diodes
-(pin 9) ----|>|-------+------> Power
-		      |
-(pin 8) ----|>|-------+
-		      |
-(pin 7) ----|>|-------+
-		      |
- <and so on>          :
-		      |
-(pin 4) ----|>|-------+
-
-  Ground is quite easy. On PC's parallel port the ground is on any of the
-pins from pin 18 to pin 25. So use any pin of these you like for the ground.
-
-(pin 18) -----> Ground
-
-  NES and SNES pads have two input bits, Clock and Latch, which drive the
-serial transfer. These are connected to pins 2 and 3 of the parallel port,
-respectively.
-
-(pin 2) -----> Clock
-(pin 3) -----> Latch
-
-  And the last thing is the NES / SNES data wire. Only that isn't shared and
-each pad needs its own data pin. The parallel port pins are:
-
-(pin 10) -----> Pad 1 data
-(pin 11) -----> Pad 2 data
-(pin 12) -----> Pad 3 data
-(pin 13) -----> Pad 4 data
-(pin 15) -----> Pad 5 data
-
-  Note that pin 14 is not used, since it is not an input pin on the parallel
-port.
-
-  This is everything you need on the PC's side of the connection, now on to
-the gamepads side. The NES and SNES have different connectors. Also, there
-are quite a lot of NES clones, and because Nintendo used proprietary
-connectors for their machines, the cloners couldn't and used standard D-Cannon
-connectors. Anyway, if you've got a gamepad, and it has buttons A, B, Turbo
-A, Turbo B, Select and Start, and is connected through 5 wires, then it is
-either a NES or NES clone and will work with this connection. SNES gamepads
-also use 5 wires, but have more buttons. They will work as well, of course.
-
-Pinout for NES gamepads                 Pinout for SNES gamepads
-
-	   +----> Power                   +-----------------------\
-	   |                            7 | o  o  o  o |  x  x  o  | 1
- 5 +---------+  7                         +-----------------------/
-   | x  x  o   \                            |  |  |  |          |
-   | o  o  o  o |                           |  |  |  |          +-> Ground
- 4 +------------+ 1                         |  |  |  +------------> Data
-     |  |  |  |                             |  |  +---------------> Latch
-     |  |  |  +-> Ground                    |  +------------------> Clock
-     |  |  +----> Clock                     +---------------------> Power
-     |  +-------> Latch
-     +----------> Data
-
-Pinout for NES clone (db9) gamepads     Pinout for NES clone (db15) gamepads
-
-	+---------> Clock                    +-----------------> Data
-	| +-------> Latch                    |             +---> Ground
-	| | +-----> Data                     |             |
-	| | |                              ___________________
-    _____________                        8 \ o x x x x x x o / 1
-  5 \ x o o o x / 1                         \ o x x o x x o /
-     \ x o x o /                          15 `~~~~~~~~~~~~~' 9
-    9 `~~~~~~~' 6                             |     |     |
-	 |   |                                |     |     +----> Clock
-	 |   +----> Power                     |     +----------> Latch
-	 +--------> Ground                    +----------------> Power
-
-2.2 Multisystem joysticks
-~~~~~~~~~~~~~~~~~~~~~~~~~
-  In the era of 8-bit machines, there was something like de-facto standard
-for joystick ports. They were all digital, and all used D-Cannon 9 pin
-connectors (db9). Because of that, a single joystick could be used without
-hassle on Atari (130, 800XE, 800XL, 2600, 7200), Amiga, Commodore C64,
-Amstrad CPC, Sinclair ZX Spectrum and many other machines. That's why these
-joysticks are called "Multisystem".
-
-  Now their pinout:
-
-      +---------> Right
-      | +-------> Left
-      | | +-----> Down
-      | | | +---> Up
-      | | | |
-  _____________
-5 \ x o o o o / 1
-   \ x o x o /
-  9 `~~~~~~~' 6
-       |   |
-       |   +----> Button
-       +--------> Ground
-
-  However, as time passed, extension to this standard developed, and these
-were not compatible with each other:
-
-
-  Atari 130, 800(XL/XE)                    MSX
-
-					 +-----------> Power
-      +---------> Right                  | +---------> Right
-      | +-------> Left                   | | +-------> Left
-      | | +-----> Down                   | | | +-----> Down
-      | | | +---> Up                     | | | | +---> Up
-      | | | |                            | | | | |
-  _____________                        _____________
-5 \ x o o o o / 1                    5 \ o o o o o / 1
-   \ x o o o /                          \ o o o o /
-  9 `~~~~~~~' 6                        9 `~~~~~~~' 6
-       | | |                              | | | |
-       | | +----> Button                  | | | +----> Button 1
-       | +------> Power                   | | +------> Button 2
-       +--------> Ground                  | +--------> Output 3
-					  +----------> Ground
-
-       Amstrad CPC                         Commodore C64
-
-					 +-----------> Analog Y
-      +---------> Right                  | +---------> Right
-      | +-------> Left                   | | +-------> Left
-      | | +-----> Down                   | | | +-----> Down
-      | | | +---> Up                     | | | | +---> Up
-      | | | |                            | | | | |
-  _____________                        _____________
-5 \ x o o o o / 1                    5 \ o o o o o / 1
-   \ x o o o /                          \ o o o o /
-  9 `~~~~~~~' 6                        9 `~~~~~~~' 6
-       | | |                              | | | |
-       | | +----> Button 1                | | | +----> Button
-       | +------> Button 2                | | +------> Power
-       +--------> Ground                  | +--------> Ground
-					  +----------> Analog X
-
-  And there were many others.
-
-2.2.1 Multisystem joysticks using db9.c
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-  For the Multisystem joysticks, and their derivatives, the db9.c driver
-was written. It allows only one joystick / gamepad per parallel port, but
-the interface is easy to build and works with almost anything.
-
-  For the basic 1-button Multisystem joystick you connect its wires to the
-parallel port like this:
-
-(pin  1) -----> Power
-(pin 18) -----> Ground
-
-(pin  2) -----> Up
-(pin  3) -----> Down
-(pin  4) -----> Left
-(pin  5) -----> Right
-(pin  6) -----> Button 1
-
-  However, if the joystick is switch based (eg. clicks when you move it),
-you might or might not, depending on your parallel port, need 10 kOhm pullup
-resistors on each of the direction and button signals, like this:
-
-(pin 2) ------------+------> Up
-	  Resistor  |
-(pin 1) --[10kOhm]--+
-
-  Try without, and if it doesn't work, add them. For TTL based joysticks /
-gamepads the pullups are not needed.
-
-  For joysticks with two buttons you connect the second button to pin 7 on
-the parallel port.
-
-(pin 7) -----> Button 2
-
-  And that's it.
-
-  On a side note, if you have already built a different adapter for use with
-the digital joystick driver 0.8.0.2, this is also supported by the db9.c
-driver, as device type 8. (See section 3.2)
-
-2.2.2 Multisystem joysticks using gamecon.c
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-  For some people just one joystick per parallel port is not enough, and/or
-want to use them on one parallel port together with NES/SNES/PSX pads. This is
-possible using the gamecon.c. It supports up to 5 devices of the above types,
-including 1 and 2 buttons Multisystem joysticks.
-
-  However, there is nothing for free. To allow more sticks to be used at
-once, you need the sticks to be purely switch based (that is non-TTL), and
-not to need power. Just a plain simple six switches inside. If your
-joystick can do more (eg. turbofire) you'll need to disable it totally first
-if you want to use gamecon.c.
-
-  Also, the connection is a bit more complex. You'll need a bunch of diodes,
-and one pullup resistor. First, you connect the Directions and the button
-the same as for db9, however with the diodes inbetween.
-
-	    Diodes
-(pin 2) -----|<|----> Up
-(pin 3) -----|<|----> Down
-(pin 4) -----|<|----> Left
-(pin 5) -----|<|----> Right
-(pin 6) -----|<|----> Button 1
-
-  For two button sticks you also connect the other button.
-
-(pin 7) -----|<|----> Button 2
-
-  And finally, you connect the Ground wire of the joystick, like done in
-this little schematic to Power and Data on the parallel port, as described
-for the NES / SNES pads in section 2.1 of this file - that is, one data pin
-for each joystick. The power source is shared.
-
-Data    ------------+-----> Ground
-	  Resistor  |
-Power   --[10kOhm]--+
-
-  And that's all, here we go!
-
-2.2.3 Multisystem joysticks using turbografx.c
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-  The TurboGraFX interface, designed by
-
-	Steffen Schwenke <schwenke@burg-halle.de>
-
-  allows up to 7 Multisystem joysticks connected to the parallel port. In
-Steffen's version, there is support for up to 5 buttons per joystick.  However,
-since this doesn't work reliably on all parallel ports, the turbografx.c driver
-supports only one button per joystick. For more information on how to build the
-interface, see
-
-	http://www2.burg-halle.de/~schwenke/parport.html
-
-2.3 Sony Playstation
-~~~~~~~~~~~~~~~~~~~~
-
-  WARNING: PSX support is experimental, and at the moment doesn't seem to
-work for most people. If you like adventure, you can try yourself.
-
-  The PSX controller is supported by the gamecon.c.
-
-Pinout of the PSX controller (compatible with DirectPadPro):
-
-  +---------+---------+---------+
-9 | o  o  o | o  o  o | o  o  o | 1               parallel
-   \________|_________|________/                  port pins
-    |  |      |  |  |   |
-    |  |      |  |  |   +-------->  Clock    ---  (4)
-    |  |      |  |  +------------>  Select   ---  (3)
-    |  |      |  +--------------->  Power    ---  (5-9)
-    |  |      +------------------>  Ground   ---  (18-25)
-    |  +------------------------->  Command  ---  (2)
-    +---------------------------->  Data     ---  (10,11,12,13,15) one only...
-
-  You may have to add pull up/down resistors. Maybe your pad also won't like
-the 5V (PSX uses 3.7V).
-
-  Currently the driver supports only one psx pad per parallel port, and these
-controllers:
-
- * Standard PSX Pad
- * NegCon PSX Pad
- * Analog PSX Pad (red mode)
- * Analog PSX Pad (green mode)
-
-2.4 Sega
-~~~~~~~~
-  All the Sega controllers are more or less based on the standard 2-button
-Multisystem joystick. However, since they don't use switches and use TTL
-logic, the only driver usable with them is the db9.c driver.
-
-2.4.1 Sega Master System
-~~~~~~~~~~~~~~~~~~~~~~~~
-  The SMS gamepads are almost exactly the same as normal 2-button
-Multisystem joysticks. Set the driver to Multi2 mode, use the corresponding
-parallel port pins, and the following schematic:
-
-    +-----------> Power
-    | +---------> Right
-    | | +-------> Left
-    | | | +-----> Down
-    | | | | +---> Up
-    | | | | |
-  _____________
-5 \ o o o o o / 1
-   \ o o x o /
-  9 `~~~~~~~' 6
-     | |   |
-     | |   +----> Button 1
-     | +--------> Ground
-     +----------> Button 2
-
-2.4.2 Sega Genesis aka MegaDrive
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-  The Sega Genesis (in Europe sold as Sega MegaDrive) pads are an extension
-to the Sega Master System pads. They use more buttons (3+1, 5+1, 6+1).  Use
-the following schematic:
-
-    +-----------> Power
-    | +---------> Right
-    | | +-------> Left
-    | | | +-----> Down
-    | | | | +---> Up
-    | | | | |
-  _____________
-5 \ o o o o o / 1
-   \ o o o o /
-  9 `~~~~~~~' 6
-     | | | |
-     | | | +----> Button 1
-     | | +------> Select
-     | +--------> Ground
-     +----------> Button 2
-
-  The Select pin goes to pin 14 on the parallel port.
-
-(pin 14) -----> Select
-
-  The rest is the same as for Multi2 joysticks using db9.c
-
-2.4.3 Sega Saturn
-~~~~~~~~~~~~~~~~~
-  Sega Saturn has eight buttons, and to transfer that, without hacks like
-Genesis 6 pads use, it needs one more select pin. Anyway, it is still
-handled by the db9.c driver. Its pinout is very different from anything
-else.  Use this schematic:
-
-    +-----------> Select 1
-    | +---------> Power
-    | | +-------> Up
-    | | | +-----> Down
-    | | | | +---> Ground
-    | | | | |
-  _____________
-5 \ o o o o o / 1
-   \ o o o o /
-  9 `~~~~~~~' 6
-     | | | |
-     | | | +----> Select 2
-     | | +------> Right
-     | +--------> Left
-     +----------> Power
-
-  Select 1 is pin 14 on the parallel port, Select 2 is pin 16 on the
-parallel port.
-
-(pin 14) -----> Select 1
-(pin 16) -----> Select 2
-
-  The other pins (Up, Down, Right, Left, Power, Ground) are the same as for
-Multi joysticks using db9.c
-
-3. The drivers
-~~~~~~~~~~~~~~
-  There are three drivers for the parallel port interfaces. Each, as
-described above, allows to connect a different group of joysticks and pads.
-Here are described their command lines:
-
-3.1 gamecon.c
-~~~~~~~~~~~~~
-  Using gamecon.c you can connect up to five devices to one parallel port. It
-uses the following kernel/module command line:
-
-	gc=port,pad1,pad2,pad3,pad4,pad5
-
-  Where 'port' the number of the parport interface (eg. 0 for parport0).
-
-  And 'pad1' to 'pad5' are pad types connected to different data input pins
-(10,11,12,13,15), as described in section 2.1 of this file.
-
-  The types are:
-
-	Type | Joystick/Pad
-	--------------------
-	  0  | None
-	  1  | SNES pad
-	  2  | NES pad
-	  4  | Multisystem 1-button joystick
-	  5  | Multisystem 2-button joystick
-	  6  | Sony PSX controller
-	  7  | N64 pad
-
-  The exact type of the PSX controller type is autoprobed, so you must have
-your controller plugged in before initializing.
-
-  Should you want to use more than one of parallel ports at once, you can use
-gc_2 and gc_3 as additional command line parameters for two more parallel
-ports.
-
-3.2 db9.c
-~~~~~~~~~
-  Apart from making an interface, there is nothing difficult on using the
-db9.c driver. It uses the following kernel/module command line:
-
-	db9=port,type
-
-  Where 'port' is the number of the parport interface (eg. 0 for parport0).
-
-  Caveat here: This driver only works on bidirectional parallel ports. If
-your parallel port is recent enough, you should have no trouble with this.
-Old parallel ports may not have this feature.
-
-  'Type' is the type of joystick or pad attached:
-
-	Type | Joystick/Pad
-	--------------------
-	  0  | None
-	  1  | Multisystem 1-button joystick
-	  2  | Multisystem 2-button joystick
-	  3  | Genesis pad (3+1 buttons)
-	  5  | Genesis pad (5+1 buttons)
-	  6  | Genesis pad (6+2 buttons)
-	  7  | Saturn pad (8 buttons)
-	  8  | Multisystem 1-button joystick (v0.8.0.2 pin-out)
-	  9  | Two Multisystem 1-button joysticks (v0.8.0.2 pin-out) 
-	 10  | Amiga CD32 pad
-
-  Should you want to use more than one of these joysticks/pads at once, you
-can use db9_2 and db9_3 as additional command line parameters for two
-more joysticks/pads.
-
-3.3 turbografx.c
-~~~~~~~~~~~~~~~~
-  The turbografx.c driver uses a very simple kernel/module command line:
-
-	tgfx=port,js1,js2,js3,js4,js5,js6,js7
-
-  Where 'port' is the number of the parport interface (eg. 0 for parport0).
-
-  'jsX' is the number of buttons the Multisystem joysticks connected to the
-interface ports 1-7 have. For a standard multisystem joystick, this is 1.
-
-  Should you want to use more than one of these interfaces at once, you can
-use tgfx_2 and tgfx_3 as additional command line parameters for two more
-interfaces.
-
-3.4 PC parallel port pinout
-~~~~~~~~~~~~~~~~~~~~~~~~~~~
-		  .----------------------------------------.
-   At the PC:     \ 13 12 11 10  9  8  7  6  5  4  3  2  1 /
-                   \  25 24 23 22 21 20 19 18 17 16 15 14 /
-                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-	  Pin | Name    | Description
-	~~~~~~|~~~~~~~~~|~~~~~~~~~~
-	    1 | /STROBE | Strobe
-	  2-9 | D0-D7   | Data Bit 0-7
-	   10 | /ACK    | Acknowledge
-	   11 | BUSY    | Busy
-	   12 | PE      | Paper End
-	   13 | SELIN   | Select In
-	   14 | /AUTOFD | Autofeed
-	   15 | /ERROR  | Error
-	   16 | /INIT   | Initialize
-	   17 | /SEL    | Select
-	18-25 | GND     | Signal Ground
-
-3.5 End
-~~~~~~~
-  That's all, folks! Have fun!
diff -u --recursive --new-file v2.4.9/linux/Documentation/joystick.txt linux/Documentation/joystick.txt
--- v2.4.9/linux/Documentation/joystick.txt	Fri Jul 28 12:50:51 2000
+++ linux/Documentation/joystick.txt	Wed Dec 31 16:00:00 1969
@@ -1,582 +0,0 @@
-		       Linux Joystick driver v2.0.0
-	       (c) 1996-2000 Vojtech Pavlik <vojtech@suse.cz>
-			     Sponsored by SuSE
-----------------------------------------------------------------------------
-
-0. Disclaimer
-~~~~~~~~~~~~~
-  This program is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your option)
-any later version.
-
-  This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-more details.
-
-  You should have received a copy of the GNU General Public License along
-with this program; if not, write to the Free Software Foundation, Inc., 59
-Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-  Should you need to contact me, the author, you can do so either by e-mail
-- mail your message to <vojtech@suse.cz>, or by paper mail: Vojtech Pavlik,
-Ucitelska 1576, Prague 8, 182 00 Czech Republic
-
-  For your convenience, the GNU General Public License version 2 is included
-in the package: See the file COPYING.
-
-1. Intro
-~~~~~~~~
-  The joystick driver for Linux provides support for a variety of joysticks
-and similar devices. It is based on a larger project aiming to support all
-input devices in Linux.
-
-  Should you encounter any problems while using the driver, or joysticks
-this driver can't make complete use of, I'm very interested in hearing about
-them. Bug reports and success stories are also welcome.
-
-  The input project website is at:
-
-	http://www.suse.cz/development/input/
-	http://atrey.karlin.mff.cuni.cz/~vojtech/input/
-
-  There is also a mailing list for the driver at:
-
-	listproc@atrey.karlin.mff.cuni.cz
-
-send "subscribe linux-joystick Your Name" to subscribe to it.
-
-2. Usage
-~~~~~~~~
-  For basic usage you just choose the right options in kernel config and
-you should be set.
-
-2.1 inpututils
-~~~~~~~~~~~~~~
-For testing and other purposes (for example serial devices), a set of
-utilities is available at the abovementioned website. I suggest you download
-and install it before going on.
-
-2.2 Device nodes
-~~~~~~~~~~~~~~~~
-For applications to be able to use the joysticks, in you don't use devfs,
-you'll have to manually create these nodes in /dev:
-
-cd /dev
-rm js*
-mkdir input
-mknod input/js0 c 13 0
-mknod input/js1 c 13 1
-mknod input/js2 c 13 2
-mknod input/js3 c 13 3
-ln -s input/js0 js0
-ln -s input/js1 js1
-ln -s input/js2 js2
-ln -s input/js3 js3
-
-For testing with inpututils it's also convenient to create these:
-
-mknod input/event0 c 13 64
-mknod input/event1 c 13 65
-mknod input/event2 c 13 66
-mknod input/event3 c 13 67
-
-2.4 Modules needed 
-~~~~~~~~~~~~~~~~~~
-  For all joystick drivers to function, you'll need the userland interface
-module in kernel, either loaded or compiled in:
-
-	modprobe joydev
-
-  For gameport joysticks, you'll have to load the gameport driver as well;
-
-	modprove ns558
-
-  And for serial port joysticks, you'll need the serial input line
-discipline module loaded and the inputattach utility started:
-
-	modprobe serport
-	inputattach -xxx /dev/tts/X &
-
-  In addition to that, you'll need the joystick driver module itself, most
-usually you'll have an analog joystick:
-
-	modprobe analog
-	
-  For automatic module loading, something like this might work:
-
-	alias tty-ldisc-2 serport
-	alias char-major-13 joydev ns558 analog
-
-2.5 Verifying that it works
-~~~~~~~~~~~~~~~~~~~~~~~~~~~
-  For testing the joystick driver functionality, there is the jstest
-program in the utilities package. You run it by typing:
-
-	jstest /dev/js0
-
-  And it should show a line with the joystick values, which update as you
-move the stick, and press its buttons. The axes should all be zero when the
-joystick is in the center position. They should not jitter by themselves to
-other close values, and they also should be steady in any other position of
-the stick. They should have the full range from -32767 to 32767. If all this
-is met, then it's all fine, and you can play the games. :)
-
-  If it's not, then there might be a problem. Try to calibrate the joystick,
-and if it still doesn't work, read the drivers section of this file, the
-troubleshooting section, and the FAQ.
-
-2.6. Calibration
-~~~~~~~~~~~~~~~~
-  For most joysticks you won't need any manual calibration, since the
-joystick should be autocalibrated by the driver automagically. However, with
-some analog joysticks, that either do not use linear resistors, or if you
-want better precision, you can use the jscal program
-
-	jscal -c /dev/js0
-
- included in the joystick package to set better correction coefficients than
-what the driver would choose itself.
-
-  After calibrating the joystick you can verify if you like the new
-calibration using the jstest command, and if you do, you then can save the
-correction coefficients into a file
-
-	jscal -p /dev/js0 > /etc/joystick.cal
-
-  And add a line to your rc script executing that file
-
-	source /etc/joystick.cal
-
-  This way, after the next reboot your joystick will remain calibrated. You
-can also add the jscal -p line to your shutdown script.
-
-
-3. HW specific driver information
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-In this section each of the separate hardware specific drivers is described.
-
-3.1 Analog joysticks
-~~~~~~~~~~~~~~~~~~~~
-  The analog.c uses the standard analog inputs of the gameport, and thus
-supports all standard joysticks and gamepads. It uses a very advanced
-routine for this, allowing for data precision that can't be found on any
-other system.
-
-  It also supports extensions like additional hats and buttons compatible
-with CH Flightstick Pro, ThrustMaster FCS or 6 and 8 button gamepads. Saitek
-Cyborg 'digital' joysticks are also supported by this driver, because
-they're basically souped up CHF sticks.
-
-  However the only types that can be autodetected are:
-
-* 2-axis, 4-button joystick
-* 3-axis, 4-button joystick
-* 4-axis, 4-button joystick
-* Saitek Cyborg 'digital' joysticks
-
-  For other joystick types (more/less axes, hats, and buttons) support
-you'll need to specify the types either on the kernel command line or on the
-module command line, when inserting analog.o into the kernel. The
-parameters are:
-
-	js=type,type,type,....
-
-  'type' is type of the joystick from the table below, defining joysticks
-present on gameports in the system, starting with gameport0, second 'type'
-entry defining joystick on gameport1 and so on.
-
-	Type     | Meaning
-	-----------------------------------
-	none     | No analog joystick on that port
-	auto     | Autodetect joystick
-	2btn     | 2-button n-axis joystick
-	y-joy    | Two 2-button 2-axis joysticks on an Y-cable
-	y-pad    | Two 2-button 2-axis gamepads on an Y-cable
-	fcs      | Thrustmaster FCS compatible joystick
-	chf      | Joystick with a CH Flightstick compatible hat
-	fullchf  | CH Flightstick compatible with two hats and 6 buttons
-	gamepad  | 4/6-button n-axis gamepad
-	gamepad8 | 8-button 2-axis gamepad
-
-  In case your joystick doesn't fit in any of the above categories, you can
-specify the type as a number by combining the bits in the table below. This
-is not recommended unless you really know what are you doing. It's not
-dangerous, but not simple either.
-
-	Bit | Meaning
-	--------------------------
-	 0  | Axis X1
-	 1  | Axis Y1
-	 2  | Axis X2
-	 3  | Axis Y2
-	 4  | Button A
-	 5  | Button B
-	 6  | Button C
-	 7  | Button D
-	 8  | CHF Buttons X and Y
-	 9  | CHF Hat 1
-	10  | CHF Hat 2
-	11  | FCS Hat
-	12  | Pad Button X
-	13  | Pad Button Y
-	14  | Pad Button U
-	15  | Pad Button V
-	16  | Saitek F1-F4 Buttons
-	17  | Saitek Digital Mode
-	19  | GamePad
-	20  | Joy2 Axis X1
-	21  | Joy2 Axis Y1
-	22  | Joy2 Axis X2
-	23  | Joy2 Axis Y2
-	24  | Joy2 Button A
-	25  | Joy2 Button B
-	26  | Joy2 Button C
-	27  | Joy2 Button D
-	31  | Joy2 GamePad
-
-3.2 Microsoft SideWinder joysticks
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-  Microsoft 'Digital Overdrive' protocol is supported by the sidewinder.c
-module. All currently supported joysticks:
-
-* Microsoft SideWinder 3D Pro
-* Microsoft SideWinder Force Feedback Pro
-* Microsoft SideWinder Force Feedback Wheel
-* Microsoft SideWinder FreeStyle Pro 
-* Microsoft SideWinder GamePad (up to four, chained)
-* Microsoft SideWinder Precision Pro 
-* Microsoft SideWinder Precision Pro USB 
-
-  are autodetected, and thus no module parameters are needed.
-
-  There is one caveat with the 3D Pro. There are 9 buttons reported,
-although the joystick has only 8. The 9th button is the mode switch on the
-rear side of the joystick. However, moving it, you'll reset the joystick,
-and make it unresponsive for about a one third of a second. Furthermore, the
-joystick will also re-center itself, taking the position it was in during
-this time as a new center position. Use it if you want, but think first.
-
-  The SideWinder Standard is not a digital joystick, and thus is supported
-by the analog driver described above. 
-
-3.3 Logitech ADI devices
-~~~~~~~~~~~~~~~~~~~~~~~~
-  Logitech ADI protocol is supported by the adi.c module. It should support
-any Logitech device using this protocol. This includes, but is not limited
-to:
-
-* Logitech CyberMan 2
-* Logitech ThunderPad Digital
-* Logitech WingMan Extreme Digital
-* Logitech WingMan Formula
-* Logitech WingMan Interceptor
-* Logitech WingMan GamePad
-* Logitech WingMan GamePad USB
-* Logitech WingMan GamePad Extreme
-* Logitech WingMan Extreme Digital 3D
-
-  ADI devices are autodetected, and the driver supports up to two (any
-combination of) devices on a single gameport, using an Y-cable or chained
-together.
-
-  Logitech WingMan Joystick, Logitech WingMan Attack, Logitech WingMan
-Extreme and Logitech WingMan ThunderPad are not digital joysticks and are
-handled by the analog driver described above. Logitech WingMan Warrior and
-Logitech Magellan are supported by serial drivers described below.  Logitech
-WingMan Force and Logitech WingMan Formula Force are supported by the
-I-Force driver described below. Logitech CyberMan is not supported yet.
-
-3.4 Gravis GrIP
-~~~~~~~~~~~~~~~
-  Gravis GrIP protocol is supported by the grip.c module. It currently
-supports:
-
-* Gravis GamePad Pro
-* Gravis BlackHawk Digital
-* Gravis Xterminator
-* Gravis Xterminator DualControl
-
-  All these devices are autodetected, and you can even use any combination
-of up to two of these pads either chained together or using an Y-cable on a
-single gameport.
-
-GrIP MultiPort isn't supported yet. Gravis Stinger is a serial device and
-hopefully will be supported soon. Other Gravis joysticks are supported by
-the analog driver.
-
-3.5 FPGaming A3D and MadCatz A3D
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-  The Assassin 3D protocol created by FPGaming, is used both by FPGaming
-themselves and is licensed to MadCatz. A3D devices are supported by the
-a3d.c module. It currently supports:
-
-* FPGaming Assassin 3D
-* MadCatz Panther
-* MadCatz Panther XL
-
-  All these devices are autodetected. Because the Assassin 3D and the Panther
-allow connecting analog joysticks to them, you'll need to load the analog
-driver as well to handle the attached joysticks.
-
-  The trackball should work with USB mousedev module as a normal mouse. See
-the USB documentation for how to setup an USB mouse.
-
-3.6 ThrustMaster DirectConnect (BSP)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-  The TM DirectConnect (BSP) protocol is supported by the tmdc.c
-module. This includes, but is not limited to:
-
-* ThrustMaster Millenium 3D Inceptor
-* ThrustMaster 3D Rage Pad
-* ThrustMaster Fusion Digital Game Pad
-
-  Devices not directly supported, but hopefully working are:
-
-* ThrustMaster FragMaster
-* ThrustMaster Attack Throttle
-
-  If you have one of these, contact me.
-
-  BSP devices are autodetected, and thus no parameters to the module
-are needed. Up to two TMDC devices can be connected to one gameport, using
-an Y-cable.
-
-3.7 Creative Labs Blaster
-~~~~~~~~~~~~~~~~~~~~~~~~~
-  The Blaster protocol is supported by the cobra.c module. It supports only
-the:
-
-* Creative Blaster GamePad Cobra
-
-  Up to two of these can be used on a single gameport, using an Y-cable.
-
-3.8 Genius Digital joysticks 
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-  The Genius digitally communicating joysticks are supported by the gf2k.c
-module. This includes:
-
-* Genius Flight2000 F-23 joystick 
-* Genius Flight2000 F-31 joystick 
-* Genius G-09D gamepad
-
-  Other Genius digital joysticks are not supported yet, but support can be
-added fairly easily.
-
-3.9 InterAct Digital joysticks
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-  The InterAct digitally communicating joysticks are supported by the
-interact.c module. This includes:
-
-* InterAct HammerHead/FX gamepad
-* InterAct ProPad8 gamepad 
-
-  Other InterAct digital joysticks are not supported yet, but support can be 
-added fairly easily.
-
-3.10 PDPI Lightning 4 gamecards
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-  PDPI Lightning 4 gamecards are supported by the lightning.c module.
-Once the module is loaded, the analog driver can be used to handle the
-joysticks. Digitally communicating joystick will work only on port 0, while
-using Y-cables, you can connect up to 8 analog joysticks to a single L4
-card, 16 in case you have two in your system.
-
-3.11 Trident 4DWave / Aureal Vortex
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-  Soundcards with a Trident 4DWave DX/NX or Aureal Vortex/Vortex2 chipsets
-provide an "Enhanced Game Port" mode where the soundcard handles polling the
-joystick.  This mode is supported by the pcigame.c module. Once loaded the
-analog driver can use the enhanced features of these gameports..
-
-3.12 Amiga
-~~~~~~~~~~
-  Amiga joysticks, connected to an Amiga, are supported by the amijoy.c
-driver. Since they can't be autodetected, the driver has a command line.
-
-	amijoy=a,b
-
-  a and b define the joysticks connected to the JOY0DAT and JOY1DAT ports of
-the Amiga.
-
-	Value | Joystick type
-	---------------------
-	  0   | None
-	  1   | 1-button digital joystick
-
-  No more joystick types are supported now, but that should change in the
-future if I get an Amiga in the reach of my fingers.
-
-3.13 Game console and 8-bit pads and joysticks
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-See joystick-parport.txt for more info.
-
-3.14 SpaceTec/LabTec devices
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-  SpaceTec serial devices communicate using the SpaceWare protocol. It is
-supported by the spaceorb.c and spaceball.c drivers. The devices currently
-supported by spaceorb.c are:
-
-* SpaceTec SpaceBall Avenger
-* SpaceTec SpaceOrb 360
-
-Devices currently supported by spaceball.c are:
-
-* SpaceTec SpaceBall 4000 FLX
-
-  In addition to having the spaceorb/spaceball and serport modules in the
-kernel, you also need to attach a serial port to it. to do that, run the
-jsattach program:
-
-	inputattach --spaceorb /dev/tts/x &
-or
-	jsattach --spaceball /dev/tts/x &
-
-where /dev/tts/x is the serial port which the device is connected to. After
-doing this, the device will be reported and will start working.
-
-  There is one caveat with the SpaceOrb. The button #6, the on the bottom
-side of the orb, although reported as an ordinary button, causes internal
-recentering of the spaceorb, moving the zero point to the position in which
-the ball is at the moment of pressing the button. So, think first before
-you bind it to some other function.
-
-SpaceTec SpaceBall 2003 FLX and 3003 FLX are not supported yet. 
-
-3.15 Logitech SWIFT devices
-~~~~~~~~~~~~~~~~~~~~~~~~~~~
-  The SWIFT serial protocol is supported by the warrior.c module. It
-currently supports only the:
-
-* Logitech WingMan Warrior
-
-but in the future, Logitech CyberMan (the original one, not CM2) could be
-supported as well. To use the module, you need to run jsattach after you
-insert/compile the module into your kernel:
-
-	inputattach --warrior /dev/tts/x &
-
-/dev/tts/x is the serial port your Warrior is attached to.
-
-3.16 Magellan / Space Mouse
-~~~~~~~~~~~~~~~~~~~~~~~~~~~
-  The Magellan (or Space Mouse), manufactured by LogiCad3d (formerly Space
-Systems), for many other companies (Logitech, HP, ...) is supported by the
-joy-magellan module. It currently supports only the:
-
-* Magellan 3D
-* Space Mouse
-
-models, the additional buttons on the 'Plus' versions are not supported yet.
-
-  To use it, you need to attach the serial port to the driver using the
-
-	inputattach --magellan /dev/tts/x &
-
-command. After that the Magellan will be detected, initialized, will beep,
-and the /dev/input/jsX device should become usable.
-
-3.17 I-Force devices 
-~~~~~~~~~~~~~~~~~~~~
-  All I-Force devices ale supported by the iforce.c module. This includes,
-but is not limited to:
-
-* Logitech WingMan Force
-* Logitech WingMan Force Wheel 
-* Guillemot Race Leader wheel 
-
-  To use it, you need to attach the serial port to the driver using the
-
-	inputattach --iforce /dev/tts/x &
-
-command. After that the I-Force device will be detected, and the
-/dev/input/jsX device should become usable.
-
-  In case you're using the device via the USB port, the inputattach command
-isn't needed.
-
-4. Troubleshooting
-~~~~~~~~~~~~~~~~~~
-  There is quite a high probability that you run into some problems. For
-testing whether the driver works, if in doubt, use the jstest utility in
-some of its modes. The most useful modes are "normal" - for the 1.x
-interface, and "old" for the "0.x" interface. You run it by typing:
-
-	jstest --normal /dev/input/js0
-	jstest --old    /dev/input/js0
-
-  Additionally you can do a test with the evtest utility:
-
-	evtest /dev/input/event0
-
-  Oh, and read the FAQ! :)
-
-5. FAQ
-~~~~~~
-Q: Running 'jstest /dev/js0' results in "File not found" error. What's the
-   cause?
-A: The device files don't exist. Create them (see section 2.2).
-
-Q: Is it possible to connect my old Atari/Commodore/Amiga/console joystick
-   or pad that uses a 9-pin D-type cannon connector to the serial port of my
-   PC?
-A: Yes, it is possible, but it'll burn your serial port or the pad. It
-   won't work, of course.
-
-Q: My joystick doesn't work with Quake / Quake 2. What's the cause?
-A: Quake / Quake 2 don't support joystick. Use joy2key to simulate keypresses
-   for them.
-
-6. Programming Interface
-~~~~~~~~~~~~~~~~~~~~~~~~
-  The 1.0 driver uses a new, event based approach to the joystick driver.
-Instead of the user program polling for the joystick values, the joystick
-driver now reports only any changes of its state. See joystick-api.txt,
-joystick.h and jstest.c included in the joystick package for more
-information. The joystick device can be used in either blocking or
-nonblocking mode and supports select() calls.
-
-  For backward compatibility the old (v0.x) interface is still included.
-Any call to the joystick driver using the old interface will return values
-that are compatible to the old interface.  This interface is still limited
-to 2 axes, and applications using it usually decode only 2 buttons, although
-the driver provides up to 32.
-
-7. Credits
-~~~~~~~~~~
-  Thanks to the following people who contributed code, ideas or specifications
-to the joystick driver development:
-
-	Arthur C. Smith		<asmith@cbnewsd.att.com>
-	Eyal Lebedinsky		<eyal@eyal.emu.id.au>
-	Jeff Tranter		<tranter@software.mitel.com>
-	Carlos Puchol		<cpg@cs.utexas.edu>
-	Matt Rhoten		<mrhoten@oz.net>
-	Dan Fandrich		<dan@fch.wimsey.bc.ca>
-	Sverker Wilberg		<sverkerw@manila.docs.uu.se>
-	Hal Maney		<maney@norden.com>
-	Bernd Schmidt		<crux@pool.informatik.rwth-aachen.de>
-	Alan Cox		<alan@lxorguk.ukuu.org.uk>
-	John Markus Bjorndalen	<johnm@cs.uit.no>
-	Boris Muehmer		<mhs@cybernet-ag.de>
-	Robert W. Grubbs	<rwgrubbs@vt.edu>
-	Pete Chown		<pete.chown@skygate.co.uk>
-	Benji York		<benji@cookeville.com>
-	Leslie F. Donaldson	<donaldlf@cs.rose-hulman.edu>
-	Eng-Jon Ong		<ongej@dcs.qmw.ac.uk>
-	Ragnar Hojland Espinosa	<ragnar@macula.net>
-	Brian Gerst		<bgerst@quark.vpplus.com>
-	Andree Borrmann		<a.borrmann@tu-bs.de>
-	Martin Giguere		<zefrench@hotmail.com>
-	David Thompson		<dcthomp@mail.utexas.edu>
-	Justin Wake		<spectre@telefragged.com>
-	Benoit Triquet		<benoit@adsl-216-100-248-201.dsl.pacbell.net>
-	John Dahlstrom		<jodaman@bradley.edu>
-	Dan Gohman		<gohmandj@mrs.umn.edu>
-	Joe Krahn		<krahn@niehs.nih.gov>
-	David Kuder		<alphagod@penguinpowered.com>
-	Raymond Ingles		<sorceror@tir.com>
-
-  If you think you should be in this list and are not, it's possible that
-I forgot to include you - contact me and I'll correct the error. :)
diff -u --recursive --new-file v2.4.9/linux/Documentation/kernel-doc-nano-HOWTO.txt linux/Documentation/kernel-doc-nano-HOWTO.txt
--- v2.4.9/linux/Documentation/kernel-doc-nano-HOWTO.txt	Fri Mar  2 18:43:11 2001
+++ linux/Documentation/kernel-doc-nano-HOWTO.txt	Fri Sep  7 18:15:17 2001
@@ -35,9 +35,9 @@
 
 - Makefile
 
-  The targets 'sgmldocs', 'psdocs', and 'pdfdocs' are used to build
-  DocBook files, PostScript files, and PDF files in
-  Documentation/DocBook.
+  The targets 'sgmldocs', 'psdocs', 'pdfdocs', and 'htmldocs' are used
+  to build DocBook files, PostScript files, PDF files, and html files
+  in Documentation/DocBook.
 
 - Documentation/DocBook/Makefile
 
@@ -49,10 +49,11 @@
 
 If you just want to read the ready-made books on the various
 subsystems (see Documentation/DocBook/*.tmpl), just type 'make
-psdocs', or 'make pdfdocs', depending on your preference.  If you
-would rather read a different format, you can type 'make sgmldocs' and
-then use DocBook tools to convert Documentation/DocBook/*.sgml to a
-format of your choice (for example, 'db2html ...').
+psdocs', or 'make pdfdocs', or 'make htmldocs', depending on your 
+preference.  If you would rather read a different format, you can type 
+'make sgmldocs' and then use DocBook tools to convert 
+Documentation/DocBook/*.sgml to a format of your choice (for example, 
+'db2html ...' if 'make htmldocs' was not defined).
 
 If you want to see man pages instead, you can do this:
 
@@ -111,7 +112,9 @@
 (*)?*/
 
 The short function description cannot be multiline, but the other
-descriptions can be.
+descriptions can be (and they can contain blank lines). Avoid putting a
+spurious blank line after the function name, or else the description will
+be repeated!
 
 All descriptive text is further processed, scanning for the following special
 patterns, which are highlighted appropriately.
diff -u --recursive --new-file v2.4.9/linux/Documentation/mips/pci/pci.README linux/Documentation/mips/pci/pci.README
--- v2.4.9/linux/Documentation/mips/pci/pci.README	Wed Dec 31 16:00:00 1969
+++ linux/Documentation/mips/pci/pci.README	Mon Aug 27 08:56:31 2001
@@ -0,0 +1,67 @@
+
+Pete Popov, ppopov@pacbell.net
+07/11/2001
+
+This README briefly explains how to use the pci and pci_auto
+code in arch/mips/kernel.  The code was ported from PowerPC and
+modified slightly. It has been tested pretty well on PPC on some
+rather complex systems with multiple bridges and devices behind
+each bridge. However, at the time this README was written, the
+mips port was tested only on boards with a single pci bus and
+no P2P bridges.  It's very possible that on boards with P2P
+bridges some modifications have to be made. The code will 
+evolve, no doubt, but currently every single mips board
+is doing its own pcibios thing and it has become a big
+mess.  This generic pci code is meant to clean up the mips
+pci mess and make it easier to add pci support to new boards.
+
+arch/mips/kernel/pci_auto.c has the pci bus enumeration code.
+This code scans the pci bus(es) and assigns all of the resources.
+Thus, you don't need the boot code to that, and many boot codes
+don't do it correctly anyway.  To enable the pci_auto code, add
+
+define_bool CONFIG_PCI_AUTO y 
+
+inside the define for your board in arch/mips/config.in. 
+For example, the Galileo EV96100 board  looks like this:
+
+if [ "$CONFIG_MIPS_EV96100" = "y" ]; then
+	define_bool CONFIG_PCI y
+	define_bool CONFIG_MIPS_GT96100 y
+	define_bool CONFIG_NEW_PCI y
+	define_bool CONFIG_PCI_AUTO y
+	define_bool CONFIG_SWAP_IO_SPACE y
+fi 
+
+
+Next, if you want to use the arch/mips/kernel/pci code, which has the
+pcibios_init() function, add
+
+define_bool CONFIG_NEW_PCI y
+ 
+inside the define for your board. Again, the EV96100 example above
+show NEW_PCI turned on.
+
+Note that you can enable CONFIG_NEW_PCI code without enabling 
+CONFIG_PCI_AUTO. But you can't do the opposite because the pci_auto
+routines are called from pcibios_init(), which is part of the 
+CONFIG_NEW_PCI code.
+
+
+Now you need to add your files to hook in your pci configuration
+cycles.  Usually you'll need only a couple of files named something
+like pci_fixups.c and pci_ops.c.  You can copy the templates
+provided and fill in the code.
+
+The file pci_ops.c should contain the pci configuration cycles routines.
+It also has the mips_pci_channels[] array which contains the descriptors
+of each pci controller.
+
+The file pci_fixups.c contains a few routines to do interrupt fixups,
+resources fixups, and, if needed, pci bios fixups.
+
+Usually you'll put your pci_fixups.c file in your board specific directory, 
+since the functions in that file are board specific.  The functions in
+pci_ops.c, on the other hand, are usually pci controller specific so that
+file could be shared among a few different boards using the same
+pci controller.
diff -u --recursive --new-file v2.4.9/linux/Documentation/s390/3270.txt linux/Documentation/s390/3270.txt
--- v2.4.9/linux/Documentation/s390/3270.txt	Thu May 24 15:14:08 2001
+++ linux/Documentation/s390/3270.txt	Fri Sep  7 09:28:38 2001
@@ -34,17 +34,6 @@
 dialed-in x3270.
 
 
-HELP !!!
-
-The device name of e.g. /dev/3270/tty620 noted below is at variance
-with "standard" Linux device names.  What should it be?  The portion
-"/dev/3270" was recommended by H. Peter Anvin, maintainer of the
-official Linux major-numbers list; the portion "tty620" was recommended
-by me.  Please send your thoughts on this issue at least to me at
-rbh00@utsglobal.com.  Even if you think it's okay as is, please let me
-know.  Thanks.
-
-
 INSTALLATION.
 
 You install the driver by installing a patch, doing a kernel build, and
@@ -60,9 +49,14 @@
 
 If you have chosen to make tub3270 a module, you add a line to
 /etc/modules.conf.  If you are working on a VM virtual machine, you
-can use DEF GRAF to define virtual 3270 devices.  If you generate 3270
-console support, the driver automatically converts your console at boot
-time to a 3270 if it is a 3215.
+can use DEF GRAF to define virtual 3270 devices.
+
+You may generate both 3270 and 3215 console support, or one or the
+other, or neither.  If you generate both, the console type under VM is
+not changed.  Use #CP Q TERM to see what the current console type is.
+Use #CP TERM CONMODE 3270 to change it to 3270.  If you generate only
+3270 console support, then the driver automatically converts your console
+at boot time to a 3270 if it is a 3215.
 
 In brief, these are the steps:
 	1. Install the tub3270 patch
@@ -78,21 +72,17 @@
 
 Here are the installation steps in detail:
 
-	0.  Retrieve the patch file via anonymous ftp from
-	ftp://ftp.utsglobal.com/pub/tub3270.  The patch is designed
-	to apply smoothly to an IBM 2.4.0 system with no other
-	UTS-Global patches applied.  We know of some easily resolvable
-	conflicts between this and other of our patches.
-
-	1. Apply the patch.  Then do
+	1.  The 3270 driver is a part of the official Linux kernel
+	source.  Build a tree with the kernel source and any necessary
+	patches.  Then do
 		make oldconfig
-			(Reply "y" or "m" for CONFIG_3270; if "y",
-			reply "y" or "n" for CONFIG_3270_CONSOLE)
+		(If you wish to disable 3215 console support, edit
+		.config; change CONFIG_TN3215's value to "n";
+		and rerun "make oldconfig".)
 		make dep
 		make image
 		make modules
 		make modules_install
-		<run silo in the usual way>
 
 	2. (Perform this step only if you have configured tub3270 as a
 	module.)  Add a line to /etc/modules.conf to automatically
@@ -122,12 +112,17 @@
 	config3270.sh.	Inspect the output script it produces,
 	/tmp/mkdev3270, and then run that script.  This will create the
 	necessary character special device files and make the necessary
-	changes to /etc/inittab.  Then notify /sbin/init that /etc/inittab
-	has changed, by issuing the telinit command with the q operand:
+	changes to /etc/inittab.  If you have selected DEVFS, the driver
+	itself creates the device files, and /tmp/mkdev3270 only changes
+	/etc/inittab.
+
+	Then notify /sbin/init that /etc/inittab has changed, by issuing
+	the telinit command with the q operand:
 		cd /usr/src/linux/Documentation/s390
 		sh config3270.sh
 		sh /tmp/mkdev3270
 		telinit q
+
 	This should be sufficient for your first time.	If your 3270
 	configuration has changed and you're reusing config3270, you
 	should follow these steps:
diff -u --recursive --new-file v2.4.9/linux/Documentation/s390/config3270.sh linux/Documentation/s390/config3270.sh
--- v2.4.9/linux/Documentation/s390/config3270.sh	Wed Apr 11 19:02:27 2001
+++ linux/Documentation/s390/config3270.sh	Fri Sep  7 09:28:38 2001
@@ -37,10 +37,14 @@
 echo "#!/bin/sh" > $SCR || exit 1
 echo " " >> $SCR
 echo "# Script built by /sbin/config3270" >> $SCR
-echo rm -rf "$D/$SUBD/*" >> $SCR
+if [ ! -d /dev/dasd ]; then
+	echo rm -rf "$D/$SUBD/*" >> $SCR
+fi
 echo "grep -v $TTY $INITTAB > $NINITTAB" > $SCRTMP || exit 1
 echo "echo $ADDNOTE >> $NINITTAB" >> $SCRTMP
-echo mkdir -p $D/$SUBD >> $SCR
+if [ ! -d /dev/dasd ]; then
+	echo mkdir -p $D/$SUBD >> $SCR
+fi
 
 # Now query the tub3270 driver for 3270 device information
 # and add appropriate mknod and mingetty lines to our files
@@ -48,13 +52,19 @@
 while read devno maj min;do
 	if [ $min = 0 ]; then
 		fsmaj=$maj
-		echo mknod $D/$TUB c $fsmaj 0 >> $SCR
-		echo chmod 666 $D/$TUB >> $SCR
+		if [ ! -d /dev/dasd ]; then
+			echo mknod $D/$TUB c $fsmaj 0 >> $SCR
+			echo chmod 666 $D/$TUB >> $SCR
+		fi
 	elif [ $maj = CONSOLE ]; then
-		echo mknod $D/$TUB$devno c $fsmaj $min >> $SCR
+		if [ ! -d /dev/dasd ]; then
+			echo mknod $D/$TUB$devno c $fsmaj $min >> $SCR
+		fi
 	else
-		echo mknod $D/$TTY$devno c $maj $min >>$SCR
-		echo mknod $D/$TUB$devno c $fsmaj $min >> $SCR
+		if [ ! -d /dev/dasd ]; then
+			echo mknod $D/$TTY$devno c $maj $min >>$SCR
+			echo mknod $D/$TUB$devno c $fsmaj $min >> $SCR
+		fi
 		echo "echo t$min$GETTYLINE $TTY$devno >> $NINITTAB" >> $SCRTMP
 	fi
 done < $P
diff -u --recursive --new-file v2.4.9/linux/Documentation/sound/CMI8338 linux/Documentation/sound/CMI8338
--- v2.4.9/linux/Documentation/sound/CMI8338	Wed Jul 25 17:10:17 2001
+++ linux/Documentation/sound/CMI8338	Fri Sep  7 09:28:38 2001
@@ -69,8 +69,8 @@
   Some functions for the cm8738 can be configured in Kernel Configuration
   or modules parameters. Set these parameters to 1 to enable.
 
-  mpu_io:	I/O ports base for MPU-401, 0 if disabled.
-  fm_io:	I/O ports base for OPL-3, 0 if disabled.
+  mpuio:	I/O ports base for MPU-401, 0 if disabled.
+  fmio:		I/O ports base for OPL-3, 0 if disabled.
   spdif_inverse:Inverse the S/PDIF-in signal, this depends on your
 		CD-ROM or DVD-ROM.
   spdif_loop:   Enable S/PDIF loop, this route S/PDIF-in to S/PDIF-out
@@ -80,8 +80,6 @@
                 rear-out.
   use_line_as_bass:Enable this if you want to use line-in as
                 bass-out.
-  modem:	You will need to set this parameter if you want to use
-		the HSP modem. You need install the pctel.o, the modem
-		driver itself.
   joystick:	Enable joystick. You will need to install Linux joystick
 		driver.
+
diff -u --recursive --new-file v2.4.9/linux/Documentation/sound/WaveArtist linux/Documentation/sound/WaveArtist
--- v2.4.9/linux/Documentation/sound/WaveArtist	Wed Dec 31 16:00:00 1969
+++ linux/Documentation/sound/WaveArtist	Fri Sep  7 09:28:38 2001
@@ -0,0 +1,170 @@
+
+ (the following is from the armlinux CVS)
+
+ WaveArtist mixer and volume levels can be accessed via these commands:
+
+  nn30	read registers nn, where nn = 00 - 09 for mixer settings
+		                              0a - 13 for channel volumes
+  mm31	write the volume setting in pairs, where mm = (nn - 10) / 2
+  rr32	write the mixer settings in pairs, where rr = nn/2
+  xx33	reset all settings to default
+  0y34	select mono source, y=0 = left, y=1 = right
+
+                                           bits
+ nn  15  14 13 12 11   10    9     8     7    6     5     4     3     2     1     0
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 00 | 0 | 0  0  1  1 | left line mixer gain       | left aux1 mixer gain        |lmute|
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 01 | 0 | 0  1  0  1 | left aux2 mixer gain       | right 2 left mic gain       |mmute|
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 02 | 0 | 0  1  1  1 | left mic mixer gain        | left mic  | left mixer gain |dith |
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 03 | 0 | 1  0  0  1 | left mixer input select                |lrfg | left ADC gain   |
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 04 | 0 | 1  0  1  1 | right line mixer gain      | right aux1 mixer gain       |rmute|
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 05 | 0 | 1  1  0  1 | right aux2 mixer gain      | left 2 right mic gain       |test |
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 06 | 0 | 1  1  1  1 | right mic mixer gain       | right mic |right mixer gain |rbyps|
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 07 | 1 | 0  0  0  1 | right mixer select                     |rrfg | right ADC gain  |
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 08 | 1 | 0  0  1  1 | mono mixer gain            |right ADC mux sel|left ADC mux sel |
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 09 | 1 | 0  1  0  1 |loopb|left linout|loop|ADCch|TxFch|OffCD|test |loopb|loopb|osamp|
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 0a | 0 | left PCM channel volume                                                     |
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 0b | 0 | right PCM channel volume                                                    |
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 0c | 0 | left FM channel volume                                                      |
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 0d | 0 | right FM channel volume                                                     |
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 0e | 0 | left wavetable channel volume                                               |
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 0f | 0 | right wavetable channel volume                                              |
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 10 | 0 | left PCM expansion channel volume                                           |
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 11 | 0 | right PCM expansion channel volume                                          |
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 12 | 0 | left FM expansion channel volume                                            |
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+ 13 | 0 | right FM expansion channel volume                                           |
+----+---+------------+-----+-----+-----+----+-----+-----+-----+-----+-----+-----+-----+
+
+ lmute: left mute
+ mmute: mono mute
+ dith: dithds
+ lrfg:
+ rmute: right mute
+ rbyps: right bypass
+ rrfg:
+ ADCch:
+ TxFch:
+ OffCD:
+ osamp:
+
+ And the following diagram is derived from the description in the CVS archive:
+
+ MIC L (mouthpiece)
+   +------+
+ -->PreAmp>-\
+   +--^---+ |
+      |     |
+    r2b4-5  |                                +--------+
+       /----*-------------------------------->5       |
+       |                                     |        |
+       | /----------------------------------->4       |
+       | |                                   |        |
+       | | /--------------------------------->3 1of5  |  +---+
+       | | |                                 |  mux   >-->AMP>--> ADC L
+       | | | /------------------------------->2       |  +-^-+
+       | | | |                               |        |    |
+ Line  | | | | +----+  +------+  +---+  /---->1       |  r3b3-0
+ ------------*->mute>--> Gain >-->   |  |    |        |
+  L    | | |   +----+  +------+  |   |  |  *->0       |
+       | | |                     |   |  |    +---^----+
+ Aux2  | | |   +----+  +------+  |   |  |        |
+ ----------*--->mute>--> Gain >--> M |  |     r8b0-2
+  L    | |     +----+  +------+  |   |  |
+       | |                       |   |  \------\
+ Aux1  | |     +----+  +------+  |   |         |
+ --------*----->mute>--> Gain >--> I |         |
+  L    |       +----+  +------+  |   |         |
+       |                         |   |         |
+       |       +----+  +------+  |   |  +---+  |
+       *------->mute>--> Gain >--> X >-->AMP>--*
+       |       +----+  +------+  |   |  +-^-+  |
+       |                         |   |    |    |
+       |       +----+  +------+  |   |  r2b1-3 |  
+       | /----->mute>--> Gain >--> E |         |
+       | |     +----+  +------+  |   |         |
+       | |                       |   |         |
+       | |     +----+  +------+  |   |         |
+       | | /--->mute>--> Gain >--> R |         |
+       | | |   +----+  +------+  |   |         |
+       | | |                     |   |         |   r9b8-9
+       | | |   +----+  +------+  |   |         |     |
+       | | | /->mute>--> Gain >-->   |         | +---v---+
+       | | | | +----+  +------+  +---+       /-*->0      |
+ DAC   | | | |                               |   |       |
+ ------------*----------------------------------->?      |  +----+
+  L    | | |                                 |   |  Mux  >-->mute>--> L output
+       | | |                                 | /->?      |  +--^-+
+       | | |                                 | | |       |     |
+       | | |                           /--------->?      |   r0b0
+       | | |                           |     | | +-------+
+       | | |                           |     | |
+ Mono  | | |                           |     | | +-------+
+ ----------*                           |     \--->       |  +----+
+       | | |                           |       | |  Mix  >-->mute>--> Mono output
+       | | |                           |       *->       |  +--^-+
+       | | |                           |       | +-------+     |
+       | | |                           |       |             r1b0
+ DAC   | | |                           |       | +-------+
+ ------------*-------------------------*--------->1      |  +----+
+  R    | | | |                                 | |  Mux  >-->mute>--> R output
+       | | | | +----+  +------+  +---+         *->0      |  +--^-+
+       | | | \->mute>--> Gain >-->   |         | +---^---+     |
+       | | |   +----+  +------+  |   |         |     |       r5b0
+       | | |                     |   |         |   r6b0
+       | | |   +----+  +------+  |   |         |
+       | | \--->mute>--> Gain >--> M |         |
+       | |     +----+  +------+  |   |         |
+       | |                       |   |         |
+       | |     +----+  +------+  |   |         |
+       | *----->mute>--> Gain >--> I |         |
+       | |     +----+  +------+  |   |         |
+       | |                       |   |         |
+       | |     +----+  +------+  |   |  +---+  |
+       \------->mute>--> Gain >--> X >-->AMP>--*
+         |     +----+  +------+  |   |  +-^-+  |
+      /--/                       |   |    |    |
+ Aux1 |        +----+  +------+  |   |  r6b1-3 |
+ -------*------>mute>--> Gain >--> E |         |
+  R   | |      +----+  +------+  |   |         |
+      | |                        |   |         |
+ Aux2 | |      +----+  +------+  |   |  /------/
+ ---------*---->mute>--> Gain >--> R |  |
+  R   | | |    +----+  +------+  |   |  |
+      | | |                      |   |  |    +--------+
+ Line | | |    +----+  +------+  |   |  |  *->0       |
+ -----------*-->mute>--> Gain >-->   |  |    |        |
+  R   | | | |  +----+  +------+  +---+  \---->1       |
+      | | | |                                |        |
+      | | | \-------------------------------->2       |  +---+
+      | | |                                  |  Mux   >-->AMP>--> ADC R
+      | | \---------------------------------->3       |  +-^-+
+      | |                                    |        |    |
+      | \------------------------------------>4       |  r7b3-0
+      |                                      |        |
+      \-----*-------------------------------->5       |
+            |                                +---^----+
+    r6b4-5  |                                    |
+      |     |                                  r8b3-5
+   +--v---+ |
+ -->PreAmp>-/
+   +------+
+ MIC R (electret mic)
diff -u --recursive --new-file v2.4.9/linux/Documentation/sysctl/vm.txt linux/Documentation/sysctl/vm.txt
--- v2.4.9/linux/Documentation/sysctl/vm.txt	Wed Mar 14 14:39:07 2001
+++ linux/Documentation/sysctl/vm.txt	Mon Sep 10 14:36:25 2001
@@ -33,32 +33,29 @@
 This file controls the operation of the bdflush kernel
 daemon. The source code to this struct can be found in
 linux/fs/buffer.c. It currently contains 9 integer values,
-of which 6 are actually used by the kernel.
+of which 4 are actually used by the kernel.
 
 From linux/fs/buffer.c:
 --------------------------------------------------------------
-union bdflush_param{
-    struct {
-        int nfract;      /* Percentage of buffer cache dirty to
-                            activate bdflush */
-        int ndirty;      /* Maximum number of dirty blocks to
-                            write out per wake-cycle */
-        int nrefill;     /* Number of clean buffers to try to
-                            obtain each time we call refill */
-        int nref_dirt;   /* Dirty buffer threshold for activating
-                            bdflush when trying to refill buffers. */
-        int dummy1;      /* unused */
-        int age_buffer;  /* Time for normal buffer to age before
-                            we flush it */
-        int age_super;   /* Time for superblock to age before we
-                            flush it */
-        int dummy2;      /* unused */
-        int dummy3;      /* unused */
-    } b_un;
-    unsigned int data[N_PARAM];
-} bdf_prm = {{40, 500, 64, 256, 15, 30*HZ, 5*HZ, 1884, 2}};
+union bdflush_param {
+	struct {
+		int nfract;	/* Percentage of buffer cache dirty to 
+				   activate bdflush */
+		int dummy1;	/* old "ndirty" */
+		int dummy2;	/* old "nrefill" */
+		int dummy3;	/* unused */
+		int interval;	/* jiffies delay between kupdate flushes */
+		int age_buffer;	/* Time for normal buffer to age */
+		int nfract_sync;/* Percentage of buffer cache dirty to 
+				   activate bdflush synchronously */
+		int dummy4;	/* unused */
+		int dummy5;	/* unused */
+	} b_un;
+	unsigned int data[N_PARAM];
+} bdf_prm = {{30, 64, 64, 256, 5*HZ, 30*HZ, 60, 0, 0}};
 --------------------------------------------------------------
 
+int nfract:
 The first parameter governs the maximum number of dirty
 buffers in the buffer cache. Dirty means that the contents
 of the buffer still have to be written to disk (as opposed
@@ -66,32 +63,31 @@
 Setting this to a high value means that Linux can delay disk
 writes for a long time, but it also means that it will have
 to do a lot of I/O at once when memory becomes short. A low
-value will spread out disk I/O more evenly.
-
-The second parameter (ndirty) gives the maximum number of
-dirty buffers that bdflush can write to the disk in one time.
-A high value will mean delayed, bursty I/O, while a small
-value can lead to memory shortage when bdflush isn't woken
-up often enough...
-
-The third parameter (nrefill) is the number of buffers that
-bdflush will add to the list of free buffers when
-refill_freelist() is called. It is necessary to allocate free
-buffers beforehand, since the buffers often are of a different
-size than memory pages and some bookkeeping needs to be done
-beforehand. The higher the number, the more memory will be
-wasted and the less often refill_freelist() will need to run.
-
-When refill_freelist() comes across more than nref_dirt dirty
-buffers, it will wake up bdflush.
-
-Finally, the age_buffer and age_super parameters govern the
-maximum time Linux waits before writing out a dirty buffer
-to disk. The value is expressed in jiffies (clockticks), the
-number of jiffies per second is 100, except on Alpha machines
-(1024). Age_buffer is the maximum age for data blocks, while
-age_super is for filesystem metadata.
-
+value will spread out disk I/O more evenly, at the cost of
+more frequent I/O operations.  The default value is 30%,
+the minimum is 0%, and the maximum is 100%.
+
+int interval:
+The fifth parameter, interval, is the minimum rate at
+which kupdate will wake and flush.  The value is expressed in
+jiffies (clockticks), the number of jiffies per second is
+normally 100 (Alpha is 1024). Thus, x*HZ is x seconds.  The
+default value is 5 seconds, the minimum is 0 seconds, and the
+maximum is 600 seconds.
+
+int age_buffer:
+The sixth parameter, age_buffer, governs the maximum time
+Linux waits before writing out a dirty buffer to disk.  The
+value is in jiffies.  The default value is 30 seconds,
+the minimum is 1 second, and the maximum 6,000 seconds.
+
+int nfract_sync:
+The seventh parameter, nfract_sync, governs the percentage
+of buffer cache that is dirty before bdflush activates
+synchronously.  This can be viewed as the hard limit before
+bdflush forces buffers to disk.  The default is 60%, the
+minimum is 0%, and the maximum is 100%.
+ 
 ==============================================================
 buffermem:
 
diff -u --recursive --new-file v2.4.9/linux/Documentation/usb/hiddev.txt linux/Documentation/usb/hiddev.txt
--- v2.4.9/linux/Documentation/usb/hiddev.txt	Wed Dec 31 16:00:00 1969
+++ linux/Documentation/usb/hiddev.txt	Wed Sep 12 15:34:06 2001
@@ -0,0 +1,162 @@
+Care and feeding of your Human Interface Devices
+
+INTRODUCTION
+
+In addition to the normal input type HID devices, USB also uses the
+human interface device protocols for things that are not really human
+interfaces, but have similar sorts of communication needs. The two big
+examples for this are power devices (especially uninterruptable power
+supplies) and monitor control on higher end monitors.
+
+To support these disparite requirements, the Linux USB system provides
+HID events to two seperate interfaces:
+* the input subsystem, which converts HID events into normal input
+device interfaces (such as keyboard, mouse and joystick) and a
+normalised event interface - see Documentation/input/input.txt
+* the hiddev interface, which provides fairly raw HID events
+
+The data flow for a HID event produced by a device is something like
+the following :
+
+ usb.c ---> hid.c  ----> input.c ----> [keyboard/mouse/joystick/event]
+                    |
+                    |
+                    --> hiddev.c ----> POWER / MONITOR CONTROL 
+
+In addition, other subsystems (apart from USB) can potentially feed
+events into the input subsystem, but these have no effect on the hid
+device interface.
+
+USING THE HID DEVICE INTERFACE
+
+The hiddev interface is a char interface using the normal USB major,
+with the minor numbers starting at 96 and finishing at 111. Therefore,
+you need the following commands:
+mknod /dev/usb/hiddev0 c 180 96
+mknod /dev/usb/hiddev1 c 180 97
+mknod /dev/usb/hiddev2 c 180 98
+mknod /dev/usb/hiddev3 c 180 99
+mknod /dev/usb/hiddev4 c 180 100
+mknod /dev/usb/hiddev5 c 180 101
+mknod /dev/usb/hiddev6 c 180 102
+mknod /dev/usb/hiddev7 c 180 103
+mknod /dev/usb/hiddev8 c 180 104
+mknod /dev/usb/hiddev9 c 180 105
+mknod /dev/usb/hiddev10 c 180 106
+mknod /dev/usb/hiddev11 c 180 107
+mknod /dev/usb/hiddev12 c 180 108
+mknod /dev/usb/hiddev13 c 180 109
+mknod /dev/usb/hiddev14 c 180 110
+mknod /dev/usb/hiddev15 c 180 111
+
+So you point your hiddev compliant user-space program at the correct
+interface for your device, and it all just works.
+
+Assuming that you have a hiddev compliant user-space program, of
+course. If you need to write one, read on.
+
+
+THE HIDDEV API
+This description should be read in conjunction with the HID
+specification, freely available from http://www.usb.org, and
+conveniently linked of http://www.linux-usb.org.
+
+The hiddev API uses a read() interface, and a set of ioctl() calls.
+
+
+read():
+This is the event interface. When the HID device performs an
+interrupt transfer, indicating a change of state, data will be made
+available at the associated hiddev device with the content of a struct
+hiddev_event: 
+
+       struct hiddev_event {
+           unsigned hid;
+           signed int value;
+       };
+
+containing the HID usage identifier for the status that changed, and
+the value that it was changed to. Note that the structure is defined
+within <linux/hiddev.h>, along with some other useful #defines and
+structures. 
+
+
+ioctl(): 
+This is the control interface. There are a number of controls: 
+
+HIDIOCGVERSION - int (read)
+Gets the version code out of the hiddev driver.
+
+HIDIOCAPPLICATION - (none)
+This ioctl call returns the HID application usage associated with the
+hid device. The third argument to ioctl() specifies which application
+index to get. This is useful when the device has more than one
+application collection. If the index is invalid (greater or equal to
+the number of application collections this device has) the ioctl
+returns -1. You can find out beforehand how many application
+collections the device has from the num_applications field from the
+hiddev_devinfo structure. 
+
+HIDIOCGDEVINFO - struct hiddev_devinfo (read)
+Gets a hiddev_devinfo structure which describes the device.
+
+HIDIOCGSTRING - struct struct hiddev_string_descriptor (read/write)
+Gets a string descriptor from the device. The caller must fill in the
+"index" field to indicate which descriptor should be returned.
+
+HIDIOCINITREPORT - (none)
+Instructs the kernel to retrieve all input and feature report values
+from the device. At this point, all the usage structures will contain
+current values for the device, and will maintain it as the device
+changes.
+
+HIDIOCGNAME - string (variable length)
+Gets the device name
+
+HIDIOCGREPORT - struct hiddev_report_info (write)
+Instructs the kernel to get a feature or input report from the device,
+in order to selectively update the usage structures (in contrast to
+INITREPORT). 
+
+HIDIOCSREPORT - struct hiddev_report_info (write)
+Instructs the kernel to send a report to the device. This report can
+be filled in by the user through HIDIOCSUSAGE calls (below) to fill in
+individual usage values in the report beforesending the report in full
+to the device. 
+
+HIDIOCGREPORTINFO - struct hiddev_report_info (read/write)
+Fills in a hiddev_report_info structure for the user. The report is
+looked up by type (input, output or feature) and id, so these fields
+must be filled in by the user. The ID can be absolute -- the actual
+report id as reported by the device -- or relative --
+HID_REPORT_ID_FIRST for the first report, and (HID_REPORT_ID_NEXT |
+report_id) for the next report after report_id. Without a-priori
+information about report ids, the right way to use this ioctl is to
+use the relative IDs above to enumerate the valid IDs. The ioctl
+returns non-zero when there is no more next ID. The real report ID is
+filled into the returned hiddev_report_info structure. 
+
+HIDIOCGFIELDINFO - struct hiddev_field_info (read/write)
+Returns the field information associated with a report in a
+hiddev_field_info structure. The user must fill in report_id and
+report_type in this structure, as above. The field_index should also
+be filled in, which should be a number from 0 and maxfield-1, as
+returned from a previous HIDIOCGREPORTINFO call. 
+
+HIDIOCGUCODE - struct hiddev_usage_ref (read/write)
+Returns the usage_code in a hiddev_usage_ref structure, given that
+given its report type, report id, field index, and index within the
+field have already been filled into the structure.
+
+HIDIOCGUSAGE - struct hiddev_usage_ref (read/write)
+Returns the value of a usage in a hiddev_usage_ref structure. The
+usage to be retrieved can be specified as above, or the user can
+choose to fill in the report_type field and specify the report_id as
+HID_REPORT_ID_UNKNOWN. In this case, the hiddev_usage_ref will be
+filled in with the report and field infomation associated with this
+usage if it is found. 
+
+HIDIOCSUSAGE - struct hiddev_usage_ref (write)
+Sets the value of a usage in an output report.
+
+
diff -u --recursive --new-file v2.4.9/linux/Documentation/usb/input.txt linux/Documentation/usb/input.txt
--- v2.4.9/linux/Documentation/usb/input.txt	Fri Jul 28 12:50:52 2000
+++ linux/Documentation/usb/input.txt	Wed Dec 31 16:00:00 1969
@@ -1,306 +0,0 @@
-			  Linux Input drivers v1.0
-	       (c) 1999-2000 Vojtech Pavlik <vojtech@suse.cz>
-			     Sponsored by SuSE
-	    $Id: input.txt,v 1.4 2000/05/28 17:57:22 vojtech Exp $
-----------------------------------------------------------------------------
-
-0. Disclaimer
-~~~~~~~~~~~~~
-  This program is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your option)
-any later version.
-
-  This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-more details.
-
-  You should have received a copy of the GNU General Public License along
-with this program; if not, write to the Free Software Foundation, Inc., 59
-Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-  Should you need to contact me, the author, you can do so either by e-mail
-- mail your message to <vojtech@suse.cz>, or by paper mail: Vojtech Pavlik,
-Ucitelska 1576, Prague 8, 182 00 Czech Republic
-
-  For your convenience, the GNU General Public License version 2 is included
-in the package: See the file COPYING.
-
-1. Introduction
-~~~~~~~~~~~~~~~
-  This is a collection of drivers that is designed to support all input
-devices under Linux. However, in the current kernels, although it's
-possibilities are much bigger, it's limited to USB devices only. This is
-also why it resides in the drivers/usb subdirectory.
-
-  The center of the input drivers is the input.o module, which must be
-loaded before any other of the input modules - it serves as a way of
-communication between two groups of modules:
-
-1.1 Device drivers
-~~~~~~~~~~~~~~~~~~
-  These modules talk to the hardware (for example via USB), and provide
-events (keystrokes, mouse movements) to the input.o module.
-
-1.2 Event handlers
-~~~~~~~~~~~~~~~~~~
-  These modules get events from input.o and pass them where needed via
-various interfaces - keystrokes to the kernel, mouse movements via a
-simulated PS/2 interface to GPM and X and so on.
-
-2. Simple Usage
-~~~~~~~~~~~~~~~
-  For the most usual configuration, with one USB mouse and one USB keyboard,
-you'll have to load the following modules (or have them built in to the
-kernel):
-
-	input.o
-	mousedev.o
-	keybdev.o
-	usbcore.o
-	usb-[uo]hci.o
-	hid.o
-
-  After this, the USB keyboard will work straight away, and the USB mouse
-will be available as a character device on major 13, minor 63:
-
-	crw-r--r--   1 root     root      13,  63 Mar 28 22:45 mice
-
-  This device, has to be created, unless you use devfs, in which case it's
-created automatically. The commands to do that are:
-
-	cd /dev
-	mkdir input
-	mknod input/mice c 13 63
-
-  After that you have to point GPM (the textmode mouse cut&paste tool) and
-XFree to this device to use it - GPM should be called like:
-
-	gpm -t ps2 -m /dev/input/mice
-
-  And in X:
-
-	Section "Pointer"
-	    Protocol    "ImPS/2"
-	    Device      "/dev/input/mice"
-	    ZAxisMapping 4 5
-	EndSection
-
-  When you do all of the above, you can use your USB mouse and keyboard.
-
-3. Detailed Description
-~~~~~~~~~~~~~~~~~~~~~~~
-3.1 Device drivers
-~~~~~~~~~~~~~~~~~~
-  Device drivers are the modules that generate events. The events are
-however not useful without being handled, so you also will need to use some
-of the modules from section 3.2.
-
-3.1.1 hid.c
-~~~~~~~~~~~
-  Hid.c is the largest and most complex driver of the whole suite. It
-handles all HID devices, and because there is a very wide variety of them,
-and because the USB HID specification isn't simple, it needs to be this big.
-
-  Currently, it handles USB mice, joysticks, gamepads, steering wheels
-keyboards, trackballs and digitizers.
-
- However, USB uses HID also for monitor controls, speaker controls, UPSs,
-LCDs and many other purposes.
-
- The monitor and speaker controls should be easy to add to the hid/input
-interface, but for the UPSs and LCDs it doesn't make much sense. The driver
-doesn't support these yet, and a new, non-event interface should be designed
-for them. If you have any of these devices (I don't), feel free to design
-something and if it's good, it'll get into the driver.
-
-  The usage of the hid.o module is very simple, it takes no parameters,
-detects everything automatically and when a HID device is inserted, it
-detects it appropriately.
-
-  However, because the devices vary wildly, you might happen to have a
-device that doesn't work well. In that case #define DEBUG at the beginning
-of hid.c and send me the syslog traces.
-
-3.1.2 usbmouse.c
-~~~~~~~~~~~~~~~~
-  For embedded systems, for mice with broken HID descriptors and just any
-other use when the big hid.c wouldn't be a good choice, there is the
-usbmouse.c driver. It handles USB mice only. It uses a simpler HIDBP
-protocol. This also means the mice must support this simpler protocol. Not
-all do. If you don't have any strong reason to use this module, use hid.c
-instead.
-
-3.1.3 usbkbd.c
-~~~~~~~~~~~~~~
-  Much like usbmouse.c, this module talks to keyboards with a simplified
-HIDBP protocol. It's smaller, but doesn't support any extra special keys.
-Use hid.c instead if there isn't any special reason to use this.
-
-3.1.4 wacom.c
-~~~~~~~~~~~~~
-  This is a driver for Wacom Graphire and Intuos tablets. Not for Wacom
-PenPartner, that one is handled by the HID driver. Although the Intuos and
-Graphire tablets claim that they are HID tablets as well, they are not and
-thus need this specific driver.
-
-3.1.5 wmforce.c
-~~~~~~~~~~~~~~~
-  A driver for the Logitech WingMan Force joysticks, when connected via the
-USB port. It works quite well, but there is no force feedback support yet,
-because the interface to do that is a trade secret of Immersion Corp, and
-even Logitech can't disclose it.
-
-  Support for Logitech WingMan Force Wheel isn't present in this driver, but
-if someone has the device, and is willing to cooperate, it should be a
-matter of a couple days to add it.
-
-3.2 Event handlers
-~~~~~~~~~~~~~~~~~~
-  Event handlers distribute the events from the devices to userland and
-kernel, as needed.
-
-3.2.1 keybdev.c
-~~~~~~~~~~~~~~~
-  Keybdev is currently a rather ugly hack that translates the input events
-into architecture-specific keyboard raw mode (Xlated AT Set2 on x86), and
-passes them into the handle_scancode function of the keyboard.c module. This
-works well enough on all architectures that keybdev can generate rawmode on,
-other architectures can be added to it.
-
-  The right way would be to pass the events to keyboard.c directly, best if
-keyboard.c would itself be an event handler. This is done in the input
-patch, available on the webpage mentioned below.
-
-3.2.2 mousedev.c
-~~~~~~~~~~~~~~~~
-  Mousedev is also a hack to make programs that use mouse input work. It
-takes events from either mice or digitizers/tablets and makes a PS/2-style
-(a la /dev/psaux) mouse device available to the userland. Ideally, the
-programs could use a more reasonable interface, for example evdev.c
-
-  Mousedev devices in /dev/input (as shown above) are:
-
-	crw-r--r--   1 root     root      13,  32 Mar 28 22:45 mouse0
-	crw-r--r--   1 root     root      13,  33 Mar 29 00:41 mouse1
-	crw-r--r--   1 root     root      13,  34 Mar 29 00:41 mouse2
-	crw-r--r--   1 root     root      13,  35 Apr  1 10:50 mouse3
-	...
-	...
-	crw-r--r--   1 root     root      13,  62 Apr  1 10:50 mouse30
-	crw-r--r--   1 root     root      13,  63 Apr  1 10:50 mice
-
-Each 'mouse' device is assigned to a single mouse or digitizer, except the last
-one - 'mice'. This single character device is shared by all mice and
-digitizers, and even if none are connected, the device is present.  This is
-useful for hotplugging USB mice, so that programs can open the device even when
-no mice are present.
-
-  CONFIG_INPUT_MOUSEDEV_SCREEN_[XY] in the kernel configuration are the size
-of your screen (in pixels) in XFree86. This is needed if you want to use
-your digitizer in X, because it's movement is sent to X via a virtual PS/2
-mouse and thus needs to be scaled accordingly. These values won't be used if
-you use a mouse only.
-
-  Mousedev will generate either PS/2, ImPS/2 (Microsoft IntelliMouse) or
-GenPS/2 (Genius NetMouse/NetScroll) protocols, depending on what the program
-reading the data wishes. You can set GPM and X to any of these. You'll need
-ImPS/2 if you want to make use of a wheel on a USB mouse and GenPS/2 if you
-want to use extra (up to 5) buttons. I'm not sure how much is GenPS/2 supported
-in X, though.
-
-3.2.3 joydev.c
-~~~~~~~~~~~~~~
-  Joydev implements v0.x and v1.x Linux joystick api, much like
-drivers/char/joystick/joystick.c. See joystick-api.txt in the Documentation
-subdirectory for details. Joydev does it on top of the input subsystem,
-though. As soon as any USB joystick is connected, it can be accessed in
-/dev/input on:
-
-	crw-r--r--   1 root     root      13,   0 Apr  1 10:50 js0
-	crw-r--r--   1 root     root      13,   1 Apr  1 10:50 js1
-	crw-r--r--   1 root     root      13,   2 Apr  1 10:50 js2
-	crw-r--r--   1 root     root      13,   3 Apr  1 10:50 js3
-	...
-
-And so on up to js31.
-
-3.2.4 evdev.c
-~~~~~~~~~~~~~
-  Evdev is the generic input event interface. It passes the events generated
-in the kernel straight to the program, with timestamps. The API is still
-evolving, but should be usable now. It's described in section 5.
-
-  This should be the way for GPM and X to get keyboard and mouse mouse
-events. It allows for multihead in X without any specific multihead kernel
-support. The event codes are the same on all architectures and are hardware
-independent.
-
-  The devices are in /dev/input:
-
-	crw-r--r--   1 root     root      13,  64 Apr  1 10:49 event0
-	crw-r--r--   1 root     root      13,  65 Apr  1 10:50 event1
-	crw-r--r--   1 root     root      13,  66 Apr  1 10:50 event2
-	crw-r--r--   1 root     root      13,  67 Apr  1 10:50 event3
-	...
-
-3. Contacts
-~~~~~~~~~~~
-  This effort has it's home page at:
-
-	http://www.suse.cz/development/input/
-
-You'll find both the latest HID driver and the complete Input driver there
-as well as information how to access the CVS repository for latest revisions
-of the drivers.
-
-
-  There is also a mailing list for this:
-
-	majordomo@atrey.karlin.mff.cuni.cz
-
-Send "subscribe linux-input" to subscribe to it.
-
-4. Verifying if it works
-~~~~~~~~~~~~~~~~~~~~~~~~
-  Typing a couple keys on the keyboard should be enough to check that a USB
-keyboard works and is correctly connected to the kernel keyboard driver.
-
-  Doing a cat /dev/input/mouse0 (c, 13, 32) will verify that a mouse is also
-emulated, characters should appear if you move it.
-
-  You can test the joystick emulation with the 'jstest' utility, available
-in the joystick package (see Documentation/joystick.txt).
-
-  You can test the event devics with the 'evtest' utility available on the
-input driver homepage (see the URL above).
-
-5. Event interface
-~~~~~~~~~~~~~~~~~~
-  Should you want to add event device support into any application (X, gpm,
-svgalib ...) I <vojtech@suse.cz> will be happy to provide you any help I
-can. Here goes a description of the current state of things, which is going
-to be extended, but not changed incompatibly as time goes:
-
-  You can use blocking and nonblocking reads, also select() on the
-/dev/input/eventX devices, and you'll always get a whole number of input
-events on a read. Their layout is:
-
-struct input_event {
-	struct timeval time;
-	unsigned short type;
-	unsigned short code;
-	unsigned int value;
-};
-
-  'time' is the timestamp, it returns the time at which the event happened.
-Type is for example EV_REL for relative movement, REL_KEY for a keypress or
-release. More types are defined in include/linux/input.h.
-
-  'code' is event code, for example REL_X or KEY_BACKSPACE, again a complete
-list is in include/linux/input.h.
-
-  'value' is the value the event carries. Either a relative change for
-EV_REL, absolute new value for EV_ABS (joysticks ...), or 0 for EV_KEY for
-release, 1 for keypress and 2 for autorepeat.
diff -u --recursive --new-file v2.4.9/linux/Documentation/watchdog.txt linux/Documentation/watchdog.txt
--- v2.4.9/linux/Documentation/watchdog.txt	Fri Aug 11 15:57:57 2000
+++ linux/Documentation/watchdog.txt	Fri Sep  7 09:28:38 2001
@@ -11,6 +11,7 @@
 	ICS	WDT501-P (no fan tachometer)
 	ICS	WDT500-P
 	Software Only
+	SA1100 Internal Watchdog
 	Berkshire Products PC Watchdog Revision A & C (by Ken Hollis)
 
 
@@ -35,6 +36,9 @@
 The wdt card cannot be safely probed for. Instead you need to pass
 wdt=ioaddr,irq as a boot parameter - eg "wdt=0x240,11".
 
+The SA1100 watchdog module can be configured with the "sa1100_margin"
+commandline argument which specifies timeout value in seconds.
+
 The i810 TCO watchdog modules can be configured with the "i810_margin"
 commandline argument which specifies the counter initial value. The counter
 is decremented every 0.6 seconds and default to 50 (30 seconds). Values can
@@ -47,15 +51,15 @@
 
 Features
 --------
-		WDT501P		WDT500P		Software	Berkshire	i810 TCO
-Reboot Timer	   X               X                X		    X               X
-External Reboot	   X	           X                o		    o               o
-I/O Port Monitor   o		   o		    o		    X               o
-Temperature	   X		   o		    o               X               o
-Fan Speed          X		   o		    o               o               o
-Power Under	   X               o                o               o               o
-Power Over         X               o                o               o               o
-Overheat           X               o                o               o               o
+		WDT501P		WDT500P		Software	Berkshire	i810 TCO	SA1100WD
+Reboot Timer	   X               X                X		    X               X               X
+External Reboot	   X	           X                o		    o               o               X
+I/O Port Monitor   o		   o		    o		    X               o               o
+Temperature	   X		   o		    o               X               o               o
+Fan Speed          X		   o		    o               o               o               o
+Power Under	   X               o                o               o               o               o
+Power Over         X               o                o               o               o               o
+Overheat           X               o                o               o               o               o
 
 The external event interfaces on the WDT boards are not currently supported.
 Minor numbers are however allocated for it.
diff -u --recursive --new-file v2.4.9/linux/MAINTAINERS linux/MAINTAINERS
--- v2.4.9/linux/MAINTAINERS	Mon Aug 27 12:41:37 2001
+++ linux/MAINTAINERS	Sun Sep  9 10:52:35 2001
@@ -81,6 +81,12 @@
 L:	linux-net@vger.kernel.org
 S:	Maintained
 
+53C700 AND 53C700-66 SCSI DRIVER
+P:	James E.J. Bottomley
+M:	James.Bottomley@HansenPartnership.com
+L:	linux-scsi@vger.kernel.org
+S:	Maintained
+
 6PACK NETWORK DRIVER FOR AX.25
 P:	Andreas Koensgen
 M:	ajk@iehk.rwth-aachen.de
@@ -182,9 +188,9 @@
 M:	linux@treblig.org
 S:	Maintained
 
-ARM PORT
+ARM/STRONGARM110 PORT
 P:	Russell King
-M:	linux@arm.linux.org.uk
+M:	rmk@arm.linux.org.uk
 L:	linux-arm-kernel@lists.arm.linux.org.uk
 W:	http://www.arm.linux.org.uk/
 S:	Maintained
@@ -337,7 +343,7 @@
 
 CYBERPRO FB DRIVER
 P:	Russell King
-M:	linux@arm.linux.org.uk
+M:	rmk@arm.linux.org.uk
 W:	http://www.arm.linux.org.uk/
 S:	Maintained
 
@@ -689,8 +695,8 @@
 S:	Orphan
 
 IEEE 1394 OHCI DRIVER
-P:	Sebastien Rougeaux
-M:	sebastien.rougeaux@anu.edu.au
+P:	Ben Collins
+M:	bcollins@debian.org
 L:	linux1394-devel@lists.sourceforge.net
 S:	Maintained
 
@@ -823,6 +829,12 @@
 L:	linux-x25@vger.kernel.org
 S:	Maintained
 
+LASI 53c700 driver for PARISC
+P:	James E.J. Bottomley
+M:	James.Bottomley@HansenPartnership.com
+L:	linux-scsi@vger.kernel.org
+S:	Maintained
+
 LINUX FOR IBM pSERIES (RS/6000)
 P:	Paul Mackerras
 M:	paulus@au.ibm.com
@@ -902,9 +914,9 @@
 
 MIPS
 P:	Ralf Baechle
-M:	ralf@gnu.ai.mit.edu
-W:	http://lena.fnet.fr/
-L:	linux-mips@fnet.fr
+M:	ralf@gnu.org
+W:	http://oss.sgi.com/mips/mips-howto.html
+L:	linux-mips@oss.sgi.com
 S:	Maintained
 
 MISCELLANEOUS MCA-SUPPORT
@@ -948,6 +960,12 @@
 L:	linware@sh.cvut.cz
 S:	Maintained
 
+NCR DUAL 700 SCSI DRIVER (MICROCHANNEL)
+P:	James E.J. Bottomley
+M:	James.Bottomley@HansenPartnership.com
+L:	linux-scsi@vger.kernel.org
+S:	Maintained
+
 NETFILTER
 P:	Rusty Russell
 M:	rusty@rustcorp.com.au
@@ -1413,15 +1431,6 @@
 W:	http://www.kernel.dk
 S:	Maintained
 
-USB SUBSYSTEM
-P:	Johannes Erdfelt
-M:	jerdfelt@valinux.com
-M:	johannes@erdfelt.com
-L:	linux-usb-users@lists.sourceforge.net
-L:	linux-usb-devel@lists.sourceforge.net
-W:	http://www.linux-usb.org
-S:	Supported
-
 USB ACM DRIVER
 P:	Vojtech Pavlik
 M:	vojtech@suse.cz
@@ -1437,6 +1446,13 @@
 S:	Maintained
 W:	http://www.kroah.com/linux-usb/
 
+USB CDC ETHERNET DRIVER
+P:	Brad Hards
+M:	bhards@bigpond.net.au
+L:	linux-usb-users@lists.sourceforge.net
+L:	linux-usb-devel@lists.sourceforge.net
+S:	Maintained
+
 USB HID/HIDBP/INPUT DRIVERS
 P:	Vojtech Pavlik
 M:	vojtech@suse.cz
@@ -1453,6 +1469,21 @@
 L:	linux-usb-devel@lists.sourceforge.net
 S:	Maintained
 
+USB KAWASAKI LSI DRIVER
+P:	Brad Hards
+M:	bhards@bigpond.net.au
+L:	linux-usb-users@lists.sourceforge.net
+L:	linux-usb-devel@lists.sourceforge.net
+S:	Maintained
+
+USB MASS STORAGE DRIVER
+P:	Matthew Dharm
+M:	mdharm-usb@one-eyed-alien.net
+L:	linux-usb-users@lists.sourceforge.net
+L:	linux-usb-devel@lists.sourceforge.net
+S:	Maintained
+W:	http://www.one-eyed-alien.net/~mdharm/linux-usb/
+
 USB OHCI DRIVER
 P:	Roman Weissgaerber
 M:	weissg@vienna.at
@@ -1482,21 +1513,21 @@
 L:	linux-usb-devel@lists.sourceforge.net
 S:	Supported
 
-USB SERIAL DIGI ACCELEPORT DRIVER
-P:	Peter Berger and Al Borchers
-M:	pberger@brimson.com
-M:	alborchers@steinerpoint.com
+USB SE401 DRIVER
+P:	Jeroen Vreeken
+M:	pe1rxq@amsat.org
 L:	linux-usb-users@lists.sourceforge.net
 L:	linux-usb-devel@lists.sourceforge.net
+W:	http://www.chello.nl/~j.vreeken/se401/
 S:	Maintained
 
-USB SERIAL KEYSPAN DRIVER
-P:	Hugh Blemings
-M:	hugh@misc.nu
+USB SERIAL DIGI ACCELEPORT DRIVER
+P:	Peter Berger and Al Borchers
+M:	pberger@brimson.com
+M:	alborchers@steinerpoint.com
 L:	linux-usb-users@lists.sourceforge.net
 L:	linux-usb-devel@lists.sourceforge.net
 S:	Maintained
-W:	http://misc.nu/hugh/keyspan/
 
 USB SERIAL DRIVER
 P:	Greg Kroah-Hartman
@@ -1514,6 +1545,12 @@
 L:	linux-usb-devel@lists.sourceforge.net
 S:	Maintained
 
+USB SERIAL CYBERJACK PINPAD/E-COM DRIVER
+M:	linux-usb@sii.li
+L:	linux-usb-users@lists.sourceforge.net
+L:	linux-usb-devel@lists.sourceforge.net
+S:	Supported
+
 USB SERIAL EMPEG EMPEG-CAR MARK I/II DRIVER
 P:	Gary Brubaker
 M:	xavyer@ix.netcom.com
@@ -1521,19 +1558,22 @@
 L:	linux-usb-devel@lists.sourceforge.net
 S:	Maintained
 
-USB SERIAL CYBERJACK PINPAD/E-COM DRIVER
-M:  linux-usb@sii.li
-L:  linux-usb-users@lists.sourceforge.net
-L:  linux-usb-devel@lists.sourceforge.net
-S:  Supported
-
-USB MASS STORAGE DRIVER
-P:	Matthew Dharm
-M:	mdharm-usb@one-eyed-alien.net
+USB SERIAL KEYSPAN DRIVER
+P:	Hugh Blemings
+M:	hugh@misc.nu
 L:	linux-usb-users@lists.sourceforge.net
 L:	linux-usb-devel@lists.sourceforge.net
 S:	Maintained
-W:	http://www.one-eyed-alien.net/~mdharm/linux-usb/
+W:	http://misc.nu/hugh/keyspan/
+
+USB SUBSYSTEM
+P:	Johannes Erdfelt
+M:	jerdfelt@valinux.com
+M:	johannes@erdfelt.com
+L:	linux-usb-users@lists.sourceforge.net
+L:	linux-usb-devel@lists.sourceforge.net
+W:	http://www.linux-usb.org
+S:	Supported
 
 USB UHCI DRIVER
 P:	Georg Acher
diff -u --recursive --new-file v2.4.9/linux/Makefile linux/Makefile
--- v2.4.9/linux/Makefile	Mon Aug 27 12:41:37 2001
+++ linux/Makefile	Mon Sep 10 17:45:38 2001
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 4
-SUBLEVEL = 9
-EXTRAVERSION =
+SUBLEVEL = 10
+EXTRAVERSION =-pre9
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
@@ -197,6 +197,10 @@
 	drivers/zorro/devlist.h drivers/zorro/gen-devlist \
 	drivers/sound/bin2hex drivers/sound/hex2hex \
 	drivers/atm/fore200e_mkfirm drivers/atm/{pca,sba}*{.bin,.bin1,.bin2} \
+	drivers/scsi/aic7xxx/aicasm/aicasm_gram.c \
+	drivers/scsi/aic7xxx/aicasm/aicasm_scan.c \
+	drivers/scsi/aic7xxx/aicasm/y.tab.h \
+	drivers/scsi/aic7xxx/aicasm/aicasm \
 	net/khttpd/make_times_h \
 	net/khttpd/times.h \
 	submenu*
diff -u --recursive --new-file v2.4.9/linux/arch/alpha/kernel/alpha_ksyms.c linux/arch/alpha/kernel/alpha_ksyms.c
--- v2.4.9/linux/arch/alpha/kernel/alpha_ksyms.c	Mon Aug 27 12:41:37 2001
+++ linux/arch/alpha/kernel/alpha_ksyms.c	Thu Sep 13 15:21:32 2001
@@ -77,6 +77,14 @@
 EXPORT_SYMBOL(_writeb);
 EXPORT_SYMBOL(_writew);
 EXPORT_SYMBOL(_writel);
+EXPORT_SYMBOL(___raw_readb); 
+EXPORT_SYMBOL(___raw_readw); 
+EXPORT_SYMBOL(___raw_readl); 
+EXPORT_SYMBOL(___raw_readq); 
+EXPORT_SYMBOL(___raw_writeb); 
+EXPORT_SYMBOL(___raw_writew); 
+EXPORT_SYMBOL(___raw_writel); 
+EXPORT_SYMBOL(___raw_writeq); 
 EXPORT_SYMBOL(_memcpy_fromio);
 EXPORT_SYMBOL(_memcpy_toio);
 EXPORT_SYMBOL(_memset_c_io);
@@ -200,6 +208,8 @@
 EXPORT_SYMBOL(cpu_data);
 EXPORT_SYMBOL(__cpu_number_map);
 EXPORT_SYMBOL(smp_num_cpus);
+EXPORT_SYMBOL(smp_call_function);
+EXPORT_SYMBOL(smp_call_function_on_cpu);
 EXPORT_SYMBOL(global_irq_holder);
 EXPORT_SYMBOL(__global_cli);
 EXPORT_SYMBOL(__global_sti);
diff -u --recursive --new-file v2.4.9/linux/arch/alpha/kernel/core_cia.c linux/arch/alpha/kernel/core_cia.c
--- v2.4.9/linux/arch/alpha/kernel/core_cia.c	Tue May 22 16:29:57 2001
+++ linux/arch/alpha/kernel/core_cia.c	Thu Sep 13 15:21:32 2001
@@ -352,13 +352,15 @@
 	   so use them and read at window 3 base exactly 4 times. Reading
 	   more sometimes makes the chip crazy.  -ink */
 
-	bus_addr = cia_ioremap(CIA_BROKEN_TBIA_BASE);
+	bus_addr = cia_ioremap(CIA_BROKEN_TBIA_BASE, 32768 * 4);
 
 	cia_readl(bus_addr + 0x00000);
 	cia_readl(bus_addr + 0x08000);
 	cia_readl(bus_addr + 0x10000);
 	cia_readl(bus_addr + 0x18000);
 
+	cia_iounmap(bus_addr);
+
 	/* Restore normal PCI operation.  */
 	mb();
 	*(vip)CIA_IOC_CIA_CTRL = ctrl;
@@ -396,6 +398,7 @@
 	struct pci_iommu_arena *arena = pci_isa_hose->sg_isa;
 	int ctrl, addr0, tag0, pte0, data0;
 	int temp, use_tbia_try2 = 0;
+	unsigned long bus_addr;
 
 	/* pyxis -- tbia is broken */
 	if (pci_isa_hose->dense_io_base)
@@ -429,6 +432,9 @@
 	*(vip)CIA_IOC_TBn_PAGEm(0,3) = 0;
 	mb();
 
+	/* Get a usable bus address */
+	bus_addr = cia_ioremap(addr0, 8*PAGE_SIZE);
+
 	/* First, verify we can read back what we've written.  If
 	   this fails, we can't be sure of any of the other testing
 	   we're going to do, so bail.  */
@@ -464,7 +470,7 @@
 	mcheck_expected(0) = 1;
 	mcheck_taken(0) = 0;
 	mb();
-	temp = cia_readl(cia_ioremap(addr0));
+	temp = cia_readl(bus_addr);
 	mb();
 	mcheck_expected(0) = 0;
 	mb();
@@ -501,7 +507,7 @@
 	mcheck_expected(0) = 1;
 	mcheck_taken(0) = 0;
 	mb();
-	temp = cia_readl(cia_ioremap(addr0 + 4*PAGE_SIZE));
+	temp = cia_readl(bus_addr + 4*PAGE_SIZE);
 	mb();
 	mcheck_expected(0) = 0;
 	mb();
@@ -525,7 +531,7 @@
 	mcheck_expected(0) = 1;
 	mcheck_taken(0) = 0;
 	mb();
-	temp = cia_readl(cia_ioremap(addr0 + 5*PAGE_SIZE));
+	temp = cia_readl(bus_addr + 5*PAGE_SIZE);
 	mb();
 	mcheck_expected(0) = 0;
 	mb();
@@ -549,7 +555,7 @@
 	mcheck_expected(0) = 1;
 	mcheck_taken(0) = 0;
 	mb();
-	temp = cia_readl(cia_ioremap(addr0 + 6*PAGE_SIZE));
+	temp = cia_readl(bus_addr + 6*PAGE_SIZE);
 	mb();
 	mcheck_expected(0) = 0;
 	mb();
@@ -575,6 +581,9 @@
 	alpha_mv.mv_pci_tbi(arena->hose, 0, -1);
 
 exit:
+	/* unmap the bus addr */
+	cia_iounmap(bus_addr);
+
 	/* Restore normal PCI operation.  */
 	mb();
 	*(vip)CIA_IOC_CIA_CTRL = ctrl;
diff -u --recursive --new-file v2.4.9/linux/arch/alpha/kernel/core_irongate.c linux/arch/alpha/kernel/core_irongate.c
--- v2.4.9/linux/arch/alpha/kernel/core_irongate.c	Fri Mar  2 11:12:07 2001
+++ linux/arch/alpha/kernel/core_irongate.c	Thu Sep 13 15:21:32 2001
@@ -30,6 +30,8 @@
 
 #undef DEBUG_IRONGATE 		/* define to enable verbose Irongate debug */
 
+#define IRONGATE_DEFAULT_AGP_APER_SIZE	(256*1024*1024) /* 256MB */
+
 /*
  * BIOS32-style PCI interface:
  */
@@ -374,6 +376,14 @@
 	irongate_register_dump(__FUNCTION__);
 
 	/*
+	 * HACK: set AGP aperture size to 256MB.
+	 * This should really be changed during PCI probe, when the
+	 * size of the aperture the AGP card wants is known.
+	 */
+	printk("irongate_init_arch: AGPVA was 0x%x\n", IRONGATE0->agpva);
+	IRONGATE0->agpva = (IRONGATE0->agpva & ~0x0000000f) | 0x00000007;
+
+	/*
 	 * Create our single hose.
 	 */
 
@@ -396,4 +406,202 @@
 	hose->sg_isa = hose->sg_pci = NULL;
 	__direct_map_base = 0;
 	__direct_map_size = 0xffffffff;
+}
+
+/*
+ * IO map and AGP support
+ */
+#include <linux/vmalloc.h>
+#include <asm/pgalloc.h>
+
+static inline void 
+irongate_remap_area_pte(pte_t * pte, unsigned long address, unsigned long size, 
+		     unsigned long phys_addr, unsigned long flags)
+{
+	unsigned long end;
+
+	address &= ~PMD_MASK;
+	end = address + size;
+	if (end > PMD_SIZE)
+		end = PMD_SIZE;
+	if (address >= end)
+		BUG();
+	do {
+		if (!pte_none(*pte)) {
+			printk("irongate_remap_area_pte: page already exists\n");
+			BUG();
+		}
+		set_pte(pte, 
+			mk_pte_phys(phys_addr, 
+				    __pgprot(_PAGE_VALID | _PAGE_ASM | 
+					     _PAGE_KRE | _PAGE_KWE | flags)));
+		address += PAGE_SIZE;
+		phys_addr += PAGE_SIZE;
+		pte++;
+	} while (address && (address < end));
+}
+
+static inline int 
+irongate_remap_area_pmd(pmd_t * pmd, unsigned long address, unsigned long size, 
+		     unsigned long phys_addr, unsigned long flags)
+{
+	unsigned long end;
+
+	address &= ~PGDIR_MASK;
+	end = address + size;
+	if (end > PGDIR_SIZE)
+		end = PGDIR_SIZE;
+	phys_addr -= address;
+	if (address >= end)
+		BUG();
+	do {
+		pte_t * pte = pte_alloc(&init_mm, pmd, address);
+		if (!pte)
+			return -ENOMEM;
+		irongate_remap_area_pte(pte, address, end - address, 
+				     address + phys_addr, flags);
+		address = (address + PMD_SIZE) & PMD_MASK;
+		pmd++;
+	} while (address && (address < end));
+	return 0;
+}
+
+static int
+irongate_remap_area_pages(unsigned long address, unsigned long phys_addr,
+		       unsigned long size, unsigned long flags)
+{
+	pgd_t * dir;
+	unsigned long end = address + size;
+
+	phys_addr -= address;
+	dir = pgd_offset(&init_mm, address);
+	flush_cache_all();
+	if (address >= end)
+		BUG();
+	do {
+		pmd_t *pmd;
+		pmd = pmd_alloc(&init_mm, dir, address);
+		if (!pmd)
+			return -ENOMEM;
+		if (irongate_remap_area_pmd(pmd, address, end - address,
+					 phys_addr + address, flags))
+			return -ENOMEM;
+		address = (address + PGDIR_SIZE) & PGDIR_MASK;
+		dir++;
+	} while (address && (address < end));
+	return 0;
+}
+
+#include <linux/agp_backend.h>
+#include <linux/agpgart.h>
+
+#define GET_PAGE_DIR_OFF(addr) (addr >> 22)
+#define GET_PAGE_DIR_IDX(addr) (GET_PAGE_DIR_OFF(addr))
+
+#define GET_GATT_OFF(addr) ((addr & 0x003ff000) >> 12) 
+#define GET_GATT(addr) (gatt_pages[GET_PAGE_DIR_IDX(addr)])
+
+unsigned long
+irongate_ioremap(unsigned long addr, unsigned long size)
+{
+	struct vm_struct *area;
+	unsigned long vaddr;
+	unsigned long baddr, last;
+	u32 *mmio_regs, *gatt_pages, *cur_gatt, pte;
+	unsigned long gart_bus_addr, gart_aper_size;
+
+	gart_bus_addr = (unsigned long)IRONGATE0->bar0 &
+			PCI_BASE_ADDRESS_MEM_MASK; 
+
+	if (!gart_bus_addr) /* FIXME - there must be a better way!!! */
+		return addr + IRONGATE_MEM;
+
+	gart_aper_size = IRONGATE_DEFAULT_AGP_APER_SIZE; /* FIXME */
+
+	/* 
+	 * Check for within the AGP aperture...
+	 */
+	do {
+		/*
+		 * Check the AGP area
+		 */
+		if (addr >= gart_bus_addr && addr + size - 1 < 
+		    gart_bus_addr + gart_aper_size)
+			break;
+
+		/*
+		 * Not found - assume legacy ioremap
+		 */
+		return addr + IRONGATE_MEM;
+	} while(0);
+
+	mmio_regs = (u32 *)(((unsigned long)IRONGATE0->bar1 &
+			PCI_BASE_ADDRESS_MEM_MASK) + IRONGATE_MEM);
+
+	gatt_pages = (u32 *)(phys_to_virt(mmio_regs[1])); /* FIXME */
+
+	/*
+	 * Adjust the limits (mappings must be page aligned)
+	 */
+	if (addr & ~PAGE_MASK) {
+		printk("AGP ioremap failed... addr not page aligned (0x%lx)\n",
+		       addr);
+		return addr + IRONGATE_MEM;
+	}
+	last = addr + size - 1;
+	size = PAGE_ALIGN(last) - addr;
+
+#if 0
+	printk("irongate_ioremap(0x%lx, 0x%lx)\n", addr, size);
+	printk("irongate_ioremap:  gart_bus_addr  0x%lx\n", gart_bus_addr);
+	printk("irongate_ioremap:  gart_aper_size 0x%lx\n", gart_aper_size);
+	printk("irongate_ioremap:  mmio_regs      %p\n", mmio_regs);
+	printk("irongate_ioremap:  gatt_pages     %p\n", gatt_pages);
+	
+	for(baddr = addr; baddr <= last; baddr += PAGE_SIZE)
+	{
+		cur_gatt = phys_to_virt(GET_GATT(baddr) & ~1);
+		pte = cur_gatt[GET_GATT_OFF(baddr)] & ~1;
+		printk("irongate_ioremap:  cur_gatt %p pte 0x%x\n",
+		       cur_gatt, pte);
+	}
+#endif
+
+	/*
+	 * Map it
+	 */
+	area = get_vm_area(size, VM_IOREMAP);
+	if (!area) return (unsigned long)NULL;
+
+	for(baddr = addr, vaddr = (unsigned long)area->addr; 
+	    baddr <= last; 
+	    baddr += PAGE_SIZE, vaddr += PAGE_SIZE)
+	{
+		cur_gatt = phys_to_virt(GET_GATT(baddr) & ~1);
+		pte = cur_gatt[GET_GATT_OFF(baddr)] & ~1;
+
+		if (irongate_remap_area_pages(VMALLOC_VMADDR(vaddr), 
+					   pte, PAGE_SIZE, 0)) {
+			printk("AGP ioremap: FAILED to map...\n");
+			vfree(area->addr);
+			return (unsigned long)NULL;
+		}
+	}
+
+	flush_tlb_all();
+
+	vaddr = (unsigned long)area->addr + (addr & ~PAGE_MASK);
+#if 0
+	printk("irongate_ioremap(0x%lx, 0x%lx) returning 0x%lx\n",
+	       addr, size, vaddr);
+#endif
+	return vaddr;
+}
+
+void
+irongate_iounmap(unsigned long addr)
+{
+	if (((long)addr >> 41) == -2)
+		return;	/* kseg map, nothing to do */
+	if (addr) return vfree((void *)(PAGE_MASK & addr)); 
 }
diff -u --recursive --new-file v2.4.9/linux/arch/alpha/kernel/machvec_impl.h linux/arch/alpha/kernel/machvec_impl.h
--- v2.4.9/linux/arch/alpha/kernel/machvec_impl.h	Wed Jun 21 22:30:59 2000
+++ linux/arch/alpha/kernel/machvec_impl.h	Thu Sep 13 15:21:32 2001
@@ -80,7 +80,8 @@
 	mv_writew:		CAT(low,_writew),			\
 	mv_writel:		CAT(low,_writel),			\
 	mv_writeq:		CAT(low,_writeq),			\
-	mv_ioremap:		CAT(low,_ioremap)			\
+	mv_ioremap:		CAT(low,_ioremap),			\
+	mv_iounmap:		CAT(low,_iounmap)			\
 
 #define IO(UP,low)							\
 	IO_LITE(UP,low),						\
diff -u --recursive --new-file v2.4.9/linux/arch/alpha/kernel/pci-noop.c linux/arch/alpha/kernel/pci-noop.c
--- v2.4.9/linux/arch/alpha/kernel/pci-noop.c	Fri Mar  2 11:12:07 2001
+++ linux/arch/alpha/kernel/pci-noop.c	Thu Sep 13 15:21:32 2001
@@ -102,3 +102,38 @@
 	else
 		return -ENODEV;
 }
+/* stubs for the routines in pci_iommu.c */
+void *
+pci_alloc_consistent(struct pci_dev *pdev, long size, dma_addr_t *dma_addrp)
+{
+}
+void
+pci_free_consistent(struct pci_dev *pdev, long size, void *cpu_addr,
+		    dma_addr_t dma_addr)
+{
+}
+dma_addr_t
+pci_map_single(struct pci_dev *pdev, void *cpu_addr, long size,
+	       int direction)
+{
+}
+void
+pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, long size,
+		 int direction)
+{
+}
+int
+pci_map_sg(struct pci_dev *pdev, struct scatterlist *sg, int nents,
+	   int direction)
+{
+}
+void
+pci_unmap_sg(struct pci_dev *pdev, struct scatterlist *sg, int nents,
+	     int direction)
+{
+}
+int
+pci_dma_supported(struct pci_dev *hwdev, dma_addr_t mask)
+{
+	return 0;
+}
diff -u --recursive --new-file v2.4.9/linux/arch/alpha/kernel/pci.c linux/arch/alpha/kernel/pci.c
--- v2.4.9/linux/arch/alpha/kernel/pci.c	Mon May 21 13:38:41 2001
+++ linux/arch/alpha/kernel/pci.c	Thu Sep 13 15:21:32 2001
@@ -76,6 +76,9 @@
 		dev->resource[3].end = dev->resource[3].start + 7;
 }
 
+static void __init
+quirk_cypress(struct pci_dev *dev)
+{
 /*
  * Notorious Cy82C693 chip. One of its numerous bugs: although
  * Cypress IDE controller doesn't support native mode, it has
@@ -85,31 +88,27 @@
  * and floppy controller. Ugh.
  * Fix that.
  */
-static void __init
-quirk_cypress_ide_ports(struct pci_dev *dev)
-{
-	if (dev->class >> 8 != PCI_CLASS_STORAGE_IDE)
+	if (dev->class >> 8 == PCI_CLASS_STORAGE_IDE) {
+		dev->resource[0].flags = 0;
+		dev->resource[1].flags = 0;
 		return;
-	dev->resource[0].flags = 0;
-	dev->resource[1].flags = 0;
-}
-
-static void __init
-quirk_vga_enable_rom(struct pci_dev *dev)
-{
-	/* If it's a VGA, enable its BIOS ROM at C0000.
-	   But if its a Cirrus 543x/544x DISABLE it, since
-	   enabling ROM disables the memory... */
-	if ((dev->class >> 8) == PCI_CLASS_DISPLAY_VGA &&
-	    (dev->vendor != PCI_VENDOR_ID_CIRRUS ||
-	     (dev->device < 0x00a0) || (dev->device > 0x00ac)))
-	{
-		u32 reg;
-
-		pci_read_config_dword(dev, dev->rom_base_reg, &reg);
-		reg |= PCI_ROM_ADDRESS_ENABLE;
-		pci_write_config_dword(dev, dev->rom_base_reg, reg);
-		dev->resource[PCI_ROM_RESOURCE].flags |= PCI_ROM_ADDRESS_ENABLE;
+	}
+/*
+ * Another "feature": Cypress bridge responds on the PCI bus
+ * in the address range 0xffff0000-0xffffffff (conventional
+ * x86 BIOS ROM). No way to turn this off, so if we use
+ * large SG window, we must avoid these addresses.
+ */
+	if (dev->class >> 8 == PCI_CLASS_BRIDGE_ISA) {
+		struct pci_controller *hose = dev->sysdata;
+		long overlap;
+
+		if (hose->sg_pci) {
+			overlap = hose->sg_pci->dma_base + hose->sg_pci->size;
+			overlap -= 0xffff0000;
+			if (overlap > 0)
+				hose->sg_pci->size -= overlap;
+		}
 	}
 }
 
@@ -121,8 +120,7 @@
 	{ PCI_FIXUP_HEADER, PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M5229,
 	  quirk_ali_ide_ports },
 	{ PCI_FIXUP_HEADER, PCI_VENDOR_ID_CONTAQ, PCI_DEVICE_ID_CONTAQ_82C693,
-	  quirk_cypress_ide_ports },
-	{ PCI_FIXUP_FINAL, PCI_ANY_ID, PCI_ANY_ID, quirk_vga_enable_rom },
+	  quirk_cypress },
 	{ 0 }
 };
 
@@ -148,10 +146,8 @@
 		/*
 		 * Put everything into 0x00-0xff region modulo 0x400
 		 */
-		if (start & 0x300) {
+		if (start & 0x300)
 			start = (start + 0x3ff) & ~0x3ff;
-			res->start = start;
-		}
 	}
 	else if	(res->flags & IORESOURCE_MEM) {
 		/* Make sure we start at our min on all hoses */
@@ -177,13 +173,13 @@
 		/* Align to multiple of size of minimum base.  */
 		alignto = MAX(0x1000, size);
 		start = ALIGN(start, alignto);
-		if (size <= 7 * 16*MB) {
+		if (hose->sparse_mem_base && size <= 7 * 16*MB) {
 			if (((start / (16*MB)) & 0x7) == 0) {
 				start &= ~(128*MB - 1);
 				start += 16*MB;
 				start  = ALIGN(start, alignto);
 			}
-			if (start/(128*MB) != (start + size)/(128*MB)) {
+			if (start/(128*MB) != (start + size - 1)/(128*MB)) {
 				start &= ~(128*MB - 1);
 				start += (128 + 16)*MB;
 				start  = ALIGN(start, alignto);
diff -u --recursive --new-file v2.4.9/linux/arch/alpha/kernel/pci_impl.h linux/arch/alpha/kernel/pci_impl.h
--- v2.4.9/linux/arch/alpha/kernel/pci_impl.h	Fri May 25 09:54:50 2001
+++ linux/arch/alpha/kernel/pci_impl.h	Thu Sep 13 15:21:32 2001
@@ -49,7 +49,7 @@
  * APECS and LCA have only 34 bits for physical addresses, thus limiting PCI
  * bus memory addresses for SPARSE access to be less than 128Mb.
  */
-#define APECS_AND_LCA_DEFAULT_MEM_BASE ((32+2)*1024*1024)
+#define APECS_AND_LCA_DEFAULT_MEM_BASE ((16+2)*1024*1024)
 
 /*
  * Because the MCPCIA core logic supports more bits for physical addresses,
@@ -136,6 +136,7 @@
 	spinlock_t lock;
 	struct pci_controller *hose;
 #define IOMMU_INVALID_PTE 0x2 /* 32:63 bits MBZ */
+#define IOMMU_RESERVED_PTE 0xface
 	unsigned long *ptes;
 	dma_addr_t dma_base;
 	unsigned int size;
@@ -161,3 +162,10 @@
 extern const char *const pci_io_names[];
 extern const char *const pci_mem_names[];
 extern const char pci_hae0_name[];
+
+extern int iommu_reserve(struct pci_iommu_arena *, long, long);
+extern int iommu_release(struct pci_iommu_arena *, long, long);
+extern int iommu_bind(struct pci_iommu_arena *, long, long, unsigned long *);
+extern int iommu_unbind(struct pci_iommu_arena *, long, long);
+
+
diff -u --recursive --new-file v2.4.9/linux/arch/alpha/kernel/pci_iommu.c linux/arch/alpha/kernel/pci_iommu.c
--- v2.4.9/linux/arch/alpha/kernel/pci_iommu.c	Mon Aug 27 12:41:37 2001
+++ linux/arch/alpha/kernel/pci_iommu.c	Thu Sep 13 15:21:32 2001
@@ -42,24 +42,6 @@
 	return (bytes + PAGE_SIZE - 1) >> PAGE_SHIFT;
 }
 
-static void __init
-iommu_arena_fixup(struct pci_iommu_arena * arena)
-{
-	unsigned long base, size;
-
-	/*
-	 * The Cypress chip has a quirk, it get confused by addresses
-	 * above -1M so reserve the pagetables that maps pci addresses
-	 * above -1M.
-	 */
-	base = arena->dma_base;
-	size = arena->size;
-	if (base + size > 0xfff00000) {
-		int i, fixup_start = (0xfff00000 - base) >> PAGE_SHIFT;
-		for (i= 0; i < (0x100000 >> PAGE_SHIFT); i++)
-			arena->ptes[fixup_start+i] = IOMMU_INVALID_PTE;
-	}
-}
 
 struct pci_iommu_arena *
 iommu_arena_new(struct pci_controller *hose, dma_addr_t base,
@@ -90,24 +72,19 @@
 	   unless there are chip bugs.  */
 	arena->align_entry = 1;
 
-	iommu_arena_fixup(arena);
-
 	return arena;
 }
 
-long
-iommu_arena_alloc(struct pci_iommu_arena *arena, long n)
+/* Must be called with the arena lock held */
+static long
+iommu_arena_find_pages(struct pci_iommu_arena *arena, long n, long mask)
 {
-	unsigned long flags;
 	unsigned long *ptes;
-	long i, p, nent, mask;
+	long i, p, nent;
 
-	spin_lock_irqsave(&arena->lock, flags);
-
-	/* Search forward for the first sequence of N empty ptes.  */
+	/* Search forward for the first mask-aligned sequence of N free ptes */
 	ptes = arena->ptes;
 	nent = arena->size >> PAGE_SHIFT;
-	mask = arena->align_entry - 1;
 	p = (arena->next_entry + mask) & ~mask;
 	i = 0;
 	while (i < n && p+i < nent) {
@@ -130,10 +107,31 @@
 				i = i + 1;
 		}
 
-		if (i < n) {
-			spin_unlock_irqrestore(&arena->lock, flags);
+		if (i < n)
 			return -1;
-		}
+	}
+
+	/* Success. It's the responsibility of the caller to mark them
+	   in use before releasing the lock */
+	return p;
+}
+
+long
+iommu_arena_alloc(struct pci_iommu_arena *arena, long n)
+{
+	unsigned long flags;
+	unsigned long *ptes;
+	long i, p, mask;
+
+	spin_lock_irqsave(&arena->lock, flags);
+
+	/* Search for N empty ptes */
+	ptes = arena->ptes;
+	mask = arena->align_entry - 1;
+	p = iommu_arena_find_pages(arena, n, mask);
+	if (p < 0) {
+		spin_unlock_irqrestore(&arena->lock, flags);
+		return -1;
 	}
 
 	/* Success.  Mark them all in use, ie not zero and invalid
@@ -660,6 +658,104 @@
 	arena = hose->sg_pci;
 	if (arena && arena->dma_base + arena->size - 1 <= mask)
 		return 1;
+
+	return 0;
+}
+
+
+/*
+ * AGP GART extensions to the IOMMU
+ */
+int
+iommu_reserve(struct pci_iommu_arena *arena, long pg_count, long align_mask) 
+{
+	unsigned long flags;
+	unsigned long *ptes;
+	long i, p;
+
+	if (!arena) return -EINVAL;
+
+	spin_lock_irqsave(&arena->lock, flags);
+
+	/* Search for N empty ptes.  */
+	ptes = arena->ptes;
+	p = iommu_arena_find_pages(arena, pg_count, align_mask);
+	if (p < 0) {
+		spin_unlock_irqrestore(&arena->lock, flags);
+		return -1;
+	}
+
+	/* Success.  Mark them all reserved (ie not zero and invalid)
+	   for the iommu tlb that could load them from under us.
+	   They will be filled in with valid bits by _bind() */
+	for (i = 0; i < pg_count; ++i)
+		ptes[p+i] = IOMMU_RESERVED_PTE;
+
+	arena->next_entry = p + pg_count;
+	spin_unlock_irqrestore(&arena->lock, flags);
+
+	return p;
+}
+
+int 
+iommu_release(struct pci_iommu_arena *arena, long pg_start, long pg_count)
+{
+	unsigned long *ptes;
+	long i;
+
+	if (!arena) return -EINVAL;
+
+	ptes = arena->ptes;
+
+	/* Make sure they're all reserved first... */
+	for(i = pg_start; i < pg_start + pg_count; i++)
+		if (ptes[i] != IOMMU_RESERVED_PTE)
+			return -EBUSY;
+
+	iommu_arena_free(arena, pg_start, pg_count);
+	return 0;
+}
+
+int
+iommu_bind(struct pci_iommu_arena *arena, long pg_start, long pg_count, 
+	   unsigned long *physaddrs)
+{
+	unsigned long flags;
+	unsigned long *ptes;
+	long i, j;
+
+	if (!arena) return -EINVAL;
+	
+	spin_lock_irqsave(&arena->lock, flags);
+
+	ptes = arena->ptes;
+
+	for(j = pg_start; j < pg_start + pg_count; j++) {
+		if (ptes[j] != IOMMU_RESERVED_PTE) {
+			spin_unlock_irqrestore(&arena->lock, flags);
+			return -EBUSY;
+		}
+	}
+		
+	for(i = 0, j = pg_start; i < pg_count; i++, j++)
+		ptes[j] = mk_iommu_pte(physaddrs[i]);
+
+	spin_unlock_irqrestore(&arena->lock, flags);
+
+	return 0;
+}
+
+int
+iommu_unbind(struct pci_iommu_arena *arena, long pg_start, long pg_count)
+{
+	unsigned long *p;
+	long i;
+
+	if (!arena) return -EINVAL;
+
+	p = arena->ptes + pg_start;
+	for(i = 0; i < pg_count; i++)
+		p[i] = IOMMU_RESERVED_PTE;
 
 	return 0;
 }
diff -u --recursive --new-file v2.4.9/linux/arch/alpha/kernel/smp.c linux/arch/alpha/kernel/smp.c
--- v2.4.9/linux/arch/alpha/kernel/smp.c	Mon Aug 27 12:41:38 2001
+++ linux/arch/alpha/kernel/smp.c	Thu Sep 13 15:21:32 2001
@@ -1,5 +1,13 @@
 /*
  *	linux/arch/alpha/kernel/smp.c
+ *
+ *      2001-07-09 Phil Ezolt (Phillip.Ezolt@compaq.com)
+ *            Renamed modified smp_call_function to smp_call_function_on_cpu()
+ *            Created an function that conforms to the old calling convention
+ *            of smp_call_function().
+ *
+ *            This is helpful for DCPI.
+ *
  */
 
 #include <linux/errno.h>
@@ -867,23 +875,31 @@
  */
 
 int
-smp_call_function (void (*func) (void *info), void *info, int retry, int wait)
+smp_call_function_on_cpu (void (*func) (void *info), void *info, int retry,
+			  int wait, unsigned long to_whom)
 {
-	unsigned long to_whom = cpu_present_mask ^ (1UL << smp_processor_id());
 	struct smp_call_struct data;
 	long timeout;
+	int num_cpus_to_call;
+	long i,j;
 	
 	data.func = func;
 	data.info = info;
 	data.wait = wait;
-	atomic_set(&data.unstarted_count, smp_num_cpus - 1);
-	atomic_set(&data.unfinished_count, smp_num_cpus - 1);
+
+	to_whom &= ~(1L << smp_processor_id());
+	for (i = 0, j = 1, num_cpus_to_call = 0; i < NR_CPUS; ++i, j <<= 1)
+		if (to_whom & j)
+			num_cpus_to_call++;
+
+	atomic_set(&data.unstarted_count, num_cpus_to_call);
+	atomic_set(&data.unfinished_count, num_cpus_to_call);
 
 	/* Acquire the smp_call_function_data mutex.  */
 	if (pointer_lock(&smp_call_function_data, &data, retry))
 		return -EBUSY;
 
-	/* Send a message to all other CPUs.  */
+	/* Send a message to the requested CPUs.  */
 	send_ipi_message(to_whom, IPI_CALL_FUNC);
 
 	/* Wait for a minimal response.  */
@@ -905,6 +921,13 @@
 	}
 
 	return 0;
+}
+
+int
+smp_call_function (void (*func) (void *info), void *info, int retry, int wait)
+{
+	return smp_call_function_on_cpu (func, info, retry, wait,
+					 cpu_present_mask);
 }
 
 static void
diff -u --recursive --new-file v2.4.9/linux/arch/alpha/kernel/sys_jensen.c linux/arch/alpha/kernel/sys_jensen.c
--- v2.4.9/linux/arch/alpha/kernel/sys_jensen.c	Fri Mar  2 11:12:07 2001
+++ linux/arch/alpha/kernel/sys_jensen.c	Thu Sep 13 15:21:32 2001
@@ -35,14 +35,16 @@
 
 /*
  * Jensen is special: the vector is 0x8X0 for EISA interrupt X, and
- * 0x9X0 for the local motherboard interrupts..
+ * 0x9X0 for the local motherboard interrupts.
+ *
+ * Note especially that those local interrupts CANNOT be masked,
+ * which causes much of the pain below...
  *
  *	0x660 - NMI
  *
  *	0x800 - IRQ0  interval timer (not used, as we use the RTC timer)
  *	0x810 - IRQ1  line printer (duh..)
  *	0x860 - IRQ6  floppy disk
- *	0x8E0 - IRQ14 SCSI controller
  *
  *	0x900 - COM1
  *	0x920 - COM2
@@ -52,27 +54,77 @@
  * PCI-based systems are more sane: they don't have the local
  * interrupts at all, and have only normal PCI interrupts from
  * devices.  Happily it's easy enough to do a sane mapping from the
- * Jensen..  Note that this means that we may have to do a hardware
- * "ack" to a different interrupt than we report to the rest of the
+ * Jensen.
+ * 
+ * Note that this means that we may have to do a hardware
+ * "local_op" to a different interrupt than we report to the rest of the
  * world.
  */
 
+static unsigned int
+jensen_local_startup(unsigned int irq)
+{
+	/* the parport is really hw IRQ 1, silly Jensen.  */
+	if (irq == 7)
+		i8259a_startup_irq(1);
+	else
+		/*
+		 * For all true local interrupts, set the flag that prevents
+		 * the IPL from being dropped during handler processing.
+		 */
+		if (irq_desc[irq].action)
+			irq_desc[irq].action->flags |= SA_INTERRUPT;
+	return 0;
+}
+
+static void
+jensen_local_shutdown(unsigned int irq)
+{
+	/* the parport is really hw IRQ 1, silly Jensen.  */
+	if (irq == 7)
+		i8259a_disable_irq(1);
+}
+
+static void
+jensen_local_enable(unsigned int irq)
+{
+	/* the parport is really hw IRQ 1, silly Jensen.  */
+	if (irq == 7)
+		i8259a_enable_irq(1);
+}
+
+static void
+jensen_local_disable(unsigned int irq)
+{
+	/* the parport is really hw IRQ 1, silly Jensen.  */
+	if (irq == 7)
+		i8259a_disable_irq(1);
+}
+
 static void
 jensen_local_ack(unsigned int irq)
 {
-	/* irq1 is supposed to be the keyboard, silly Jensen.  */
+	/* the parport is really hw IRQ 1, silly Jensen.  */
 	if (irq == 7)
 		i8259a_mask_and_ack_irq(1);
 }
 
+static void
+jensen_local_end(unsigned int irq)
+{
+	/* the parport is really hw IRQ 1, silly Jensen.  */
+	if (irq == 7)
+		i8259a_end_irq(1);
+}
+
 static struct hw_interrupt_type jensen_local_irq_type = {
 	typename:	"LOCAL",
-	startup:	i8259a_startup_irq,
-	shutdown:	i8259a_disable_irq,
-	enable:		i8259a_enable_irq,
-	disable:	i8259a_disable_irq,
+	startup:	jensen_local_startup,
+	shutdown:	jensen_local_shutdown,
+	enable:		jensen_local_enable,
+	disable:	jensen_local_disable,
 	ack:		jensen_local_ack,
-	end:		i8259a_end_irq,
+	end:		jensen_local_end,
 };
 
 static void 
@@ -104,6 +156,47 @@
 		break;
 	}
 
+	/* If there is no handler yet... */
+	if (irq_desc[irq].action == NULL) {
+	    /* If it is a local interrupt that cannot be masked... */
+	    if (vector >= 0x900)
+	    {
+	        /* Clear keyboard/mouse state */
+	    	inb(0x64);
+		inb(0x60);
+		/* Reset serial ports */
+		inb(0x3fa);
+		inb(0x2fa);
+		outb(0x0c, 0x3fc);
+		outb(0x0c, 0x2fc);
+		/* Clear NMI */
+		outb(0,0x61);
+		outb(0,0x461);
+	    }
+	}
+
+#if 0
+        /* A useful bit of code to find out if an interrupt is going wild.  */
+        {
+          static unsigned int last_msg = 0, last_cc = 0;
+          static int last_irq = -1, count = 0;
+          unsigned int cc;
+
+          __asm __volatile("rpcc %0" : "=r"(cc));
+          ++count;
+#define JENSEN_CYCLES_PER_SEC	(150000000)
+          if (cc - last_msg > ((JENSEN_CYCLES_PER_SEC) * 3) ||
+	      irq != last_irq) {
+                printk(KERN_CRIT " irq %d count %d cc %u @ %lx\n",
+                       irq, count, cc-last_cc, regs->pc);
+                count = 0;
+                last_msg = cc;
+                last_irq = irq;
+          }
+          last_cc = cc;
+        }
+#endif
+
 	handle_irq(irq, regs);
 }
 
@@ -164,7 +257,7 @@
 	BUS(jensen),
 	machine_check:		jensen_machine_check,
 	max_dma_address:	ALPHA_MAX_DMA_ADDRESS,
-	rtc_port: 0x170,
+	rtc_port:		0x170,
 
 	nr_irqs:		16,
 	device_interrupt:	jensen_device_interrupt,
diff -u --recursive --new-file v2.4.9/linux/arch/alpha/kernel/traps.c linux/arch/alpha/kernel/traps.c
--- v2.4.9/linux/arch/alpha/kernel/traps.c	Mon Aug 27 12:41:38 2001
+++ linux/arch/alpha/kernel/traps.c	Thu Sep 13 15:21:32 2001
@@ -19,9 +19,37 @@
 #include <asm/uaccess.h>
 #include <asm/unaligned.h>
 #include <asm/sysinfo.h>
+#include <asm/hwrpb.h>
 
 #include "proto.h"
 
+/* data/code implementing a work-around for some SRMs which
+   mishandle opDEC faults
+*/
+static int opDEC_testing = 0;
+static int opDEC_fix = 0;
+static unsigned long opDEC_test_pc = 0;
+
+static void
+opDEC_check(void)
+{
+	unsigned long test_pc;
+
+	lock_kernel();
+	opDEC_testing = 1;
+
+	__asm__ __volatile__(
+		"       br      %0,1f\n"
+		"1:     addq    %0,8,%0\n"
+		"       stq     %0,%1\n"
+		"       cvttq/svm $f31,$f31\n"
+		: "=&r"(test_pc), "=m"(opDEC_test_pc)
+		: );
+
+	opDEC_testing = 0;
+	unlock_kernel();
+}
+
 void
 dik_show_regs(struct pt_regs *regs, unsigned long *r9_15)
 {
@@ -56,10 +84,12 @@
 #endif
 }
 
+#if 0
 static char * ireg_name[] = {"v0", "t0", "t1", "t2", "t3", "t4", "t5", "t6",
 			   "t7", "s0", "s1", "s2", "s3", "s4", "s5", "s6",
 			   "a0", "a1", "a2", "a3", "a4", "a5", "t8", "t9",
 			   "t10", "t11", "ra", "pv", "at", "gp", "sp", "zero"};
+#endif
 
 static void
 dik_show_code(unsigned int *pc)
@@ -188,8 +218,10 @@
 	 unsigned long a2, unsigned long a3, unsigned long a4,
 	 unsigned long a5, struct pt_regs regs)
 {
-	die_if_kernel((type == 1 ? "Kernel Bug" : "Instruction fault"),
+	if (!opDEC_testing || type != 4) {
+		die_if_kernel((type == 1 ? "Kernel Bug" : "Instruction fault"),
 		      &regs, type, 0);
+	}
 
 	switch (type) {
 	      case 0: /* breakpoint */
@@ -242,6 +274,21 @@
 
 	      case 4: /* opDEC */
 		if (implver() == IMPLVER_EV4) {
+			/* The some versions of SRM do not handle
+			   the opDEC properly - they return the PC of the
+			   opDEC fault, not the instruction after as the
+			   Alpha architecture requires.  Here we fix it up.
+			   We do this by intentionally causing an opDEC
+			   fault during the boot sequence and testing if
+			   we get the correct PC.  If not, we set a flag
+			   to correct it every time through.
+			*/
+			if (opDEC_testing && regs.pc == opDEC_test_pc) {
+				opDEC_fix = 4;
+				printk("opDEC fixup enabled.\n");
+			}
+			regs.pc += opDEC_fix; 
+			
 			/* EV4 does not implement anything except normal
 			   rounding.  Everything else will come here as
 			   an illegal instruction.  Emulate them.  */
@@ -257,7 +304,7 @@
 }
 
 /* There is an ifdef in the PALcode in MILO that enables a 
-   "kernel debugging entry point" as an unprivilaged call_pal.
+   "kernel debugging entry point" as an unpriviledged call_pal.
 
    We don't want to have anything to do with it, but unfortunately
    several versions of MILO included in distributions have it enabled,
@@ -933,4 +980,11 @@
 	wrent(entUna, 4);
 	wrent(entSys, 5);
 	wrent(entDbg, 6);
+
+	/* Hack for Multia (UDB) and JENSEN: some of their SRMs have
+	 * a bug in the handling of the opDEC fault.  Fix it up if so.
+	 */
+	if (implver() == IMPLVER_EV4) {
+		opDEC_check();
+	}
 }
diff -u --recursive --new-file v2.4.9/linux/arch/arm/kernel/arthur.c linux/arch/arm/kernel/arthur.c
--- v2.4.9/linux/arch/arm/kernel/arthur.c	Thu Apr 12 12:20:31 2001
+++ linux/arch/arm/kernel/arthur.c	Mon Sep 10 13:04:33 2001
@@ -1,7 +1,7 @@
 /*
  *  linux/arch/arm/kernel/arthur.c
  *
- *  Copyright (C) 1998, 1999, 2000 Philip Blundell
+ *  Copyright (C) 1998, 1999, 2000, 2001 Philip Blundell
  *
  * Arthur personality
  */
@@ -58,14 +58,14 @@
 {
 	struct siginfo info;
 	info.si_signo = SIGSWI;
-	info.si_code = nr;
+	info.si_errno = nr;
 	/* Bounce it to the emulator */
 	send_sig_info(SIGSWI, &info, current);
 }
 
 static struct exec_domain arthur_exec_domain = {
 	"Arthur",	/* name */
-	(lcall7_func)arthur_lcall7,
+	arthur_lcall7,
 	PER_RISCOS, PER_RISCOS,
 	arthur_to_linux_signals,
 	linux_to_arthur_signals,
diff -u --recursive --new-file v2.4.9/linux/arch/arm/kernel/process.c linux/arch/arm/kernel/process.c
--- v2.4.9/linux/arch/arm/kernel/process.c	Mon Aug 27 12:41:38 2001
+++ linux/arch/arm/kernel/process.c	Fri Sep  7 09:28:38 2001
@@ -124,7 +124,7 @@
 		pm_power_off();
 }
 
-void machine_restart(void * __unused)
+void machine_restart(char * __unused)
 {
 	/*
 	 * Clean and disable cache, and turn off interrupts
diff -u --recursive --new-file v2.4.9/linux/arch/arm/kernel/traps.c linux/arch/arm/kernel/traps.c
--- v2.4.9/linux/arch/arm/kernel/traps.c	Mon Aug 27 12:41:38 2001
+++ linux/arch/arm/kernel/traps.c	Mon Sep 10 13:04:33 2001
@@ -19,6 +19,7 @@
 #include <linux/sched.h>
 #include <linux/mm.h>
 #include <linux/spinlock.h>
+#include <linux/personality.h>
 #include <linux/ptrace.h>
 #include <linux/elf.h>
 #include <linux/init.h>
diff -u --recursive --new-file v2.4.9/linux/arch/arm/lib/io-readsl-armv4.S linux/arch/arm/lib/io-readsl-armv4.S
--- v2.4.9/linux/arch/arm/lib/io-readsl-armv4.S	Mon Aug 27 12:41:38 2001
+++ linux/arch/arm/lib/io-readsl-armv4.S	Fri Sep  7 09:28:38 2001
@@ -63,8 +63,8 @@
 		strne	ip, [r1], #4
 		movne	ip, r3, lsr #8
 		bne	7b
-		strb	ip, [r1], #1
-		mov	ip, ip, lsr #8
 		strh	ip, [r1], #2
+		mov	ip, ip, lsr #16
+		strb	ip, [r1]
 		mov	pc, lr
 
diff -u --recursive --new-file v2.4.9/linux/arch/arm/lib/io-writesl.S linux/arch/arm/lib/io-writesl.S
--- v2.4.9/linux/arch/arm/lib/io-writesl.S	Mon Aug 27 12:41:38 2001
+++ linux/arch/arm/lib/io-writesl.S	Fri Sep  7 09:28:38 2001
@@ -25,31 +25,30 @@
 
 2:		bic	r1, r1, #3
 		cmp	ip, #2
-		ldr	ip, [r1], #4
-		mov	ip, ip, lsr #16
-		blt	4f
-		bgt	5f
+		ldr	r3, [r1], #4
+		bgt	4f
+		blt	5f
 
-3:		ldr	r3, [r1], #4
+3:		mov	ip, r3, lsr #16
+		ldr	r3, [r1], #4
 		orr	ip, ip, r3, lsl #16
 		str	ip, [r0]
-		mov	ip, r3, lsr #16
 		subs	r2, r2, #1
 		bne	3b
 		mov	pc, lr
 
-4:		ldr	r3, [r1], #4
+4:		mov	ip, r3, lsr #24
+		ldr	r3, [r1], #4
 		orr	ip, ip, r3, lsl #8
 		str	ip, [r0]
-		mov	ip, r3, lsr #24
 		subs	r2, r2, #1
 		bne	4b
 		mov	pc, lr
 
-5:		ldr	r3, [r1], #4
+5:		mov	ip, r3, lsr #8
+		ldr	r3, [r1], #4
 		orr	ip, ip, r3, lsl #24
 		str	ip, [r0]
-		mov	ip, r3, lsr #8
 		subs	r2, r2, #1
 		bne	5b
 		mov	pc, lr
diff -u --recursive --new-file v2.4.9/linux/arch/arm/mm/fault-armv.c linux/arch/arm/mm/fault-armv.c
--- v2.4.9/linux/arch/arm/mm/fault-armv.c	Mon Aug 27 12:41:38 2001
+++ linux/arch/arm/mm/fault-armv.c	Fri Sep  7 09:28:38 2001
@@ -20,6 +20,7 @@
 #include <linux/mm.h>
 #include <linux/interrupt.h>
 #include <linux/proc_fs.h>
+#include <linux/bitops.h>
 #include <linux/init.h>
 
 #include <asm/system.h>
@@ -366,8 +367,7 @@
 	ai_multi += 1;
 
 	/* count the number of registers in the mask to be transferred */
-	for (regbits = REGMASK_BITS(instr), nr_regs = 0; regbits; regbits >>= 1)
-		nr_regs += 4;
+	nr_regs = hweight16(REGMASK_BITS(instr)) * 4;
 
 	rn = RN_BITS(instr);
 	newaddr = eaddr = regs->uregs[rn];
@@ -385,10 +385,12 @@
 	 * This is a "hint" - we already have eaddr worked out by the
 	 * processor for us.
 	 */
-	if (addr != eaddr)
+	if (addr != eaddr) {
 		printk(KERN_ERR "LDMSTM: PC = %08lx, instr = %08lx, "
 			"addr = %08lx, eaddr = %08lx\n",
 			 instruction_pointer(regs), instr, addr, eaddr);
+		show_regs(regs);
+	}
 
 	for (regbits = REGMASK_BITS(instr), rd = 0; regbits; regbits >>= 1, rd += 1)
 		if (regbits & 1) {
diff -u --recursive --new-file v2.4.9/linux/arch/arm/tools/Makefile linux/arch/arm/tools/Makefile
--- v2.4.9/linux/arch/arm/tools/Makefile	Tue Jul  3 17:08:18 2001
+++ linux/arch/arm/tools/Makefile	Fri Sep  7 09:28:38 2001
@@ -26,7 +26,8 @@
 # directories
 
 dep:
-	$(TOPDIR)/scripts/mkdep getconstants.c | sed s,getconstants.o,$(TOPDIR)/include/asm-arm/constants.h, > .depend
+	$(TOPDIR)/scripts/mkdep $(CFLAGS) $(EXTRA_CFLAGS) -- getconstants.c |\
+	 sed s,getconstants.o,$(TOPDIR)/include/asm-arm/constants.h, > .depend
 	$(MAKE) all
 
 .PHONY:	all dep
diff -u --recursive --new-file v2.4.9/linux/arch/arm/tools/mach-types linux/arch/arm/tools/mach-types
--- v2.4.9/linux/arch/arm/tools/mach-types	Mon Aug 27 12:41:38 2001
+++ linux/arch/arm/tools/mach-types	Fri Sep  7 09:28:38 2001
@@ -6,7 +6,7 @@
 # To add an entry into this database, please see Documentation/arm/README,
 # or contact rmk@arm.linux.org.uk
 #
-# Last update: Thu Aug 9 22:46:02 2001
+# Last update: Thu Aug 23 12:38:13 2001
 #
 # machine_is_xxx	CONFIG_xxxx		MACH_TYPE_xxx		number
 #
@@ -31,7 +31,7 @@
 l7200			ARCH_L7200		L7200			19
 pleb			SA1100_PLEB		PLEB			20
 integrator		ARCH_INTEGRATOR		INTEGRATOR		21
-bitsy			SA1100_BITSY		BITSY			22
+h3600			SA1100_H3600		H3600			22
 ixp1200			ARCH_IXP1200		IXP1200			23
 p720t			ARCH_P720T		P720T			24
 assabet			SA1100_ASSABET		ASSABET			25
@@ -89,7 +89,7 @@
 tardis			ARCH_TARDIS		TARDIS			77
 mercury			ARCH_MERCURY		MERCURY			78
 empeg			SA1100_EMPEG		EMPEG			79
-adi_eb			ARCH_I80200FCC		I80200FCC		80
+adi_evb			ARCH_I80200FCC		I80200FCC		80
 itt_cpb			SA1100_ITT_CPB		ITT_CPB			81
 svc			SA1100_SVC		SVC			82
 alpha2			SA1100_ALPHA2		ALPHA2			84
@@ -115,3 +115,10 @@
 granite			ARCH_GRANITE		GRANITE			104
 consus			SA1100_CONSUS		CONSUS			105
 aaec2000_aaed20		ARCH_AAEC2000_AAED2000	AAEC2000_AAED2000	106
+cdb89712		ARCH_CDB89712		CDB89712		107
+graphicsmaster		SA1100_GRAPHICSMASTER	GRAPHICSMASTER		108
+adsbitsy		SA1100_ADSBITSY		ADSBITSY		109
+cotulla_idp		ARCH_COTULLA_IDP	COTULLA_IDP		110
+plce			ARCH_PLCE		PLCE			111
+pt_system3		SA1100_PT_SYSTEM3	PT_SYSTEM3		112
+medalb			ARCH_MEDALB		MEDALB			113
diff -u --recursive --new-file v2.4.9/linux/arch/cris/drivers/usb-host.c linux/arch/cris/drivers/usb-host.c
--- v2.4.9/linux/arch/cris/drivers/usb-host.c	Mon Aug 27 12:41:39 2001
+++ linux/arch/cris/drivers/usb-host.c	Mon Sep 10 09:04:53 2001
@@ -2258,11 +2258,11 @@
 	case RH_GET_DESCRIPTOR:
 		switch ((wValue & 0xff00) >> 8) {
 		case (0x01):	/* device descriptor */
-			len = min(unsigned int, leni, min(unsigned int, sizeof (root_hub_dev_des), wLength));
+			len = min_t(unsigned int, leni, min_t(unsigned int, sizeof (root_hub_dev_des), wLength));
 			memcpy (data, root_hub_dev_des, len);
 			OK (len);
 		case (0x02):	/* configuration descriptor */
-			len = min(unsigned int, leni, min(unsigned int, sizeof (root_hub_config_des), wLength));
+			len = min_t(unsigned int, leni, min_t(unsigned int, sizeof (root_hub_config_des), wLength));
 			memcpy (data, root_hub_config_des, len);
 			OK (len);
 		case (0x03):	/* string descriptors */
@@ -2270,7 +2270,7 @@
 						   0xff, "ETRAX 100LX",
 						   data, wLength);
 			if (len > 0) {
-				OK(min(int, leni, len));
+				OK(min_t(int, leni, len));
 			} else 
 				stat = -EPIPE;
 		}
@@ -2278,7 +2278,7 @@
 		
 	case RH_GET_DESCRIPTOR | RH_CLASS:
 		root_hub_hub_des[2] = hc->rh.numports;
-		len = min(unsigned int, leni, min(unsigned int, sizeof (root_hub_hub_des), wLength));
+		len = min_t(unsigned int, leni, min_t(unsigned int, sizeof (root_hub_hub_des), wLength));
 		memcpy (data, root_hub_hub_des, len);
 		OK (len);
 		
diff -u --recursive --new-file v2.4.9/linux/arch/i386/boot/compressed/Makefile linux/arch/i386/boot/compressed/Makefile
--- v2.4.9/linux/arch/i386/boot/compressed/Makefile	Tue Mar  7 11:04:12 2000
+++ linux/arch/i386/boot/compressed/Makefile	Tue Sep 11 23:08:12 2001
@@ -9,7 +9,6 @@
 
 OBJECTS = $(HEAD) misc.o
 
-CFLAGS = $(CPPFLAGS) -O2 -DSTDC_HEADERS
 ZLDFLAGS = -e startup_32
 
 #
diff -u --recursive --new-file v2.4.9/linux/arch/i386/boot/compressed/misc.c linux/arch/i386/boot/compressed/misc.c
--- v2.4.9/linux/arch/i386/boot/compressed/misc.c	Tue Feb 13 13:15:04 2001
+++ linux/arch/i386/boot/compressed/misc.c	Tue Sep 11 23:02:02 2001
@@ -12,6 +12,7 @@
 #include <linux/vmalloc.h>
 #include <linux/tty.h>
 #include <asm/io.h>
+
 /*
  * gzip declarations
  */
@@ -21,6 +22,14 @@
 
 #undef memset
 #undef memcpy
+
+/*
+ * Why do we do this? Don't ask me..
+ *
+ * Incomprehensible are the ways of bootloaders.
+ */
+static void* memset(void *, int, size_t);
+static void* memcpy(void *, __const void *, size_t);
 #define memzero(s, n)     memset ((s), 0, (n))
 
 typedef unsigned char  uch;
@@ -194,7 +203,7 @@
 	outb_p(0xff & (pos >> 1), vidport+1);
 }
 
-void* memset(void* s, int c, size_t n)
+static void* memset(void* s, int c, size_t n)
 {
 	int i;
 	char *ss = (char*)s;
@@ -203,7 +212,7 @@
 	return s;
 }
 
-void* memcpy(void* __dest, __const void* __src,
+static void* memcpy(void* __dest, __const void* __src,
 			    size_t __n)
 {
 	int i;
diff -u --recursive --new-file v2.4.9/linux/arch/i386/defconfig linux/arch/i386/defconfig
--- v2.4.9/linux/arch/i386/defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/i386/defconfig	Thu Sep 13 16:20:13 2001
@@ -175,6 +175,7 @@
 #
 # CONFIG_PHONE is not set
 # CONFIG_PHONE_IXJ is not set
+# CONFIG_PHONE_IXJ_PCMCIA is not set
 
 #
 # ATA/IDE/MFM/RLL support
@@ -288,6 +289,7 @@
 # CONFIG_SCSI_AHA1740 is not set
 # CONFIG_SCSI_AIC7XXX is not set
 # CONFIG_SCSI_AIC7XXX_OLD is not set
+# CONFIG_SCSI_DPT_I2O is not set
 # CONFIG_SCSI_ADVANSYS is not set
 # CONFIG_SCSI_IN2000 is not set
 # CONFIG_SCSI_AM53C974 is not set
@@ -306,6 +308,7 @@
 # CONFIG_SCSI_INITIO is not set
 # CONFIG_SCSI_INIA100 is not set
 # CONFIG_SCSI_NCR53C406A is not set
+# CONFIG_SCSI_NCR_D700 is not set
 # CONFIG_SCSI_NCR53C7xx is not set
 # CONFIG_SCSI_NCR53C8XX is not set
 CONFIG_SCSI_SYM53C8XX=y
@@ -495,6 +498,10 @@
 # Input core support
 #
 # CONFIG_INPUT is not set
+# CONFIG_INPUT_KEYBDEV is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
 
 #
 # Character devices
@@ -525,7 +532,11 @@
 #
 # Joysticks
 #
-# CONFIG_JOYSTICK is not set
+# CONFIG_INPUT_GAMEPORT is not set
+
+#
+# Input core support is needed for gameports
+#
 
 #
 # Input core support is needed for joysticks
@@ -705,6 +716,7 @@
 CONFIG_USB_STORAGE=y
 # CONFIG_USB_STORAGE_DEBUG is not set
 # CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_ISD200 is not set
 # CONFIG_USB_STORAGE_DPCM is not set
 # CONFIG_USB_ACM is not set
 # CONFIG_USB_PRINTER is not set
@@ -738,10 +750,10 @@
 #
 # USB Network adaptors
 #
-# CONFIG_USB_PLUSB is not set
 # CONFIG_USB_PEGASUS is not set
 # CONFIG_USB_CATC is not set
-# CONFIG_USB_NET1080 is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_USBNET is not set
 
 #
 # USB port drivers
diff -u --recursive --new-file v2.4.9/linux/arch/i386/kernel/bluesmoke.c linux/arch/i386/kernel/bluesmoke.c
--- v2.4.9/linux/arch/i386/kernel/bluesmoke.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/i386/kernel/bluesmoke.c	Sat Sep  8 12:23:14 2001
@@ -19,7 +19,7 @@
 	u32 mcgstl, mcgsth;
 	int i;
 	
-	rdmsr(0x17a, mcgstl, mcgsth);
+	rdmsr(MSR_IA32_MCG_STATUS, mcgstl, mcgsth);
 	if(mcgstl&(1<<0))	/* Recoverable ? */
 		recover=0;
 
@@ -27,7 +27,7 @@
 	
 	for(i=0;i<banks;i++)
 	{
-		rdmsr(0x401+i*4,low, high);
+		rdmsr(MSR_IA32_MC0_STATUS+i*4,low, high);
 		if(high&(1<<31))
 		{
 			if(high&(1<<29))
@@ -38,18 +38,18 @@
 			high&=~(1<<31);
 			if(high&(1<<27))
 			{
-				rdmsr(0x402+i*4, alow, ahigh);
+				rdmsr(MSR_IA32_MC0_MISC+i*4, alow, ahigh);
 				printk("[%08x%08x]", alow, ahigh);
 			}
 			if(high&(1<<26))
 			{
-				rdmsr(0x402+i*4, alow, ahigh);
+				rdmsr(MSR_IA32_MC0_ADDR+i*4, alow, ahigh);
 				printk(" at %08x%08x", 
 					high, low);
 			}
 			printk("\n");
 			/* Clear it */
-			wrmsr(0x401+i*4, 0UL, 0UL);
+			wrmsr(MSR_IA32_MC0_STATUS+i*4, 0UL, 0UL);
 			/* Serialize */
 			wmb();
 		}
@@ -61,7 +61,7 @@
 		panic("Unable to continue");
 	printk(KERN_EMERG "Attempting to continue.\n");
 	mcgstl&=~(1<<2);
-	wrmsr(0x17a,mcgstl, mcgsth);
+	wrmsr(MSR_IA32_MCG_STATUS,mcgstl, mcgsth);
 }
 
 /*
@@ -71,8 +71,8 @@
 static void pentium_machine_check(struct pt_regs * regs, long error_code)
 {
 	u32 loaddr, hi, lotype;
-	rdmsr(0x0, loaddr, hi);
-	rdmsr(0x1, lotype, hi);
+	rdmsr(MSR_IA32_P5_MC_ADDR, loaddr, hi);
+	rdmsr(MSR_IA32_P5_MC_TYPE, lotype, hi);
 	printk(KERN_EMERG "CPU#%d: Machine Check Exception:  0x%8X (type 0x%8X).\n", smp_processor_id(), loaddr, lotype);
 	if(lotype&(1<<5))
 		printk(KERN_EMERG "CPU#%d: Possible thermal failure (CPU on fire ?).\n", smp_processor_id());
@@ -133,8 +133,8 @@
 		machine_check_vector = pentium_machine_check;
 		wmb();
 		/* Read registers before enabling */
-		rdmsr(0x0, l, h);
-		rdmsr(0x1, l, h);
+		rdmsr(MSR_IA32_P5_MC_ADDR, l, h);
+		rdmsr(MSR_IA32_P5_MC_TYPE, l, h);
 		if(done==0)
 			printk(KERN_INFO "Intel old style machine check architecture supported.\n");
 		/* Enable MCE */		
@@ -161,17 +161,17 @@
 	
 	if(done==0)
 		printk(KERN_INFO "Intel machine check architecture supported.\n");
-	rdmsr(0x179, l, h);
+	rdmsr(MSR_IA32_MCG_CAP, l, h);
 	if(l&(1<<8))
-		wrmsr(0x17b, 0xffffffff, 0xffffffff);
+		wrmsr(MSR_IA32_MCG_CTL, 0xffffffff, 0xffffffff);
 	banks = l&0xff;
 	for(i=1;i<banks;i++)
 	{
-		wrmsr(0x400+4*i, 0xffffffff, 0xffffffff); 
+		wrmsr(MSR_IA32_MC0_CTL+4*i, 0xffffffff, 0xffffffff);
 	}
 	for(i=0;i<banks;i++)
 	{
-		wrmsr(0x401+4*i, 0x0, 0x0); 
+		wrmsr(MSR_IA32_MC0_STATUS+4*i, 0x0, 0x0);
 	}
 	set_in_cr4(X86_CR4_MCE);
 	printk(KERN_INFO "Intel machine check reporting enabled on CPU#%d.\n", smp_processor_id());
@@ -191,10 +191,10 @@
 	/* Winchip C6 */
 	machine_check_vector = winchip_machine_check;
 	wmb();
-	rdmsr(0x107, lo, hi);
+	rdmsr(MSR_IDT_FCR1, lo, hi);
 	lo|= (1<<2);	/* Enable EIERRINT (int 18 MCE) */
 	lo&= ~(1<<4);	/* Enable MCE */
-	wrmsr(0x107, lo, hi);
+	wrmsr(MSR_IDT_FCR1, lo, hi);
 	__asm__ __volatile__ (
 		"movl %%cr4, %%eax\n\t"
 		"orl $0x40, %%eax\n\t"
@@ -236,6 +236,6 @@
 static int __init mcheck_disable(char *str)
 {
 	mce_disabled = 1;
-	return 1;
+	return 0;
 }
 __setup("nomce", mcheck_disable);
diff -u --recursive --new-file v2.4.9/linux/arch/i386/kernel/entry.S linux/arch/i386/kernel/entry.S
--- v2.4.9/linux/arch/i386/kernel/entry.S	Tue Jul  3 17:08:18 2001
+++ linux/arch/i386/kernel/entry.S	Sat Sep  8 12:02:32 2001
@@ -621,12 +621,6 @@
 	.long SYMBOL_NAME(sys_fcntl64)
 	.long SYMBOL_NAME(sys_ni_syscall)	/* reserved for TUX */
 
-	/*
-	 * NOTE!! This doesn't have to be exact - we just have
-	 * to make sure we have _enough_ of the "sys_ni_syscall"
-	 * entries. Don't panic if you notice that this hasn't
-	 * been shrunk every time we add a new system call.
-	 */
-	.rept NR_syscalls-221
+	.rept NR_syscalls-(.-sys_call_table)/4
 		.long SYMBOL_NAME(sys_ni_syscall)
 	.endr
diff -u --recursive --new-file v2.4.9/linux/arch/i386/kernel/i386_ksyms.c linux/arch/i386/kernel/i386_ksyms.c
--- v2.4.9/linux/arch/i386/kernel/i386_ksyms.c	Mon Aug 27 12:41:39 2001
+++ linux/arch/i386/kernel/i386_ksyms.c	Mon Sep 10 07:31:30 2001
@@ -72,7 +72,7 @@
 EXPORT_SYMBOL(apm_info);
 EXPORT_SYMBOL(gdt);
 
-#ifdef CONFIG_IO_DEBUG
+#ifdef CONFIG_DEBUG_IOVIRT
 EXPORT_SYMBOL(__io_virt_debug);
 #endif
 
diff -u --recursive --new-file v2.4.9/linux/arch/i386/kernel/mtrr.c linux/arch/i386/kernel/mtrr.c
--- v2.4.9/linux/arch/i386/kernel/mtrr.c	Thu May 24 15:14:08 2001
+++ linux/arch/i386/kernel/mtrr.c	Sat Sep  1 11:05:16 2001
@@ -389,21 +389,19 @@
 	 return;
 
     /*  Save value of CR4 and clear Page Global Enable (bit 7)  */
-    if ( test_bit(X86_FEATURE_PGE, &boot_cpu_data.x86_capability) )
-	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");
+    if ( test_bit(X86_FEATURE_PGE, &boot_cpu_data.x86_capability) ) {
+	ctxt->cr4val = read_cr4();
+	write_cr4(ctxt->cr4val & (unsigned char) ~(1<<7));
+    }
 
     /*  Disable and flush caches. Note that wbinvd flushes the TLBs as
 	a side-effect  */
-    asm volatile ("movl  %%cr0, %0\n\t"
-		  "orl   $0x40000000, %0\n\t"
-		  "wbinvd\n\t"
-		  "movl  %0, %%cr0\n\t"
-		  "wbinvd\n\t"
-		  : "=r" (tmp) : : "memory");
+    {
+	unsigned int cr0 = read_cr0() | 0x40000000;
+	wbinvd();
+	write_cr0( cr0 );
+	wbinvd();
+    }
 
     if ( mtrr_if == MTRR_IF_INTEL ) {
 	/*  Disable MTRRs, and set the default type to uncached  */
@@ -420,15 +418,13 @@
 /*  Restore the processor after a set_mtrr_prepare  */
 static void set_mtrr_done (struct set_mtrr_context *ctxt)
 {
-    unsigned long tmp;
-
     if ( mtrr_if != MTRR_IF_INTEL && mtrr_if != MTRR_IF_CYRIX_ARR ) {
 	 __restore_flags (ctxt->flags);
 	 return;
     }
 
     /*  Flush caches and TLBs  */
-    asm volatile ("wbinvd" : : : "memory" );
+    wbinvd();
 
     /*  Restore MTRRdefType  */
     if ( mtrr_if == MTRR_IF_INTEL ) {
@@ -440,15 +436,11 @@
     }
 
     /*  Enable caches  */
-    asm volatile ("movl  %%cr0, %0\n\t"
-		  "andl  $0xbfffffff, %0\n\t"
-		  "movl  %0, %%cr0\n\t"
-		  : "=r" (tmp) : : "memory");
+    write_cr0( read_cr0() & 0xbfffffff );
 
     /*  Restore value of CR4  */
     if ( test_bit(X86_FEATURE_PGE, &boot_cpu_data.x86_capability) )
-	asm volatile ("movl  %0, %%cr4"
-		      : : "r" (ctxt->cr4val) : "memory");
+	write_cr4(ctxt->cr4val);
 
     /*  Re-enable interrupts locally (if enabled previously)  */
     __restore_flags (ctxt->flags);
@@ -607,7 +599,7 @@
 {
     unsigned long low, high;
 
-    rdmsr (0xC0000085, low, high);
+    rdmsr (MSR_K6_UWCCR, low, high);
     /*  Upper dword is region 1, lower is region 0  */
     if (reg == 1) low = high;
     /*  The base masks off on the right alignment  */
@@ -771,7 +763,7 @@
     /*
      *	Low is MTRR0 , High MTRR 1
      */
-    rdmsr (0xC0000085, regs[0], regs[1]);
+    rdmsr (MSR_K6_UWCCR, regs[0], regs[1]);
     /*
      *	Blank to disable
      */
@@ -792,8 +784,8 @@
      *	The writeback rule is quite specific. See the manual. Its
      *	disable local interrupts, write back the cache, set the mtrr
      */
-    __asm__ __volatile__ ("wbinvd" : : : "memory");
-    wrmsr (0xC0000085, regs[0], regs[1]);
+	wbinvd();
+	wrmsr (MSR_K6_UWCCR, regs[0], regs[1]);
     if (do_safe) set_mtrr_done (&ctxt);
 }   /*  End Function amd_set_mtrr_up  */
 
@@ -826,7 +818,7 @@
     }
     centaur_mcr[reg].high = high;
     centaur_mcr[reg].low = low;
-    wrmsr (0x110 + reg, low, high);
+    wrmsr (MSR_IDT_MCR0 + reg, low, high);
     if (do_safe) set_mtrr_done( &ctxt );
 }   /*  End Function centaur_set_mtrr_up  */
 
@@ -2012,12 +2004,12 @@
      * find out what the bios might have done.
      */
      
-    rdmsr(0x120, lo, hi);
+    rdmsr(MSR_IDT_MCR_CTRL, lo, hi);
     if(((lo>>17)&7)==1)		/* Type 1 Winchip2 MCR */
     {
     	lo&= ~0x1C0;		/* clear key */
     	lo|= 0x040;		/* set key to 1 */
-	wrmsr(0x120, lo, hi);	/* unlock MCR */
+	wrmsr(MSR_IDT_MCR_CTRL, lo, hi);	/* unlock MCR */
     }    
     
     centaur_mcr_type = 1;
@@ -2031,7 +2023,7 @@
     	if(centaur_mcr[i]. high == 0 && centaur_mcr[i].low == 0)
     	{
     		if(!(lo & (1<<(9+i))))
-			wrmsr (0x110 + i , 0, 0);
+			wrmsr (MSR_IDT_MCR0 + i , 0, 0);
 		else
 			/*
 			 *	If the BIOS set up an MCR we cannot see it
@@ -2047,7 +2039,7 @@
      */
 
     lo |= 15;			/* Write combine enables */
-    wrmsr(0x120, lo, hi);
+    wrmsr(MSR_IDT_MCR_CTRL, lo, hi);
 }   /*  End Function centaur_mcr1_init  */
 
 /*
@@ -2071,10 +2063,10 @@
     for (i = 0; i < 8; ++i)
     {
     	if(centaur_mcr[i]. high == 0 && centaur_mcr[i].low == 0)
-		wrmsr (0x110 + i , 0, 0);
+		wrmsr (MSR_IDT_MCR0 + i , 0, 0);
     }
 
-    wrmsr(0x120, 0x01F0001F, 0);	/* Write only */
+    wrmsr(MSR_IDT_MCR_CTRL, 0x01F0001F, 0);	/* Write only */
 }   /*  End Function centaur_mcr0_init  */
 
 /*
@@ -2230,6 +2222,8 @@
 	 *  :-)
 	 */
 	cyrix_arr_init_secondary ();
+	break;
+    case MTRR_IF_NONE:
 	break;
     default:
 	/* I see no MTRRs I can support in SMP mode... */
diff -u --recursive --new-file v2.4.9/linux/arch/i386/kernel/pci-pc.c linux/arch/i386/kernel/pci-pc.c
--- v2.4.9/linux/arch/i386/kernel/pci-pc.c	Mon Aug 27 12:41:39 2001
+++ linux/arch/i386/kernel/pci-pc.c	Sat Sep  1 11:01:28 2001
@@ -20,65 +20,145 @@
 unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2;
 
 int pcibios_last_bus = -1;
-struct pci_bus *pci_root_bus;
-struct pci_ops *pci_root_ops;
+struct pci_bus *pci_root_bus = NULL;
+struct pci_ops *pci_root_ops = NULL;
+
+int (*pci_config_read)(int seg, int bus, int dev, int fn, int reg, int len, u32 *value) = NULL;
+int (*pci_config_write)(int seg, int bus, int dev, int fn, int reg, int len, u32 value) = NULL;
 
 /*
- * Direct access to PCI hardware...
+ * This interrupt-safe spinlock protects all accesses to PCI
+ * configuration space.
  */
+spinlock_t pci_config_lock = SPIN_LOCK_UNLOCKED;
 
-#ifdef CONFIG_PCI_DIRECT
 
 /*
  * Functions for accessing PCI configuration space with type 1 accesses
  */
 
-#define CONFIG_CMD(dev, where)   (0x80000000 | (dev->bus->number << 16) | (dev->devfn << 8) | (where & ~3))
+#ifdef CONFIG_PCI_DIRECT
+
+#define PCI_CONF1_ADDRESS(bus, dev, fn, reg) \
+	(0x80000000 | (bus << 16) | (dev << 11) | (fn << 8) | (reg & ~3))
+
+static int pci_conf1_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
+{
+	unsigned long flags;
+
+	if (!value || (bus > 255) || (dev > 31) || (fn > 7) || (reg > 255))
+		return -EINVAL;
+
+	spin_lock_irqsave(&pci_config_lock, flags);
+
+	outl(PCI_CONF1_ADDRESS(bus, dev, fn, reg), 0xCF8);
+
+	switch (len) {
+	case 1:
+		*value = inb(0xCFC + (reg & 3));
+		break;
+	case 2:
+		*value = inw(0xCFC + (reg & 2));
+		break;
+	case 4:
+		*value = inl(0xCFC);
+		break;
+	}
+
+	spin_unlock_irqrestore(&pci_config_lock, flags);
+
+	return 0;
+}
+
+static int pci_conf1_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
+{
+	unsigned long flags;
+
+	if ((bus > 255) || (dev > 31) || (fn > 7) || (reg > 255)) 
+		return -EINVAL;
+
+	spin_lock_irqsave(&pci_config_lock, flags);
+
+	outl(PCI_CONF1_ADDRESS(bus, dev, fn, reg), 0xCF8);
+
+	switch (len) {
+	case 1:
+		outb((u8)value, 0xCFC + (reg & 3));
+		break;
+	case 2:
+		outw((u16)value, 0xCFC + (reg & 2));
+		break;
+	case 4:
+		outl((u32)value, 0xCFC);
+		break;
+	}
+
+	spin_unlock_irqrestore(&pci_config_lock, flags);
+
+	return 0;
+}
+
+#undef PCI_CONF1_ADDRESS
 
 static int pci_conf1_read_config_byte(struct pci_dev *dev, int where, u8 *value)
 {
-	outl(CONFIG_CMD(dev,where), 0xCF8);
-	*value = inb(0xCFC + (where&3));
-	return PCIBIOS_SUCCESSFUL;
+	int result; 
+	u32 data;
+
+	if (!value) 
+		return -EINVAL;
+
+	result = pci_conf1_read(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 1, &data);
+
+	*value = (u8)data;
+
+	return result;
 }
 
 static int pci_conf1_read_config_word(struct pci_dev *dev, int where, u16 *value)
 {
-	outl(CONFIG_CMD(dev,where), 0xCF8);    
-	*value = inw(0xCFC + (where&2));
-	return PCIBIOS_SUCCESSFUL;    
+	int result; 
+	u32 data;
+
+	if (!value) 
+		return -EINVAL;
+
+	result = pci_conf1_read(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 2, &data);
+
+	*value = (u16)data;
+
+	return result;
 }
 
 static int pci_conf1_read_config_dword(struct pci_dev *dev, int where, u32 *value)
 {
-	outl(CONFIG_CMD(dev,where), 0xCF8);
-	*value = inl(0xCFC);
-	return PCIBIOS_SUCCESSFUL;    
+	if (!value) 
+		return -EINVAL;
+
+	return pci_conf1_read(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 4, value);
 }
 
 static int pci_conf1_write_config_byte(struct pci_dev *dev, int where, u8 value)
 {
-	outl(CONFIG_CMD(dev,where), 0xCF8);    
-	outb(value, 0xCFC + (where&3));
-	return PCIBIOS_SUCCESSFUL;
+	return pci_conf1_write(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 1, value);
 }
 
 static int pci_conf1_write_config_word(struct pci_dev *dev, int where, u16 value)
 {
-	outl(CONFIG_CMD(dev,where), 0xCF8);
-	outw(value, 0xCFC + (where&2));
-	return PCIBIOS_SUCCESSFUL;
+	return pci_conf1_write(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 2, value);
 }
 
 static int pci_conf1_write_config_dword(struct pci_dev *dev, int where, u32 value)
 {
-	outl(CONFIG_CMD(dev,where), 0xCF8);
-	outl(value, 0xCFC);
-	return PCIBIOS_SUCCESSFUL;
+	return pci_conf1_write(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 4, value);
 }
 
-#undef CONFIG_CMD
-
 static struct pci_ops pci_direct_conf1 = {
 	pci_conf1_read_config_byte,
 	pci_conf1_read_config_word,
@@ -88,68 +168,131 @@
 	pci_conf1_write_config_dword
 };
 
+
 /*
  * Functions for accessing PCI configuration space with type 2 accesses
  */
 
-#define IOADDR(devfn, where)	((0xC000 | ((devfn & 0x78) << 5)) + where)
-#define FUNC(devfn)		(((devfn & 7) << 1) | 0xf0)
-#define SET(dev)		if (dev->devfn & 0x80) return PCIBIOS_DEVICE_NOT_FOUND;		\
-				outb(FUNC(dev->devfn), 0xCF8);					\
-				outb(dev->bus->number, 0xCFA);
+#define PCI_CONF2_ADDRESS(dev, reg)	(u16)(0xC000 | (dev << 8) | reg)
 
-static int pci_conf2_read_config_byte(struct pci_dev *dev, int where, u8 *value)
+static int pci_conf2_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
 {
-	SET(dev);
-	*value = inb(IOADDR(dev->devfn,where));
+	unsigned long flags;
+
+	if (!value || (bus > 255) || (dev > 31) || (fn > 7) || (reg > 255))
+		return -EINVAL;
+
+	if (dev & 0x10) 
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
+	spin_lock_irqsave(&pci_config_lock, flags);
+
+	outb((u8)(0xF0 | (fn << 1)), 0xCF8);
+	outb((u8)bus, 0xCFA);
+
+	switch (len) {
+	case 1:
+		*value = inb(PCI_CONF2_ADDRESS(dev, reg));
+		break;
+	case 2:
+		*value = inw(PCI_CONF2_ADDRESS(dev, reg));
+		break;
+	case 4:
+		*value = inl(PCI_CONF2_ADDRESS(dev, reg));
+		break;
+	}
+
 	outb (0, 0xCF8);
-	return PCIBIOS_SUCCESSFUL;
+
+	spin_unlock_irqrestore(&pci_config_lock, flags);
+
+	return 0;
+}
+
+static int pci_conf2_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
+{
+	unsigned long flags;
+
+	if ((bus > 255) || (dev > 31) || (fn > 7) || (reg > 255)) 
+		return -EINVAL;
+
+	if (dev & 0x10) 
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
+	spin_lock_irqsave(&pci_config_lock, flags);
+
+	outb((u8)(0xF0 | (fn << 1)), 0xCF8);
+	outb((u8)bus, 0xCFA);
+
+	switch (len) {
+	case 1:
+		outb ((u8)value, PCI_CONF2_ADDRESS(dev, reg));
+		break;
+	case 2:
+		outw ((u16)value, PCI_CONF2_ADDRESS(dev, reg));
+		break;
+	case 4:
+		outl ((u32)value, PCI_CONF2_ADDRESS(dev, reg));
+		break;
+	}
+
+	outb (0, 0xCF8);    
+
+	spin_unlock_irqrestore(&pci_config_lock, flags);
+
+	return 0;
+}
+
+#undef PCI_CONF2_ADDRESS
+
+static int pci_conf2_read_config_byte(struct pci_dev *dev, int where, u8 *value)
+{
+	int result; 
+	u32 data;
+	result = pci_conf2_read(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 1, &data);
+	*value = (u8)data;
+	return result;
 }
 
 static int pci_conf2_read_config_word(struct pci_dev *dev, int where, u16 *value)
 {
-	SET(dev);
-	*value = inw(IOADDR(dev->devfn,where));
-	outb (0, 0xCF8);
-	return PCIBIOS_SUCCESSFUL;
+	int result; 
+	u32 data;
+	result = pci_conf2_read(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 2, &data);
+	*value = (u8)data;
+	return result;
 }
 
 static int pci_conf2_read_config_dword(struct pci_dev *dev, int where, u32 *value)
 {
-	SET(dev);
-	*value = inl (IOADDR(dev->devfn,where));    
-	outb (0, 0xCF8);    
-	return PCIBIOS_SUCCESSFUL;
+	int result; 
+	u32 data;
+	result = pci_conf2_read(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 4, &data);
+	*value = (u8)data;
+	return result;
 }
 
 static int pci_conf2_write_config_byte(struct pci_dev *dev, int where, u8 value)
 {
-	SET(dev);
-	outb (value, IOADDR(dev->devfn,where));
-	outb (0, 0xCF8);    
-	return PCIBIOS_SUCCESSFUL;
+	return pci_conf2_write(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 1, value);
 }
 
 static int pci_conf2_write_config_word(struct pci_dev *dev, int where, u16 value)
 {
-	SET(dev);
-	outw (value, IOADDR(dev->devfn,where));
-	outb (0, 0xCF8);    
-	return PCIBIOS_SUCCESSFUL;
+	return pci_conf2_write(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 2, value);
 }
 
 static int pci_conf2_write_config_dword(struct pci_dev *dev, int where, u32 value)
 {
-	SET(dev);
-	outl (value, IOADDR(dev->devfn,where));    
-	outb (0, 0xCF8);    
-	return PCIBIOS_SUCCESSFUL;
+	return pci_conf2_write(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 4, value);
 }
 
-#undef SET
-#undef IOADDR
-#undef FUNC
-
 static struct pci_ops pci_direct_conf2 = {
 	pci_conf2_read_config_byte,
 	pci_conf2_read_config_word,
@@ -159,6 +302,7 @@
 	pci_conf2_write_config_dword
 };
 
+
 /*
  * Before we decide to use direct hardware access mechanisms, we try to do some
  * trivial checks to ensure it at least _seems_ to be working -- we just test
@@ -420,114 +564,176 @@
 	return (int) (ret & 0xff00) >> 8;
 }
 
+static int pci_bios_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
+{
+	unsigned long result = 0;
+	unsigned long flags;
+	unsigned long bx = ((bus << 8) | (dev << 3) | fn);
+
+	if (!value || (bus > 255) || (dev > 31) || (fn > 7) || (reg > 255))
+		return -EINVAL;
+
+	spin_lock_irqsave(&pci_config_lock, flags);
+
+	switch (len) {
+	case 1:
+		__asm__("lcall (%%esi); cld\n\t"
+			"jc 1f\n\t"
+			"xor %%ah, %%ah\n"
+			"1:"
+			: "=c" (*value),
+			  "=a" (result)
+			: "1" (PCIBIOS_READ_CONFIG_BYTE),
+			  "b" (bx),
+			  "D" ((long)reg),
+			  "S" (&pci_indirect));
+		break;
+	case 2:
+		__asm__("lcall (%%esi); cld\n\t"
+			"jc 1f\n\t"
+			"xor %%ah, %%ah\n"
+			"1:"
+			: "=c" (*value),
+			  "=a" (result)
+			: "1" (PCIBIOS_READ_CONFIG_WORD),
+			  "b" (bx),
+			  "D" ((long)reg),
+			  "S" (&pci_indirect));
+		break;
+	case 4:
+		__asm__("lcall (%%esi); cld\n\t"
+			"jc 1f\n\t"
+			"xor %%ah, %%ah\n"
+			"1:"
+			: "=c" (*value),
+			  "=a" (result)
+			: "1" (PCIBIOS_READ_CONFIG_DWORD),
+			  "b" (bx),
+			  "D" ((long)reg),
+			  "S" (&pci_indirect));
+		break;
+	}
+
+	spin_unlock_irqrestore(&pci_config_lock, flags);
+
+	return (int)((result & 0xff00) >> 8);
+}
+
+static int pci_bios_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
+{
+	unsigned long result = 0;
+	unsigned long flags;
+	unsigned long bx = ((bus << 8) | (dev << 3) | fn);
+
+	if ((bus > 255) || (dev > 31) || (fn > 7) || (reg > 255)) 
+		return -EINVAL;
+
+	spin_lock_irqsave(&pci_config_lock, flags);
+
+	switch (len) {
+	case 1:
+		__asm__("lcall (%%esi); cld\n\t"
+			"jc 1f\n\t"
+			"xor %%ah, %%ah\n"
+			"1:"
+			: "=a" (result)
+			: "0" (PCIBIOS_WRITE_CONFIG_BYTE),
+			  "c" (value),
+			  "b" (bx),
+			  "D" ((long)reg),
+			  "S" (&pci_indirect));
+		break;
+	case 2:
+		__asm__("lcall (%%esi); cld\n\t"
+			"jc 1f\n\t"
+			"xor %%ah, %%ah\n"
+			"1:"
+			: "=a" (result)
+			: "0" (PCIBIOS_WRITE_CONFIG_WORD),
+			  "c" (value),
+			  "b" (bx),
+			  "D" ((long)reg),
+			  "S" (&pci_indirect));
+		break;
+	case 4:
+		__asm__("lcall (%%esi); cld\n\t"
+			"jc 1f\n\t"
+			"xor %%ah, %%ah\n"
+			"1:"
+			: "=a" (result)
+			: "0" (PCIBIOS_WRITE_CONFIG_DWORD),
+			  "c" (value),
+			  "b" (bx),
+			  "D" ((long)reg),
+			  "S" (&pci_indirect));
+		break;
+	}
+
+	spin_unlock_irqrestore(&pci_config_lock, flags);
+
+	return (int)((result & 0xff00) >> 8);
+}
+
 static int pci_bios_read_config_byte(struct pci_dev *dev, int where, u8 *value)
 {
-	unsigned long ret;
-	unsigned long bx = (dev->bus->number << 8) | dev->devfn;
+	int result; 
+	u32 data;
 
-	__asm__("lcall (%%esi); cld\n\t"
-		"jc 1f\n\t"
-		"xor %%ah, %%ah\n"
-		"1:"
-		: "=c" (*value),
-		  "=a" (ret)
-		: "1" (PCIBIOS_READ_CONFIG_BYTE),
-		  "b" (bx),
-		  "D" ((long) where),
-		  "S" (&pci_indirect));
-	return (int) (ret & 0xff00) >> 8;
+	if (!value) 
+		return -EINVAL;
+
+	result = pci_bios_read(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 1, &data);
+
+	*value = (u8)data;
+
+	return result;
 }
 
 static int pci_bios_read_config_word(struct pci_dev *dev, int where, u16 *value)
 {
-	unsigned long ret;
-	unsigned long bx = (dev->bus->number << 8) | dev->devfn;
+	int result; 
+	u32 data;
 
-	__asm__("lcall (%%esi); cld\n\t"
-		"jc 1f\n\t"
-		"xor %%ah, %%ah\n"
-		"1:"
-		: "=c" (*value),
-		  "=a" (ret)
-		: "1" (PCIBIOS_READ_CONFIG_WORD),
-		  "b" (bx),
-		  "D" ((long) where),
-		  "S" (&pci_indirect));
-	return (int) (ret & 0xff00) >> 8;
+	if (!value) 
+		return -EINVAL;
+
+	result = pci_bios_read(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 2, &data);
+
+	*value = (u16)data;
+
+	return result;
 }
 
 static int pci_bios_read_config_dword(struct pci_dev *dev, int where, u32 *value)
 {
-	unsigned long ret;
-	unsigned long bx = (dev->bus->number << 8) | dev->devfn;
-
-	__asm__("lcall (%%esi); cld\n\t"
-		"jc 1f\n\t"
-		"xor %%ah, %%ah\n"
-		"1:"
-		: "=c" (*value),
-		  "=a" (ret)
-		: "1" (PCIBIOS_READ_CONFIG_DWORD),
-		  "b" (bx),
-		  "D" ((long) where),
-		  "S" (&pci_indirect));
-	return (int) (ret & 0xff00) >> 8;
+	if (!value) 
+		return -EINVAL;
+	
+	return pci_bios_read(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 4, value);
 }
 
 static int pci_bios_write_config_byte(struct pci_dev *dev, int where, u8 value)
 {
-	unsigned long ret;
-	unsigned long bx = (dev->bus->number << 8) | dev->devfn;
-
-	__asm__("lcall (%%esi); cld\n\t"
-		"jc 1f\n\t"
-		"xor %%ah, %%ah\n"
-		"1:"
-		: "=a" (ret)
-		: "0" (PCIBIOS_WRITE_CONFIG_BYTE),
-		  "c" (value),
-		  "b" (bx),
-		  "D" ((long) where),
-		  "S" (&pci_indirect));
-	return (int) (ret & 0xff00) >> 8;
+	return pci_bios_write(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 1, value);
 }
 
 static int pci_bios_write_config_word(struct pci_dev *dev, int where, u16 value)
 {
-	unsigned long ret;
-	unsigned long bx = (dev->bus->number << 8) | dev->devfn;
-
-	__asm__("lcall (%%esi); cld\n\t"
-		"jc 1f\n\t"
-		"xor %%ah, %%ah\n"
-		"1:"
-		: "=a" (ret)
-		: "0" (PCIBIOS_WRITE_CONFIG_WORD),
-		  "c" (value),
-		  "b" (bx),
-		  "D" ((long) where),
-		  "S" (&pci_indirect));
-	return (int) (ret & 0xff00) >> 8;
+	return pci_bios_write(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 2, value);
 }
 
 static int pci_bios_write_config_dword(struct pci_dev *dev, int where, u32 value)
 {
-	unsigned long ret;
-	unsigned long bx = (dev->bus->number << 8) | dev->devfn;
-
-	__asm__("lcall (%%esi); cld\n\t"
-		"jc 1f\n\t"
-		"xor %%ah, %%ah\n"
-		"1:"
-		: "=a" (ret)
-		: "0" (PCIBIOS_WRITE_CONFIG_DWORD),
-		  "c" (value),
-		  "b" (bx),
-		  "D" ((long) where),
-		  "S" (&pci_indirect));
-	return (int) (ret & 0xff00) >> 8;
+	return pci_bios_write(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 4, value);
 }
 
+
 /*
  * Function table for BIOS32 access
  */
@@ -981,34 +1187,47 @@
 	pci_read_bridge_bases(b);
 }
 
-/*
- * Initialization. Try all known PCI access methods. Note that we support
- * using both PCI BIOS and direct access: in such cases, we use I/O ports
- * to access config space, but we still keep BIOS order of cards to be
- * compatible with 2.0.X. This should go away some day.
- */
 
-void __init pcibios_init(void)
+void __init pcibios_config_init(void)
 {
-	struct pci_ops *bios = NULL;
-	struct pci_ops *dir = NULL;
+	/*
+	 * Try all known PCI access methods. Note that we support using 
+	 * both PCI BIOS and direct access, with a preference for direct.
+	 */
 
 #ifdef CONFIG_PCI_BIOS
-	if ((pci_probe & PCI_PROBE_BIOS) && ((bios = pci_find_bios()))) {
+	if ((pci_probe & PCI_PROBE_BIOS) 
+		&& ((pci_root_ops = pci_find_bios()))) {
 		pci_probe |= PCI_BIOS_SORT;
 		pci_bios_present = 1;
+		pci_config_read = pci_bios_read;
+		pci_config_write = pci_bios_write;
 	}
 #endif
+
 #ifdef CONFIG_PCI_DIRECT
-	if (pci_probe & (PCI_PROBE_CONF1 | PCI_PROBE_CONF2))
-		dir = pci_check_direct();
+	if ((pci_probe & (PCI_PROBE_CONF1 | PCI_PROBE_CONF2)) 
+		&& (pci_root_ops = pci_check_direct())) {
+		if (pci_root_ops == &pci_direct_conf1) {
+			pci_config_read = pci_conf1_read;
+			pci_config_write = pci_conf1_write;
+		}
+		else {
+			pci_config_read = pci_conf2_read;
+			pci_config_write = pci_conf2_write;
+		}
+	}
 #endif
-	if (dir)
-		pci_root_ops = dir;
-	else if (bios)
-		pci_root_ops = bios;
-	else {
-		printk("PCI: No PCI bus detected\n");
+
+	return;
+}
+
+void __init pcibios_init(void)
+{
+	if (!pci_root_ops)
+		pcibios_config_init();
+	if (!pci_root_ops) {
+		printk("PCI: System does not support PCI\n");
 		return;
 	}
 
diff -u --recursive --new-file v2.4.9/linux/arch/i386/kernel/setup.c linux/arch/i386/kernel/setup.c
--- v2.4.9/linux/arch/i386/kernel/setup.c	Wed Jul 25 17:10:17 2001
+++ linux/arch/i386/kernel/setup.c	Sat Sep  8 21:56:53 2001
@@ -64,6 +64,9 @@
  *
  *  VIA C3 Support.
  *  Dave Jones <davej@suse.de>, March 2001
+ *
+ *  AMD Athlon/Duron/Thunderbird bluesmoke support.
+ *  Dave Jones <davej@suse.de>, April 2001.
  */
 
 /*
@@ -93,6 +96,7 @@
 #include <linux/bootmem.h>
 #include <asm/processor.h>
 #include <linux/console.h>
+#include <asm/mtrr.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include <asm/io.h>
@@ -145,9 +149,9 @@
 
 unsigned char aux_device_present;
 
+extern void mcheck_init(struct cpuinfo_x86 *c);
 extern int root_mountflags;
 extern char _text, _etext, _edata, _end;
-extern unsigned long cpu_khz;
 
 static int disable_x86_serial_nr __initdata = 1;
 static int disable_x86_fxsr __initdata = 0;
@@ -937,7 +941,6 @@
 	 * trampoline before removing it. (see the GDT stuff)
 	 */
 	reserve_bootmem(PAGE_SIZE, PAGE_SIZE);
-	smp_alloc_memory(); /* AP processor realmode stacks in low memory*/
 #endif
 
 #ifdef CONFIG_X86_IO_APIC
@@ -946,18 +949,6 @@
 	 */
 	find_smp_config();
 #endif
-	paging_init();
-#ifdef CONFIG_X86_IO_APIC
-	/*
-	 * get boot-time SMP configuration:
-	 */
-	if (smp_found_config)
-		get_smp_config();
-#endif
-#ifdef CONFIG_X86_LOCAL_APIC
-	init_apic_mappings();
-#endif
-
 #ifdef CONFIG_BLK_DEV_INITRD
 	if (LOADER_TYPE && INITRD_START) {
 		if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
@@ -977,6 +968,26 @@
 #endif
 
 	/*
+	 * NOTE: before this point _nobody_ is allowed to allocate
+	 * any memory using the bootmem allocator.
+	 */
+
+#ifdef CONFIG_SMP
+	smp_alloc_memory(); /* AP processor realmode stacks in low memory*/
+#endif
+	paging_init();
+#ifdef CONFIG_X86_IO_APIC
+	/*
+	 * get boot-time SMP configuration:
+	 */
+	if (smp_found_config)
+		get_smp_config();
+#endif
+#ifdef CONFIG_X86_LOCAL_APIC
+	init_apic_mappings();
+#endif
+
+	/*
 	 * Request address space for all standard RAM and ROM resources
 	 * and also for regions reported as reserved by the e820.
 	 */
@@ -1088,11 +1099,18 @@
 	l2size = ecx >> 16;
 
 	/* AMD errata T13 (order #21922) */
-	if (c->x86_vendor == X86_VENDOR_AMD &&
-	    c->x86 == 6 &&
-	    c->x86_model == 3 &&
-	    c->x86_mask == 0) {
-		l2size = 64;
+	if ((c->x86_vendor == X86_VENDOR_AMD) && (c->x86 == 6)) {
+		if (c->x86_model == 3 && c->x86_mask == 0)	/* Duron Rev A0 */
+			l2size = 64;
+		if (c->x86_model == 4 &&
+			(c->x86_mask==0 || c->x86_mask==1))	/* Tbird rev A1/A2 */
+			l2size = 256;
+	}
+
+	/* VIA C3 CPUs (670-68F) need further shifting. */
+	if (c->x86_vendor == X86_VENDOR_CENTAUR && (c->x86 == 6) &&
+		((c->x86_model == 7) || (c->x86_model == 8))) {
+		l2size = l2size >> 8;
 	}
 
 	if ( l2size == 0 )
@@ -1109,7 +1127,7 @@
  *	misexecution of code under Linux. Owners of such processors should
  *	contact AMD for precise details and a CPU swap.
  *
- *	See	http://www.mygale.com/~poulot/k6bug.html
+ *	See	http://www.multimania.com/poulot/k6bug.html
  *		http://www.amd.com/K6/k6docs/revgd.html
  *
  *	The following test is erm.. interesting. AMD neglected to up
@@ -1126,6 +1144,12 @@
 	int mbytes = max_mapnr >> (20-PAGE_SHIFT);
 	int r;
 
+	/*
+	 *	FIXME: We should handle the K5 here. Set up the write
+	 *	range and also turn on MSR 83 bits 4 and 31 (write alloc,
+	 *	no bus pipeline)
+	 */
+
 	/* Bit 31 in normal CPUID used for nonstandard 3DNow ID;
 	   3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway */
 	clear_bit(0*32+31, &c->x86_capability);
@@ -1185,13 +1209,13 @@
 				if(mbytes>508)
 					mbytes=508;
 					
-				rdmsr(0xC0000082, l, h);
+				rdmsr(MSR_K6_WHCR, l, h);
 				if ((l&0x0000FFFF)==0) {
 					unsigned long flags;
 					l=(1<<0)|((mbytes/4)<<1);
 					local_irq_save(flags);
-					__asm__ __volatile__ ("wbinvd": : :"memory");
-					wrmsr(0xC0000082, l, h);
+					wbinvd();
+					wrmsr(MSR_K6_WHCR, l, h);
 					local_irq_restore(flags);
 					printk(KERN_INFO "Enabling old style K6 write allocation for %d Mb\n",
 						mbytes);
@@ -1206,13 +1230,13 @@
 				if(mbytes>4092)
 					mbytes=4092;
 
-				rdmsr(0xC0000082, l, h);
+				rdmsr(MSR_K6_WHCR, l, h);
 				if ((l&0xFFFF0000)==0) {
 					unsigned long flags;
 					l=((mbytes>>2)<<22)|(1<<16);
 					local_irq_save(flags);
-					__asm__ __volatile__ ("wbinvd": : :"memory");
-					wrmsr(0xC0000082, l, h);
+					wbinvd();
+					wrmsr(MSR_K6_WHCR, l, h);
 					local_irq_restore(flags);
 					printk(KERN_INFO "Enabling new style K6 write allocation for %d Mb\n",
 						mbytes);
@@ -1226,10 +1250,10 @@
 					set_bit(X86_FEATURE_K6_MTRR, &c->x86_capability);
 				break;
 			}
-
 			break;
 
 		case 6:	/* An Athlon/Duron. We can trust the BIOS probably */
+			mcheck_init(c);
 			break;		
 	}
 
@@ -1312,9 +1336,10 @@
 
 static void __init check_cx686_slop(struct cpuinfo_x86 *c)
 {
+	unsigned long flags;
+
 	if (Cx86_dir0_msb == 3) {
 		unsigned char ccr3, ccr5;
-		unsigned long flags;
 
 		local_irq_save(flags);
 		ccr3 = getCx86(CX86_CCR3);
@@ -1551,14 +1576,12 @@
 				name="??";
 			}
 
-			/* get FCR  */
-			rdmsr(0x107, lo, hi);
-
+			rdmsr(MSR_IDT_FCR1, lo, hi);
 			newlo=(lo|fcr_set) & (~fcr_clr);
 
 			if (newlo!=lo) {
 				printk(KERN_INFO "Centaur FCR was 0x%X now 0x%X\n", lo, newlo );
-				wrmsr(0x107, newlo, hi );
+				wrmsr(MSR_IDT_FCR1, newlo, hi );
 			} else {
 				printk(KERN_INFO "Centaur FCR is 0x%X\n",lo);
 			}
@@ -1577,14 +1600,15 @@
 				c->x86_cache_size = (cc>>24)+(dd>>24);
 			}
 			sprintf( c->x86_model_id, "WinChip %s", name );
+			mcheck_init(c);
 			break;
 
 		case 6:
 			switch (c->x86_model) {
 				case 6 ... 7:		/* Cyrix III or C3 */
-					rdmsr (0x1107, lo, hi);
+					rdmsr (MSR_VIA_FCR, lo, hi);
 					lo |= (1<<1 | 1<<7);	/* Report CX8 & enable PGE */
-					wrmsr (0x1107, lo, hi);
+					wrmsr (MSR_VIA_FCR, lo, hi);
 
 					set_bit(X86_FEATURE_CX8, &c->x86_capability);
 					set_bit(X86_FEATURE_3DNOW, &c->x86_capability);
@@ -1595,7 +1619,6 @@
 			}
 			break;
 	}
-
 }
 
 
@@ -1668,7 +1691,6 @@
 	if (c->x86_model > 2)
 		printk(" II");
 	printk("\n");
-	printk("If you have one of these please email davej@suse.de\n");
 
 	/* Unhide possibly hidden capability flags
 	   The mp6 iDragon family don't have MSRs.
@@ -1694,7 +1716,6 @@
 #ifndef CONFIG_M686
 	static int f00f_workaround_enabled = 0;
 #endif
-	extern void mcheck_init(struct cpuinfo_x86 *c);
 	char *p = NULL;
 	unsigned int l1i = 0, l1d = 0, l2 = 0, l3 = 0; /* Cache sizes */
 
@@ -1989,9 +2010,9 @@
 	    disable_x86_serial_nr ) {
 		/* Disable processor serial number */
 		unsigned long lo,hi;
-		rdmsr(0x119,lo,hi);
+		rdmsr(MSR_IA32_BBL_CR_CTL,lo,hi);
 		lo |= 0x200000;
-		wrmsr(0x119,lo,hi);
+		wrmsr(MSR_IA32_BBL_CR_CTL,lo,hi);
 		printk(KERN_NOTICE "CPU serial number disabled.\n");
 		clear_bit(X86_FEATURE_PN, &c->x86_capability);
 
diff -u --recursive --new-file v2.4.9/linux/arch/i386/kernel/signal.c linux/arch/i386/kernel/signal.c
--- v2.4.9/linux/arch/i386/kernel/signal.c	Wed Jul 25 17:10:17 2001
+++ linux/arch/i386/kernel/signal.c	Mon Sep 10 13:04:33 2001
@@ -19,6 +19,7 @@
 #include <linux/unistd.h>
 #include <linux/stddef.h>
 #include <linux/tty.h>
+#include <linux/personality.h>
 #include <asm/ucontext.h>
 #include <asm/uaccess.h>
 #include <asm/i387.h>
diff -u --recursive --new-file v2.4.9/linux/arch/i386/lib/Makefile linux/arch/i386/lib/Makefile
--- v2.4.9/linux/arch/i386/lib/Makefile	Tue Jul  3 17:08:18 2001
+++ linux/arch/i386/lib/Makefile	Mon Sep 10 07:31:30 2001
@@ -13,5 +13,6 @@
 
 obj-$(CONFIG_X86_USE_3DNOW) += mmx.o
 obj-$(CONFIG_HAVE_DEC_LOCK) += dec_and_lock.o
+obj-$(CONFIG_DEBUG_IOVIRT)  += iodebug.o
 
 include $(TOPDIR)/Rules.make
diff -u --recursive --new-file v2.4.9/linux/arch/i386/mm/fault.c linux/arch/i386/mm/fault.c
--- v2.4.9/linux/arch/i386/mm/fault.c	Tue May 15 00:16:51 2001
+++ linux/arch/i386/mm/fault.c	Fri Sep  7 19:11:12 2001
@@ -313,7 +313,7 @@
 	tsk->thread.cr2 = address;
 	tsk->thread.error_code = error_code;
 	tsk->thread.trap_no = 14;
-	info.si_code = SIGBUS;
+	info.si_signo = SIGBUS;
 	info.si_errno = 0;
 	info.si_code = BUS_ADRERR;
 	info.si_addr = (void *)address;
diff -u --recursive --new-file v2.4.9/linux/arch/m68k/amiga/config.c linux/arch/m68k/amiga/config.c
--- v2.4.9/linux/arch/m68k/amiga/config.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/m68k/amiga/config.c	Thu Sep 13 15:21:32 2001
@@ -44,22 +44,22 @@
 unsigned char amiga_psfreq;
 struct amiga_hw_present amiga_hw_present;
 
-static const char s_a500[] __initdata = "A500";
-static const char s_a500p[] __initdata = "A500+";
-static const char s_a600[] __initdata = "A600";
-static const char s_a1000[] __initdata = "A1000";
-static const char s_a1200[] __initdata = "A1200";
-static const char s_a2000[] __initdata = "A2000";
-static const char s_a2500[] __initdata = "A2500";
-static const char s_a3000[] __initdata = "A3000";
-static const char s_a3000t[] __initdata = "A3000T";
-static const char s_a3000p[] __initdata = "A3000+";
-static const char s_a4000[] __initdata = "A4000";
-static const char s_a4000t[] __initdata = "A4000T";
-static const char s_cdtv[] __initdata = "CDTV";
-static const char s_cd32[] __initdata = "CD32";
-static const char s_draco[] __initdata = "Draco";
-static const char *amiga_models[] __initdata = {
+static char s_a500[] __initdata = "A500";
+static char s_a500p[] __initdata = "A500+";
+static char s_a600[] __initdata = "A600";
+static char s_a1000[] __initdata = "A1000";
+static char s_a1200[] __initdata = "A1200";
+static char s_a2000[] __initdata = "A2000";
+static char s_a2500[] __initdata = "A2500";
+static char s_a3000[] __initdata = "A3000";
+static char s_a3000t[] __initdata = "A3000T";
+static char s_a3000p[] __initdata = "A3000+";
+static char s_a4000[] __initdata = "A4000";
+static char s_a4000t[] __initdata = "A4000T";
+static char s_cdtv[] __initdata = "CDTV";
+static char s_cd32[] __initdata = "CD32";
+static char s_draco[] __initdata = "Draco";
+static char *amiga_models[] __initdata = {
     s_a500, s_a500p, s_a600, s_a1000, s_a1200, s_a2000, s_a2500, s_a3000,
     s_a3000t, s_a3000p, s_a4000, s_a4000t, s_cdtv, s_cd32, s_draco,
 };
diff -u --recursive --new-file v2.4.9/linux/arch/mips/Makefile linux/arch/mips/Makefile
--- v2.4.9/linux/arch/mips/Makefile	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/Makefile	Sun Sep  9 10:43:02 2001
@@ -36,8 +36,9 @@
 # crossformat linking we rely on the elf2ecoff tool for format conversion.
 #
 GCCFLAGS	:= -G 0 -mno-abicalls -fno-pic
-LINKFLAGS	+= -static -G 0
+LINKFLAGS	+= -static
 MODFLAGS	+= -mlong-calls
+LD		:= $(LD) -G 0
 
 ifdef CONFIG_REMOTE_DEBUG
 CFLAGS		:= $(CFLAGS) -g
@@ -55,12 +56,18 @@
 ifdef CONFIG_CPU_R4300
 GCCFLAGS	+= -mcpu=r4300 -mips2 -Wa,--trap
 endif
+ifdef CONFIG_CPU_VR41XX
+GCCFLAGS	+= -mcpu=r4600 -mips2 -Wa,--trap
+endif
 ifdef CONFIG_CPU_R4X00
 GCCFLAGS	+= -mcpu=r4600 -mips2 -Wa,--trap
 endif
 ifdef CONFIG_CPU_MIPS32
 GCCFLAGS	+= -mcpu=r4600 -mips2 -Wa,--trap
 endif
+ifdef CONFIG_CPU_MIPS64
+GCCFLAGS	+= -mcpu=r4600 -mips2 -Wa,--trap
+endif
 ifdef CONFIG_CPU_R5000
 GCCFLAGS	+= -mcpu=r5000 -mips2 -Wa,--trap
 endif
@@ -68,7 +75,8 @@
 GCCFLAGS        += -mcpu=r5000 -mips2 -Wa,--trap
 endif
 ifdef CONFIG_CPU_NEVADA
-GCCFLAGS	+= -mcpu=r5000 -mips2 -Wa,--trap -mmad
+# Cannot use -mmad with currently recommended tools
+GCCFLAGS	+= -mcpu=r5000 -mips2 -Wa,--trap
 endif
 ifdef CONFIG_CPU_RM7000
 GCCFLAGS	+= -mcpu=r5000 -mips2 -Wa,--trap
@@ -77,11 +85,6 @@
 GCCFLAGS	+= -mcpu=sb1 -mips2 -Wa,--trap
 endif
 
-ifdef CONFIG_MIPS_FPU_EMULATOR
-CORE_FILES	+=arch/mips/math-emu/fpu_emulator.o
-SUBDIRS		+=arch/mips/math-emu
-endif
-
 GCCFLAGS	+= -pipe
 
 CFLAGS		:= -I $(TOPDIR)/include/asm/gcc $(CFLAGS) $(GCCFLAGS)
@@ -89,6 +92,12 @@
 ASFLAGS		+= $(GCCFLAGS)
 
 #
+# We unconditionally build the math emulator
+#
+CORE_FILES	+=arch/mips/math-emu/fpu_emulator.o
+SUBDIRS		+=arch/mips/math-emu
+
+#
 # Board-dependent options and extra files
 #
 ifdef CONFIG_ALGOR_P4032
@@ -229,11 +238,27 @@
 # ITE 8172 eval board with QED 5231 CPU
 #
 ifdef CONFIG_MIPS_ITE8172
-LIBS		+= arch/mips/ite-boards/qed-4n-s01b/ite.o		     \
-		   arch/mips/ite-boards/generic/it8172.o
-SUBDIRS		+= arch/mips/ite-boards/generic				     \
-		   arch/mips/ite-boards/qed-4n-s01b
-LOADADDR	+= 0x80100000
+LIBS          += arch/mips/ite-boards/qed-4n-s01b/ite.o arch/mips/ite-boards/generic/it8172.o
+SUBDIRS       += arch/mips/ite-boards/generic arch/mips/ite-boards/qed-4n-s01b
+LOADADDR      += 0x80100000
+endif
+
+#
+# Globespan IVR eval board with QED 5231 CPU
+#
+ifdef CONFIG_MIPS_IVR
+LIBS          += arch/mips/ite-boards/ivr/ivr.o arch/mips/ite-boards/generic/it8172.o
+SUBDIRS       += arch/mips/ite-boards/generic arch/mips/ite-boards/ivr
+LOADADDR      += 0x80100000
+endif
+
+#
+# Au1000 eval board
+#
+ifdef CONFIG_MIPS_PB1000
+LIBS          += arch/mips/au1000/pb1000/pb1000.o arch/mips/au1000/common/au1000.o
+SUBDIRS       += arch/mips/au1000/pb1000 arch/mips/au1000/common
+LOADADDR      += 0x80100000
 endif
 
 #
@@ -273,14 +298,6 @@
 
 vmlinux.ecoff: vmlinux
 	@$(MAKEBOOT) $@
-
-zImage: vmlinux
-	@$(MAKEBOOT) zImage
-
-compressed: zImage
-
-zdisk: vmlinux
-	@$(MAKEBOOT) zdisk
 
 archclean:
 	@$(MAKEBOOT) clean
diff -u --recursive --new-file v2.4.9/linux/arch/mips/au1000/common/Makefile linux/arch/mips/au1000/common/Makefile
--- v2.4.9/linux/arch/mips/au1000/common/Makefile	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/au1000/common/Makefile	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,31 @@
+#
+#  Copyright 2000 MontaVista Software Inc.
+#  Author: MontaVista Software, Inc.
+#     	ppopov@mvista.com or source@mvista.com
+#
+# Makefile for the Alchemy Au1000 CPU, generic files.
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+
+.S.s:
+	$(CPP) $(CFLAGS) $< -o $*.s
+.S.o:
+	$(CC) $(CFLAGS) -c $< -o $*.o
+
+all: au1000.o
+
+O_TARGET := au1000.o
+
+obj-y := prom.o dbg_io.o int-handler.o irq.o puts.o time.o reset.o
+
+obj-$(CONFIG_AU1000_UART) += serial.o             
+obj-$(CONFIG_REMOTE_DEBUG) += dbg_io.o             
+obj-$(CONFIG_BLK_DEV_INITRD) += ramdisk.o
+
+ramdisk.o: 
+	mkramobj ramdisk ramdisk.o
+
+include $(TOPDIR)/Rules.make
diff -u --recursive --new-file v2.4.9/linux/arch/mips/au1000/common/dbg_io.c linux/arch/mips/au1000/common/dbg_io.c
--- v2.4.9/linux/arch/mips/au1000/common/dbg_io.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/au1000/common/dbg_io.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,118 @@
+
+#include <linux/config.h>
+#include <asm/io.h>
+#include <asm/au1000.h>
+
+#ifdef CONFIG_REMOTE_DEBUG
+
+/*
+ * FIXME the user should be able to select the
+ * uart to be used for debugging.
+ */
+#define	DEBUG_BASE  UART2_ADDR
+/**/
+
+/* we need uint32 uint8 */
+/* #include "types.h" */
+typedef         unsigned char uint8;
+typedef         unsigned int  uint32;
+
+#define         UART16550_BAUD_2400             2400
+#define         UART16550_BAUD_4800             4800
+#define         UART16550_BAUD_9600             9600
+#define         UART16550_BAUD_19200            19200
+#define         UART16550_BAUD_38400            38400
+#define         UART16550_BAUD_57600            57600
+#define         UART16550_BAUD_115200           115200
+
+#define         UART16550_PARITY_NONE           0
+#define         UART16550_PARITY_ODD            0x08
+#define         UART16550_PARITY_EVEN           0x18
+#define         UART16550_PARITY_MARK           0x28
+#define         UART16550_PARITY_SPACE          0x38
+
+#define         UART16550_DATA_5BIT             0x0
+#define         UART16550_DATA_6BIT             0x1
+#define         UART16550_DATA_7BIT             0x2
+#define         UART16550_DATA_8BIT             0x3
+
+#define         UART16550_STOP_1BIT             0x0
+#define         UART16550_STOP_2BIT             0x4
+
+
+#define UART_RX		0	/* Receive buffer */
+#define UART_TX		4	/* Transmit buffer */
+#define UART_IER	8	/* Interrupt Enable Register */
+#define UART_IIR	0xC	/* Interrupt ID Register */
+#define UART_FCR	0x10	/* FIFO Control Register */
+#define UART_LCR	0x14	/* Line Control Register */
+#define UART_MCR	0x18	/* Modem Control Register */
+#define UART_LSR	0x1C	/* Line Status Register */
+#define UART_MSR	0x20	/* Modem Status Register */
+#define UART_CLK	0x28	/* Baud Rat4e Clock Divider */
+#define UART_MOD_CNTRL	0x100	/* Module Control */
+
+/* memory-mapped read/write of the port */
+#define UART16550_READ(y)    (inl(DEBUG_BASE + y) & 0xff)
+#define UART16550_WRITE(y,z) (outl(z&0xff, DEBUG_BASE + y))
+
+void debugInit(uint32 baud, uint8 data, uint8 parity, uint8 stop)
+{
+
+	if (UART16550_READ(UART_MOD_CNTRL) != 0x3) {
+		UART16550_WRITE(UART_MOD_CNTRL, 3);
+	}
+	cal_r4koff();
+
+	/* disable interrupts */
+	UART16550_WRITE(UART_IER, 0);
+
+	/* set up baud rate */
+	{ 
+		uint32 divisor;
+
+		/* set divisor */
+		divisor = get_au1000_uart_baud() / baud;
+		UART16550_WRITE(UART_CLK, divisor & 0xffff);
+	}
+
+	/* set data format */
+	UART16550_WRITE(UART_LCR, data | parity | stop);
+}
+
+static int remoteDebugInitialized = 0;
+
+uint8 getDebugChar(void)
+{
+	if (!remoteDebugInitialized) {
+		remoteDebugInitialized = 1;
+		debugInit(UART16550_BAUD_115200,
+			  UART16550_DATA_8BIT,
+			  UART16550_PARITY_NONE,
+			  UART16550_STOP_1BIT);
+	}
+
+	while((UART16550_READ(UART_LSR) & 0x1) == 0);
+	return UART16550_READ(UART_RX);
+}
+
+
+int putDebugChar(uint8 byte)
+{
+	int i;
+	if (!remoteDebugInitialized) {
+		remoteDebugInitialized = 1;
+		debugInit(UART16550_BAUD_115200,
+			  UART16550_DATA_8BIT,
+			  UART16550_PARITY_NONE,
+			  UART16550_STOP_1BIT);
+	}
+
+	while ((UART16550_READ(UART_LSR)&0x40) == 0);
+	UART16550_WRITE(UART_TX, byte);
+	//for (i=0;i<0xfff;i++);
+
+	return 1;
+}
+
+#endif
diff -u --recursive --new-file v2.4.9/linux/arch/mips/au1000/common/int-handler.S linux/arch/mips/au1000/common/int-handler.S
--- v2.4.9/linux/arch/mips/au1000/common/int-handler.S	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/au1000/common/int-handler.S	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: ppopov@mvista.com
+ *
+ * Interrupt dispatcher for Au1000 boards.
+ *
+ * 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 <linux/config.h>
+#include <asm/asm.h>
+#include <asm/mipsregs.h>
+#include <asm/addrspace.h>
+#include <asm/regdef.h>
+#include <asm/stackframe.h>
+
+	.text
+	.set	macro
+	.set	noat
+	.align	5
+
+NESTED(au1000_IRQ, PT_SIZE, sp)
+	SAVE_ALL
+	CLI				# Important: mark KERNEL mode !
+
+	mfc0	t0,CP0_CAUSE		# get pending interrupts
+	mfc0	t1,CP0_STATUS		# get enabled interrupts
+	and	t0,t1			# isolate allowed ones
+
+	andi	t0,0xff00		# isolate pending bits
+	beqz	t0, 3f			# spurious interrupt
+
+	andi	a0, t0, CAUSEF_IP7
+	beq	a0, zero, 1f
+	move	a0, sp
+	jal	mips_timer_interrupt
+	j	ret_from_irq
+
+1:
+	andi	a0, t0, CAUSEF_IP2	# Interrupt Controller 0, Request 0
+	beq	a0, zero, 2f	        
+	move	a0,sp  
+	jal	intc0_req0_irqdispatch
+	j	ret_from_irq
+2:
+	andi	a0, t0, CAUSEF_IP3	# Interrupt Controller 0, Request 1
+	beq	a0, zero, 3f	       
+	move	a0,sp  
+	jal	intc0_req1_irqdispatch
+	j	ret_from_irq
+3:
+	andi	a0, t0, CAUSEF_IP4	# Interrupt Controller 1, Request 0
+	beq	a0, zero, 4f	       
+	move	a0,sp  
+	jal	intc1_req0_irqdispatch
+	j	ret_from_irq
+4:
+	andi	a0, t0, CAUSEF_IP5	# Interrupt Controller 1, Request 1
+	beq	a0, zero, 5f	       
+	move	a0, sp  
+	jal	intc1_req1_irqdispatch
+	j	ret_from_irq
+
+5:	
+	move	a0, sp
+	jal	mips_spurious_interrupt
+done:
+	j	ret_from_irq
+END(au1000_IRQ)
diff -u --recursive --new-file v2.4.9/linux/arch/mips/au1000/common/irq.c linux/arch/mips/au1000/common/irq.c
--- v2.4.9/linux/arch/mips/au1000/common/irq.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/au1000/common/irq.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,471 @@
+/*
+ * BRIEF MODULE DESCRIPTION
+ *	Au1000 interrupt routines.
+ *
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: MontaVista Software, Inc.
+ *		ppopov@mvista.com or source@mvista.com
+ *
+ *  This program is free software; you can redistribute	 it and/or modify it
+ *  under  the terms of	 the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the	License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED	  ``AS	IS'' AND   ANY	EXPRESS OR IMPLIED
+ *  WARRANTIES,	  INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO	EVENT  SHALL   THE AUTHOR  BE	 LIABLE FOR ANY	  DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED	  TO, PROCUREMENT OF  SUBSTITUTE GOODS	OR SERVICES; LOSS OF
+ *  USE, DATA,	OR PROFITS; OR	BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN	 CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kernel_stat.h>
+#include <linux/module.h>
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/ioport.h>
+#include <linux/timex.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+#include <linux/delay.h>
+
+#include <asm/bitops.h>
+#include <asm/bootinfo.h>
+#include <asm/io.h>
+#include <asm/mipsregs.h>
+#include <asm/system.h>
+#include <asm/au1000.h>
+
+#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
+
+#undef DEBUG_IRQ
+#ifdef DEBUG_IRQ
+/* note: prints function name for you */
+#define DPRINTK(fmt, args...) printk("%s: " fmt, __FUNCTION__ , ## args)
+#else
+#define DPRINTK(fmt, args...)
+#endif
+
+#define EXT_INTC0_REQ0 2 /* IP 2 */
+#define EXT_INTC0_REQ1 3 /* IP 3 */
+#define EXT_INTC1_REQ0 4 /* IP 4 */
+#define EXT_INTC1_REQ1 5 /* IP 5 */
+#define MIPS_TIMER_IP  7 /* IP 7 */
+
+#ifdef CONFIG_REMOTE_DEBUG
+extern void breakpoint(void);
+#endif
+
+extern asmlinkage void au1000_IRQ(void);
+
+extern void set_debug_traps(void);
+extern irq_cpustat_t irq_stat [];
+extern irq_desc_t irq_desc[NR_IRQS];
+
+unsigned int local_bh_count[NR_CPUS];
+unsigned int local_irq_count[NR_CPUS];
+
+static void setup_local_irq(unsigned int irq, int type, int int_req);
+static unsigned int startup_irq(unsigned int irq);
+static void end_irq(unsigned int irq_nr);
+static inline void mask_and_ack_level_irq(unsigned int irq_nr);
+static inline void mask_and_ack_rise_edge_irq(unsigned int irq_nr);
+static inline void mask_and_ack_fall_edge_irq(unsigned int irq_nr);
+static inline void local_enable_irq(unsigned int irq_nr);
+static inline void local_disable_irq(unsigned int irq_nr);
+
+unsigned long spurious_interrupts;
+extern unsigned int do_IRQ(int irq, struct pt_regs *regs);
+extern void __init init_generic_irq(void);
+
+static inline void sync(void)
+{
+	__asm volatile ("sync");
+}
+
+
+/* Function for careful CP0 interrupt mask access */
+static inline void modify_cp0_intmask(unsigned clr_mask, unsigned set_mask)
+{
+	unsigned long status = read_32bit_cp0_register(CP0_STATUS);
+	status &= ~((clr_mask & 0xFF) << 8);
+	status |=   (set_mask & 0xFF) << 8;
+	write_32bit_cp0_register(CP0_STATUS, status);
+}
+
+
+static inline void mask_cpu_irq_input(unsigned int irq_nr)
+{
+	modify_cp0_intmask(irq_nr, 0);
+}
+
+
+static inline void unmask_cpu_irq_input(unsigned int irq_nr)
+{
+	modify_cp0_intmask(0, irq_nr);
+}
+
+
+static void disable_cpu_irq_input(unsigned int irq_nr)
+{
+	unsigned long flags;
+
+	save_and_cli(flags);
+	mask_cpu_irq_input(irq_nr);
+	restore_flags(flags);
+}
+
+
+static void enable_cpu_irq_input(unsigned int irq_nr)
+{
+	unsigned long flags;
+
+	save_and_cli(flags);
+	unmask_cpu_irq_input(irq_nr);
+	restore_flags(flags);
+}
+
+
+static void setup_local_irq(unsigned int irq_nr, int type, int int_req)
+{
+	/* Config2[n], Config1[n], Config0[n] */
+	if (irq_nr > AU1000_LAST_INTC0_INT) {
+		switch (type) {
+			case INTC_INT_RISE_EDGE: /* 0:0:1 */
+				outl(1<<irq_nr,INTC1_CONFIG2_CLEAR);
+				outl(1<<irq_nr, INTC1_CONFIG1_CLEAR);
+				outl(1<<irq_nr, INTC1_CONFIG0_SET);
+				break;
+			case INTC_INT_FALL_EDGE: /* 0:1:0 */
+				outl(1<<irq_nr, INTC1_CONFIG2_CLEAR);
+				outl(1<<irq_nr, INTC1_CONFIG1_SET);
+				outl(1<<irq_nr, INTC1_CONFIG0_CLEAR);
+				break;
+			case INTC_INT_HIGH_LEVEL: /* 1:0:1 */
+				outl(1<<irq_nr, INTC1_CONFIG2_SET);
+				outl(1<<irq_nr, INTC1_CONFIG1_CLEAR);
+				outl(1<<irq_nr, INTC1_CONFIG0_SET);
+				break;
+			case INTC_INT_LOW_LEVEL: /* 1:1:0 */
+				outl(1<<irq_nr, INTC1_CONFIG2_SET);
+				outl(1<<irq_nr, INTC1_CONFIG1_SET);
+				outl(1<<irq_nr, INTC1_CONFIG0_CLEAR);
+				break;
+			case INTC_INT_DISABLED: /* 0:0:0 */
+				outl(1<<irq_nr, INTC1_CONFIG0_CLEAR);
+				outl(1<<irq_nr, INTC1_CONFIG1_CLEAR);
+				outl(1<<irq_nr, INTC1_CONFIG2_CLEAR);
+				break;
+			default: /* disable the interrupt */
+				printk("unexpected int type %d (irq %d)\n", type, irq_nr);
+				outl(1<<irq_nr, INTC1_CONFIG0_CLEAR);
+				outl(1<<irq_nr, INTC1_CONFIG1_CLEAR);
+				outl(1<<irq_nr, INTC1_CONFIG2_CLEAR);
+				return;
+		}
+		if (int_req) /* assign to interrupt request 1 */
+			outl(1<<irq_nr, INTC1_ASSIGN_REQ_CLEAR);
+		else	     /* assign to interrupt request 0 */
+			outl(1<<irq_nr, INTC1_ASSIGN_REQ_SET);
+		outl(1<<irq_nr, INTC1_SOURCE_SET);
+		outl(1<<irq_nr, INTC1_MASK_CLEAR);
+	}
+	else {
+		switch (type) {
+			case INTC_INT_RISE_EDGE: /* 0:0:1 */
+				outl(1<<irq_nr,INTC0_CONFIG2_CLEAR);
+				outl(1<<irq_nr, INTC0_CONFIG1_CLEAR);
+				outl(1<<irq_nr, INTC0_CONFIG0_SET);
+				break;
+			case INTC_INT_FALL_EDGE: /* 0:1:0 */
+				outl(1<<irq_nr, INTC0_CONFIG2_CLEAR);
+				outl(1<<irq_nr, INTC0_CONFIG1_SET);
+				outl(1<<irq_nr, INTC0_CONFIG0_CLEAR);
+				break;
+			case INTC_INT_HIGH_LEVEL: /* 1:0:1 */
+				outl(1<<irq_nr, INTC0_CONFIG2_SET);
+				outl(1<<irq_nr, INTC0_CONFIG1_CLEAR);
+				outl(1<<irq_nr, INTC0_CONFIG0_SET);
+				break;
+			case INTC_INT_LOW_LEVEL: /* 1:1:0 */
+				outl(1<<irq_nr, INTC0_CONFIG2_SET);
+				outl(1<<irq_nr, INTC0_CONFIG1_SET);
+				outl(1<<irq_nr, INTC0_CONFIG0_CLEAR);
+				break;
+			case INTC_INT_DISABLED: /* 0:0:0 */
+				outl(1<<irq_nr, INTC0_CONFIG0_CLEAR);
+				outl(1<<irq_nr, INTC0_CONFIG1_CLEAR);
+				outl(1<<irq_nr, INTC0_CONFIG2_CLEAR);
+				break;
+			default: /* disable the interrupt */
+				printk("unexpected int type %d (irq %d)\n", type, irq_nr);
+				outl(1<<irq_nr, INTC0_CONFIG0_CLEAR);
+				outl(1<<irq_nr, INTC0_CONFIG1_CLEAR);
+				outl(1<<irq_nr, INTC0_CONFIG2_CLEAR);
+				return;
+		}
+		if (int_req) /* assign to interrupt request 1 */
+			outl(1<<irq_nr, INTC0_ASSIGN_REQ_CLEAR);
+		else	     /* assign to interrupt request 0 */
+			outl(1<<irq_nr, INTC0_ASSIGN_REQ_SET);
+		outl(1<<irq_nr, INTC0_SOURCE_SET);
+		outl(1<<irq_nr, INTC0_MASK_CLEAR);
+	}
+	sync();
+}
+
+
+static unsigned int startup_irq(unsigned int irq_nr)
+{
+	local_enable_irq(irq_nr);
+	return 0; 
+}
+
+
+static void shutdown_irq(unsigned int irq_nr)
+{
+	local_disable_irq(irq_nr);
+	return;
+}
+
+
+static inline void local_enable_irq(unsigned int irq_nr)
+{
+	if (irq_nr > AU1000_LAST_INTC0_INT) {
+		outl(1<<irq_nr, INTC1_MASK_SET);
+	}
+	else {
+		outl(1<<irq_nr, INTC0_MASK_SET);
+	}
+	sync();
+}
+
+
+static inline void local_disable_irq(unsigned int irq_nr)
+{
+	if (irq_nr > AU1000_LAST_INTC0_INT) {
+		outl(1<<irq_nr, INTC1_MASK_CLEAR);
+	}
+	else {
+		outl(1<<irq_nr, INTC0_MASK_CLEAR);
+	}
+	sync();
+}
+
+
+static inline void mask_and_ack_rise_edge_irq(unsigned int irq_nr)
+{
+	if (irq_nr > AU1000_LAST_INTC0_INT) {
+		outl(1<<irq_nr, INTC1_R_EDGE_DETECT_CLEAR);
+		outl(1<<irq_nr, INTC1_MASK_CLEAR);
+	}
+	else {
+		outl(1<<irq_nr, INTC0_R_EDGE_DETECT_CLEAR);
+		outl(1<<irq_nr, INTC0_MASK_CLEAR);
+	}
+	sync();
+}
+
+
+static inline void mask_and_ack_fall_edge_irq(unsigned int irq_nr)
+{
+	if (irq_nr > AU1000_LAST_INTC0_INT) {
+		outl(1<<irq_nr, INTC1_F_EDGE_DETECT_CLEAR);
+		outl(1<<irq_nr, INTC1_MASK_CLEAR);
+	}
+	else {
+		outl(1<<irq_nr, INTC0_F_EDGE_DETECT_CLEAR);
+		outl(1<<irq_nr, INTC0_MASK_CLEAR);
+	}
+}
+
+
+static inline void mask_and_ack_level_irq(unsigned int irq_nr)
+{
+	local_disable_irq(irq_nr);
+	sync();
+	return;
+}
+
+
+static void end_irq(unsigned int irq_nr)
+{
+	if (!(irq_desc[irq_nr].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		local_enable_irq(irq_nr);
+	else
+		printk("warning: end_irq %d did not enable\n", irq_nr);
+}
+
+
+static struct hw_interrupt_type rise_edge_irq_type = {
+	"Au1000 Rise Edge",
+	startup_irq,
+	shutdown_irq,
+	local_enable_irq,
+	local_disable_irq,
+	mask_and_ack_rise_edge_irq,
+	end_irq,
+	NULL
+};
+
+
+static struct hw_interrupt_type fall_edge_irq_type = {
+	"Au1000 Fall Edge",
+	startup_irq,
+	shutdown_irq,
+	local_enable_irq,
+	local_disable_irq,
+	mask_and_ack_fall_edge_irq,
+	end_irq,
+	NULL
+};
+
+
+static struct hw_interrupt_type level_irq_type = {
+	"Au1000 Level",
+	startup_irq,
+	shutdown_irq,
+	local_enable_irq,
+	local_disable_irq,
+	mask_and_ack_level_irq,
+	end_irq,
+	NULL
+};
+
+
+void enable_cpu_timer(void)
+{
+	enable_cpu_irq_input(1<<MIPS_TIMER_IP); /* timer interrupt */
+}
+
+
+void __init init_IRQ(void)
+{
+	int i;
+	unsigned long cp0_status;
+
+	cp0_status = read_32bit_cp0_register(CP0_STATUS);
+	memset(irq_desc, 0, sizeof(irq_desc));
+	set_except_vector(0, au1000_IRQ);
+
+	init_generic_irq();
+	
+	/* 
+	 * Setup high priority interrupts on int_request0; low priority on
+	 * int_request1
+	 */
+	for (i = 0; i <= NR_IRQS; i++) {
+		switch (i) {
+			case AU1000_MAC0_DMA_INT:
+			case AU1000_MAC1_DMA_INT:
+				setup_local_irq(i, INTC_INT_HIGH_LEVEL, 0);
+				irq_desc[i].handler = &level_irq_type;
+				break;
+			default: /* active high, level interrupt */
+				setup_local_irq(i, INTC_INT_HIGH_LEVEL, 1);
+				irq_desc[i].handler = &level_irq_type;
+				break;
+		}
+	}
+
+	set_cp0_status(ALLINTS);
+#ifdef CONFIG_REMOTE_DEBUG
+	/* If local serial I/O used for debug port, enter kgdb at once */
+	puts("Waiting for kgdb to connect...");
+	set_debug_traps();
+	breakpoint(); 
+#endif
+}
+
+
+void mips_spurious_interrupt(struct pt_regs *regs)
+{
+	spurious_interrupts++;
+}
+
+
+void intc0_req0_irqdispatch(struct pt_regs *regs)
+{
+	int irq = 0, i;
+	unsigned long int_request;
+
+	int_request = inl(INTC0_REQ0_INT);
+
+	if (!int_request) return;
+
+	for (i=0; i<32; i++) {
+		if ((int_request & 0x1)) {
+			do_IRQ(irq, regs);
+		}
+		irq++;
+		int_request >>= 1;
+	}
+}
+
+
+void intc0_req1_irqdispatch(struct pt_regs *regs)
+{
+	int irq = 0, i;
+	unsigned long int_request;
+
+	int_request = inl(INTC0_REQ1_INT);
+
+	if (!int_request) return;
+
+	for (i=0; i<32; i++) {
+		if ((int_request & 0x1)) {
+			do_IRQ(irq, regs);
+		}
+		irq++;
+		int_request >>= 1;
+	}
+}
+
+
+void intc1_req0_irqdispatch(struct pt_regs *regs)
+{
+	int irq = 0, i;
+	unsigned long int_request;
+
+	int_request = inl(INTC1_REQ0_INT);
+
+	if (!int_request) return;
+
+	for (i=0; i<32; i++) {
+		if ((int_request & 0x1)) {
+			do_IRQ(irq, regs);
+		}
+		irq++;
+		int_request >>= 1;
+	}
+}
+
+
+void intc1_req1_irqdispatch(struct pt_regs *regs)
+{
+	int irq = 0, i;
+	unsigned long int_request;
+
+	int_request = inl(INTC1_REQ1_INT);
+
+	if (!int_request) return;
+
+	for (i=0; i<32; i++) {
+		if ((int_request & 0x1)) {
+			do_IRQ(irq, regs);
+		}
+		irq++;
+		int_request >>= 1;
+	}
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/au1000/common/prom.c linux/arch/mips/au1000/common/prom.c
--- v2.4.9/linux/arch/mips/au1000/common/prom.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/au1000/common/prom.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,120 @@
+/*
+ *
+ * BRIEF MODULE DESCRIPTION
+ *    PROM library initialisation code, assuming a version of
+ *    pmon is the boot code.
+ *
+ * Copyright 2000 MontaVista Software Inc.
+ * Author: MontaVista Software, Inc.
+ *         	ppopov@mvista.com or source@mvista.com
+ *
+ * This file was derived from Carsten Langgaard's 
+ * arch/mips/mips-boards/xx files.
+ *
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 1999,2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/string.h>
+
+#include <asm/bootinfo.h>
+
+/* #define DEBUG_CMDLINE */
+
+char arcs_cmdline[COMMAND_LINE_SIZE];
+int prom_argc;
+char **prom_argv, **prom_envp;
+
+typedef struct {
+	char *name;
+/*	char *val; */
+} t_env_var;
+
+
+char * __init prom_getcmdline(void)
+{
+	return &(arcs_cmdline[0]);
+}
+
+void  __init prom_init_cmdline(void)
+{
+	char *cp;
+	int actr;
+
+	actr = 1; /* Always ignore argv[0] */
+
+	cp = &(arcs_cmdline[0]);
+	while(actr < prom_argc) {
+	        strcpy(cp, prom_argv[actr]);
+		cp += strlen(prom_argv[actr]);
+		*cp++ = ' ';
+		actr++;
+	}
+	if (cp != &(arcs_cmdline[0])) /* get rid of trailing space */
+		--cp;
+	*cp = '\0';
+
+}
+
+
+char *prom_getenv(char *envname)
+{
+	/*
+	 * Return a pointer to the given environment variable.
+	 * Environment variables are stored in the form of "memsize=64".
+	 */
+
+	t_env_var *env = (t_env_var *)prom_envp;
+	int i;
+
+	i = strlen(envname);
+
+	while(env->name) {
+		if(strncmp(envname, env->name, i) == 0) {
+			return(env->name + strlen(envname) + 1);
+		}
+		env++;
+	}
+	return(NULL);
+}
+
+static inline unsigned char str2hexnum(unsigned char c)
+{
+	if(c >= '0' && c <= '9')
+	return c - '0';
+	if(c >= 'a' && c <= 'f')
+	return c - 'a' + 10;
+	return 0; /* foo */
+}
+
+int __init page_is_ram(unsigned long pagenr)
+{
+	return 1;
+}
+
+void prom_free_prom_memory (void)
+{
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/au1000/common/puts.c linux/arch/mips/au1000/common/puts.c
--- v2.4.9/linux/arch/mips/au1000/common/puts.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/au1000/common/puts.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,144 @@
+/*
+ *
+ * BRIEF MODULE DESCRIPTION
+ *	Low level uart routines to directly access a 16550 uart.
+ *
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: MontaVista Software, Inc.
+ *         	ppopov@mvista.com or source@mvista.com
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/types.h>
+
+#define SERIAL_BASE   0xB1100000 /* au1000, uart 0 */
+#define SER_CMD       0x7
+#define SER_DATA      0x1
+#define TX_BUSY       0x20
+
+#define TIMEOUT       0xffffff
+#define SLOW_DOWN
+
+static const char digits[16] = "0123456789abcdef";
+static volatile unsigned long * const com1 = (unsigned char *)SERIAL_BASE;
+
+
+#ifdef SLOW_DOWN
+static inline void slow_down()
+{
+    int k;
+    for (k=0; k<10000; k++);
+}
+#else
+#define slow_down()
+#endif
+
+void
+putch(const unsigned char c)
+{
+    unsigned char ch;
+    int i = 0;
+
+    do {
+        ch = com1[SER_CMD];
+        slow_down();
+        i++;
+        if (i>TIMEOUT) {
+            break;
+        }
+    } while (0 == (ch & TX_BUSY));
+    com1[SER_DATA] = c;
+}
+
+void
+puts(unsigned char *cp)
+{
+    unsigned char ch;
+    int i = 0;
+
+    while (*cp) {
+        do {
+             ch = com1[SER_CMD];
+            slow_down();
+            i++;
+            if (i>TIMEOUT) {
+                break;
+            }
+        } while (0 == (ch & TX_BUSY));
+        com1[SER_DATA] = *cp++;
+    }
+    putch('\r');
+    putch('\n');
+}
+
+void
+fputs(unsigned char *cp)
+{
+    unsigned char ch;
+    int i = 0;
+
+    while (*cp) {
+
+        do {
+             ch = com1[SER_CMD];
+             slow_down();
+            i++;
+            if (i>TIMEOUT) {
+                break;
+            }
+        } while (0 == (ch & TX_BUSY));
+        com1[SER_DATA] = *cp++;
+    }
+}
+
+
+void
+put64(uint64_t ul)
+{
+    int cnt;
+    unsigned ch;
+
+    cnt = 16;            /* 16 nibbles in a 64 bit long */
+    putch('0');
+    putch('x');
+    do {
+        cnt--;
+        ch = (unsigned char)(ul >> cnt * 4) & 0x0F;
+                putch(digits[ch]);
+    } while (cnt > 0);
+}
+
+void
+put32(unsigned u)
+{
+    int cnt;
+    unsigned ch;
+
+    cnt = 8;            /* 8 nibbles in a 32 bit long */
+    putch('0');
+    putch('x');
+    do {
+        cnt--;
+        ch = (unsigned char)(u >> cnt * 4) & 0x0F;
+                putch(digits[ch]);
+    } while (cnt > 0);
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/au1000/common/reset.c linux/arch/mips/au1000/common/reset.c
--- v2.4.9/linux/arch/mips/au1000/common/reset.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/au1000/common/reset.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,60 @@
+/*
+ *
+ * BRIEF MODULE DESCRIPTION
+ *	Au1000 reset routines.
+ *
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: MontaVista Software, Inc.
+ *         	ppopov@mvista.com or source@mvista.com
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <asm/io.h>
+#include <asm/pgtable.h>
+#include <asm/processor.h>
+#include <asm/reboot.h>
+#include <asm/system.h>
+
+void au1000_restart(char *command)
+{
+	set_cp0_status(ST0_BEV | ST0_ERL);
+	set_cp0_config(CONF_CM_UNCACHED);
+	flush_cache_all();
+	write_32bit_cp0_register(CP0_WIRED, 0);
+	__asm__ __volatile__("jr\t%0"::"r"(0xbfc00000));
+}
+
+void au1000_halt(void)
+{
+	printk(KERN_NOTICE "\n** You can safely turn off the power\n");
+	while (1)
+		__asm__(".set\tmips3\n\t"
+	                "wait\n\t"
+			".set\tmips0");
+}
+
+void au1000_power_off(void)
+{
+	au1000_halt();
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/au1000/common/serial.c linux/arch/mips/au1000/common/serial.c
--- v2.4.9/linux/arch/mips/au1000/common/serial.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/au1000/common/serial.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,3100 @@
+/*
+ *
+ * BRIEF MODULE DESCRIPTION
+ *	Au1000 serial port driver.
+ *
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: MontaVista Software, Inc.
+ *         	ppopov@mvista.com or source@mvista.com
+ *
+ *  Derived almost entirely from drivers/char/serial.c:
+ *
+ *  Copyright (C) 1991, 1992  Linus Torvalds
+ *  Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 
+ * 		1998, 1999  Theodore Ts'o
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+static char *serial_version = "1.01";
+static char *serial_revdate = "2001-02-08";
+
+
+#include <linux/config.h>
+#include <linux/version.h>
+
+#undef SERIAL_PARANOIA_CHECK
+#define CONFIG_SERIAL_NOPAUSE_IO
+#define SERIAL_DO_RESTART
+
+
+/* Set of debugging defines */
+
+#undef SERIAL_DEBUG_INTR
+#undef SERIAL_DEBUG_OPEN
+#undef SERIAL_DEBUG_FLOW
+#undef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
+#undef SERIAL_DEBUG_PCI
+#undef SERIAL_DEBUG_AUTOCONF
+
+#ifdef MODULE
+#undef CONFIG_AU1000_SERIAL_CONSOLE
+#endif
+
+#define CONFIG_SERIAL_RSA
+
+#define RS_STROBE_TIME (10*HZ)
+#define RS_ISR_PASS_LIMIT 256
+  
+/*
+ * End of serial driver configuration section.
+ */
+
+#ifdef MODVERSIONS
+#include <linux/modversions.h>
+#endif
+#include <linux/module.h>
+
+#include <linux/types.h>
+#ifdef LOCAL_HEADERS
+#include "serial_local.h"
+#else
+#include <linux/serial.h>
+#include <linux/serialP.h>
+#include <asm/au1000.h>
+#include <asm/serial.h>
+#define LOCAL_VERSTRING ""
+#endif
+
+#include <linux/errno.h>
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/timer.h>
+#include <linux/interrupt.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/major.h>
+#include <linux/string.h>
+#include <linux/fcntl.h>
+#include <linux/ptrace.h>
+#include <linux/ioport.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <asm/uaccess.h>
+#include <linux/delay.h>
+#ifdef CONFIG_AU1000_SERIAL_CONSOLE
+#include <linux/console.h>
+#endif
+#ifdef CONFIG_MAGIC_SYSRQ
+#include <linux/sysrq.h>
+#endif
+
+#include <asm/system.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/bitops.h>
+
+#ifdef CONFIG_MAC_SERIAL
+#define SERIAL_DEV_OFFSET	2
+#else
+#define SERIAL_DEV_OFFSET	0
+#endif
+
+#ifdef SERIAL_INLINE
+#define _INLINE_ inline
+#else
+#define _INLINE_
+#endif
+
+static char *serial_name = "Serial driver";
+
+static DECLARE_TASK_QUEUE(tq_serial);
+
+static struct tty_driver serial_driver, callout_driver;
+static int serial_refcount;
+
+static struct timer_list serial_timer;
+
+extern unsigned long get_au1000_uart_baud(void);
+
+/* serial subtype definitions */
+#ifndef SERIAL_TYPE_NORMAL
+#define SERIAL_TYPE_NORMAL	1
+#define SERIAL_TYPE_CALLOUT	2
+#endif
+
+/* number of characters left in xmit buffer before we ask for more */
+#define WAKEUP_CHARS 256
+
+/*
+ * IRQ_timeout		- How long the timeout should be for each IRQ
+ * 				should be after the IRQ has been active.
+ */
+
+static struct async_struct *IRQ_ports[NR_IRQS];
+static int IRQ_timeout[NR_IRQS];
+#ifdef CONFIG_AU1000_SERIAL_CONSOLE
+static struct console sercons;
+static int lsr_break_flag;
+#endif
+#if defined(CONFIG_AU1000_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+static unsigned long break_pressed; /* break, really ... */
+#endif
+
+static void autoconfig(struct serial_state * state);
+static void change_speed(struct async_struct *info, struct termios *old);
+static void rs_wait_until_sent(struct tty_struct *tty, int timeout);
+
+/*
+ * Here we define the default xmit fifo size used for each type of
+ * UART
+ */
+static struct serial_uart_config uart_config[] = {
+	{ "unknown", 1, 0 }, 
+	{ "8250", 1, 0 }, 
+	{ "16450", 1, 0 }, 
+	{ "16550", 1, 0 }, 
+	{ 0, 0}
+};
+
+
+static struct serial_state rs_table[RS_TABLE_SIZE] = {
+	SERIAL_PORT_DFNS	/* Defined in serial.h */
+};
+
+#define NR_PORTS	(sizeof(rs_table)/sizeof(struct serial_state))
+
+#ifndef PREPARE_FUNC
+#define PREPARE_FUNC(dev)  (dev->prepare)
+#define ACTIVATE_FUNC(dev)  (dev->activate)
+#define DEACTIVATE_FUNC(dev)  (dev->deactivate)
+#endif
+
+#define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8)
+
+static struct tty_struct *serial_table[NR_PORTS];
+static struct termios *serial_termios[NR_PORTS];
+static struct termios *serial_termios_locked[NR_PORTS];
+
+
+#if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT)
+#define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \
+ kdevname(tty->device), (info->flags), serial_refcount,info->count,tty->count,s)
+#else
+#define DBG_CNT(s)
+#endif
+
+/*
+ * tmp_buf is used as a temporary buffer by serial_write.  We need to
+ * lock it in case the copy_from_user blocks while swapping in a page,
+ * and some other program tries to do a serial write at the same time.
+ * Since the lock will only come under contention when the system is
+ * swapping and available memory is low, it makes sense to share one
+ * buffer across all the serial ports, since it significantly saves
+ * memory if large numbers of serial ports are open.
+ */
+static unsigned char *tmp_buf;
+#ifdef DECLARE_MUTEX
+static DECLARE_MUTEX(tmp_buf_sem);
+#else
+static struct semaphore tmp_buf_sem = MUTEX;
+#endif
+
+
+static inline int serial_paranoia_check(struct async_struct *info,
+					kdev_t device, const char *routine)
+{
+#ifdef SERIAL_PARANOIA_CHECK
+	static const char *badmagic =
+		"Warning: bad magic number for serial struct (%s) in %s\n";
+	static const char *badinfo =
+		"Warning: null async_struct for (%s) in %s\n";
+
+	if (!info) {
+		printk(badinfo, kdevname(device), routine);
+		return 1;
+	}
+	if (info->magic != SERIAL_MAGIC) {
+		printk(badmagic, kdevname(device), routine);
+		return 1;
+	}
+#endif
+	return 0;
+}
+
+
+static _INLINE_ unsigned int serial_in(struct async_struct *info, int offset)
+{
+	return (inl(info->port+offset) & 0xff);
+}
+
+static _INLINE_ void serial_out(struct async_struct *info, int offset, int value)
+{
+	outl(value & 0xff, info->port+offset);
+}
+
+
+/*
+ * We used to support using pause I/O for certain machines.  We
+ * haven't supported this for a while, but just in case it's badly
+ * needed for certain old 386 machines, I've left these #define's
+ * in....
+ */
+#define serial_inp(info, offset)		serial_in(info, offset)
+#define serial_outp(info, offset, value)	serial_out(info, offset, value)
+
+
+/*
+ * ------------------------------------------------------------
+ * rs_stop() and rs_start()
+ *
+ * This routines are called before setting or resetting tty->stopped.
+ * They enable or disable transmitter interrupts, as necessary.
+ * ------------------------------------------------------------
+ */
+static void rs_stop(struct tty_struct *tty)
+{
+	struct async_struct *info = (struct async_struct *)tty->driver_data;
+	unsigned long flags;
+
+	if (serial_paranoia_check(info, tty->device, "rs_stop"))
+		return;
+	
+	save_flags(flags); cli();
+	if (info->IER & UART_IER_THRI) {
+		info->IER &= ~UART_IER_THRI;
+		serial_out(info, UART_IER, info->IER);
+	}
+	restore_flags(flags);
+}
+
+static void rs_start(struct tty_struct *tty)
+{
+	struct async_struct *info = (struct async_struct *)tty->driver_data;
+	unsigned long flags;
+	
+	if (serial_paranoia_check(info, tty->device, "rs_start"))
+		return;
+	
+	save_flags(flags); cli();
+	if (info->xmit.head != info->xmit.tail
+	    && info->xmit.buf
+	    && !(info->IER & UART_IER_THRI)) {
+		info->IER |= UART_IER_THRI;
+		serial_out(info, UART_IER, info->IER);
+	}
+	restore_flags(flags);
+}
+
+/*
+ * ----------------------------------------------------------------------
+ *
+ * Here starts the interrupt handling routines.  All of the following
+ * subroutines are declared as inline and are folded into
+ * rs_interrupt().  They were separated out for readability's sake.
+ *
+ * Note: rs_interrupt() is a "fast" interrupt, which means that it
+ * runs with interrupts turned off.  People who may want to modify
+ * rs_interrupt() should try to keep the interrupt handler as fast as
+ * possible.  After you are done making modifications, it is not a bad
+ * idea to do:
+ * 
+ * gcc -S -DKERNEL -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer serial.c
+ *
+ * and look at the resulting assemble code in serial.s.
+ *
+ * 				- Ted Ts'o (tytso@mit.edu), 7-Mar-93
+ * -----------------------------------------------------------------------
+ */
+
+/*
+ * This routine is used by the interrupt handler to schedule
+ * processing in the software interrupt portion of the driver.
+ */
+static _INLINE_ void rs_sched_event(struct async_struct *info,
+				  int event)
+{
+	info->event |= 1 << event;
+	queue_task(&info->tqueue, &tq_serial);
+	mark_bh(SERIAL_BH);
+}
+
+static _INLINE_ void receive_chars(struct async_struct *info,
+				 int *status, struct pt_regs * regs)
+{
+	struct tty_struct *tty = info->tty;
+	unsigned char ch;
+	int ignored = 0;
+	struct	async_icount *icount;
+
+	icount = &info->state->icount;
+	do {
+		ch = serial_inp(info, UART_RX);
+		if (tty->flip.count >= TTY_FLIPBUF_SIZE)
+			goto ignore_char;
+		*tty->flip.char_buf_ptr = ch;
+		icount->rx++;
+		
+#ifdef SERIAL_DEBUG_INTR
+		printk("DR%02x:%02x...", ch, *status);
+#endif
+		*tty->flip.flag_buf_ptr = 0;
+		if (*status & (UART_LSR_BI | UART_LSR_PE |
+			       UART_LSR_FE | UART_LSR_OE)) {
+			/*
+			 * For statistics only
+			 */
+			if (*status & UART_LSR_BI) {
+				*status &= ~(UART_LSR_FE | UART_LSR_PE);
+				icount->brk++;
+				/*
+				 * We do the SysRQ and SAK checking
+				 * here because otherwise the break
+				 * may get masked by ignore_status_mask
+				 * or read_status_mask.
+				 */
+#if defined(CONFIG_AU1000_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+				if (info->line == sercons.index) {
+					if (!break_pressed) {
+						break_pressed = jiffies;
+						goto ignore_char;
+					}
+					break_pressed = 0;
+				}
+#endif
+				if (info->flags & ASYNC_SAK)
+					do_SAK(tty);
+			} else if (*status & UART_LSR_PE)
+				icount->parity++;
+			else if (*status & UART_LSR_FE)
+				icount->frame++;
+			if (*status & UART_LSR_OE)
+				icount->overrun++;
+
+			/*
+			 * Now check to see if character should be
+			 * ignored, and mask off conditions which
+			 * should be ignored.
+			 */
+			if (*status & info->ignore_status_mask) {
+				if (++ignored > 100)
+					break;
+				goto ignore_char;
+			}
+			*status &= info->read_status_mask;
+
+#ifdef CONFIG_AU1000_SERIAL_CONSOLE
+			if (info->line == sercons.index) {
+				/* Recover the break flag from console xmit */
+				*status |= lsr_break_flag;
+				lsr_break_flag = 0;
+			}
+#endif
+			if (*status & (UART_LSR_BI)) {
+#ifdef SERIAL_DEBUG_INTR
+				printk("handling break....");
+#endif
+				*tty->flip.flag_buf_ptr = TTY_BREAK;
+			} else if (*status & UART_LSR_PE)
+				*tty->flip.flag_buf_ptr = TTY_PARITY;
+			else if (*status & UART_LSR_FE)
+				*tty->flip.flag_buf_ptr = TTY_FRAME;
+			if (*status & UART_LSR_OE) {
+				/*
+				 * Overrun is special, since it's
+				 * reported immediately, and doesn't
+				 * affect the current character
+				 */
+				tty->flip.count++;
+				tty->flip.flag_buf_ptr++;
+				tty->flip.char_buf_ptr++;
+				*tty->flip.flag_buf_ptr = TTY_OVERRUN;
+				if (tty->flip.count >= TTY_FLIPBUF_SIZE)
+					goto ignore_char;
+			}
+		}
+#if defined(CONFIG_AU1000_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+		if (break_pressed && info->line == sercons.index) {
+			if (ch != 0 &&
+			    time_before(jiffies, break_pressed + HZ*5)) {
+				handle_sysrq(ch, regs, NULL, NULL);
+				break_pressed = 0;
+				goto ignore_char;
+			}
+			break_pressed = 0;
+		}
+#endif
+		tty->flip.flag_buf_ptr++;
+		tty->flip.char_buf_ptr++;
+		tty->flip.count++;
+	ignore_char:
+		*status = serial_inp(info, UART_LSR);
+	} while (*status & UART_LSR_DR);
+	tty_flip_buffer_push(tty);
+}
+
+static _INLINE_ void transmit_chars(struct async_struct *info, int *intr_done)
+{
+	int count;
+
+	if (info->x_char) {
+		serial_outp(info, UART_TX, info->x_char);
+		info->state->icount.tx++;
+		info->x_char = 0;
+		if (intr_done)
+			*intr_done = 0;
+		return;
+	}
+	if (info->xmit.head == info->xmit.tail
+	    || info->tty->stopped
+	    || info->tty->hw_stopped) {
+		info->IER &= ~UART_IER_THRI;
+		serial_out(info, UART_IER, info->IER);
+		return;
+	}
+	
+	count = info->xmit_fifo_size;
+	do {
+		serial_out(info, UART_TX, info->xmit.buf[info->xmit.tail]);
+		info->xmit.tail = (info->xmit.tail + 1) & (SERIAL_XMIT_SIZE-1);
+		info->state->icount.tx++;
+		if (info->xmit.head == info->xmit.tail)
+			break;
+	} while (--count > 0);
+	
+	if (CIRC_CNT(info->xmit.head,
+		     info->xmit.tail,
+		     SERIAL_XMIT_SIZE) < WAKEUP_CHARS)
+		rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
+
+#ifdef SERIAL_DEBUG_INTR
+	printk("THRE...");
+#endif
+	if (intr_done)
+		*intr_done = 0;
+
+	if (info->xmit.head == info->xmit.tail) {
+		info->IER &= ~UART_IER_THRI;
+		serial_out(info, UART_IER, info->IER);
+	}
+}
+
+static _INLINE_ void check_modem_status(struct async_struct *info)
+{
+	int	status;
+	struct	async_icount *icount;
+	
+	status = serial_in(info, UART_MSR);
+
+	if (status & UART_MSR_ANY_DELTA) {
+		icount = &info->state->icount;
+		/* update input line counters */
+		if (status & UART_MSR_TERI)
+			icount->rng++;
+		if (status & UART_MSR_DDSR)
+			icount->dsr++;
+		if (status & UART_MSR_DDCD) {
+			icount->dcd++;
+#ifdef CONFIG_HARD_PPS
+			if ((info->flags & ASYNC_HARDPPS_CD) &&
+			    (status & UART_MSR_DCD))
+				hardpps();
+#endif
+		}
+		if (status & UART_MSR_DCTS)
+			icount->cts++;
+		wake_up_interruptible(&info->delta_msr_wait);
+	}
+
+	if ((info->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
+#if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
+		printk("ttys%d CD now %s...", info->line,
+		       (status & UART_MSR_DCD) ? "on" : "off");
+#endif		
+		if (status & UART_MSR_DCD)
+			wake_up_interruptible(&info->open_wait);
+		else if (!((info->flags & ASYNC_CALLOUT_ACTIVE) &&
+			   (info->flags & ASYNC_CALLOUT_NOHUP))) {
+#ifdef SERIAL_DEBUG_OPEN
+			printk("doing serial hangup...");
+#endif
+			if (info->tty)
+				tty_hangup(info->tty);
+		}
+	}
+	if (info->flags & ASYNC_CTS_FLOW) {
+		if (info->tty->hw_stopped) {
+			if (status & UART_MSR_CTS) {
+#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
+				printk("CTS tx start...");
+#endif
+				info->tty->hw_stopped = 0;
+				info->IER |= UART_IER_THRI;
+				serial_out(info, UART_IER, info->IER);
+				rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
+				return;
+			}
+		} else {
+			if (!(status & UART_MSR_CTS)) {
+#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
+				printk("CTS tx stop...");
+#endif
+				info->tty->hw_stopped = 1;
+				info->IER &= ~UART_IER_THRI;
+				serial_out(info, UART_IER, info->IER);
+			}
+		}
+	}
+}
+
+
+
+/*
+ * This is the serial driver's interrupt routine for a single port
+ */
+static void rs_interrupt_single(int irq, void *dev_id, struct pt_regs * regs)
+{
+	int status;
+	int pass_counter = 0;
+	struct async_struct * info;
+	
+#ifdef SERIAL_DEBUG_INTR
+	printk("rs_interrupt_single(%d)...", irq);
+#endif
+
+	info = IRQ_ports[irq];
+	if (!info || !info->tty)
+		return;
+
+	do {
+		status = serial_inp(info, UART_LSR);
+#ifdef SERIAL_DEBUG_INTR
+		printk("status = %x...", status);
+#endif
+		if (status & UART_LSR_DR)
+			receive_chars(info, &status, regs);
+		check_modem_status(info);
+		if (status & UART_LSR_THRE)
+			transmit_chars(info, 0);
+		if (pass_counter++ > RS_ISR_PASS_LIMIT) {
+#if 0
+			printk("rs_single loop break.\n");
+#endif
+			break;
+		}
+	} while (!(serial_in(info, UART_IIR) & UART_IIR_NO_INT));
+	info->last_active = jiffies;
+#ifdef SERIAL_DEBUG_INTR
+	printk("end.\n");
+#endif
+}
+
+
+/*
+ * -------------------------------------------------------------------
+ * Here ends the serial interrupt routines.
+ * -------------------------------------------------------------------
+ */
+
+/*
+ * This routine is used to handle the "bottom half" processing for the
+ * serial driver, known also the "software interrupt" processing.
+ * This processing is done at the kernel interrupt level, after the
+ * rs_interrupt() has returned, BUT WITH INTERRUPTS TURNED ON.  This
+ * is where time-consuming activities which can not be done in the
+ * interrupt driver proper are done; the interrupt driver schedules
+ * them using rs_sched_event(), and they get done here.
+ */
+static void do_serial_bh(void)
+{
+	run_task_queue(&tq_serial);
+}
+
+static void do_softint(void *private_)
+{
+	struct async_struct	*info = (struct async_struct *) private_;
+	struct tty_struct	*tty;
+	
+	tty = info->tty;
+	if (!tty)
+		return;
+
+	if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event)) {
+		if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
+		    tty->ldisc.write_wakeup)
+			(tty->ldisc.write_wakeup)(tty);
+		wake_up_interruptible(&tty->write_wait);
+#ifdef SERIAL_HAVE_POLL_WAIT
+		wake_up_interruptible(&tty->poll_wait);
+#endif
+	}
+}
+
+/*
+ * This subroutine is called when the RS_TIMER goes off.  It is used
+ * by the serial driver to handle ports that do not have an interrupt
+ * (irq=0).  This doesn't work very well for 16450's, but gives barely
+ * passable results for a 16550A.  (Although at the expense of much
+ * CPU overhead).
+ */
+static void rs_timer(unsigned long dummy)
+{
+	static unsigned long last_strobe;
+	struct async_struct *info;
+	unsigned int	i;
+	unsigned long flags;
+
+	if ((jiffies - last_strobe) >= RS_STROBE_TIME) {
+		for (i=0; i < NR_IRQS; i++) {
+			info = IRQ_ports[i];
+			if (!info)
+				continue;
+			save_flags(flags); cli();
+				rs_interrupt_single(i, NULL, NULL);
+			restore_flags(flags);
+		}
+	}
+	last_strobe = jiffies;
+	mod_timer(&serial_timer, jiffies + RS_STROBE_TIME);
+
+#if 0
+	if (IRQ_ports[0]) {
+		save_flags(flags); cli();
+		rs_interrupt_single(0, NULL, NULL);
+		restore_flags(flags);
+
+		mod_timer(&serial_timer, jiffies + IRQ_timeout[0]);
+	}
+#endif
+}
+
+/*
+ * ---------------------------------------------------------------
+ * Low level utility subroutines for the serial driver:  routines to
+ * figure out the appropriate timeout for an interrupt chain, routines
+ * to initialize and startup a serial port, and routines to shutdown a
+ * serial port.  Useful stuff like that.
+ * ---------------------------------------------------------------
+ */
+
+/*
+ * This routine figures out the correct timeout for a particular IRQ.
+ * It uses the smallest timeout of all of the serial ports in a
+ * particular interrupt chain.  Now only used for IRQ 0....
+ */
+static void figure_IRQ_timeout(int irq)
+{
+	struct	async_struct	*info;
+	int	timeout = 60*HZ;	/* 60 seconds === a long time :-) */
+
+	info = IRQ_ports[irq];
+	if (!info) {
+		IRQ_timeout[irq] = 60*HZ;
+		return;
+	}
+	while (info) {
+		if (info->timeout < timeout)
+			timeout = info->timeout;
+		info = info->next_port;
+	}
+	if (!irq)
+		timeout = timeout / 2;
+	IRQ_timeout[irq] = (timeout > 3) ? timeout-2 : 1;
+}
+
+
+static int startup(struct async_struct * info)
+{
+	unsigned long flags;
+	int	retval=0;
+	void (*handler)(int, void *, struct pt_regs *);
+	struct serial_state *state= info->state;
+	unsigned long page;
+
+	page = get_zeroed_page(GFP_KERNEL);
+	if (!page)
+		return -ENOMEM;
+
+	save_flags(flags); cli();
+
+	if (info->flags & ASYNC_INITIALIZED) {
+		free_page(page);
+		goto errout;
+	}
+
+	if (!CONFIGURED_SERIAL_PORT(state) || !state->type) {
+		if (info->tty)
+			set_bit(TTY_IO_ERROR, &info->tty->flags);
+		free_page(page);
+		goto errout;
+	}
+	if (info->xmit.buf)
+		free_page(page);
+	else
+		info->xmit.buf = (unsigned char *) page;
+
+
+	if (inl(UART_MOD_CNTRL + state->port) != 0x3) {
+		outl(3, UART_MOD_CNTRL + state->port);
+	}
+#ifdef SERIAL_DEBUG_OPEN
+	printk("starting up ttys%d (irq %d)...", info->line, state->irq);
+#endif
+
+
+	/*
+	 * Clear the FIFO buffers and disable them
+	 * (they will be reenabled in change_speed())
+	 */
+	if (uart_config[state->type].flags & UART_CLEAR_FIFO) {
+		serial_outp(info, UART_FCR, UART_FCR_ENABLE_FIFO);
+		serial_outp(info, UART_FCR, (UART_FCR_ENABLE_FIFO |
+					     UART_FCR_CLEAR_RCVR |
+					     UART_FCR_CLEAR_XMIT));
+		serial_outp(info, UART_FCR, 0);
+	}
+
+	/*
+	 * Clear the interrupt registers.
+	 */
+	(void) serial_inp(info, UART_LSR);
+	(void) serial_inp(info, UART_RX);
+	(void) serial_inp(info, UART_IIR);
+	(void) serial_inp(info, UART_MSR);
+
+	/*
+	 * At this point there's no way the LSR could still be 0xFF;
+	 * if it is, then bail out, because there's likely no UART
+	 * here.
+	 */
+	if (!(info->flags & ASYNC_BUGGY_UART) &&
+	    (serial_inp(info, UART_LSR) == 0xff)) {
+		printk("LSR safety check engaged!\n");
+		if (capable(CAP_SYS_ADMIN)) {
+			if (info->tty)
+				set_bit(TTY_IO_ERROR, &info->tty->flags);
+		} else
+			retval = -ENODEV;
+		goto errout;
+	}
+	
+	/*
+	 * Allocate the IRQ if necessary
+	 */
+#if 0
+	/* au1000, uart0 irq is 0 */
+	if (state->irq && (!IRQ_ports[state->irq] || !IRQ_ports[state->irq]->next_port)) {
+#endif
+	if ((!IRQ_ports[state->irq] || !IRQ_ports[state->irq]->next_port)) {
+		if (IRQ_ports[state->irq]) {
+			retval = -EBUSY;
+			goto errout;
+		} else 
+			handler = rs_interrupt_single;
+
+		retval = request_irq(state->irq, handler, SA_SHIRQ,
+				     "serial", &IRQ_ports[state->irq]);
+		if (retval) {
+			if (capable(CAP_SYS_ADMIN)) {
+				if (info->tty)
+					set_bit(TTY_IO_ERROR,
+						&info->tty->flags);
+				retval = 0;
+			}
+			goto errout;
+		}
+	}
+
+	/*
+	 * Insert serial port into IRQ chain.
+	 */
+	info->prev_port = 0;
+	info->next_port = IRQ_ports[state->irq];
+	if (info->next_port)
+		info->next_port->prev_port = info;
+	IRQ_ports[state->irq] = info;
+	figure_IRQ_timeout(state->irq);
+
+	/*
+	 * Now, initialize the UART 
+	 */
+	serial_outp(info, UART_LCR, UART_LCR_WLEN8);
+
+	info->MCR = 0;
+	if (info->tty->termios->c_cflag & CBAUD)
+		info->MCR = UART_MCR_DTR | UART_MCR_RTS;
+	{
+		if (state->irq != 0)
+			info->MCR |= UART_MCR_OUT2;
+	}
+	info->MCR |= ALPHA_KLUDGE_MCR; 		/* Don't ask */
+	serial_outp(info, UART_MCR, info->MCR);
+	
+	/*
+	 * Finally, enable interrupts
+	 */
+	info->IER = UART_IER_MSI | UART_IER_RLSI | UART_IER_RDI;
+	serial_outp(info, UART_IER, info->IER);	/* enable interrupts */
+	
+
+	/*
+	 * And clear the interrupt registers again for luck.
+	 */
+	(void)serial_inp(info, UART_LSR);
+	(void)serial_inp(info, UART_RX);
+	(void)serial_inp(info, UART_IIR);
+	(void)serial_inp(info, UART_MSR);
+
+	if (info->tty)
+		clear_bit(TTY_IO_ERROR, &info->tty->flags);
+	info->xmit.head = info->xmit.tail = 0;
+
+	/*
+	 * Set up serial timers...
+	 */
+	mod_timer(&serial_timer, jiffies + 2*HZ/100);
+
+	/*
+	 * Set up the tty->alt_speed kludge
+	 */
+	if (info->tty) {
+		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+			info->tty->alt_speed = 57600;
+		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+			info->tty->alt_speed = 115200;
+		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+			info->tty->alt_speed = 230400;
+		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+			info->tty->alt_speed = 460800;
+	}
+	
+	/*
+	 * and set the speed of the serial port
+	 */
+	change_speed(info, 0);
+
+	info->flags |= ASYNC_INITIALIZED;
+	restore_flags(flags);
+	return 0;
+	
+errout:
+	restore_flags(flags);
+	return retval;
+}
+
+/*
+ * This routine will shutdown a serial port; interrupts are disabled, and
+ * DTR is dropped if the hangup on close termio flag is on.
+ */
+static void shutdown(struct async_struct * info)
+{
+	unsigned long	flags;
+	struct serial_state *state;
+	int		retval;
+
+	if (!(info->flags & ASYNC_INITIALIZED))
+		return;
+
+	state = info->state;
+
+#ifdef SERIAL_DEBUG_OPEN
+	printk("Shutting down serial port %d (irq %d)....", info->line,
+	       state->irq);
+#endif
+	
+	save_flags(flags); cli(); /* Disable interrupts */
+
+	/*
+	 * clear delta_msr_wait queue to avoid mem leaks: we may free the irq
+	 * here so the queue might never be waken up
+	 */
+	wake_up_interruptible(&info->delta_msr_wait);
+	
+	/*
+	 * First unlink the serial port from the IRQ chain...
+	 */
+	if (info->next_port)
+		info->next_port->prev_port = info->prev_port;
+	if (info->prev_port)
+		info->prev_port->next_port = info->next_port;
+	else
+		IRQ_ports[state->irq] = info->next_port;
+	figure_IRQ_timeout(state->irq);
+	
+	/*
+	 * Free the IRQ, if necessary
+	 */
+//	if (state->irq && (!IRQ_ports[state->irq] ||
+	if ((!IRQ_ports[state->irq] ||
+			  !IRQ_ports[state->irq]->next_port)) {
+		if (IRQ_ports[state->irq]) {
+			free_irq(state->irq, &IRQ_ports[state->irq]);
+			retval = request_irq(state->irq, rs_interrupt_single,
+					     SA_SHIRQ, "serial",
+					     &IRQ_ports[state->irq]);
+			
+			if (retval)
+				printk("serial shutdown: request_irq: error %d"
+				       "  Couldn't reacquire IRQ.\n", retval);
+		} else
+			free_irq(state->irq, &IRQ_ports[state->irq]);
+	}
+
+	if (info->xmit.buf) {
+		unsigned long pg = (unsigned long) info->xmit.buf;
+		info->xmit.buf = 0;
+		free_page(pg);
+	}
+
+	info->IER = 0;
+	serial_outp(info, UART_IER, 0x00);	/* disable all intrs */
+		info->MCR &= ~UART_MCR_OUT2;
+	info->MCR |= ALPHA_KLUDGE_MCR; 		/* Don't ask */
+	
+	/* disable break condition */
+	serial_out(info, UART_LCR, serial_inp(info, UART_LCR) & ~UART_LCR_SBC);
+	
+	if (!info->tty || (info->tty->termios->c_cflag & HUPCL))
+		info->MCR &= ~(UART_MCR_DTR|UART_MCR_RTS);
+	serial_outp(info, UART_MCR, info->MCR);
+
+	/* disable FIFO's */	
+	serial_outp(info, UART_FCR, (UART_FCR_ENABLE_FIFO |
+				     UART_FCR_CLEAR_RCVR |
+				     UART_FCR_CLEAR_XMIT));
+	serial_outp(info, UART_FCR, 0);
+
+	(void)serial_in(info, UART_RX);    /* read data port to reset things */
+	
+	if (info->tty)
+		set_bit(TTY_IO_ERROR, &info->tty->flags);
+
+	info->flags &= ~ASYNC_INITIALIZED;
+	restore_flags(flags);
+}
+
+
+/*
+ * This routine is called to set the UART divisor registers to match
+ * the specified baud rate for a serial port.
+ */
+static void change_speed(struct async_struct *info,
+			 struct termios *old_termios)
+{
+	int	quot = 0, baud_base, baud;
+	unsigned cflag, cval, fcr = 0;
+	int	bits;
+	unsigned long	flags;
+
+	if (!info->tty || !info->tty->termios)
+		return;
+	cflag = info->tty->termios->c_cflag;
+	if (!CONFIGURED_SERIAL_PORT(info))
+		return;
+
+	/* byte size and parity */
+	switch (cflag & CSIZE) {
+	      case CS5: cval = 0x00; bits = 7; break;
+	      case CS6: cval = 0x01; bits = 8; break;
+	      case CS7: cval = 0x02; bits = 9; break;
+	      case CS8: cval = 0x03; bits = 10; break;
+	      /* Never happens, but GCC is too dumb to figure it out */
+	      default:  cval = 0x00; bits = 7; break;
+	      }
+	if (cflag & CSTOPB) {
+		cval |= 0x04;
+		bits++;
+	}
+	if (cflag & PARENB) {
+		cval |= UART_LCR_PARITY;
+		bits++;
+	}
+	if (!(cflag & PARODD))
+		cval |= UART_LCR_EPAR;
+#ifdef CMSPAR
+	if (cflag & CMSPAR)
+		cval |= UART_LCR_SPAR;
+#endif
+
+	/* Determine divisor based on baud rate */
+	baud = tty_get_baud_rate(info->tty);
+	if (!baud) {
+		baud = 9600;	/* B0 transition handled in rs_set_termios */
+	}
+	baud_base = info->state->baud_base;
+	//if (baud == 38400 &&
+	if (((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) {
+		quot = info->state->custom_divisor;
+	}
+	else {
+		if (baud == 134)
+			/* Special case since 134 is really 134.5 */
+			quot = (2*baud_base / 269);
+		else if (baud)
+			quot = baud_base / baud;
+	}
+	/* If the quotient is zero refuse the change */
+	if (!quot && old_termios) {
+		info->tty->termios->c_cflag &= ~CBAUD;
+		info->tty->termios->c_cflag |= (old_termios->c_cflag & CBAUD);
+		baud = tty_get_baud_rate(info->tty);
+		if (!baud)
+			baud = 9600;
+		if (baud == 38400 &&
+		    ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
+			quot = info->state->custom_divisor;
+		else {
+			if (baud == 134)
+				/* Special case since 134 is really 134.5 */
+				quot = (2*baud_base / 269);
+			else if (baud)
+				quot = baud_base / baud;
+		}
+	}
+	/* As a last resort, if the quotient is zero, default to 9600 bps */
+	if (!quot)
+		quot = baud_base / 9600;
+	
+	info->quot = quot;
+	info->timeout = ((info->xmit_fifo_size*HZ*bits*quot) / baud_base);
+	info->timeout += HZ/50;		/* Add .02 seconds of slop */
+
+	/* Set up FIFO's */
+	if (uart_config[info->state->type].flags & UART_USE_FIFO) {
+		if ((info->state->baud_base / quot) < 2400)
+			fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIGGER_1;
+		else
+			fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIGGER_8;
+	}
+	
+	/* CTS flow control flag and modem status interrupts */
+	info->IER &= ~UART_IER_MSI;
+	if (info->flags & ASYNC_HARDPPS_CD)
+		info->IER |= UART_IER_MSI;
+	if (cflag & CRTSCTS) {
+		info->flags |= ASYNC_CTS_FLOW;
+		info->IER |= UART_IER_MSI;
+	} else
+		info->flags &= ~ASYNC_CTS_FLOW;
+	if (cflag & CLOCAL)
+		info->flags &= ~ASYNC_CHECK_CD;
+	else {
+		info->flags |= ASYNC_CHECK_CD;
+		info->IER |= UART_IER_MSI;
+	}
+	serial_out(info, UART_IER, info->IER);
+
+	/*
+	 * Set up parity check flag
+	 */
+#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
+
+	info->read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
+	if (I_INPCK(info->tty))
+		info->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
+	if (I_BRKINT(info->tty) || I_PARMRK(info->tty))
+		info->read_status_mask |= UART_LSR_BI;
+	
+	/*
+	 * Characters to ignore
+	 */
+	info->ignore_status_mask = 0;
+	if (I_IGNPAR(info->tty))
+		info->ignore_status_mask |= UART_LSR_PE | UART_LSR_FE;
+	if (I_IGNBRK(info->tty)) {
+		info->ignore_status_mask |= UART_LSR_BI;
+		/*
+		 * If we're ignore parity and break indicators, ignore 
+		 * overruns too.  (For real raw support).
+		 */
+		if (I_IGNPAR(info->tty))
+			info->ignore_status_mask |= UART_LSR_OE;
+	}
+	/*
+	 * !!! ignore all characters if CREAD is not set
+	 */
+	if ((cflag & CREAD) == 0)
+		info->ignore_status_mask |= UART_LSR_DR;
+	save_flags(flags); cli();
+
+	serial_outp(info, UART_CLK, quot & 0xffff);
+	serial_outp(info, UART_LCR, cval);
+	info->LCR = cval;				/* Save LCR */
+	restore_flags(flags);
+}
+
+static void rs_put_char(struct tty_struct *tty, unsigned char ch)
+{
+	struct async_struct *info = (struct async_struct *)tty->driver_data;
+	unsigned long flags;
+
+	if (serial_paranoia_check(info, tty->device, "rs_put_char"))
+		return;
+
+	if (!tty || !info->xmit.buf)
+		return;
+
+	save_flags(flags); cli();
+	if (CIRC_SPACE(info->xmit.head,
+		       info->xmit.tail,
+		       SERIAL_XMIT_SIZE) == 0) {
+		restore_flags(flags);
+		return;
+	}
+
+	info->xmit.buf[info->xmit.head] = ch;
+	info->xmit.head = (info->xmit.head + 1) & (SERIAL_XMIT_SIZE-1);
+	restore_flags(flags);
+}
+
+static void rs_flush_chars(struct tty_struct *tty)
+{
+	struct async_struct *info = (struct async_struct *)tty->driver_data;
+	unsigned long flags;
+				
+	if (serial_paranoia_check(info, tty->device, "rs_flush_chars"))
+		return;
+
+	if (info->xmit.head == info->xmit.tail
+	    || tty->stopped
+	    || tty->hw_stopped
+	    || !info->xmit.buf)
+		return;
+
+	save_flags(flags); cli();
+	info->IER |= UART_IER_THRI;
+	serial_out(info, UART_IER, info->IER);
+	restore_flags(flags);
+}
+
+static int rs_write(struct tty_struct * tty, int from_user,
+		    const unsigned char *buf, int count)
+{
+	int	c, ret = 0;
+	struct async_struct *info = (struct async_struct *)tty->driver_data;
+	unsigned long flags;
+				
+	if (serial_paranoia_check(info, tty->device, "rs_write"))
+		return 0;
+
+	if (!tty || !info->xmit.buf || !tmp_buf)
+		return 0;
+
+	save_flags(flags);
+	if (from_user) {
+		down(&tmp_buf_sem);
+		while (1) {
+			int c1;
+			c = CIRC_SPACE_TO_END(info->xmit.head,
+					      info->xmit.tail,
+					      SERIAL_XMIT_SIZE);
+			if (count < c)
+				c = count;
+			if (c <= 0)
+				break;
+
+			c -= copy_from_user(tmp_buf, buf, c);
+			if (!c) {
+				if (!ret)
+					ret = -EFAULT;
+				break;
+			}
+			cli();
+			c1 = CIRC_SPACE_TO_END(info->xmit.head,
+					       info->xmit.tail,
+					       SERIAL_XMIT_SIZE);
+			if (c1 < c)
+				c = c1;
+			memcpy(info->xmit.buf + info->xmit.head, tmp_buf, c);
+			info->xmit.head = ((info->xmit.head + c) &
+					   (SERIAL_XMIT_SIZE-1));
+			restore_flags(flags);
+			buf += c;
+			count -= c;
+			ret += c;
+		}
+		up(&tmp_buf_sem);
+	} else {
+		cli();
+		while (1) {
+			c = CIRC_SPACE_TO_END(info->xmit.head,
+					      info->xmit.tail,
+					      SERIAL_XMIT_SIZE);
+			if (count < c)
+				c = count;
+			if (c <= 0) {
+				break;
+			}
+			memcpy(info->xmit.buf + info->xmit.head, buf, c);
+			info->xmit.head = ((info->xmit.head + c) &
+					   (SERIAL_XMIT_SIZE-1));
+			buf += c;
+			count -= c;
+			ret += c;
+		}
+		restore_flags(flags);
+	}
+	if (info->xmit.head != info->xmit.tail
+	    && !tty->stopped
+	    && !tty->hw_stopped
+	    && !(info->IER & UART_IER_THRI)) {
+		info->IER |= UART_IER_THRI;
+		serial_out(info, UART_IER, info->IER);
+	}
+	return ret;
+}
+
+static int rs_write_room(struct tty_struct *tty)
+{
+	struct async_struct *info = (struct async_struct *)tty->driver_data;
+
+	if (serial_paranoia_check(info, tty->device, "rs_write_room"))
+		return 0;
+	return CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
+}
+
+static int rs_chars_in_buffer(struct tty_struct *tty)
+{
+	struct async_struct *info = (struct async_struct *)tty->driver_data;
+				
+	if (serial_paranoia_check(info, tty->device, "rs_chars_in_buffer"))
+		return 0;
+	return CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
+}
+
+static void rs_flush_buffer(struct tty_struct *tty)
+{
+	struct async_struct *info = (struct async_struct *)tty->driver_data;
+	unsigned long flags;
+	
+	if (serial_paranoia_check(info, tty->device, "rs_flush_buffer"))
+		return;
+	save_flags(flags); cli();
+	info->xmit.head = info->xmit.tail = 0;
+	restore_flags(flags);
+	wake_up_interruptible(&tty->write_wait);
+#ifdef SERIAL_HAVE_POLL_WAIT
+	wake_up_interruptible(&tty->poll_wait);
+#endif
+	if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
+	    tty->ldisc.write_wakeup)
+		(tty->ldisc.write_wakeup)(tty);
+}
+
+/*
+ * This function is used to send a high-priority XON/XOFF character to
+ * the device
+ */
+static void rs_send_xchar(struct tty_struct *tty, char ch)
+{
+	struct async_struct *info = (struct async_struct *)tty->driver_data;
+
+	if (serial_paranoia_check(info, tty->device, "rs_send_char"))
+		return;
+
+	info->x_char = ch;
+	if (ch) {
+		/* Make sure transmit interrupts are on */
+		info->IER |= UART_IER_THRI;
+		serial_out(info, UART_IER, info->IER);
+	}
+}
+
+/*
+ * ------------------------------------------------------------
+ * rs_throttle()
+ * 
+ * This routine is called by the upper-layer tty layer to signal that
+ * incoming characters should be throttled.
+ * ------------------------------------------------------------
+ */
+static void rs_throttle(struct tty_struct * tty)
+{
+	struct async_struct *info = (struct async_struct *)tty->driver_data;
+	unsigned long flags;
+#ifdef SERIAL_DEBUG_THROTTLE
+	char	buf[64];
+	
+	printk("throttle %s: %d....\n", tty_name(tty, buf),
+	       tty->ldisc.chars_in_buffer(tty));
+#endif
+
+	if (serial_paranoia_check(info, tty->device, "rs_throttle"))
+		return;
+	
+	if (I_IXOFF(tty))
+		rs_send_xchar(tty, STOP_CHAR(tty));
+
+	if (tty->termios->c_cflag & CRTSCTS)
+		info->MCR &= ~UART_MCR_RTS;
+
+	save_flags(flags); cli();
+	serial_out(info, UART_MCR, info->MCR);
+	restore_flags(flags);
+}
+
+static void rs_unthrottle(struct tty_struct * tty)
+{
+	struct async_struct *info = (struct async_struct *)tty->driver_data;
+	unsigned long flags;
+#ifdef SERIAL_DEBUG_THROTTLE
+	char	buf[64];
+	
+	printk("unthrottle %s: %d....\n", tty_name(tty, buf),
+	       tty->ldisc.chars_in_buffer(tty));
+#endif
+
+	if (serial_paranoia_check(info, tty->device, "rs_unthrottle"))
+		return;
+	
+	if (I_IXOFF(tty)) {
+		if (info->x_char)
+			info->x_char = 0;
+		else
+			rs_send_xchar(tty, START_CHAR(tty));
+	}
+	if (tty->termios->c_cflag & CRTSCTS)
+		info->MCR |= UART_MCR_RTS;
+	save_flags(flags); cli();
+	serial_out(info, UART_MCR, info->MCR);
+	restore_flags(flags);
+}
+
+/*
+ * ------------------------------------------------------------
+ * rs_ioctl() and friends
+ * ------------------------------------------------------------
+ */
+
+static int get_serial_info(struct async_struct * info,
+			   struct serial_struct * retinfo)
+{
+	struct serial_struct tmp;
+	struct serial_state *state = info->state;
+   
+	if (!retinfo)
+		return -EFAULT;
+	memset(&tmp, 0, sizeof(tmp));
+	tmp.type = state->type;
+	tmp.line = state->line;
+	tmp.port = state->port;
+	if (HIGH_BITS_OFFSET)
+		tmp.port_high = state->port >> HIGH_BITS_OFFSET;
+	else
+		tmp.port_high = 0;
+	tmp.irq = state->irq;
+	tmp.flags = state->flags;
+	tmp.xmit_fifo_size = state->xmit_fifo_size;
+	tmp.baud_base = state->baud_base;
+	tmp.close_delay = state->close_delay;
+	tmp.closing_wait = state->closing_wait;
+	tmp.custom_divisor = state->custom_divisor;
+	tmp.hub6 = state->hub6;
+	tmp.io_type = state->io_type;
+	if (copy_to_user(retinfo,&tmp,sizeof(*retinfo)))
+		return -EFAULT;
+	return 0;
+}
+
+static int set_serial_info(struct async_struct * info,
+			   struct serial_struct * new_info)
+{
+	struct serial_struct new_serial;
+ 	struct serial_state old_state, *state;
+	unsigned int		i,change_irq,change_port;
+	int 			retval = 0;
+	unsigned long		new_port;
+
+	if (copy_from_user(&new_serial,new_info,sizeof(new_serial)))
+		return -EFAULT;
+	state = info->state;
+	old_state = *state;
+
+	new_port = new_serial.port;
+	if (HIGH_BITS_OFFSET)
+		new_port += (unsigned long) new_serial.port_high << HIGH_BITS_OFFSET;
+
+	change_irq = new_serial.irq != state->irq;
+	change_port = (new_port != ((int) state->port)) ||
+		(new_serial.hub6 != state->hub6);
+  
+	if (!capable(CAP_SYS_ADMIN)) {
+		if (change_irq || change_port ||
+		    (new_serial.baud_base != state->baud_base) ||
+		    (new_serial.type != state->type) ||
+		    (new_serial.close_delay != state->close_delay) ||
+		    (new_serial.xmit_fifo_size != state->xmit_fifo_size) ||
+		    ((new_serial.flags & ~ASYNC_USR_MASK) !=
+		     (state->flags & ~ASYNC_USR_MASK)))
+			return -EPERM;
+		state->flags = ((state->flags & ~ASYNC_USR_MASK) |
+			       (new_serial.flags & ASYNC_USR_MASK));
+		info->flags = ((info->flags & ~ASYNC_USR_MASK) |
+			       (new_serial.flags & ASYNC_USR_MASK));
+		state->custom_divisor = new_serial.custom_divisor;
+		goto check_and_exit;
+	}
+
+	new_serial.irq = irq_cannonicalize(new_serial.irq);
+
+	if ((new_serial.irq >= NR_IRQS) || (new_serial.irq < 0) || 
+	    (new_serial.baud_base < 9600)|| (new_serial.type < PORT_UNKNOWN) ||
+	    (new_serial.type > PORT_MAX) || (new_serial.type == PORT_CIRRUS) ||
+	    (new_serial.type == PORT_STARTECH)) {
+		return -EINVAL;
+	}
+
+	if ((new_serial.type != state->type) ||
+	    (new_serial.xmit_fifo_size <= 0))
+		new_serial.xmit_fifo_size =
+			uart_config[new_serial.type].dfl_xmit_fifo_size;
+
+	/* Make sure address is not already in use */
+	if (new_serial.type) {
+		for (i = 0 ; i < NR_PORTS; i++)
+			if ((state != &rs_table[i]) &&
+			    (rs_table[i].port == new_port) &&
+			    rs_table[i].type)
+				return -EADDRINUSE;
+	}
+
+	if ((change_port || change_irq) && (state->count > 1))
+		return -EBUSY;
+
+	/*
+	 * OK, past this point, all the error checking has been done.
+	 * At this point, we start making changes.....
+	 */
+
+	state->baud_base = new_serial.baud_base;
+	state->flags = ((state->flags & ~ASYNC_FLAGS) |
+			(new_serial.flags & ASYNC_FLAGS));
+	info->flags = ((state->flags & ~ASYNC_INTERNAL_FLAGS) |
+		       (info->flags & ASYNC_INTERNAL_FLAGS));
+	state->custom_divisor = new_serial.custom_divisor;
+	state->close_delay = new_serial.close_delay * HZ/100;
+	state->closing_wait = new_serial.closing_wait * HZ/100;
+	info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+	info->xmit_fifo_size = state->xmit_fifo_size =
+		new_serial.xmit_fifo_size;
+
+	if ((state->type != PORT_UNKNOWN) && state->port) {
+		release_region(state->port,8);
+	}
+	state->type = new_serial.type;
+	if (change_port || change_irq) {
+		/*
+		 * We need to shutdown the serial port at the old
+		 * port/irq combination.
+		 */
+		shutdown(info);
+		state->irq = new_serial.irq;
+		info->port = state->port = new_port;
+		info->hub6 = state->hub6 = new_serial.hub6;
+		if (info->hub6)
+			info->io_type = state->io_type = SERIAL_IO_HUB6;
+		else if (info->io_type == SERIAL_IO_HUB6)
+			info->io_type = state->io_type = SERIAL_IO_PORT;
+	}
+	if ((state->type != PORT_UNKNOWN) && state->port) {
+			request_region(state->port,8,"serial(set)");
+	}
+
+	
+check_and_exit:
+	if (!state->port || !state->type)
+		return 0;
+	if (info->flags & ASYNC_INITIALIZED) {
+		if (((old_state.flags & ASYNC_SPD_MASK) !=
+		     (state->flags & ASYNC_SPD_MASK)) ||
+		    (old_state.custom_divisor != state->custom_divisor)) {
+			if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+				info->tty->alt_speed = 57600;
+			if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+				info->tty->alt_speed = 115200;
+			if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+				info->tty->alt_speed = 230400;
+			if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+				info->tty->alt_speed = 460800;
+			change_speed(info, 0);
+		}
+	} else {
+		retval = startup(info);
+	}
+	return retval;
+}
+
+
+/*
+ * get_lsr_info - get line status register info
+ *
+ * Purpose: Let user call ioctl() to get info when the UART physically
+ * 	    is emptied.  On bus types like RS485, the transmitter must
+ * 	    release the bus after transmitting. This must be done when
+ * 	    the transmit shift register is empty, not be done when the
+ * 	    transmit holding register is empty.  This functionality
+ * 	    allows an RS485 driver to be written in user space. 
+ */
+static int get_lsr_info(struct async_struct * info, unsigned int *value)
+{
+	unsigned char status;
+	unsigned int result;
+	unsigned long flags;
+
+	save_flags(flags); cli();
+	status = serial_in(info, UART_LSR);
+	restore_flags(flags);
+	result = ((status & UART_LSR_TEMT) ? TIOCSER_TEMT : 0);
+
+	/*
+	 * If we're about to load something into the transmit
+	 * register, we'll pretend the transmitter isn't empty to
+	 * avoid a race condition (depending on when the transmit
+	 * interrupt happens).
+	 */
+	if (info->x_char || 
+	    ((CIRC_CNT(info->xmit.head, info->xmit.tail,
+		       SERIAL_XMIT_SIZE) > 0) &&
+	     !info->tty->stopped && !info->tty->hw_stopped))
+		result &= TIOCSER_TEMT;
+
+	if (copy_to_user(value, &result, sizeof(int)))
+		return -EFAULT;
+	return 0;
+}
+
+
+static int get_modem_info(struct async_struct * info, unsigned int *value)
+{
+	unsigned char control, status;
+	unsigned int result;
+	unsigned long flags;
+
+	control = info->MCR;
+	save_flags(flags); cli();
+	status = serial_in(info, UART_MSR);
+	restore_flags(flags);
+	result =  ((control & UART_MCR_RTS) ? TIOCM_RTS : 0)
+		| ((control & UART_MCR_DTR) ? TIOCM_DTR : 0)
+#ifdef TIOCM_OUT1
+		| ((control & UART_MCR_OUT1) ? TIOCM_OUT1 : 0)
+		| ((control & UART_MCR_OUT2) ? TIOCM_OUT2 : 0)
+#endif
+		| ((status  & UART_MSR_DCD) ? TIOCM_CAR : 0)
+		| ((status  & UART_MSR_RI) ? TIOCM_RNG : 0)
+		| ((status  & UART_MSR_DSR) ? TIOCM_DSR : 0)
+		| ((status  & UART_MSR_CTS) ? TIOCM_CTS : 0);
+
+	if (copy_to_user(value, &result, sizeof(int)))
+		return -EFAULT;
+	return 0;
+}
+
+static int set_modem_info(struct async_struct * info, unsigned int cmd,
+			  unsigned int *value)
+{
+	unsigned int arg;
+	unsigned long flags;
+
+	if (copy_from_user(&arg, value, sizeof(int)))
+		return -EFAULT;
+
+	switch (cmd) {
+	case TIOCMBIS: 
+		if (arg & TIOCM_RTS)
+			info->MCR |= UART_MCR_RTS;
+		if (arg & TIOCM_DTR)
+			info->MCR |= UART_MCR_DTR;
+#ifdef TIOCM_OUT1
+		if (arg & TIOCM_OUT1)
+			info->MCR |= UART_MCR_OUT1;
+		if (arg & TIOCM_OUT2)
+			info->MCR |= UART_MCR_OUT2;
+#endif
+		if (arg & TIOCM_LOOP)
+			info->MCR |= UART_MCR_LOOP;
+		break;
+	case TIOCMBIC:
+		if (arg & TIOCM_RTS)
+			info->MCR &= ~UART_MCR_RTS;
+		if (arg & TIOCM_DTR)
+			info->MCR &= ~UART_MCR_DTR;
+#ifdef TIOCM_OUT1
+		if (arg & TIOCM_OUT1)
+			info->MCR &= ~UART_MCR_OUT1;
+		if (arg & TIOCM_OUT2)
+			info->MCR &= ~UART_MCR_OUT2;
+#endif
+		if (arg & TIOCM_LOOP)
+			info->MCR &= ~UART_MCR_LOOP;
+		break;
+	case TIOCMSET:
+		info->MCR = ((info->MCR & ~(UART_MCR_RTS |
+#ifdef TIOCM_OUT1
+					    UART_MCR_OUT1 |
+					    UART_MCR_OUT2 |
+#endif
+					    UART_MCR_LOOP |
+					    UART_MCR_DTR))
+			     | ((arg & TIOCM_RTS) ? UART_MCR_RTS : 0)
+#ifdef TIOCM_OUT1
+			     | ((arg & TIOCM_OUT1) ? UART_MCR_OUT1 : 0)
+			     | ((arg & TIOCM_OUT2) ? UART_MCR_OUT2 : 0)
+#endif
+			     | ((arg & TIOCM_LOOP) ? UART_MCR_LOOP : 0)
+			     | ((arg & TIOCM_DTR) ? UART_MCR_DTR : 0));
+		break;
+	default:
+		return -EINVAL;
+	}
+	save_flags(flags); cli();
+	info->MCR |= ALPHA_KLUDGE_MCR; 		/* Don't ask */
+	serial_out(info, UART_MCR, info->MCR);
+	restore_flags(flags);
+	return 0;
+}
+
+static int do_autoconfig(struct async_struct * info)
+{
+	int retval;
+	
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+	
+	if (info->state->count > 1)
+		return -EBUSY;
+	
+	shutdown(info);
+
+	autoconfig(info->state);
+	retval = startup(info);
+	if (retval)
+		return retval;
+	return 0;
+}
+
+/*
+ * rs_break() --- routine which turns the break handling on or off
+ */
+static void rs_break(struct tty_struct *tty, int break_state)
+{
+	struct async_struct * info = (struct async_struct *)tty->driver_data;
+	unsigned long flags;
+	
+	if (serial_paranoia_check(info, tty->device, "rs_break"))
+		return;
+
+	if (!CONFIGURED_SERIAL_PORT(info))
+		return;
+	save_flags(flags); cli();
+	if (break_state == -1)
+		info->LCR |= UART_LCR_SBC;
+	else
+		info->LCR &= ~UART_LCR_SBC;
+	serial_out(info, UART_LCR, info->LCR);
+	restore_flags(flags);
+}
+
+
+static int rs_ioctl(struct tty_struct *tty, struct file * file,
+		    unsigned int cmd, unsigned long arg)
+{
+	struct async_struct * info = (struct async_struct *)tty->driver_data;
+	struct async_icount cprev, cnow;	/* kernel counter temps */
+	struct serial_icounter_struct icount;
+	unsigned long flags;
+	
+	if (serial_paranoia_check(info, tty->device, "rs_ioctl"))
+		return -ENODEV;
+
+	if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
+	    (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) &&
+	    (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) {
+		if (tty->flags & (1 << TTY_IO_ERROR))
+		    return -EIO;
+	}
+	
+	switch (cmd) {
+		case TIOCMGET:
+			return get_modem_info(info, (unsigned int *) arg);
+		case TIOCMBIS:
+		case TIOCMBIC:
+		case TIOCMSET:
+			return set_modem_info(info, cmd, (unsigned int *) arg);
+		case TIOCGSERIAL:
+			return get_serial_info(info,
+					       (struct serial_struct *) arg);
+		case TIOCSSERIAL:
+			return set_serial_info(info,
+					       (struct serial_struct *) arg);
+		case TIOCSERCONFIG:
+			return do_autoconfig(info);
+
+		case TIOCSERGETLSR: /* Get line status register */
+			return get_lsr_info(info, (unsigned int *) arg);
+
+		case TIOCSERGSTRUCT:
+			if (copy_to_user((struct async_struct *) arg,
+					 info, sizeof(struct async_struct)))
+				return -EFAULT;
+			return 0;
+				
+			
+		/*
+		 * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
+		 * - mask passed in arg for lines of interest
+ 		 *   (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
+		 * Caller should use TIOCGICOUNT to see which one it was
+		 */
+		case TIOCMIWAIT:
+			save_flags(flags); cli();
+			/* note the counters on entry */
+			cprev = info->state->icount;
+			restore_flags(flags);
+			/* Force modem status interrupts on */
+			info->IER |= UART_IER_MSI;
+			serial_out(info, UART_IER, info->IER);
+			while (1) {
+				interruptible_sleep_on(&info->delta_msr_wait);
+				/* see if a signal did it */
+				if (signal_pending(current))
+					return -ERESTARTSYS;
+				save_flags(flags); cli();
+				cnow = info->state->icount; /* atomic copy */
+				restore_flags(flags);
+				if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && 
+				    cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
+					return -EIO; /* no change => error */
+				if ( ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
+				     ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
+				     ((arg & TIOCM_CD)  && (cnow.dcd != cprev.dcd)) ||
+				     ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) {
+					return 0;
+				}
+				cprev = cnow;
+			}
+			/* NOTREACHED */
+
+		/* 
+		 * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
+		 * Return: write counters to the user passed counter struct
+		 * NB: both 1->0 and 0->1 transitions are counted except for
+		 *     RI where only 0->1 is counted.
+		 */
+		case TIOCGICOUNT:
+			save_flags(flags); cli();
+			cnow = info->state->icount;
+			restore_flags(flags);
+			icount.cts = cnow.cts;
+			icount.dsr = cnow.dsr;
+			icount.rng = cnow.rng;
+			icount.dcd = cnow.dcd;
+			icount.rx = cnow.rx;
+			icount.tx = cnow.tx;
+			icount.frame = cnow.frame;
+			icount.overrun = cnow.overrun;
+			icount.parity = cnow.parity;
+			icount.brk = cnow.brk;
+			icount.buf_overrun = cnow.buf_overrun;
+			
+			if (copy_to_user((void *)arg, &icount, sizeof(icount)))
+				return -EFAULT;
+			return 0;
+		case TIOCSERGWILD:
+		case TIOCSERSWILD:
+			/* "setserial -W" is called in Debian boot */
+			printk ("TIOCSER?WILD ioctl obsolete, ignored.\n");
+			return 0;
+
+		default:
+			return -ENOIOCTLCMD;
+		}
+	return 0;
+}
+
+static void rs_set_termios(struct tty_struct *tty, struct termios *old_termios)
+{
+	struct async_struct *info = (struct async_struct *)tty->driver_data;
+	unsigned long flags;
+	unsigned int cflag = tty->termios->c_cflag;
+	
+	if (   (cflag == old_termios->c_cflag)
+	    && (   RELEVANT_IFLAG(tty->termios->c_iflag) 
+		== RELEVANT_IFLAG(old_termios->c_iflag)))
+	  return;
+
+	change_speed(info, old_termios);
+
+	/* Handle transition to B0 status */
+	if ((old_termios->c_cflag & CBAUD) &&
+	    !(cflag & CBAUD)) {
+		info->MCR &= ~(UART_MCR_DTR|UART_MCR_RTS);
+		save_flags(flags); cli();
+		serial_out(info, UART_MCR, info->MCR);
+		restore_flags(flags);
+	}
+	
+	/* Handle transition away from B0 status */
+	if (!(old_termios->c_cflag & CBAUD) &&
+	    (cflag & CBAUD)) {
+		info->MCR |= UART_MCR_DTR;
+		if (!(tty->termios->c_cflag & CRTSCTS) || 
+		    !test_bit(TTY_THROTTLED, &tty->flags)) {
+			info->MCR |= UART_MCR_RTS;
+		}
+		save_flags(flags); cli();
+		serial_out(info, UART_MCR, info->MCR);
+		restore_flags(flags);
+	}
+	
+	/* Handle turning off CRTSCTS */
+	if ((old_termios->c_cflag & CRTSCTS) &&
+	    !(tty->termios->c_cflag & CRTSCTS)) {
+		tty->hw_stopped = 0;
+		rs_start(tty);
+	}
+}
+
+/*
+ * ------------------------------------------------------------
+ * rs_close()
+ * 
+ * This routine is called when the serial port gets closed.  First, we
+ * wait for the last remaining data to be sent.  Then, we unlink its
+ * async structure from the interrupt chain if necessary, and we free
+ * that IRQ if nothing is left in the chain.
+ * ------------------------------------------------------------
+ */
+static void rs_close(struct tty_struct *tty, struct file * filp)
+{
+	struct async_struct * info = (struct async_struct *)tty->driver_data;
+	struct serial_state *state;
+	unsigned long flags;
+
+	if (!info || serial_paranoia_check(info, tty->device, "rs_close"))
+		return;
+
+	state = info->state;
+	
+	save_flags(flags); cli();
+	
+	if (tty_hung_up_p(filp)) {
+		DBG_CNT("before DEC-hung");
+		MOD_DEC_USE_COUNT;
+		restore_flags(flags);
+		return;
+	}
+	
+#ifdef SERIAL_DEBUG_OPEN
+	printk("rs_close ttys%d, count = %d\n", info->line, state->count);
+#endif
+	if ((tty->count == 1) && (state->count != 1)) {
+		/*
+		 * Uh, oh.  tty->count is 1, which means that the tty
+		 * structure will be freed.  state->count should always
+		 * be one in these conditions.  If it's greater than
+		 * one, we've got real problems, since it means the
+		 * serial port won't be shutdown.
+		 */
+		printk("rs_close: bad serial port count; tty->count is 1, "
+		       "state->count is %d\n", state->count);
+		state->count = 1;
+	}
+	if (--state->count < 0) {
+		printk("rs_close: bad serial port count for ttys%d: %d\n",
+		       info->line, state->count);
+		state->count = 0;
+	}
+	if (state->count) {
+		DBG_CNT("before DEC-2");
+		MOD_DEC_USE_COUNT;
+		restore_flags(flags);
+		return;
+	}
+	info->flags |= ASYNC_CLOSING;
+	restore_flags(flags);
+	/*
+	 * Save the termios structure, since this port may have
+	 * separate termios for callout and dialin.
+	 */
+	if (info->flags & ASYNC_NORMAL_ACTIVE)
+		info->state->normal_termios = *tty->termios;
+	if (info->flags & ASYNC_CALLOUT_ACTIVE)
+		info->state->callout_termios = *tty->termios;
+	/*
+	 * Now we wait for the transmit buffer to clear; and we notify 
+	 * the line discipline to only process XON/XOFF characters.
+	 */
+	tty->closing = 1;
+	if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE)
+		tty_wait_until_sent(tty, info->closing_wait);
+	/*
+	 * At this point we stop accepting input.  To do this, we
+	 * disable the receive line status interrupts, and tell the
+	 * interrupt driver to stop checking the data ready bit in the
+	 * line status register.
+	 */
+	info->IER &= ~UART_IER_RLSI;
+	info->read_status_mask &= ~UART_LSR_DR;
+	if (info->flags & ASYNC_INITIALIZED) {
+		serial_out(info, UART_IER, info->IER);
+		/*
+		 * Before we drop DTR, make sure the UART transmitter
+		 * has completely drained; this is especially
+		 * important if there is a transmit FIFO!
+		 */
+		rs_wait_until_sent(tty, info->timeout);
+	}
+	shutdown(info);
+	if (tty->driver.flush_buffer)
+		tty->driver.flush_buffer(tty);
+	if (tty->ldisc.flush_buffer)
+		tty->ldisc.flush_buffer(tty);
+	tty->closing = 0;
+	info->event = 0;
+	info->tty = 0;
+	if (info->blocked_open) {
+		if (info->close_delay) {
+			set_current_state(TASK_INTERRUPTIBLE);
+			schedule_timeout(info->close_delay);
+		}
+		wake_up_interruptible(&info->open_wait);
+	}
+	info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CALLOUT_ACTIVE|
+			 ASYNC_CLOSING);
+	wake_up_interruptible(&info->close_wait);
+	MOD_DEC_USE_COUNT;
+}
+
+/*
+ * rs_wait_until_sent() --- wait until the transmitter is empty
+ */
+static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
+{
+	struct async_struct * info = (struct async_struct *)tty->driver_data;
+	unsigned long orig_jiffies, char_time;
+	int lsr;
+	
+	if (serial_paranoia_check(info, tty->device, "rs_wait_until_sent"))
+		return;
+
+	if (info->state->type == PORT_UNKNOWN)
+		return;
+
+	if (info->xmit_fifo_size == 0)
+		return; /* Just in case.... */
+
+	orig_jiffies = jiffies;
+	/*
+	 * Set the check interval to be 1/5 of the estimated time to
+	 * send a single character, and make it at least 1.  The check
+	 * interval should also be less than the timeout.
+	 * 
+	 * Note: we have to use pretty tight timings here to satisfy
+	 * the NIST-PCTS.
+	 */
+	char_time = (info->timeout - HZ/50) / info->xmit_fifo_size;
+	char_time = char_time / 5;
+	if (char_time == 0)
+		char_time = 1;
+	if (timeout && timeout < char_time)
+		char_time = timeout;
+	/*
+	 * If the transmitter hasn't cleared in twice the approximate
+	 * amount of time to send the entire FIFO, it probably won't
+	 * ever clear.  This assumes the UART isn't doing flow
+	 * control, which is currently the case.  Hence, if it ever
+	 * takes longer than info->timeout, this is probably due to a
+	 * UART bug of some kind.  So, we clamp the timeout parameter at
+	 * 2*info->timeout.
+	 */
+	if (!timeout || timeout > 2*info->timeout)
+		timeout = 2*info->timeout;
+#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
+	printk("In rs_wait_until_sent(%d) check=%lu...", timeout, char_time);
+	printk("jiff=%lu...", jiffies);
+#endif
+	while (!((lsr = serial_inp(info, UART_LSR)) & UART_LSR_TEMT)) {
+#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
+		printk("lsr = %d (jiff=%lu)...", lsr, jiffies);
+#endif
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(char_time);
+		if (signal_pending(current))
+			break;
+		if (timeout && time_after(jiffies, orig_jiffies + timeout))
+			break;
+	}
+	set_current_state(TASK_RUNNING);
+#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
+	printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);
+#endif
+}
+
+/*
+ * rs_hangup() --- called by tty_hangup() when a hangup is signaled.
+ */
+static void rs_hangup(struct tty_struct *tty)
+{
+	struct async_struct * info = (struct async_struct *)tty->driver_data;
+	struct serial_state *state = info->state;
+	
+	if (serial_paranoia_check(info, tty->device, "rs_hangup"))
+		return;
+
+	state = info->state;
+	
+	rs_flush_buffer(tty);
+	if (info->flags & ASYNC_CLOSING)
+		return;
+	shutdown(info);
+	info->event = 0;
+	state->count = 0;
+	info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CALLOUT_ACTIVE);
+	info->tty = 0;
+	wake_up_interruptible(&info->open_wait);
+}
+
+/*
+ * ------------------------------------------------------------
+ * rs_open() and friends
+ * ------------------------------------------------------------
+ */
+static int block_til_ready(struct tty_struct *tty, struct file * filp,
+			   struct async_struct *info)
+{
+	DECLARE_WAITQUEUE(wait, current);
+	struct serial_state *state = info->state;
+	int		retval;
+	int		do_clocal = 0, extra_count = 0;
+	unsigned long	flags;
+
+	/*
+	 * If the device is in the middle of being closed, then block
+	 * until it's done, and then try again.
+	 */
+	if (tty_hung_up_p(filp) ||
+	    (info->flags & ASYNC_CLOSING)) {
+		if (info->flags & ASYNC_CLOSING)
+			interruptible_sleep_on(&info->close_wait);
+#ifdef SERIAL_DO_RESTART
+		return ((info->flags & ASYNC_HUP_NOTIFY) ?
+			-EAGAIN : -ERESTARTSYS);
+#else
+		return -EAGAIN;
+#endif
+	}
+
+	/*
+	 * If this is a callout device, then just make sure the normal
+	 * device isn't being used.
+	 */
+	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+		if (info->flags & ASYNC_NORMAL_ACTIVE)
+			return -EBUSY;
+		if ((info->flags & ASYNC_CALLOUT_ACTIVE) &&
+		    (info->flags & ASYNC_SESSION_LOCKOUT) &&
+		    (info->session != current->session))
+		    return -EBUSY;
+		if ((info->flags & ASYNC_CALLOUT_ACTIVE) &&
+		    (info->flags & ASYNC_PGRP_LOCKOUT) &&
+		    (info->pgrp != current->pgrp))
+		    return -EBUSY;
+		info->flags |= ASYNC_CALLOUT_ACTIVE;
+		return 0;
+	}
+	
+	/*
+	 * If non-blocking mode is set, or the port is not enabled,
+	 * then make the check up front and then exit.
+	 */
+	if ((filp->f_flags & O_NONBLOCK) ||
+	    (tty->flags & (1 << TTY_IO_ERROR))) {
+		if (info->flags & ASYNC_CALLOUT_ACTIVE)
+			return -EBUSY;
+		info->flags |= ASYNC_NORMAL_ACTIVE;
+		return 0;
+	}
+
+	if (info->flags & ASYNC_CALLOUT_ACTIVE) {
+		if (state->normal_termios.c_cflag & CLOCAL)
+			do_clocal = 1;
+	} else {
+		if (tty->termios->c_cflag & CLOCAL)
+			do_clocal = 1;
+	}
+	
+	/*
+	 * Block waiting for the carrier detect and the line to become
+	 * free (i.e., not in use by the callout).  While we are in
+	 * this loop, state->count is dropped by one, so that
+	 * rs_close() knows when to free things.  We restore it upon
+	 * exit, either normal or abnormal.
+	 */
+	retval = 0;
+	add_wait_queue(&info->open_wait, &wait);
+#ifdef SERIAL_DEBUG_OPEN
+	printk("block_til_ready before block: ttys%d, count = %d\n",
+	       state->line, state->count);
+#endif
+	save_flags(flags); cli();
+	if (!tty_hung_up_p(filp)) {
+		extra_count = 1;
+		state->count--;
+	}
+	restore_flags(flags);
+	info->blocked_open++;
+	while (1) {
+		save_flags(flags); cli();
+		if (!(info->flags & ASYNC_CALLOUT_ACTIVE) &&
+		    (tty->termios->c_cflag & CBAUD))
+			serial_out(info, UART_MCR,
+				   serial_inp(info, UART_MCR) |
+				   (UART_MCR_DTR | UART_MCR_RTS));
+		restore_flags(flags);
+		set_current_state(TASK_INTERRUPTIBLE);
+		if (tty_hung_up_p(filp) ||
+		    !(info->flags & ASYNC_INITIALIZED)) {
+#ifdef SERIAL_DO_RESTART
+			if (info->flags & ASYNC_HUP_NOTIFY)
+				retval = -EAGAIN;
+			else
+				retval = -ERESTARTSYS;	
+#else
+			retval = -EAGAIN;
+#endif
+			break;
+		}
+		if (!(info->flags & ASYNC_CALLOUT_ACTIVE) &&
+		    !(info->flags & ASYNC_CLOSING) &&
+		    (do_clocal || (serial_in(info, UART_MSR) &
+				   UART_MSR_DCD)))
+			break;
+		if (signal_pending(current)) {
+			retval = -ERESTARTSYS;
+			break;
+		}
+#ifdef SERIAL_DEBUG_OPEN
+		printk("block_til_ready blocking: ttys%d, count = %d\n",
+		       info->line, state->count);
+#endif
+		schedule();
+	}
+	set_current_state(TASK_RUNNING);
+	remove_wait_queue(&info->open_wait, &wait);
+	if (extra_count)
+		state->count++;
+	info->blocked_open--;
+#ifdef SERIAL_DEBUG_OPEN
+	printk("block_til_ready after blocking: ttys%d, count = %d\n",
+	       info->line, state->count);
+#endif
+	if (retval)
+		return retval;
+	info->flags |= ASYNC_NORMAL_ACTIVE;
+	return 0;
+}
+
+static int get_async_struct(int line, struct async_struct **ret_info)
+{
+	struct async_struct *info;
+	struct serial_state *sstate;
+
+	sstate = rs_table + line;
+	sstate->count++;
+	if (sstate->info) {
+		*ret_info = sstate->info;
+		return 0;
+	}
+	info = kmalloc(sizeof(struct async_struct), GFP_KERNEL);
+	if (!info) {
+		sstate->count--;
+		return -ENOMEM;
+	}
+	memset(info, 0, sizeof(struct async_struct));
+	init_waitqueue_head(&info->open_wait);
+	init_waitqueue_head(&info->close_wait);
+	init_waitqueue_head(&info->delta_msr_wait);
+	info->magic = SERIAL_MAGIC;
+	info->port = sstate->port;
+	info->flags = sstate->flags;
+	info->io_type = sstate->io_type;
+	info->iomem_base = sstate->iomem_base;
+	info->iomem_reg_shift = sstate->iomem_reg_shift;
+	info->xmit_fifo_size = sstate->xmit_fifo_size;
+	info->line = line;
+	info->tqueue.routine = do_softint;
+	info->tqueue.data = info;
+	info->state = sstate;
+	if (sstate->info) {
+		kfree(info);
+		*ret_info = sstate->info;
+		return 0;
+	}
+	*ret_info = sstate->info = info;
+	return 0;
+}
+
+/*
+ * This routine is called whenever a serial port is opened.  It
+ * enables interrupts for a serial port, linking in its async structure into
+ * the IRQ chain.   It also performs the serial-specific
+ * initialization for the tty structure.
+ */
+static int rs_open(struct tty_struct *tty, struct file * filp)
+{
+	struct async_struct	*info;
+	int 			retval, line;
+	unsigned long		page;
+
+	MOD_INC_USE_COUNT;
+	line = MINOR(tty->device) - tty->driver.minor_start;
+	if ((line < 0) || (line >= NR_PORTS)) {
+		MOD_DEC_USE_COUNT;
+		return -ENODEV;
+	}
+	retval = get_async_struct(line, &info);
+	if (retval) {
+		MOD_DEC_USE_COUNT;
+		return retval;
+	}
+	tty->driver_data = info;
+	info->tty = tty;
+	if (serial_paranoia_check(info, tty->device, "rs_open")) {
+		MOD_DEC_USE_COUNT;		
+		return -ENODEV;
+	}
+
+#ifdef SERIAL_DEBUG_OPEN
+	printk("rs_open %s%d, count = %d\n", tty->driver.name, info->line,
+	       info->state->count);
+#endif
+	info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+
+	if (!tmp_buf) {
+		page = get_zeroed_page(GFP_KERNEL);
+		if (!page) {
+			MOD_DEC_USE_COUNT;
+			return -ENOMEM;
+		}
+		if (tmp_buf)
+			free_page(page);
+		else
+			tmp_buf = (unsigned char *) page;
+	}
+
+	/*
+	 * If the port is the middle of closing, bail out now
+	 */
+	if (tty_hung_up_p(filp) ||
+	    (info->flags & ASYNC_CLOSING)) {
+		if (info->flags & ASYNC_CLOSING)
+			interruptible_sleep_on(&info->close_wait);
+		MOD_DEC_USE_COUNT;
+#ifdef SERIAL_DO_RESTART
+		return ((info->flags & ASYNC_HUP_NOTIFY) ?
+			-EAGAIN : -ERESTARTSYS);
+#else
+		return -EAGAIN;
+#endif
+	}
+
+	/*
+	 * Start up serial port
+	 */
+	retval = startup(info);
+	if (retval) {
+		MOD_DEC_USE_COUNT;
+		return retval;
+	}
+
+	retval = block_til_ready(tty, filp, info);
+	if (retval) {
+#ifdef SERIAL_DEBUG_OPEN
+		printk("rs_open returning after block_til_ready with %d\n",
+		       retval);
+#endif
+		MOD_DEC_USE_COUNT;
+		return retval;
+	}
+
+	if ((info->state->count == 1) &&
+	    (info->flags & ASYNC_SPLIT_TERMIOS)) {
+		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+			*tty->termios = info->state->normal_termios;
+		else 
+			*tty->termios = info->state->callout_termios;
+		change_speed(info, 0);
+	}
+#ifdef CONFIG_AU1000_SERIAL_CONSOLE
+	if (sercons.cflag && sercons.index == line) {
+		tty->termios->c_cflag = sercons.cflag;
+		sercons.cflag = 0;
+		change_speed(info, 0);
+	}
+#endif
+	info->session = current->session;
+	info->pgrp = current->pgrp;
+
+#ifdef SERIAL_DEBUG_OPEN
+	printk("rs_open ttys%d successful...", info->line);
+#endif
+	return 0;
+}
+
+/*
+ * /proc fs routines....
+ */
+
+static inline int line_info(char *buf, struct serial_state *state)
+{
+	struct async_struct *info = state->info, scr_info;
+	char	stat_buf[30], control, status;
+	int	ret;
+	unsigned long flags;
+
+	ret = sprintf(buf, "%d: uart:%s port:%lX irq:%d",
+		      state->line, uart_config[state->type].name, 
+		      state->port, state->irq);
+
+	if (!state->port || (state->type == PORT_UNKNOWN)) {
+		ret += sprintf(buf+ret, "\n");
+		return ret;
+	}
+
+	/*
+	 * Figure out the current RS-232 lines
+	 */
+	if (!info) {
+		info = &scr_info;	/* This is just for serial_{in,out} */
+
+		info->magic = SERIAL_MAGIC;
+		info->port = state->port;
+		info->flags = state->flags;
+		info->quot = 0;
+		info->tty = 0;
+	}
+	save_flags(flags); cli();
+	status = serial_in(info, UART_MSR);
+	control = info != &scr_info ? info->MCR : serial_in(info, UART_MCR);
+	restore_flags(flags); 
+
+	stat_buf[0] = 0;
+	stat_buf[1] = 0;
+	if (control & UART_MCR_RTS)
+		strcat(stat_buf, "|RTS");
+	if (status & UART_MSR_CTS)
+		strcat(stat_buf, "|CTS");
+	if (control & UART_MCR_DTR)
+		strcat(stat_buf, "|DTR");
+	if (status & UART_MSR_DSR)
+		strcat(stat_buf, "|DSR");
+	if (status & UART_MSR_DCD)
+		strcat(stat_buf, "|CD");
+	if (status & UART_MSR_RI)
+		strcat(stat_buf, "|RI");
+
+	if (info->quot) {
+		ret += sprintf(buf+ret, " baud:%d",
+			       state->baud_base / info->quot);
+	}
+
+	ret += sprintf(buf+ret, " tx:%d rx:%d",
+		      state->icount.tx, state->icount.rx);
+
+	if (state->icount.frame)
+		ret += sprintf(buf+ret, " fe:%d", state->icount.frame);
+	
+	if (state->icount.parity)
+		ret += sprintf(buf+ret, " pe:%d", state->icount.parity);
+	
+	if (state->icount.brk)
+		ret += sprintf(buf+ret, " brk:%d", state->icount.brk);	
+
+	if (state->icount.overrun)
+		ret += sprintf(buf+ret, " oe:%d", state->icount.overrun);
+
+	/*
+	 * Last thing is the RS-232 status lines
+	 */
+	ret += sprintf(buf+ret, " %s\n", stat_buf+1);
+	return ret;
+}
+
+int rs_read_proc(char *page, char **start, off_t off, int count,
+		 int *eof, void *data)
+{
+	int i, len = 0, l;
+	off_t	begin = 0;
+
+	len += sprintf(page, "serinfo:1.0 driver:%s%s revision:%s\n",
+		       serial_version, LOCAL_VERSTRING, serial_revdate);
+	for (i = 0; i < NR_PORTS && len < 4000; i++) {
+		l = line_info(page + len, &rs_table[i]);
+		len += l;
+		if (len+begin > off+count)
+			goto done;
+		if (len+begin < off) {
+			begin += len;
+			len = 0;
+		}
+	}
+	*eof = 1;
+done:
+	if (off >= len+begin)
+		return 0;
+	*start = page + (off-begin);
+	return ((count < begin+len-off) ? count : begin+len-off);
+}
+
+/*
+ * ---------------------------------------------------------------------
+ * rs_init() and friends
+ *
+ * rs_init() is called at boot-time to initialize the serial driver.
+ * ---------------------------------------------------------------------
+ */
+
+/*
+ * This routine prints out the appropriate serial driver version
+ * number, and identifies which options were configured into this
+ * driver.
+ */
+static char serial_options[] __initdata =
+       " no serial options enabled\n";
+#undef SERIAL_OPT
+
+static _INLINE_ void show_serial_version(void)
+{
+ 	printk(KERN_INFO "%s version %s%s (%s) with%s", serial_name,
+	       serial_version, LOCAL_VERSTRING, serial_revdate,
+	       serial_options);
+}
+
+
+/*
+ * This routine is called by rs_init() to initialize a specific serial
+ * port.  It determines what type of UART chip this serial port is
+ * using: 8250, 16450, 16550, 16550A.  The important question is
+ * whether or not this UART is a 16550A or not, since this will
+ * determine whether or not we can use its FIFO features or not.
+ */
+static void autoconfig(struct serial_state * state)
+{
+	struct async_struct *info, scr_info;
+	unsigned long flags;
+
+
+#ifdef SERIAL_DEBUG_AUTOCONF
+	printk("Testing ttyS%d (0x%04lx, 0x%04x)...\n", state->line,
+	       state->port, (unsigned) state->iomem_base);
+#endif
+	
+	if (!CONFIGURED_SERIAL_PORT(state))
+		return;
+
+	if (inl(UART_MOD_CNTRL + state->port) != 0x3) {
+		outl(3, UART_MOD_CNTRL + state->port);
+	}
+		
+	state->type = PORT_16550;
+	info = &scr_info;	/* This is just for serial_{in,out} */
+
+	info->magic = SERIAL_MAGIC;
+	info->state = state;
+	info->port = state->port;
+	info->flags = state->flags;
+	info->io_type = state->io_type;
+	info->iomem_base = state->iomem_base;
+	info->iomem_reg_shift = state->iomem_reg_shift;
+
+
+	save_flags(flags); cli();
+	state->xmit_fifo_size =	uart_config[state->type].dfl_xmit_fifo_size;
+
+	if (info->port) {
+			request_region(info->port,8,"serial(auto)");
+	}
+
+	/*
+	 * Reset the UART.
+	 */
+	serial_outp(info, UART_FCR, (UART_FCR_ENABLE_FIFO |
+				     UART_FCR_CLEAR_RCVR |
+				     UART_FCR_CLEAR_XMIT));
+	serial_outp(info, UART_FCR, 0);
+	(void)serial_in(info, UART_RX);
+	serial_outp(info, UART_IER, 0);
+	
+	restore_flags(flags);
+}
+
+int register_serial(struct serial_struct *req);
+void unregister_serial(int line);
+
+EXPORT_SYMBOL(register_serial);
+EXPORT_SYMBOL(unregister_serial);
+
+
+/*
+ * The serial driver boot-time initialization code!
+ */
+static int __init rs_init(void)
+{
+	int i;
+	struct serial_state * state;
+
+	init_bh(SERIAL_BH, do_serial_bh);
+	init_timer(&serial_timer);
+	serial_timer.function = rs_timer;
+	mod_timer(&serial_timer, jiffies + RS_STROBE_TIME);
+
+	for (i = 0; i < NR_IRQS; i++) {
+		IRQ_ports[i] = 0;
+		IRQ_timeout[i] = 0;
+	}
+#ifdef CONFIG_AU1000_SERIAL_CONSOLE
+	/*
+	 *	The interrupt of the serial console port
+	 *	can't be shared.
+	 */
+	if (sercons.flags & CON_CONSDEV) {
+		for(i = 0; i < NR_PORTS; i++)
+			if (i != sercons.index &&
+			    rs_table[i].irq == rs_table[sercons.index].irq)
+				rs_table[i].irq = 0;
+	}
+#endif
+	show_serial_version();
+
+	/* Initialize the tty_driver structure */
+	
+	memset(&serial_driver, 0, sizeof(struct tty_driver));
+	serial_driver.magic = TTY_DRIVER_MAGIC;
+	serial_driver.driver_name = "serial";
+#if (LINUX_VERSION_CODE > 0x2032D && defined(CONFIG_DEVFS_FS))
+	serial_driver.name = "tts/%d";
+#else
+	serial_driver.name = "ttyS";
+#endif
+	serial_driver.major = TTY_MAJOR;
+	serial_driver.minor_start = 64 + SERIAL_DEV_OFFSET;
+	serial_driver.num = NR_PORTS;
+	serial_driver.type = TTY_DRIVER_TYPE_SERIAL;
+	serial_driver.subtype = SERIAL_TYPE_NORMAL;
+	serial_driver.init_termios = tty_std_termios;
+	serial_driver.init_termios.c_cflag =
+		B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+	serial_driver.flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS;
+	serial_driver.refcount = &serial_refcount;
+	serial_driver.table = serial_table;
+	serial_driver.termios = serial_termios;
+	serial_driver.termios_locked = serial_termios_locked;
+
+	serial_driver.open = rs_open;
+	serial_driver.close = rs_close;
+	serial_driver.write = rs_write;
+	serial_driver.put_char = rs_put_char;
+	serial_driver.flush_chars = rs_flush_chars;
+	serial_driver.write_room = rs_write_room;
+	serial_driver.chars_in_buffer = rs_chars_in_buffer;
+	serial_driver.flush_buffer = rs_flush_buffer;
+	serial_driver.ioctl = rs_ioctl;
+	serial_driver.throttle = rs_throttle;
+	serial_driver.unthrottle = rs_unthrottle;
+	serial_driver.set_termios = rs_set_termios;
+	serial_driver.stop = rs_stop;
+	serial_driver.start = rs_start;
+	serial_driver.hangup = rs_hangup;
+	serial_driver.break_ctl = rs_break;
+	serial_driver.send_xchar = rs_send_xchar;
+	serial_driver.wait_until_sent = rs_wait_until_sent;
+	serial_driver.read_proc = rs_read_proc;
+	
+	/*
+	 * The callout device is just like normal device except for
+	 * major number and the subtype code.
+	 */
+	callout_driver = serial_driver;
+#if (LINUX_VERSION_CODE > 0x2032D && defined(CONFIG_DEVFS_FS))
+	callout_driver.name = "cua/%d";
+#else
+	callout_driver.name = "cua";
+#endif
+	callout_driver.major = TTYAUX_MAJOR;
+	callout_driver.subtype = SERIAL_TYPE_CALLOUT;
+	callout_driver.read_proc = 0;
+	callout_driver.proc_entry = 0;
+
+	if (tty_register_driver(&serial_driver))
+		panic("Couldn't register serial driver\n");
+	if (tty_register_driver(&callout_driver))
+		panic("Couldn't register callout driver\n");
+	
+	for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) {
+		state->baud_base = get_au1000_uart_baud();
+		state->magic = SSTATE_MAGIC;
+		state->line = i;
+		state->type = PORT_UNKNOWN;
+		state->custom_divisor = 0;
+		state->close_delay = 5*HZ/10;
+		state->closing_wait = 30*HZ;
+		state->callout_termios = callout_driver.init_termios;
+		state->normal_termios = serial_driver.init_termios;
+		state->icount.cts = state->icount.dsr = 
+			state->icount.rng = state->icount.dcd = 0;
+		state->icount.rx = state->icount.tx = 0;
+		state->icount.frame = state->icount.parity = 0;
+		state->icount.overrun = state->icount.brk = 0;
+		state->irq = irq_cannonicalize(state->irq);
+		if (state->hub6)
+			state->io_type = SERIAL_IO_HUB6;
+		if (state->port && check_region(state->port,8)) {
+			continue;
+		}
+
+		if (state->flags & ASYNC_BOOT_AUTOCONF) {
+			autoconfig(state);
+		}
+	}
+	for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) {
+		if (state->type == PORT_UNKNOWN) {
+			continue;
+		}
+		printk(KERN_INFO "ttyS%02d%s at 0x%04lx (irq = %d) is a %s\n",
+		       state->line + SERIAL_DEV_OFFSET,
+		       (state->flags & ASYNC_FOURPORT) ? " FourPort" : "",
+		       state->port, state->irq,
+		       uart_config[state->type].name);
+		tty_register_devfs(&serial_driver, 0,
+				   serial_driver.minor_start + state->line);
+		tty_register_devfs(&callout_driver, 0,
+				   callout_driver.minor_start + state->line);
+	}
+	return 0;
+}
+
+/*
+ * register_serial and unregister_serial allows for 16x50 serial ports to be
+ * configured at run-time, to support PCMCIA modems.
+ */
+ 
+/**
+ *	register_serial - configure a 16x50 serial port at runtime
+ *	@req: request structure
+ *
+ *	Configure the serial port specified by the request. If the
+ *	port exists and is in use an error is returned. If the port
+ *	is not currently in the table it is added.
+ *
+ *	The port is then probed and if neccessary the IRQ is autodetected
+ *	If this fails an error is returned.
+ *
+ *	On success the port is ready to use and the line number is returned.
+ */
+ 
+int register_serial(struct serial_struct *req)
+{
+	int i;
+	unsigned long flags;
+	struct serial_state *state;
+	struct async_struct *info;
+	unsigned long port;
+
+	port = req->port;
+	if (HIGH_BITS_OFFSET)
+		port += (unsigned long) req->port_high << HIGH_BITS_OFFSET;
+
+	save_flags(flags); cli();
+	for (i = 0; i < NR_PORTS; i++) {
+		if ((rs_table[i].port == port) &&
+		    (rs_table[i].iomem_base == req->iomem_base))
+			break;
+	}
+	if (i == NR_PORTS) {
+		for (i = 0; i < NR_PORTS; i++)
+			if ((rs_table[i].type == PORT_UNKNOWN) &&
+			    (rs_table[i].count == 0))
+				break;
+	}
+	if (i == NR_PORTS) {
+		restore_flags(flags);
+		return -1;
+	}
+	state = &rs_table[i];
+	if (rs_table[i].count) {
+		restore_flags(flags);
+		printk("Couldn't configure serial #%d (port=%ld,irq=%d): "
+		       "device already open\n", i, port, req->irq);
+		return -1;
+	}
+	state->irq = req->irq;
+	state->port = port;
+	state->flags = req->flags;
+	state->io_type = req->io_type;
+	state->iomem_base = req->iomem_base;
+	state->iomem_reg_shift = req->iomem_reg_shift;
+	if (req->baud_base)
+		state->baud_base = req->baud_base;
+	if ((info = state->info) != NULL) {
+		info->port = port;
+		info->flags = req->flags;
+		info->io_type = req->io_type;
+		info->iomem_base = req->iomem_base;
+		info->iomem_reg_shift = req->iomem_reg_shift;
+	}
+	autoconfig(state);
+	if (state->type == PORT_UNKNOWN) {
+		restore_flags(flags);
+		printk("register_serial(): autoconfig failed\n");
+		return -1;
+	}
+	restore_flags(flags);
+
+       printk(KERN_INFO "ttyS%02d at %s 0x%04lx (irq = %d) is a %s\n",
+	      state->line + SERIAL_DEV_OFFSET,
+	      state->iomem_base ? "iomem" : "port",
+	      state->iomem_base ? (unsigned long)state->iomem_base :
+	      state->port, state->irq, uart_config[state->type].name);
+	tty_register_devfs(&serial_driver, 0,
+			   serial_driver.minor_start + state->line); 
+	tty_register_devfs(&callout_driver, 0,
+			   callout_driver.minor_start + state->line);
+	return state->line + SERIAL_DEV_OFFSET;
+}
+
+/**
+ *	unregister_serial - deconfigure a 16x50 serial port
+ *	@line: line to deconfigure
+ *
+ *	The port specified is deconfigured and its resources are freed. Any
+ *	user of the port is disconnected as if carrier was dropped. Line is
+ *	the port number returned by register_serial().
+ */
+
+void unregister_serial(int line)
+{
+	unsigned long flags;
+	struct serial_state *state = &rs_table[line];
+
+	save_flags(flags); cli();
+	if (state->info && state->info->tty)
+		tty_hangup(state->info->tty);
+	state->type = PORT_UNKNOWN;
+	printk(KERN_INFO "tty%02d unloaded\n", state->line);
+	/* These will be hidden, because they are devices that will no longer
+	 * be available to the system. (ie, PCMCIA modems, once ejected)
+	 */
+	tty_unregister_devfs(&serial_driver,
+			     serial_driver.minor_start + state->line);
+	tty_unregister_devfs(&callout_driver,
+			     callout_driver.minor_start + state->line);
+	restore_flags(flags);
+}
+
+static void __exit rs_fini(void) 
+{
+	unsigned long flags;
+	int e1, e2;
+	int i;
+	struct async_struct *info;
+
+	/* printk("Unloading %s: version %s\n", serial_name, serial_version); */
+	del_timer_sync(&serial_timer);
+	save_flags(flags); cli();
+        remove_bh(SERIAL_BH);
+	if ((e1 = tty_unregister_driver(&serial_driver)))
+		printk("serial: failed to unregister serial driver (%d)\n",
+		       e1);
+	if ((e2 = tty_unregister_driver(&callout_driver)))
+		printk("serial: failed to unregister callout driver (%d)\n", 
+		       e2);
+	restore_flags(flags);
+
+	for (i = 0; i < NR_PORTS; i++) {
+		if ((info = rs_table[i].info)) {
+			rs_table[i].info = NULL;
+			kfree(info);
+		}
+		if ((rs_table[i].type != PORT_UNKNOWN) && rs_table[i].port) {
+				release_region(rs_table[i].port, 8);
+		}
+	}
+	if (tmp_buf) {
+		unsigned long pg = (unsigned long) tmp_buf;
+		tmp_buf = NULL;
+		free_page(pg);
+	}
+}
+
+module_init(rs_init);
+module_exit(rs_fini);
+MODULE_DESCRIPTION("Au1000 serial driver");
+
+
+/*
+ * ------------------------------------------------------------
+ * Serial console driver
+ * ------------------------------------------------------------
+ */
+#ifdef CONFIG_AU1000_SERIAL_CONSOLE
+
+#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
+
+static struct async_struct async_sercons;
+
+/*
+ *	Wait for transmitter & holding register to empty
+ */
+static inline void wait_for_xmitr(struct async_struct *info)
+{
+	unsigned int status, tmout = 0xffffff;
+
+	do {
+		status = serial_in(info, UART_LSR);
+
+		if (status & UART_LSR_BI)
+			lsr_break_flag = UART_LSR_BI;
+		
+		if (--tmout == 0)
+			break;
+	} while((status & BOTH_EMPTY) != BOTH_EMPTY);
+}
+
+
+/*
+ *	Print a string to the serial port trying not to disturb
+ *	any possible real use of the port...
+ *
+ *	The console_lock must be held when we get here.
+ */
+static void serial_console_write(struct console *co, const char *s,
+				unsigned count)
+{
+	static struct async_struct *info = &async_sercons;
+	int ier;
+	unsigned i;
+
+	/*
+	 *	First save the IER then disable the interrupts
+	 */
+	ier = serial_in(info, UART_IER);
+	serial_out(info, UART_IER, 0x00);
+
+	/*
+	 *	Now, do each character
+	 */
+	for (i = 0; i < count; i++, s++) {
+		wait_for_xmitr(info);
+
+		/*
+		 *	Send the character out.
+		 *	If a LF, also do CR...
+		 */
+		serial_out(info, UART_TX, *s);
+		if (*s == 10) {
+			wait_for_xmitr(info);
+			serial_out(info, UART_TX, 13);
+		}
+	}
+
+	/*
+	 *	Finally, Wait for transmitter & holding register to empty
+	 * 	and restore the IER
+	 */
+	wait_for_xmitr(info);
+	serial_out(info, UART_IER, ier);
+}
+
+/*
+ *	Receive character from the serial port
+ */
+static int serial_console_wait_key(struct console *co)
+{
+	static struct async_struct *info;
+	int ier, c;
+
+	info = &async_sercons;
+
+	/*
+	 *	First save the IER then disable the interrupts so
+	 *	that the real driver for the port does not get the
+	 *	character.
+	 */
+	ier = serial_in(info, UART_IER);
+	serial_out(info, UART_IER, 0x00);
+ 
+	while ((serial_in(info, UART_LSR) & UART_LSR_DR) == 0);
+	c = serial_in(info, UART_RX);
+
+	/*
+	 *	Restore the interrupts
+	 */
+	serial_out(info, UART_IER, ier);
+
+	return c;
+}
+
+static kdev_t serial_console_device(struct console *c)
+{
+	return MKDEV(TTY_MAJOR, 64 + c->index);
+}
+
+/*
+ *	Setup initial baud/bits/parity. We do two things here:
+ *	- construct a cflag setting for the first rs_open()
+ *	- initialize the serial port
+ *	Return non-zero if we didn't find a serial port.
+ */
+static int __init serial_console_setup(struct console *co, char *options)
+{
+	static struct async_struct *info;
+	struct serial_state *state;
+	unsigned cval;
+	int	baud = 9600;
+	int	bits = 8;
+	int	parity = 'n';
+	int	cflag = CREAD | HUPCL | CLOCAL;
+	int	quot = 0;
+	char	*s;
+
+	if (options) {
+		baud = simple_strtoul(options, NULL, 10);
+		s = options;
+		while(*s >= '0' && *s <= '9')
+			s++;
+		if (*s) parity = *s++;
+		if (*s) bits   = *s - '0';
+	}
+
+	/*
+	 *	Now construct a cflag setting.
+	 */
+	switch(baud) {
+		case 1200:
+			cflag |= B1200;
+			break;
+		case 2400:
+			cflag |= B2400;
+			break;
+		case 4800:
+			cflag |= B4800;
+			break;
+		case 19200:
+			cflag |= B19200;
+			break;
+		case 38400:
+			cflag |= B38400;
+			break;
+		case 57600:
+			cflag |= B57600;
+			break;
+		case 115200:
+			cflag |= B115200;
+			break;
+		case 9600:
+		default:
+			cflag |= B9600;
+			break;
+	}
+	switch(bits) {
+		case 7:
+			cflag |= CS7;
+			break;
+		default:
+		case 8:
+			cflag |= CS8;
+			break;
+	}
+	switch(parity) {
+		case 'o': case 'O':
+			cflag |= PARODD;
+			break;
+		case 'e': case 'E':
+			cflag |= PARENB;
+			break;
+	}
+	co->cflag = cflag;
+
+	/*
+	 *	Divisor, bytesize and parity
+	 */
+	state = rs_table + co->index;
+	info = &async_sercons;
+	info->magic = SERIAL_MAGIC;
+	info->state = state;
+	info->port = state->port;
+	info->flags = state->flags;
+	info->io_type = state->io_type;
+	info->iomem_base = state->iomem_base;
+	info->iomem_reg_shift = state->iomem_reg_shift;
+	state->baud_base = get_au1000_uart_baud();
+	quot = state->baud_base / baud;
+
+	cval = cflag & (CSIZE | CSTOPB);
+	cval >>= 4;
+	if (cflag & PARENB)
+		cval |= UART_LCR_PARITY;
+	if (!(cflag & PARODD))
+		cval |= UART_LCR_EPAR;
+
+	/*
+	 *	Disable UART interrupts, set DTR and RTS high
+	 *	and set speed.
+	 */
+	serial_out(info, UART_CLK, quot & 0xffff);
+	serial_out(info, UART_IER, 0);
+	serial_out(info, UART_MCR, UART_MCR_DTR | UART_MCR_RTS);
+
+	/*
+	 *	If we read 0xff from the LSR, there is no UART here.
+	 */
+	if (serial_in(info, UART_LSR) == 0xff)
+		return -1;
+
+	return 0;
+}
+
+static struct console sercons = {
+	name:		"ttyS",
+	write:		serial_console_write,
+	device:		serial_console_device,
+	wait_key:	serial_console_wait_key,
+	setup:		serial_console_setup,
+	flags:		CON_PRINTBUFFER,
+	index:		-1,
+};
+
+/*
+ *	Register console.
+ */
+void __init au1000_serial_console_init(void)
+{
+	register_console(&sercons);
+}
+#endif
+
+/*
+  Local variables:
+  compile-command: "gcc -D__KERNEL__ -I../../include -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -fno-strict-aliasing -pipe -fno-strength-reduce -march=i586 -DMODULE -DMODVERSIONS -include ../../include/linux/modversions.h   -DEXPORT_SYMTAB -c serial.c"
+  End:
+*/
diff -u --recursive --new-file v2.4.9/linux/arch/mips/au1000/common/time.c linux/arch/mips/au1000/common/time.c
--- v2.4.9/linux/arch/mips/au1000/common/time.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/au1000/common/time.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,286 @@
+/*
+ * Copyright (C) 2001 MontaVista Software, ppopov@mvista.com
+ * Copied and modified Carsten Langgaard's time.c
+ *
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 1999,2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ * ########################################################################
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * ########################################################################
+ *
+ * Setting up the clock on the MIPS boards.
+ */
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/kernel_stat.h>
+#include <linux/sched.h>
+#include <linux/spinlock.h>
+
+#include <asm/mipsregs.h>
+#include <asm/ptrace.h>
+#include <asm/div64.h>
+#include <asm/au1000.h>
+
+#include <linux/mc146818rtc.h>
+#include <linux/timex.h>
+
+extern volatile unsigned long wall_jiffies;
+unsigned long missed_heart_beats = 0;
+unsigned long uart_baud_base;
+
+static unsigned long r4k_offset; /* Amount to increment compare reg each time */
+static unsigned long r4k_cur;    /* What counter should be at next timer irq */
+extern rwlock_t xtime_lock;
+
+#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
+
+static inline void ack_r4ktimer(unsigned long newval)
+{
+	write_32bit_cp0_register(CP0_COMPARE, newval);
+}
+
+
+/*
+ * There are a lot of conceptually broken versions of the MIPS timer interrupt
+ * handler floating around.  This one is rather different, but the algorithm
+ * is provably more robust.
+ */
+unsigned long wtimer;
+void mips_timer_interrupt(struct pt_regs *regs)
+{
+	int irq = 7;
+
+	if (r4k_offset == 0)
+		goto null;
+
+	do {
+		kstat.irqs[0][irq]++;
+		do_timer(regs);
+		r4k_cur += r4k_offset;
+		ack_r4ktimer(r4k_cur);
+
+	} while (((unsigned long)read_32bit_cp0_register(CP0_COUNT)
+	         - r4k_cur) < 0x7fffffff);
+
+	return;
+
+null:
+	ack_r4ktimer(0);
+}
+
+/* 
+ * Figure out the r4k offset, the amount to increment the compare
+ * register for each time tick. 
+ * Use the Programmable Counter 1 to do this.
+ */
+unsigned long cal_r4koff(void)
+{
+	unsigned long count;
+	unsigned long cpu_pll;
+	unsigned long cpu_speed;
+	unsigned long start, end;
+	unsigned long counter;
+	int i;
+	int trim_divide = 16;
+
+	counter = inl(PC_COUNTER_CNTRL);
+	outl(counter | PC_CNTRL_EN1, PC_COUNTER_CNTRL);
+
+	while (inl(PC_COUNTER_CNTRL) & PC_CNTRL_T1S);
+	outl(trim_divide-1, PC1_TRIM);    /* RTC now ticks at 32.768/16 kHz */
+	while (inl(PC_COUNTER_CNTRL) & PC_CNTRL_T1S);
+
+	while (inl(PC_COUNTER_CNTRL) & PC_CNTRL_C1S);
+	outl (0, PC1_COUNTER_WRITE);
+	while (inl(PC_COUNTER_CNTRL) & PC_CNTRL_C1S);
+
+	start = inl(PC1_COUNTER_READ);
+	start += 2;
+	/* wait for the beginning of a new tick */
+	while (inl(PC1_COUNTER_READ) < start);
+
+	/* Start r4k counter. */
+	write_32bit_cp0_register(CP0_COUNT, 0);
+	end = start + (32768 / trim_divide)/2; /* wait 0.5 seconds */
+
+	while (end > inl(PC1_COUNTER_READ));
+
+	count = read_32bit_cp0_register(CP0_COUNT);
+	cpu_speed = count * 2;
+	uart_baud_base = (((cpu_speed) / 4) / 16);
+	return (cpu_speed / HZ);
+}
+
+static unsigned long __init get_mips_time(void)
+{
+	return inl(PC0_COUNTER_READ);
+}
+
+void __init time_init(void)
+{
+        unsigned int est_freq, flags;
+
+	printk("calculating r4koff... ");
+	r4k_offset = cal_r4koff();
+	printk("%08lx(%d)\n", r4k_offset, (int) r4k_offset);
+
+	//est_freq = 2*r4k_offset*HZ;	
+	est_freq = r4k_offset*HZ;	
+	est_freq += 5000;    /* round */
+	est_freq -= est_freq%10000;
+	printk("CPU frequency %d.%02d MHz\n", est_freq/1000000, 
+	       (est_freq%1000000)*100/1000000);
+	r4k_cur = (read_32bit_cp0_register(CP0_COUNT) + r4k_offset);
+
+	write_32bit_cp0_register(CP0_COMPARE, r4k_cur);
+	set_cp0_status(ALLINTS);
+
+	/* Read time from the RTC chipset. */
+	write_lock_irqsave (&xtime_lock, flags);
+	xtime.tv_sec = get_mips_time();
+	xtime.tv_usec = 0;
+	write_unlock_irqrestore(&xtime_lock, flags);
+}
+
+/* This is for machines which generate the exact clock. */
+#define USECS_PER_JIFFY (1000000/HZ)
+#define USECS_PER_JIFFY_FRAC ((1000000ULL << 32) / HZ & 0xffffffff)
+
+/* Cycle counter value at the previous timer interrupt.. */
+
+static unsigned int timerhi = 0, timerlo = 0;
+
+static unsigned long
+div64_32(unsigned long v1, unsigned long v2, unsigned long v3)
+{
+	unsigned long r0;
+	do_div64_32(r0, v1, v2, v3);
+	return r0;
+}
+
+
+/*
+ * FIXME: Does playing with the RP bit in c0_status interfere with this code?
+ */
+static unsigned long do_fast_gettimeoffset(void)
+{
+	u32 count;
+	unsigned long res, tmp;
+	unsigned long r0;
+
+	/* Last jiffy when do_fast_gettimeoffset() was called. */
+	static unsigned long last_jiffies=0;
+	unsigned long quotient;
+
+	/*
+	 * Cached "1/(clocks per usec)*2^32" value.
+	 * It has to be recalculated once each jiffy.
+	 */
+	static unsigned long cached_quotient=0;
+
+	tmp = jiffies;
+
+	quotient = cached_quotient;
+
+	if (tmp && last_jiffies != tmp) {
+		last_jiffies = tmp;
+		if (last_jiffies != 0) {
+			r0 = div64_32(timerhi, timerlo, tmp);
+			quotient = div64_32(USECS_PER_JIFFY, USECS_PER_JIFFY_FRAC, r0);
+			cached_quotient = quotient;
+		}
+	}
+
+	/* Get last timer tick in absolute kernel time */
+	count = read_32bit_cp0_register(CP0_COUNT);
+
+	/* .. relative to previous jiffy (32 bits is enough) */
+	count -= timerlo;
+
+	__asm__("multu\t%1,%2\n\t"
+		"mfhi\t%0"
+		:"=r" (res)
+		:"r" (count),
+		 "r" (quotient));
+
+	/*
+ 	 * Due to possible jiffies inconsistencies, we need to check 
+	 * the result so that we'll get a timer that is monotonic.
+	 */
+	if (res >= USECS_PER_JIFFY)
+		res = USECS_PER_JIFFY-1;
+
+	return res;
+}
+
+void do_gettimeofday(struct timeval *tv)
+{
+	unsigned int flags;
+
+	read_lock_irqsave (&xtime_lock, flags);
+	*tv = xtime;
+	tv->tv_usec += do_fast_gettimeoffset();
+
+	/*
+	 * xtime is atomically updated in timer_bh. jiffies - wall_jiffies
+	 * is nonzero if the timer bottom half hasnt executed yet.
+	 */
+	if (jiffies - wall_jiffies)
+		tv->tv_usec += USECS_PER_JIFFY;
+
+	read_unlock_irqrestore (&xtime_lock, flags);
+
+	if (tv->tv_usec >= 1000000) {
+		tv->tv_usec -= 1000000;
+		tv->tv_sec++;
+	}
+}
+
+void do_settimeofday(struct timeval *tv)
+{
+	write_lock_irq (&xtime_lock);
+
+	/* This is revolting. We need to set the xtime.tv_usec correctly.
+	 * However, the value in this location is is value at the last tick.
+	 * Discover what correction gettimeofday would have done, and then
+	 * undo it!
+	 */
+	tv->tv_usec -= do_fast_gettimeoffset();
+
+	if (tv->tv_usec < 0) {
+		tv->tv_usec += 1000000;
+		tv->tv_sec--;
+	}
+
+	xtime = *tv;
+	time_adjust = 0;		/* stop active adjtime() */
+	time_status |= STA_UNSYNC;
+	time_maxerror = NTP_PHASE_LIMIT;
+	time_esterror = NTP_PHASE_LIMIT;
+
+	write_unlock_irq (&xtime_lock);
+}
+
+/*
+ * The UART baud base is not known at compile time ... if
+ * we want to be able to use the same code on different
+ * speed CPUs.
+ */
+unsigned long get_au1000_uart_baud()
+{
+	return uart_baud_base;
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/au1000/pb1000/Makefile linux/arch/mips/au1000/pb1000/Makefile
--- v2.4.9/linux/arch/mips/au1000/pb1000/Makefile	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/au1000/pb1000/Makefile	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,24 @@
+#
+#  Copyright 2000 MontaVista Software Inc.
+#  Author: MontaVista Software, Inc.
+#     	ppopov@mvista.com or source@mvista.com
+#
+# Makefile for the Alchemy Semiconductor PB1000 board.
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+
+.S.s:
+	$(CPP) $(CFLAGS) $< -o $*.s
+.S.o:
+	$(CC) $(CFLAGS) -c $< -o $*.o
+
+all: pb1000.o
+
+O_TARGET := pb1000.o
+
+obj-y := init.o setup.o
+
+include $(TOPDIR)/Rules.make
diff -u --recursive --new-file v2.4.9/linux/arch/mips/au1000/pb1000/init.c linux/arch/mips/au1000/pb1000/init.c
--- v2.4.9/linux/arch/mips/au1000/pb1000/init.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/au1000/pb1000/init.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,59 @@
+/*
+ *
+ * BRIEF MODULE DESCRIPTION
+ *	PB1000 board setup
+ *
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: MontaVista Software, Inc.
+ *         	ppopov@mvista.com or source@mvista.com
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <linux/bootmem.h>
+#include <asm/addrspace.h>
+#include <asm/bootinfo.h>
+#include <linux/config.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+
+extern int prom_argc;
+extern char **prom_argv, **prom_envp;
+extern void  __init prom_init_cmdline(void);
+
+int __init prom_init(int argc, char **argv, char **envp, int *prom_vec)
+{
+	prom_argc = argc;
+	prom_argv = argv;
+	prom_envp = envp;
+
+	mips_machgroup = MACH_GROUP_ALCHEMY;
+	mips_machtype = MACH_PB1000;  
+
+	prom_init_cmdline();
+
+	add_memory_region(1, 64 << 20, BOOT_MEM_RAM);
+
+	return 0;
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/au1000/pb1000/setup.c linux/arch/mips/au1000/pb1000/setup.c
--- v2.4.9/linux/arch/mips/au1000/pb1000/setup.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/au1000/pb1000/setup.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,117 @@
+/*
+ *
+ * BRIEF MODULE DESCRIPTION
+ *	Au1000-based board setup.
+ *
+ * Copyright 2000 MontaVista Software Inc.
+ * Author: MontaVista Software, Inc.
+ *         	ppopov@mvista.com or source@mvista.com
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/ioport.h>
+#include <linux/console.h>
+#include <linux/mc146818rtc.h>
+
+#include <asm/cpu.h>
+#include <asm/bootinfo.h>
+#include <asm/irq.h>
+#include <asm/mipsregs.h>
+#include <asm/reboot.h>
+#include <asm/au1000.h>
+
+#if defined(CONFIG_AU1000_SERIAL_CONSOLE)
+extern void console_setup(char *, int *);
+char serial_console[20];
+#endif
+
+void (*__wbflush) (void);
+extern struct rtc_ops no_rtc_ops;
+extern char * __init prom_getcmdline(void);
+extern void au1000_restart(void);
+extern void au1000_halt(void);
+extern void au1000_power_off(void);
+
+struct {
+    struct resource ram;
+    struct resource io;
+    struct resource sram;
+    struct resource flash;
+    struct resource boot;
+    struct resource pcmcia;
+    struct resource lcd;
+} au1000_resources = {
+    { "RAM",           0,          0x3FFFFFF,  IORESOURCE_MEM },
+    { "I/O",           0x10000000, 0x119FFFFF                 },
+    { "SRAM",          0x1e000000, 0x1E03FFFF                 },
+    { "System Flash",  0x1F800000, 0x1FBFFFFF                 },
+    { "Boot ROM",      0x1FC00000, 0x1FFFFFFF                 },
+    { "PCMCIA",        0x20000000, 0x27FFFFFF                 },
+    { "LCD",           0x60000000, 0x603FFFFF                 },
+};
+
+void au1000_wbflush(void)
+{
+	__asm__ volatile ("sync");
+}
+
+void __init au1000_setup(void)
+{
+	char *argptr;
+
+	argptr = prom_getcmdline();
+
+#ifdef CONFIG_AU1000_SERIAL_CONSOLE
+	if ((argptr = strstr(argptr, "console=ttyS0")) == NULL) {
+		argptr = prom_getcmdline();
+		strcat(argptr, " console=ttyS0,115200");
+	}
+#endif	  
+
+	//set_cp0_status(ST0_FR,0);
+	rtc_ops = &no_rtc_ops;
+        __wbflush = au1000_wbflush;
+	_machine_restart = au1000_restart;
+	_machine_halt = au1000_halt;
+	_machine_power_off = au1000_power_off;
+
+	/*
+	 * IO/MEM resources. 
+	 */
+	mips_io_port_base = KSEG1;
+	ioport_resource.start = au1000_resources.io.start;
+	ioport_resource.end = au1000_resources.lcd.end;
+
+#ifdef CONFIG_BLK_DEV_INITRD
+	ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);
+#endif
+
+	outl(PC_CNTRL_E0 | PC_CNTRL_EN0 | PC_CNTRL_EN0, PC_COUNTER_CNTRL);
+	while (inl(PC_COUNTER_CNTRL) & PC_CNTRL_T0S);
+	outl(0x8000-1, PC0_TRIM);
+
+	printk("Alchemy Semi PB1000 Board\n");
+	printk("Au1000/PB1000 port (C) 2001 MontaVista Software, Inc. (source@mvista.com)\n");
+}
+
diff -u --recursive --new-file v2.4.9/linux/arch/mips/baget/irq.c linux/arch/mips/baget/irq.c
--- v2.4.9/linux/arch/mips/baget/irq.c	Tue Mar  6 19:44:36 2001
+++ linux/arch/mips/baget/irq.c	Sun Sep  9 10:43:01 2001
@@ -4,8 +4,6 @@
  * Copyright (C) 1998 Vladimir Roganov & Gleb Raiko
  *      Code (mostly sleleton and comments) derived from DECstation IRQ
  *      handling.
- *
- * $Id: irq.c,v 1.6 2000/02/04 07:40:23 ralf Exp $
  */
 #include <linux/errno.h>
 #include <linux/init.h>
@@ -180,7 +178,7 @@
 	int do_random, cpu;
 
 	cpu = smp_processor_id();
-	irq_enter(cpu);
+	irq_enter(cpu, irq);
 	kstat.irqs[cpu][irq]++;
 
 	mask_irq(irq);  
@@ -202,7 +200,7 @@
 		printk("do_IRQ: Unregistered IRQ (0x%X) occurred\n", irq);
 	}
 	unmask_irq(irq);
-	irq_exit(cpu);
+	irq_exit(cpu, irq);
 
 	/* unmasking and bottom half handling is done magically for us. */
 }
@@ -358,13 +356,6 @@
 	}
 	printk("Trying to free free IRQ%d\n",irq);
 }
-
-static int baget_irq_canonicalize(int irq) 
-{
-	return irq;
-}
-
-int (*irq_cannonicalize)(int irq) = baget_irq_canonicalize; 
 
 unsigned long probe_irq_on (void)
 {
diff -u --recursive --new-file v2.4.9/linux/arch/mips/baget/prom/init.c linux/arch/mips/baget/prom/init.c
--- v2.4.9/linux/arch/mips/baget/prom/init.c	Mon Feb 28 07:18:20 2000
+++ linux/arch/mips/baget/prom/init.c	Sun Sep  9 10:43:01 2001
@@ -2,25 +2,24 @@
  * init.c: PROM library initialisation code.
  *
  * Copyright (C) 1998 Gleb Raiko & Vladimir Roganov 
- *
- * $Id: init.c,v 1.3 1999/10/09 00:00:57 ralf Exp $
  */
 #include <linux/init.h>
+#include <asm/addrspace.h>
 #include <asm/bootinfo.h>
 
-char arcs_cmdline[CL_SIZE];
+char arcs_cmdline[COMMAND_LINE_SIZE];
 
-int __init prom_init(unsigned int mem_upper)
+void __init prom_init(unsigned int mem_upper)
 {
-	mips_memory_upper = mem_upper;
+	mem_upper = PHYSADDR(mem_upper);
+
 	mips_machgroup  = MACH_GROUP_UNKNOWN;
 	mips_machtype   = MACH_UNKNOWN;
 	arcs_cmdline[0] = 0;
-	return 0;
-}
 
-void __init prom_fixup_mem_map(unsigned long start, unsigned long end)
-{
+	vac_memory_upper = mem_upper;
+
+	add_memory_region(0, mem_upper, BOOT_MEM_RAM);
 }
 
 void prom_free_prom_memory (void)
diff -u --recursive --new-file v2.4.9/linux/arch/mips/baget/setup.c linux/arch/mips/baget/setup.c
--- v2.4.9/linux/arch/mips/baget/setup.c	Mon Feb 28 07:18:20 2000
+++ linux/arch/mips/baget/setup.c	Sun Sep  9 10:43:01 2001
@@ -14,7 +14,7 @@
 
 #include <asm/baget/baget.h>
 
-extern long mips_memory_upper;
+long int vac_memory_upper;
 
 #define CACHEABLE_STR(val) ((val) ? "not cached" : "cached")
 #define MIN(a,b)           (((a)<(b)) ? (a):(b)) 
@@ -172,7 +172,7 @@
 
 static void __init vac_init(void)
 {
-	unsigned short mem_limit = ((mips_memory_upper-KSEG0) >> 16);
+	unsigned short mem_limit = (vac_memory_upper >> 16);
 
 	switch(vac_inw(VAC_ID)) {
 	case 0x1AC0:
diff -u --recursive --new-file v2.4.9/linux/arch/mips/baget/time.c linux/arch/mips/baget/time.c
--- v2.4.9/linux/arch/mips/baget/time.c	Sat May 13 08:29:14 2000
+++ linux/arch/mips/baget/time.c	Sun Sep  9 10:43:01 2001
@@ -1,4 +1,4 @@
-/* $Id: time.c,v 1.3 1999/08/17 22:18:37 ralf Exp $
+/*
  * time.c: Baget/MIPS specific time handling details
  *
  * Copyright (C) 1998 Gleb Raiko & Vladimir Roganov
@@ -13,7 +13,7 @@
 #include <linux/mm.h>
 #include <linux/interrupt.h>
 #include <linux/timex.h>
-#include <linux/kernel_stat.h>
+#include <linux/spinlock.h>
 
 #include <asm/bootinfo.h>
 #include <asm/io.h>
@@ -23,11 +23,14 @@
 
 #include <asm/baget/baget.h>
 
+extern rwlock_t xtime_lock;
+
 /* 
  *  To have precision clock, we need to fix available clock frequency
  */
 #define FREQ_NOM  79125  /* Baget frequency ratio */
 #define FREQ_DEN  10000
+
 static inline int timer_intr_valid(void) 
 {
 	static unsigned long long ticks, valid_ticks;
@@ -47,8 +50,8 @@
 void static timer_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
 	if (timer_intr_valid()) {
-	sti();
-	do_timer(regs);
+		sti();
+		do_timer(regs);
 	}
 }
 
@@ -76,21 +79,20 @@
 
 void do_gettimeofday(struct timeval *tv)
 {
-        unsigned long flags;
+	unsigned long flags;
 
-        save_and_cli(flags);
-        *tv = xtime;
-        restore_flags(flags);
+	read_lock_irqsave (&xtime_lock, flags);
+	*tv = xtime;
+	read_unlock_irqrestore (&xtime_lock, flags);
 }
 
 void do_settimeofday(struct timeval *tv)
 {
-        unsigned long flags;
-  
-        save_and_cli(flags);
-        xtime = *tv;
-        time_state = TIME_BAD;
-        time_maxerror = MAXPHASE;
-        time_esterror = MAXPHASE;
-        restore_flags(flags);
-} 
+	write_lock_irq (&xtime_lock);
+	xtime = *tv;
+	time_adjust = 0;		/* stop active adjtime() */
+	time_status |= STA_UNSYNC;
+	time_maxerror = NTP_PHASE_LIMIT;
+	time_esterror = NTP_PHASE_LIMIT;
+	write_unlock_irq (&xtime_lock);
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/baget/vacserial.c linux/arch/mips/baget/vacserial.c
--- v2.4.9/linux/arch/mips/baget/vacserial.c	Fri Feb  9 11:29:44 2001
+++ linux/arch/mips/baget/vacserial.c	Sun Sep  9 10:43:01 2001
@@ -1,4 +1,4 @@
-/* $Id: vacserial.c,v 1.3 1999/08/17 22:18:37 ralf Exp $
+/*
  * vacserial.c: VAC UART serial driver
  *              This code stealed and adopted from linux/drivers/char/serial.c
  *              See that for author info
@@ -1300,7 +1300,7 @@
 		goto check_and_exit;
 	}
 
-	new_serial.irq = irq_cannonicalize(new_serial.irq);
+	new_serial.irq = new_serial.irq;
 
 	if ((new_serial.irq >= NR_IRQS) || (new_serial.port > 0xffff) ||
 	    (new_serial.baud_base == 0) || (new_serial.type < PORT_UNKNOWN) ||
@@ -1417,12 +1417,10 @@
 static int set_modem_info(struct async_struct * info, unsigned int cmd,
 			  unsigned int *value)
 {
-	int error;
 	unsigned int arg;
 
-	error = get_user(arg, value);
-	if (error)
-		return error;
+	if (get_user(arg, value))
+		return -EFAULT;
 	switch (cmd) {
 	default:
 		return -EINVAL;
@@ -2426,7 +2424,7 @@
 		state->icount.rx = state->icount.tx = 0;
 		state->icount.frame = state->icount.parity = 0;
 		state->icount.overrun = state->icount.brk = 0;
-		state->irq = irq_cannonicalize(state->irq);
+		state->irq = state->irq;
 		if (check_region(state->port,8))
 			continue;
 	        if (state->flags & ASYNC_BOOT_AUTOCONF)
diff -u --recursive --new-file v2.4.9/linux/arch/mips/boot/Makefile linux/arch/mips/boot/Makefile
--- v2.4.9/linux/arch/mips/boot/Makefile	Sun Jul  9 22:18:15 2000
+++ linux/arch/mips/boot/Makefile	Sun Sep  9 10:43:01 2001
@@ -1,10 +1,9 @@
-# $Id: Makefile,v 1.9 1999/04/07 18:45:23 harald Exp $
 #
 # This file is subject to the terms and conditions of the GNU General Public
 # License.  See the file "COPYING" in the main directory of this archive
 # for more details.
 #
-# Copyright (C) 1995, 1998 by Ralf Baechle
+# Copyright (C) 1995, 1998, 2001 by Ralf Baechle
 #
 
 .S.s:
@@ -46,25 +45,12 @@
 
 clean:
 	rm -f vmlinux.ecoff
-	rm -f zImage zImage.tmp mkboot
+	rm -f zImage zImage.tmp
 
 mrproper:
 	rm -f vmlinux.ecoff
 	rm -f addinitrd
 	rm -f elf2ecoff
-
-zImage:	$(CONFIGURE) mkboot $(TOPDIR)/vmlinux
-	$(OBJCOPY) $(strip-flags) $(TOPDIR)/vmlinux zImage.tmp
-	./mkboot zImage.tmp zImage
-	rm -f zImage.tmp
-
-mkboot: mkboot.c
-	$(HOSTCC) -o $@ $^
-
-zdisk: 	zImage
-	cp $(TOPDIR)/vmlinux $(TOPDIR)/vm
-	$(STRIP) $(TOPDIR)/vm
-	gzip -9f $(TOPDIR)/vm
 
 dummy:
 
diff -u --recursive --new-file v2.4.9/linux/arch/mips/boot/mkboot.c linux/arch/mips/boot/mkboot.c
--- v2.4.9/linux/arch/mips/boot/mkboot.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/boot/mkboot.c	Wed Dec 31 16:00:00 1969
@@ -1,658 +0,0 @@
-/*
- * Make a bootable image from a Linux/MIPS kernel.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1996, 2001 by Ralf Baechle
- *
- * This file is written in plain Kernighan & Ritchie C as it has to run
- * on all crosscompile hosts no matter how braindead.  This code might
- * also become part of Milo.  It's therefore important that we don't use
- * seek because the Seek() call of the Magnum 4000 ARC BIOS is broken.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-/*
- * Define this for verbose debugging output.
- */
-#undef VERBOSE
-
-/*
- * Don't use the host's elf.h - it might be using incompatible defines
- */
-
-#define EI_NIDENT 16
-
-/*
- * Basic ELF types.
- */
-typedef unsigned short Elf32_Half;
-typedef unsigned short Elf32_Section;
-typedef unsigned int Elf32_Word;
-typedef unsigned int Elf32_Addr;
-typedef unsigned int Elf32_Off;
-
-typedef struct
-{
-  unsigned char e_ident[EI_NIDENT];     /* Magic number and other info */
-  Elf32_Half    e_type;                 /* Object file type */
-  Elf32_Half    e_machine;              /* Architecture */
-  Elf32_Word    e_version;              /* Object file version */
-  Elf32_Addr    e_entry;                /* Entry point virtual address */
-  Elf32_Off     e_phoff;                /* Program header table file offset */
-  Elf32_Off     e_shoff;                /* Section header table file offset */
-  Elf32_Word    e_flags;                /* Processor-specific flags */
-  Elf32_Half    e_ehsize;               /* ELF header size in bytes */
-  Elf32_Half    e_phentsize;            /* Program header table entry size */
-  Elf32_Half    e_phnum;                /* Program header table entry count */
-  Elf32_Half    e_shentsize;            /* Section header table entry size */
-  Elf32_Half    e_shnum;                /* Section header table entry count */
-  Elf32_Half    e_shstrndx;             /* Section header string table index */
-} Elf32_Ehdr;
-
-/*
- * ELF magic number
- */
-#define ELFMAG          "\177ELF"
-#define SELFMAG         4
-
-#define EI_CLASS        4               /* File class byte index */
-#define ELFCLASSNONE    0               /* Invalid class */
-#define ELFCLASS32      1               /* 32-bit objects */
-#define ELFCLASS64      2               /* 64-bit objects */
-
-#define EI_DATA         5               /* Data encoding byte index */
-#define ELFDATA2LSB     1               /* 2's complement, little endian */
-#define ELFDATA2MSB     2               /* 2's complement, big endian */
-
-#define EI_VERSION      6               /* File version byte index */
-#define EV_CURRENT      1               /* Current version */
-
-/*
- * Acceptable machine type in e_machine.
- */
-#define EM_MIPS         8               /* MIPS R3000 big-endian */
-
-/*
- * The type of ELF file we accept.
- */
-#define ET_EXEC         2               /* Executable file */
-
-/*
- * Definition of a single program header structure
- */
-typedef struct
-{
-  Elf32_Word    p_type;                 /* Segment type */
-  Elf32_Off     p_offset;               /* Segment file offset */
-  Elf32_Addr    p_vaddr;                /* Segment virtual address */
-  Elf32_Addr    p_paddr;                /* Segment physical address */
-  Elf32_Word    p_filesz;               /* Segment size in file */
-  Elf32_Word    p_memsz;                /* Segment size in memory */
-  Elf32_Word    p_flags;                /* Segment flags */
-  Elf32_Word    p_align;                /* Segment alignment */
-} Elf32_Phdr;
-
-/*
- * Legal values for p_type
- */
-#define PT_NULL         0               /* Program header table entry unused */
-#define PT_LOAD         1               /* Loadable program segment */
-#define PT_DYNAMIC      2               /* Dynamic linking information */
-#define PT_INTERP       3               /* Program interpreter */
-#define PT_NOTE         4               /* Auxiliary information */
-#define PT_SHLIB        5               /* Reserved */
-#define PT_PHDR         6               /* Entry for header table itself */
-#define PT_NUM          7               /* Number of defined types.  */
-#define PT_LOPROC       0x70000000      /* Start of processor-specific */
-#define PT_HIPROC       0x7fffffff      /* End of processor-specific */
-
-typedef struct
-{
-  Elf32_Word    sh_name;                /* Section name (string tbl index) */
-  Elf32_Word    sh_type;                /* Section type */
-  Elf32_Word    sh_flags;               /* Section flags */
-  Elf32_Addr    sh_addr;                /* Section virtual addr at execution */
-  Elf32_Off     sh_offset;              /* Section file offset */
-  Elf32_Word    sh_size;                /* Section size in bytes */
-  Elf32_Word    sh_link;                /* Link to another section */
-  Elf32_Word    sh_info;                /* Additional section information */
-  Elf32_Word    sh_addralign;           /* Section alignment */
-  Elf32_Word    sh_entsize;             /* Entry size if section holds table */
-} Elf32_Shdr;
-
-typedef struct
-{
-  Elf32_Word    st_name;                /* Symbol name (string tbl index) */
-  Elf32_Addr    st_value;               /* Symbol value */
-  Elf32_Word    st_size;                /* Symbol size */
-  unsigned char st_info;                /* Symbol type and binding */
-  unsigned char st_other;               /* No defined meaning, 0 */
-  Elf32_Section st_shndx;               /* Section index */
-} Elf32_Sym;
-
-/* How to extract and insert information held in the st_info field.  */
-#define ELF32_ST_BIND(val)              (((unsigned char) (val)) >> 4)
-#define ELF32_ST_TYPE(val)              ((val) & 0xf)
-
-/* Legal values for ST_BIND subfield of st_info (symbol binding).  */
-#define STB_GLOBAL      1               /* Global symbol */
-
-/* Legal values for ST_TYPE subfield of st_info (symbol type).  */
-#define STT_NOTYPE      0               /* Symbol type is unspecified */
-#define STT_OBJECT      1               /* Symbol is a data object */
-#define STT_FUNC        2               /* Symbol is a code object */
-
-static unsigned int
-get_Elf32_Half(unsigned char *p)
-{
-	return p[0] | (p[1] << 8);
-}
-#define get_Elf32_Section(p) get_Elf32_Half(p)
-
-static unsigned int
-get_Elf32_Word(unsigned char *p)
-{
-	return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
-}
-#define get_Elf32_Addr(p) get_Elf32_Word(p)
-#define get_Elf32_Off(p) get_Elf32_Word(p)
-
-static void
-put_byte(p, x)
-	unsigned char *p;
-	unsigned char x;
-{
-	p[0] = x;
-}
-
-static void
-put_half(p, x)
-	unsigned char *p;
-	unsigned short x;
-{
-	p[0] = x & 0xff;
-	p[1] = (x >> 8) & 0xff;
-}
-
-static void
-put_word(p, x)
-	unsigned char *p;
-	unsigned long x;
-{
-	p[0] = x & 0xff;
-	p[1] = (x >> 8) & 0xff;
-	p[2] = (x >> 16) & 0xff;
-	p[3] = (x >> 24) & 0xff;
-}
-
-/*
- * Swap a program header in.
- */
-static void
-get_elfph(p, ph)
-	unsigned char *p;
-	Elf32_Phdr *ph;
-{
-	ph->p_type   = get_Elf32_Word(p);
-	ph->p_offset = get_Elf32_Off(p + 4);
-	ph->p_vaddr  = get_Elf32_Addr(p + 8);
-	ph->p_paddr  = get_Elf32_Addr(p + 12);
-	ph->p_filesz = get_Elf32_Word(p + 16);
-	ph->p_memsz  = get_Elf32_Word(p + 20);
-	ph->p_flags  = get_Elf32_Word(p + 24);
-	ph->p_align  = get_Elf32_Word(p + 28);
-}
-
-/*
- * Swap a section header in.
- */
-static void
-get_elfsh(p, sh)
-	unsigned char *p;
-	Elf32_Shdr *sh;
-{
-	sh->sh_name      = get_Elf32_Word(p);
-	sh->sh_type      = get_Elf32_Word(p + 4);
-	sh->sh_flags     = get_Elf32_Word(p + 8);
-	sh->sh_addr      = get_Elf32_Addr(p + 12);
-	sh->sh_offset    = get_Elf32_Off(p + 16);
-	sh->sh_size      = get_Elf32_Word(p + 20);
-	sh->sh_link      = get_Elf32_Word(p + 24);
-	sh->sh_info      = get_Elf32_Word(p + 28);
-	sh->sh_addralign = get_Elf32_Word(p + 32);
-	sh->sh_entsize   = get_Elf32_Word(p + 36);
-}
-
-/*
- * Swap a section header in.
- */
-static void
-get_elfsym(p, sym)
-	unsigned char *p;
-	Elf32_Sym *sym;
-{
-	sym->st_name      = get_Elf32_Word(p);
-	sym->st_value     = get_Elf32_Addr(p + 4);
-	sym->st_size      = get_Elf32_Word(p + 8);
-	sym->st_info      = *(p + 12);
-	sym->st_other     = *(p + 13);
-	sym->st_shndx     = get_Elf32_Section(p + 14);
-}
-
-/*
- * The a.out magic number
- */
-#define OMAGIC 0407	/* Code indicating object file or impure executable. */
-#define M_MIPS1 151	/* MIPS R3000/R3000 binary */
-#define M_MIPS2 152	/* MIPS R6000/R4000 binary */
-
-/*
- * Compute and return an a.out magic number.
- */
-#define AOUT_INFO(magic, type, flags) \
-        (((magic) & 0xffff) | \
-         (((int)(type) & 0xff) << 16) | \
-         (((flags) & 0xff) << 24))
-
-/*
- * a.out symbols
- */
-#define N_UNDF 0
-#define N_ABS 2
-#define N_TEXT 4
-#define N_DATA 6
-#define N_BSS 8
-#define N_FN 15
-#define N_EXT 1
-
-#define min(x,y) (((x)<(y))?(x):(y))
-
-static void
-do_read(fd, buf, size)
-	int fd;
-	char *buf;
-	ssize_t size;
-{
-	ssize_t rd;
-
-	while(size != 0) {
-		rd = read(fd, buf, size);
-		if (rd == -1) {
-			perror("Can't read from file.");
-			exit(1);
-		}
-		size -= rd;
-	}
-}
-
-static void
-writepad(fd, size)
-	int fd;
-	size_t size;
-{
-	static void *zeropage = NULL;
-	ssize_t written;
-
-	if (zeropage == NULL) {
-		zeropage = malloc(4096);
-		if (zeropage == NULL) {
-			fprintf(stderr, "Couldn't allocate zero buffer.\n");
-			exit(1);
-		}
-		memset(zeropage, '\0', 4096);
-	}
-	while(size != 0) {
-		written = write(fd, zeropage, min(4096, size));
-		if (written == -1) {
-			perror("Can't write to boot image");
-			exit(1);
-		}
-		size -= written;
-	}
-}
-
-static void
-do_write(fd, buf, size)
-	int fd;
-	char *buf;
-	ssize_t size;
-{
-	ssize_t written;
-
-	while(size != 0) {
-		written = write(fd, buf, size);
-		if (written == -1) {
-			perror("Can't write to boot image");
-			exit(1);
-		}
-		size -= written;
-	}
-}
-
-static int
-usage(program_name)
-	char *program_name;
-{
-	fprintf(stderr, "Usage: %s infile outfile\n", program_name);
-	exit(0);
-}
-
-int
-main(argc, argv)
-	int argc;
-	char *argv[];
-{
-	char *infile, *outfile;
-	struct stat ifstat;
-	off_t ifsize;
-	char *image;
-	int ifd, ofd, i, symtabix, strtabix;
-	Elf32_Ehdr eh;
-	Elf32_Phdr *ph;
-	Elf32_Shdr *sh;
-	unsigned long vaddr, entry, bss, kernel_entry, kernel_end;
-	unsigned char ahdr[32];
-	Elf32_Sym sym;
-	int	symnum;
-	char *symname;
-
-	/*
-	 * Verify some basic assuptions about type sizes made in this code
-	 */
-	if (sizeof(Elf32_Half) != 2) {
-		fprintf(stderr, "Fix mkboot: sizeof(Elf32_Half) != 2\n");
-		exit(1);
-	}
-	if (sizeof(Elf32_Word) != 4) {
-		fprintf(stderr, "Fix mkboot: sizeof(Elf32_Word) != 4\n");
-		exit(1);
-	}
-	if (sizeof(Elf32_Addr) != 4) {
-		fprintf(stderr, "Fix mkboot: sizeof(Elf32_Addr) != 4\n");
-		exit(1);
-	}
-
-	if (argc != 3)
-		usage(argv[0]);
-
-	infile = argv[1];
-	outfile = argv[2];
-
-	if (stat(infile, &ifstat) < 0) {
-		perror("Can't stat kernel image.");
-		exit(1);
-	}
-
-	if (!S_ISREG(ifstat.st_mode)) {
-		fprintf(stderr, "Input file isn't a regular file.\n");
-		exit(1);
-	}
-	ifsize = ifstat.st_size;
-
-	image = malloc((size_t)ifsize);
-	if (image == NULL) {
-		fprintf(stderr, "Can't allocate memory to read file\n");
-		exit(1);
-	}
-
-	/*
-	 * Read the entire input file in.
-	 */
-	ifd = open(infile, O_RDONLY);
-	if(ifd == 0) {
-		fprintf(stderr, "Can't open input file\n");
-		exit(1);
-	}
-	do_read(ifd, image, ifsize);
-	close(ifd);
-
-	/*
-	 * Now swap the ELF header in.  This is ugly but we the file
-	 * we're reading might have different type sizes, byteorder
-	 * or alignment than the host.
-	 */
-	memcpy(eh.e_ident, (void *)image, sizeof(eh.e_ident));
-	if(memcmp(eh.e_ident, ELFMAG, SELFMAG)) {
-		fprintf(stderr, "Input file isn't a ELF file\n");
-		exit(1);
-	}
-	if(eh.e_ident[EI_CLASS] != ELFCLASS32) {
-		fprintf(stderr, "Input file isn't a 32 bit ELF file\n");
-		exit(1);
-	}
-	if(eh.e_ident[EI_DATA] != ELFDATA2LSB) {
-		fprintf(stderr, "Input file isn't a little endian ELF file\n");
-		exit(1);
-	}
-	if(eh.e_ident[EI_VERSION] != EV_CURRENT) {
-		fprintf(stderr, "Input file isn't a version %d ELF file\n",
-		        EV_CURRENT);
-		exit(1);
-	}
-
-	/*
-	 * Ok, so far the file looks ok.  Now swap the rest of the header in
-	 * and do some more paranoia checks.
-	 */
-	eh.e_type      = get_Elf32_Half(image + 16);
-	eh.e_machine   = get_Elf32_Half(image + 18);
-	eh.e_version   = get_Elf32_Word(image + 20);
-	eh.e_entry     = get_Elf32_Addr(image + 24);
-	eh.e_phoff     = get_Elf32_Off(image + 28);
-	eh.e_shoff     = get_Elf32_Off(image + 32);
-	eh.e_flags     = get_Elf32_Word(image + 36);
-	eh.e_ehsize    = get_Elf32_Half(image + 40);
-	eh.e_phentsize = get_Elf32_Half(image + 42);
-	eh.e_phnum     = get_Elf32_Half(image + 44);
-	eh.e_shentsize = get_Elf32_Half(image + 46);
-	eh.e_shnum     = get_Elf32_Half(image + 48);
-	eh.e_shstrndx  = get_Elf32_Half(image + 50);
-
-	if(eh.e_type != ET_EXEC) {
-		fprintf(stderr, "Input file isn't a executable.\n");
-		exit(1);
-	}
-	if(eh.e_machine != EM_MIPS) {
-		fprintf(stderr, "Input file isn't a MIPS executable.\n");
-		exit(1);
-	}
-
-	/*
-	 * Now read the program headers ...
-	 */
-	ph = malloc(sizeof(Elf32_Phdr) * eh.e_phnum);
-	if (ph == NULL) {
-		fprintf(stderr, "No memory for program header table.\n");
-		exit(1);
-	}
-	for(i = 0;i < eh.e_phnum; i++)
-		get_elfph((void *)(image + eh.e_phoff + i * 32), ph + i);
-
-	/*
-	 * ... and then the section headers.
-	 */
-	sh = malloc(sizeof(Elf32_Shdr) * eh.e_shnum);
-	if (sh == NULL) {
-		fprintf(stderr, "No memory for section header table.\n");
-		exit(1);
-	}
-	for(i = 0;i < eh.e_shnum; i++)
-		get_elfsh((void *)(image + eh.e_shoff + (i * 40)), sh + i);
-
-	/*
-	 * Find the symboltable and the stringtable in the file.
-	 */
-	for(i = 0;i < eh.e_shnum; i++) {
-		if (!strcmp (image + sh [eh.e_shstrndx].sh_offset + sh[i].sh_name,
-		             ".symtab")) {
-			symtabix = i;
-			continue;
-		}
-		if (!strcmp (image + sh [eh.e_shstrndx].sh_offset + sh[i].sh_name,
-		             ".strtab")) {
-			strtabix = i;
-			continue;
-		}
-	}
-
-	if (symtabix == -1) {
-		fprintf(stderr, "The executable doesn't have a symbol table\n");
-		exit(1);
-	}
-	if (strtabix == -1) {
-		fprintf(stderr, "The executable doesn't have a string table\n");
-		exit(1);
-	}
-
-	/*
-	 * Dig for the two required symbols in the symbol table.
-	 */
-	symnum = sh[symtabix].sh_size / 16;
-	for(i = 0;i < symnum;i++) {
-		get_elfsym(image + sh[symtabix].sh_offset + (i * 16), &sym);
-		symname = image + sh[strtabix].sh_offset + sym.st_name;
-		if (ELF32_ST_BIND(sym.st_info) != STB_GLOBAL)
-			continue;
-		if (ELF32_ST_TYPE(sym.st_info) != STT_NOTYPE &&
-		    ELF32_ST_TYPE(sym.st_info) != STT_OBJECT &&
-		    ELF32_ST_TYPE(sym.st_info) != STT_FUNC)
-			continue;
-		if (strcmp("kernel_entry", symname) == 0) {
-			kernel_entry = sym.st_value;
-			continue;
-		}
-		if (strcmp("_end", symname) == 0) {
-			kernel_end = sym.st_value;
-			continue;
-		}
-	}
-
-#ifdef VERBOSE
-	/*
-	 * And print what we will be loaded into memory.
-	 */
-	for(i = 0;i < eh.e_phnum; i++) {
-		if (ph[i].p_type != PT_LOAD) {
-			continue;
-		}
-		printf("  Offset: %08lx\n", ph[i].p_offset);
-		printf("  file size: %08lx\n", ph[i].p_filesz);
-		printf("  mem size: %08lx\n", ph[i].p_memsz);
-		printf("    Loading: %08lx - %08lx\n",
-		       ph[i].p_vaddr, ph[i].p_vaddr + ph[i].p_filesz);
-		printf("    Zero mapping: %08lx - %08lx\n",
-		       ph[i].p_vaddr + ph[i].p_filesz,
-		       ph[i].p_vaddr + ph[i].p_memsz);
-	}
-#endif
-
-	/*
-	 * Time to open the outputfile.
-	 */
-	ofd = open(outfile, O_WRONLY|O_CREAT|O_TRUNC, 0666);
-	if (ofd == -1) {
-		perror("Can't open boot image for output.");
-		exit(1);
-	}
-
-	/*
-	 * First compute the layout of the file.  We need to do this
-	 * first because we can't seek back to the beginning due to the
-	 * broken Seek() call in the Magnum firmware.
-	 */
-	entry = vaddr = 0xffffffff;
-	bss = 0;
-	for(i = 0;i < eh.e_phnum; i++) {
-		if (ph[i].p_type != PT_LOAD)
-			continue;
-		if (vaddr == 0xffffffff)
-			entry = vaddr = ph[i].p_vaddr;
-		vaddr = ph[i].p_vaddr + ph[i].p_filesz;
-		bss = ph[i].p_memsz - ph[i].p_filesz;
-	}
-
-	/*
-	 * In the next step we construct the boot image.  The boot file
-	 * looks essentially like a dump of the loaded kernel with a
-	 * minimal header.  Because Milo supports already a.out image
-	 * we simply dump the image in an a.out image ...  First let's
-	 * write the header.
-	 */
-
-	/*
-	 * Create and write the a.out header.
-	 */
-	put_word(ahdr, AOUT_INFO(OMAGIC, M_MIPS1, 0));
-	put_word(ahdr + 4, vaddr - entry);	/* text size */
-	put_word(ahdr + 8, 0);			/* data size */
-	put_word(ahdr + 12, bss);		/* bss size */
-	put_word(ahdr + 16, 2 * 12);		/* size of symbol table */
-	put_word(ahdr + 20, entry);		/* base address */
-	put_word(ahdr + 24, 0);			/* size of text relocations */
-	put_word(ahdr + 28, 0);			/* size of data relocations */
-	do_write(ofd, ahdr, 32);
-
-	/*
-	 * Write text and data segment combined into the a.out text segment
-	 * and a zero length data segment into the file.
-	 */
-	vaddr = 0xffffffff;
-	bss = 0;
-	for(i = 0;i < eh.e_phnum; i++) {
-		if (ph[i].p_type != PT_LOAD)
-			continue;
-		if (vaddr == 0xffffffff)
-			vaddr = ph[i].p_vaddr;
-		writepad(ofd, ph[i].p_vaddr - vaddr);	/* Write zero pad */
-		do_write(ofd, image + ph[i].p_offset, ph[i].p_filesz);
-		vaddr = ph[i].p_vaddr + ph[i].p_filesz;
-		bss = ph[i].p_memsz - ph[i].p_filesz;
-	}
-
-	/*
-	 * Now write the symbol table.  It has only two symbols,
-	 * kernel_entry and _end which we need for booting.
-	 */
-	put_word(ahdr    , 4);			/* n_un.n_strx */
-	put_byte(ahdr + 4, N_TEXT | N_EXT);	/* n_type */
-	put_byte(ahdr + 5, 0);			/* n_other */
-	put_half(ahdr + 6, 0);			/* n_desc */
-	put_word(ahdr + 8, kernel_entry);	/* n_value */
-	do_write(ofd, ahdr, 12);
-
-	put_word(ahdr    , 4 + 13);		/* n_un.n_strx */
-	put_byte(ahdr + 4, N_ABS | N_EXT);	/* n_type */
-	put_byte(ahdr + 5, 0);			/* n_other */
-	put_half(ahdr + 6, 0);			/* n_desc */
-	put_word(ahdr + 8, kernel_end);		/* n_value */
-	do_write(ofd, ahdr, 12);
-
-	/*
-	 * Now write stringtable size and the strings.
-	 */
-	put_word(ahdr, 4 + 20);
-	do_write(ofd, ahdr, 4);
-	do_write(ofd, "kernel_entry\0_end\0\0", 20);
-
-	/*
-	 * That's is all ...
-	 */
-	close(ofd);
-
-#ifdef VERBOSE
-	printf("Entry: %08lx\n", entry);
-	printf("Dumped image %08lx - %08lx\n", 0x80000000, vaddr);
-	printf("Extra bss at end: %08lx\n", bss);
-#endif
-
-	return 0;
-}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/config.in linux/arch/mips/config.in
--- v2.4.9/linux/arch/mips/config.in	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/config.in	Sun Sep  9 10:43:02 2001
@@ -76,6 +76,7 @@
 #
 unset CONFIG_ARC32
 unset CONFIG_BOARD_SCACHE
+unset CONFIG_COHERENT_IO
 unset CONFIG_HAVE_STD_PC_SERIAL_PORT
 unset CONFIG_I8259
 unset CONFIG_ISA
@@ -92,6 +93,8 @@
    define_bool CONFIG_PCI y
    define_bool CONFIG_MIPS_GT96100 y
    define_bool CONFIG_SWAP_IO_SPACE y
+   define_bool CONFIG_NEW_PCI y
+   define_bool CONFIG_PCI_AUTO y
 fi
 if [ "$CONFIG_MIPS_EV64120" = "y" ]; then
    define_bool CONFIG_PCI y
@@ -132,6 +135,7 @@
    define_bool CONFIG_I8259 y
    define_bool CONFIG_PCI y
    define_bool CONFIG_HAVE_STD_PC_SERIAL_PORT y
+   define_bool CONFIG_NEW_IRQ y
    define_bool CONFIG_SWAP_IO_SPACE y
 fi
 if [ "$CONFIG_MOMENCO_OCELOT" = "y" ]; then
@@ -158,7 +162,7 @@
    define_bool CONFIG_ROTTEN_IRQ y
    define_bool CONFIG_OLD_TIME_C y
 fi
-if [ "$CONFIG_DDB5074" = "y"]; then
+if [ "$CONFIG_DDB5074" = "y" ]; then
    define_bool CONFIG_I8259 y
    define_bool CONFIG_ISA y
    define_bool CONFIG_PCI y
@@ -168,7 +172,6 @@
    define_bool CONFIG_OLD_TIME_C y
 fi
 if [ "$CONFIG_DDB5476"  = "y" ]; then
-   define_bool CONFIG_I8259 y
    define_bool CONFIG_ISA y
    define_bool CONFIG_PCI y
    define_bool CONFIG_PC_KEYB y
@@ -186,6 +189,8 @@
    define_bool CONFIG_PCI y
    define_bool CONFIG_IT8712 y
    define_bool CONFIG_PC_KEYB y
+   define_bool CONFIG_NEW_PCI y
+   define_bool CONFIG_PCI_AUTO y
 fi
 if [ "$CONFIG_MIPS_IVR" = "y" ]; then
    define_bool CONFIG_PCI y
@@ -229,33 +234,45 @@
 choice 'CPU type' \
 	"R3000 CONFIG_CPU_R3000	\
 	 R6000 CONFIG_CPU_R6000	\
+	 R41xx CONFIG_CPU_VR41XX \
 	 R4300 CONFIG_CPU_R4300	\
 	 R4x00 CONFIG_CPU_R4X00	\
 	 R5000 CONFIG_CPU_R5000	\
-         R5432 CONFIG_CPU_R5432 \
+	 R5432 CONFIG_CPU_R5432 \
 	 RM7000 CONFIG_CPU_RM7000 \
 	 R52xx CONFIG_CPU_NEVADA \
 	 R10000 CONFIG_CPU_R10000 \
 	 SB1    CONFIG_CPU_SB1    \
-	 MIPS32 CONFIG_CPU_MIPS32" R4x00
+	 MIPS32 CONFIG_CPU_MIPS32 \
+	 MIPS64 CONFIG_CPU_MIPS64" R4x00
 
 bool 'Override CPU Options' CONFIG_CPU_ADVANCED
 
 if [ "$CONFIG_CPU_ADVANCED" = "y" ]; then
    bool '  ll/sc Instructions available' CONFIG_CPU_HAS_LLSC
+   bool '  lld/scd Instructions available' CONFIG_CPU_HAS_LLDSCD
    bool '  Writeback Buffer available' CONFIG_CPU_HAS_WB
 else
-   if [ "$CONFIG_CPU_R3000" = "y" ]; then
-      if [ "$CONFIG_DECSTATION" = "y" ]; then
+   if [ "$CONFIG_CPU_R3000" = "y" -o "$CONFIG_CPU_VR41XX" = "y" ]; then
+      if [ "CONFIG_DECSTATION" = "y" ]; then
 	 define_bool CONFIG_CPU_HAS_LLSC n
+	 define_bool CONFIG_CPU_HAS_LLDSCD n
 	 define_bool CONFIG_CPU_HAS_WB y
       else
 	 define_bool CONFIG_CPU_HAS_LLSC n
+	 define_bool CONFIG_CPU_HAS_LLDSCD n
 	 define_bool CONFIG_CPU_HAS_WB n
       fi
    else
+      if [ "$CONFIG_CPU_MIPS32" = "y" ]; then
+	 define_bool CONFIG_CPU_HAS_LLSC y
+	 define_bool CONFIG_CPU_HAS_LLDSCD n
+	 define_bool CONFIG_CPU_HAS_WB n
+      else
 	 define_bool CONFIG_CPU_HAS_LLSC y
+	 define_bool CONFIG_CPU_HAS_LLDSCD y
 	 define_bool CONFIG_CPU_HAS_WB n
+      fi
    fi
 fi
 endmenu
@@ -270,7 +287,6 @@
 else
    bool 'Generate little endian code' CONFIG_CPU_LITTLE_ENDIAN
 fi
-bool 'Kernel floating-point emulation' CONFIG_MIPS_FPU_EMULATOR
 
 if [ "$CONFIG_PROC_FS" = "y" ]; then
    define_bool CONFIG_KCORE_ELF y
@@ -361,7 +377,7 @@
 
 if [ "$CONFIG_DECSTATION" != "y" -a \
      "$CONFIG_SGI_IP22" != "y" ]; then
-   source drivers/message/i2o/Config.in
+   source drivers/i2o/Config.in
 fi
 
 if [ "$CONFIG_NET" = "y" ]; then
@@ -492,9 +508,6 @@
 comment 'Kernel hacking'
 
 bool 'Are you using a crosscompiler' CONFIG_CROSSCOMPILE
-if [ "$CONFIG_MODULES" = "y" ]; then
-   bool ' Build fp execption handler module' CONFIG_MIPS_FPE_MODULE
-fi
 if [ "$CONFIG_SERIAL" = "y" -o "$CONFIG_AU1000_UART" = "y" ]; then
   bool 'Remote GDB kernel debugging' CONFIG_REMOTE_DEBUG
   dep_bool 'Console output to GDB' CONFIG_GDB_CONSOLE $CONFIG_REMOTE_DEBUG
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5074/pci.c linux/arch/mips/ddb5074/pci.c
--- v2.4.9/linux/arch/mips/ddb5074/pci.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/ddb5074/pci.c	Sun Sep  9 10:43:01 2001
@@ -417,5 +417,9 @@
 	}
 }
 
+unsigned __init int pcibios_assign_all_busses(void)
+{
+	return 1;
+}
 
 struct pci_fixup pcibios_fixups[] = { };
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5476/int-handler.S linux/arch/mips/ddb5476/int-handler.S
--- v2.4.9/linux/arch/mips/ddb5476/int-handler.S	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/ddb5476/int-handler.S	Sun Sep  9 10:43:01 2001
@@ -68,6 +68,8 @@
 	and	s0, s1, t2		# isolate allowed ones
 #endif
 	/* First we check for r4k counter/timer IRQ. */
+	andi	a0, s0, CAUSEF_IP7	# cpu timer */
+	bnez	a0, cpu_timer_irq
 	andi	a0, s0, CAUSEF_IP2	# delay slot, check local level zero
 	beq	a0, zero, 1f
 	 andi	a0, s0, CAUSEF_IP3	# delay slot, check local level one
@@ -119,6 +121,15 @@
 	/* phamtom interrupt */
 	move 	a0, s1
 	jal	ddb_phantom_irq
+	nop
+	j	ret_from_irq
+	nop
+
+cpu_timer_irq:
+	li	a0, 0
+	move	a1, sp
+	jal	do_IRQ 
+	/* jal	ll_timer_interrupt */
 	nop
 	j	ret_from_irq
 	nop
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5476/pci.c linux/arch/mips/ddb5476/pci.c
--- v2.4.9/linux/arch/mips/ddb5476/pci.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/ddb5476/pci.c	Sun Sep  9 10:43:01 2001
@@ -14,7 +14,6 @@
 
 #include <asm-mips/nile4.h>
 
-
 static u32 nile4_pre_pci_access0(int slot_num)
 {
 	u32 pci_addr = 0;
@@ -490,6 +489,11 @@
 		start = (start + 1024 - 1) & ~(1024 - 1);
 		res->start = start;
 	}
+}
+
+unsigned __init int pcibios_assign_all_busses(void)
+{
+	return 1;
 }
 
 struct pci_fixup pcibios_fixups[] = { {0} };
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5476/setup.c linux/arch/mips/ddb5476/setup.c
--- v2.4.9/linux/arch/mips/ddb5476/setup.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/ddb5476/setup.c	Sun Sep  9 10:43:01 2001
@@ -24,6 +24,7 @@
 #include <asm/reboot.h>
 #include <asm/gdb-stub.h>
 #include <asm/nile4.h>
+#include <asm/time.h>
 
 
 #ifdef CONFIG_REMOTE_DEBUG
@@ -71,13 +72,27 @@
 
 extern void ddb_irq_setup(void);
 
-void (*board_time_init) (struct irqaction * irq);
-
-
 static void __init ddb_time_init(struct irqaction *irq)
 {
-	/* set the clock to 1 Hz */
-	nile4_out32(NILE4_T2CTRL, 1000000);
+	printk("ddb_time_init invoked.\n");
+	mips_counter_frequency = 83000000;
+}
+
+static void __init ddb_timer_setup(struct irqaction *irq)
+{
+	unsigned int count;
+
+	/* we are using the cpu counter for timer interrupts */
+	i8259_setup_irq(0, irq);
+	set_cp0_status(IE_IRQ5);
+
+	/* to generate the first timer interrupt */
+	count = read_32bit_cp0_register(CP0_COUNT);
+	write_32bit_cp0_register(CP0_COMPARE, count + 1000);
+
+#if 0		/* the old way to do timer interrupt */
+	/* set the clock to 100 Hz */
+	nile4_out32(NILE4_T2CTRL, 830000);
 	/* enable the General-Purpose Timer */
 	nile4_out32(NILE4_T2CTRL + 4, 0x00000001);
 	/* reset timer */
@@ -85,6 +100,7 @@
 	/* enable interrupt */
 	nile4_enable_irq(NILE4_INT_GPT);
 	i8259_setup_irq(nile4_to_irq(NILE4_INT_GPT), irq);
+#endif
 }
 
 static struct {
@@ -119,7 +135,9 @@
 	irq_setup = ddb_irq_setup;
 	mips_io_port_base = NILE4_PCI_IO_BASE;
 	isa_slot_offset = NILE4_PCI_MEM_BASE;
+
 	board_time_init = ddb_time_init;
+	board_timer_setup = ddb_timer_setup;
 
 	_machine_restart = ddb_machine_restart;
 	_machine_halt = ddb_machine_halt;
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5xxx/common/Makefile linux/arch/mips/ddb5xxx/common/Makefile
--- v2.4.9/linux/arch/mips/ddb5xxx/common/Makefile	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ddb5xxx/common/Makefile	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,18 @@
+#
+# Makefile for the common code of NEC DDB-Vrc5xxx board
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+
+.S.s:
+	$(CPP) $(CFLAGS) $< -o $*.s
+.S.o:
+	$(CC) $(CFLAGS) -c $< -o $*.o
+
+O_TARGET:= ddb5xxx.o
+
+obj-y	 += irq.o irq_cpu.o nile4.o prom.o pci.o pci_auto.o rtc_ds1386.o
+
+include $(TOPDIR)/Rules.make
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5xxx/common/irq.c linux/arch/mips/ddb5xxx/common/irq.c
--- v2.4.9/linux/arch/mips/ddb5xxx/common/irq.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ddb5xxx/common/irq.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: jsun@mvista.com or jsun@junsun.net
+ *
+ * arch/mips/ddb5xxx/common/irq.c
+ *     Common irq code for DDB boards.  This really should belong
+ *	arch/mips/kernel/irq.c.  Need to talk to Ralf.
+ *
+ * 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 <linux/config.h>
+#include <linux/init.h>
+
+void (*irq_setup)(void);
+
+void __init init_IRQ(void)
+{
+#ifdef CONFIG_REMOTE_DEBUG
+	extern void breakpoint(void);
+	extern void set_debug_traps(void);
+
+	printk("Wait for gdb client connection ...\n");
+	set_debug_traps();
+	breakpoint();
+#endif
+
+	/* invoke board-specific irq setup */
+	irq_setup();
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5xxx/common/irq_cpu.c linux/arch/mips/ddb5xxx/common/irq_cpu.c
--- v2.4.9/linux/arch/mips/ddb5xxx/common/irq_cpu.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ddb5xxx/common/irq_cpu.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,115 @@
+/***********************************************************************
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
+ *
+ *  arch/mips/ddb5xxx/common/irq_cpu.c
+ *     This file define the irq handler for MIPS CPU interrupts.
+ *
+ * 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.
+ ***********************************************************************
+ */
+
+/*
+ * Almost all MIPS CPUs define 8 interrupt sources.  They are typically
+ * level triggered (i.e., cannot be cleared from CPU; must be cleared from
+ * device).  The first two are software interrupts.  The last one is 
+ * usually cpu timer interrupt if coutner register is present.
+ *
+ * This file exports one global function:
+ *	mips_cpu_irq_init(u32 irq_base);
+ */
+
+#include <linux/irq.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+
+#include <asm/mipsregs.h>
+
+/* [jsun] sooner or later we should move this debug stuff to MIPS common */
+#include <asm/ddb5xxx/debug.h>
+
+static int mips_cpu_irq_base=-1;
+
+static void 
+mips_cpu_irq_enable(unsigned int irq)
+{
+	MIPS_ASSERT(mips_cpu_irq_base != -1);
+	MIPS_ASSERT(irq >= mips_cpu_irq_base);
+	MIPS_ASSERT(irq < mips_cpu_irq_base+8);
+
+	clear_cp0_cause( 1 << (irq - mips_cpu_irq_base + 8));
+	set_cp0_status(1 << (irq - mips_cpu_irq_base + 8));
+}
+
+static void 
+mips_cpu_irq_disable(unsigned int irq)
+{
+	MIPS_ASSERT(mips_cpu_irq_base != -1);
+	MIPS_ASSERT(irq >= mips_cpu_irq_base);
+	MIPS_ASSERT(irq < mips_cpu_irq_base+8);
+
+	clear_cp0_status(1 << (irq - mips_cpu_irq_base + 8));
+}
+
+static unsigned int mips_cpu_irq_startup(unsigned int irq)
+{
+	mips_cpu_irq_enable(irq);
+	return 0;
+}
+
+#define	mips_cpu_irq_shutdown	mips_cpu_irq_disable
+
+static void
+mips_cpu_irq_ack(unsigned int irq)
+{
+	MIPS_ASSERT(mips_cpu_irq_base != -1);
+	MIPS_ASSERT(irq >= mips_cpu_irq_base);
+	MIPS_ASSERT(irq < mips_cpu_irq_base+8);
+
+	/* although we attemp to clear the IP bit in cause reigster, I think
+	 * usually it is cleared by device (irq source)
+	 */
+	clear_cp0_cause( 1 << (irq - mips_cpu_irq_base + 8));
+
+	/* I am not fully convinced that I should disable irq here */
+}
+
+static void
+mips_cpu_irq_end(unsigned int irq)
+{
+	MIPS_ASSERT(mips_cpu_irq_base != -1);
+	MIPS_ASSERT(irq >= mips_cpu_irq_base);
+	MIPS_ASSERT(irq < mips_cpu_irq_base+8);
+	/* I am not fully convinced that I should enable irq here */
+}
+
+static hw_irq_controller mips_cpu_irq_controller = {
+	"CPU_irq",
+	mips_cpu_irq_startup,
+	mips_cpu_irq_shutdown,
+	mips_cpu_irq_enable,
+	mips_cpu_irq_disable,
+	mips_cpu_irq_ack,
+	mips_cpu_irq_end,
+	NULL			/* no affinity stuff for UP */
+};
+
+
+void 
+mips_cpu_irq_init(u32 irq_base)
+{
+	extern irq_desc_t irq_desc[];
+	u32 i;
+
+	for (i= irq_base; i< irq_base+8; i++) {
+		irq_desc[i].status = IRQ_DISABLED;
+		irq_desc[i].action = NULL;
+		irq_desc[i].depth = 1;
+		irq_desc[i].handler = &mips_cpu_irq_controller;
+	}
+
+	mips_cpu_irq_base = irq_base;
+} 
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5xxx/common/nile4.c linux/arch/mips/ddb5xxx/common/nile4.c
--- v2.4.9/linux/arch/mips/ddb5xxx/common/nile4.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ddb5xxx/common/nile4.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,135 @@
+/***********************************************************************
+ *
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: jsun@mvista.com or jsun@junsun.net
+ *
+ * arch/mips/ddb5xxx/common/nile4.c
+ *     misc low-level routines for vrc-5xxx controllers.
+ *
+ * derived from original code by Geert Uytterhoeven <geert@sonycom.com>
+ *
+ * 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 <linux/config.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+
+#include <asm/ddb5xxx/ddb5xxx.h>
+#include <asm/ddb5xxx/debug.h>
+
+u32
+ddb_calc_pdar(u32 phys, u32 size, int width, 
+	      int on_memory_bus, int pci_visible)
+{
+        u32 maskbits;
+        u32 widthbits;
+
+        switch (size) {
+#if 0                           /* We don't support 4 GB yet */
+        case 0x100000000:       /* 4 GB */
+                maskbits = 4;
+                break;
+#endif
+        case 0x80000000:        /* 2 GB */
+                maskbits = 5;
+                break;
+        case 0x40000000:        /* 1 GB */
+                maskbits = 6;
+                break;
+        case 0x20000000:        /* 512 MB */
+                maskbits = 7;
+                break;
+        case 0x10000000:        /* 256 MB */
+                maskbits = 8;
+                break;
+        case 0x08000000:        /* 128 MB */
+                maskbits = 9;
+                break;
+        case 0x04000000:        /* 64 MB */
+                maskbits = 10;
+                break;
+        case 0x02000000:        /* 32 MB */
+                maskbits = 11;
+                break;
+        case 0x01000000:        /* 16 MB */
+                maskbits = 12;
+                break;
+        case 0x00800000:        /* 8 MB */
+                maskbits = 13;
+                break;
+        case 0x00400000:        /* 4 MB */
+                maskbits = 14;
+                break;
+        case 0x00200000:        /* 2 MB */
+                maskbits = 15;
+                break;
+        case 0:         /* OFF */
+                maskbits = 0;
+                break;
+        default:
+                panic("nile4_set_pdar: unsupported size %p\n", (void *) size);
+        }
+        switch (width) {
+        case 8:
+                widthbits = 0;
+                break;
+        case 16:
+                widthbits = 1;
+                break;
+        case 32:
+                widthbits = 2;
+                break;
+        case 64:
+                widthbits = 3;
+                break;
+        default:
+                panic("nile4_set_pdar: unsupported width %d\n", width);
+        }
+
+	return maskbits | (on_memory_bus ? 0x10 : 0) |
+		(pci_visible ? 0x20 : 0) | (widthbits << 6) |
+		(phys & 0xffe00000);
+}
+
+void
+ddb_set_pdar(u32 pdar, u32 phys, u32 size, int width,
+	     int on_memory_bus, int pci_visible)
+{
+	u32 temp= ddb_calc_pdar(phys, size, width, on_memory_bus, pci_visible);
+	ddb_out32(pdar, temp);
+	ddb_out32(pdar + 4, 0);
+
+        /*
+         * When programming a PDAR, the register should be read immediately
+         * after writing it. This ensures that address decoders are properly
+         * configured.
+	 * [jsun] is this really necesary?
+         */
+        ddb_in32(pdar);
+        ddb_in32(pdar + 4);
+}
+
+/*
+ * routines that mess with PCIINITx registers
+ */
+
+void ddb_set_pmr(u32 pmr, u32 type, u32 addr, u32 options)
+{
+        switch (type) {
+        case DDB_PCICMD_IACK: /* PCI Interrupt Acknowledge */
+        case DDB_PCICMD_IO:   /* PCI I/O Space */
+        case DDB_PCICMD_MEM:  /* PCI Memory Space */
+        case DDB_PCICMD_CFG:  /* PCI Configuration Space */
+                break;
+        default:
+                panic("nile4_set_pmr: invalid type %d\n", type);
+        }
+        ddb_out32(pmr, (type << 1) | (addr & 0xffe00000) | options );
+        ddb_out32(pmr + 4, 0);
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5xxx/common/pci.c linux/arch/mips/ddb5xxx/common/pci.c
--- v2.4.9/linux/arch/mips/ddb5xxx/common/pci.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ddb5xxx/common/pci.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,179 @@
+/***********************************************************************
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
+ *
+ * arch/mips/ddb5xxx/common/pci.c
+ *     Common PCI routines for DDB5xxx - as a matter of fact, meant for all 
+ *	MIPS machines.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ ***********************************************************************
+ */
+
+/*
+ * This file contains common PCI routines meant to be shared for
+ * all MIPS machines.
+ *
+ * Strategies:
+ *
+ * . We rely on pci_auto.c file to assign PCI resources (MEM and IO)
+ *   TODO: this shold be optional for some machines where they do have
+ *   a real "pcibios" that does resource assignment.
+ *
+ * . We then use pci_scan_bus() to "discover" all the resources for
+ *   later use by Linux.
+ *
+ * . We finally reply on a board supplied function, pcibios_fixup_irq(), to 
+ *   to assign the interrupts.  We may use setup-irq.c under drivers/pci
+ *   later.
+ *
+ * . Specifically, we will *NOT* use pci_assign_unassigned_resources(),
+ *   because we assume all PCI devices should have the resources correctly
+ *   assigned and recorded.
+ *
+ * Limitations:
+ *
+ * . We "collapse" all IO and MEM spaces in sub-buses under a top-level bus 
+ *   into a contiguous range.  
+ * 
+ * . In the case of Memory space, the rnage is 1:1 mapping with CPU physical
+ *   address space.
+ *
+ * . In the case of IO space, it starts from 0, and the beginning address
+ *   is mapped to KSEG0ADDR(mips_io_port) in the CPU physical address.
+ *
+ * . These are the current MIPS limitations (by ioremap, etc).  In the
+ *   future, we may remove them.
+ *
+ * Credits:
+ *	Most of the code are derived from the pci routines from PPC and Alpha,
+ *	which were mostly writtne by
+ *		Cort Dougan, cort@fsmlabs.com
+ *		Matt Porter, mporter@mvista.com
+ *		Dave Rusling david.rusling@reo.mts.dec.com
+ *		David Mosberger davidm@cs.arizona.edu
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+
+#include <asm/ddb5xxx/pci.h>
+#include <asm/ddb5xxx/debug.h>
+
+
+struct pci_fixup pcibios_fixups[] = { {0} };
+
+
+extern int pciauto_assign_resources(int busno, struct pci_channel * hose);
+void __init pcibios_init(void)
+{
+	struct pci_channel *p;
+	struct pci_bus *bus;
+	int busno;
+
+	/* assign resources */
+	busno=0;
+	for (p= mips_pci_channels; p->pci_ops != NULL; p++) {
+		busno = pciauto_assign_resources(busno, p) + 1;
+	}
+
+	/* scan the buses */
+	busno = 0;
+	for (p= mips_pci_channels; p->pci_ops != NULL; p++) {
+		bus = pci_scan_bus(busno, p->pci_ops, p);
+		busno = bus->subordinate+1;
+	}
+
+	/* fixup irqs (board specific routines) */
+	pcibios_fixup_irqs();
+
+	/* 
+	 * should we do a fixup of ioport_resource and iomem_resource
+	 * based on mips_pci_channels?  
+	 * Let us wait and see if this is a common need and whether there
+	 * are exceptions.  Until then, each board should adjust them
+	 * perhaps in their setup() function.
+	 */
+}
+
+int pcibios_enable_device(struct pci_dev *dev)
+{
+	/* pciauto_assign_resources() will enable all devices found */
+	return 0;
+}
+
+unsigned long __init
+pci_bridge_check_io(struct pci_dev *bridge)
+{
+        u16 io;
+
+        pci_read_config_word(bridge, PCI_IO_BASE, &io);
+        if (!io) {
+                pci_write_config_word(bridge, PCI_IO_BASE, 0xf0f0);
+                pci_read_config_word(bridge, PCI_IO_BASE, &io);
+                pci_write_config_word(bridge, PCI_IO_BASE, 0x0);
+        }
+        if (io)
+                return IORESOURCE_IO;
+        printk(KERN_WARNING "PCI: bridge %s does not support I/O forwarding!\n",
+                                bridge->name);
+        return 0;
+}
+
+void __init pcibios_fixup_bus(struct pci_bus *bus)
+{
+        /* Propogate hose info into the subordinate devices.  */
+
+        struct pci_channel *hose = bus->sysdata;
+        struct pci_dev *dev = bus->self;
+
+        if (!dev) {
+                /* Root bus */
+                bus->resource[0] = hose->io_resource;
+                bus->resource[1] = hose->mem_resource;
+        } else {
+                /* This is a bridge. Do not care how it's initialized,
+                   just link its resources to the bus ones */
+                int i;
+
+                for(i=0; i<3; i++) {
+                        bus->resource[i] =
+                                &dev->resource[PCI_BRIDGE_RESOURCES+i];
+                        bus->resource[i]->name = bus->name;
+                }
+                bus->resource[0]->flags |= pci_bridge_check_io(dev);
+                bus->resource[1]->flags |= IORESOURCE_MEM;
+                /* For now, propogate hose limits to the bus;
+                   we'll adjust them later. */
+                bus->resource[0]->end = hose->io_resource->end;
+                bus->resource[1]->end = hose->mem_resource->end;
+                /* Turn off downstream PF memory address range by default */
+                bus->resource[2]->start = 1024*1024;
+                bus->resource[2]->end = bus->resource[2]->start - 1;
+        }
+}
+
+char *pcibios_setup(char *str)
+{
+	return str;
+}
+
+void
+pcibios_align_resource(void *data, struct resource *res, unsigned long size)
+{
+	/* this should not be called */
+	MIPS_ASSERT(1 == 0);
+}
+
+void
+pcibios_update_resource(struct pci_dev *dev, struct resource *root,
+                             struct resource *res, int resource)
+{
+	/* this should not be called */
+	MIPS_ASSERT(1 == 0);
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5xxx/common/pci_auto.c linux/arch/mips/ddb5xxx/common/pci_auto.c
--- v2.4.9/linux/arch/mips/ddb5xxx/common/pci_auto.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ddb5xxx/common/pci_auto.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,396 @@
+/*
+ * arch/ppc/kernel/pci_auto.c
+ * 
+ * PCI autoconfiguration library
+ *
+ * Author: Matt Porter <mporter@mvista.com>
+ *
+ * Copyright 2000, 2001 MontaVista Software Inc.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+/*
+ * Modified for MIPS by Jun Sun, jsun@mvista.com
+ *
+ * . Simplify the interface between pci_auto and the rest: a single function.
+ * . Assign resources from low address to upper address.
+ * . change most int to u32.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+
+#include <asm/ddb5xxx/pci.h>
+#include <asm/ddb5xxx/debug.h>
+
+#define	DEBUG
+#ifdef 	DEBUG
+#define	DBG(x...)	printk(x)
+#else
+#define	DBG(x...)	
+#endif
+
+/* These are used for config access before all the PCI probing
+   has been done. */
+int early_read_config_byte(struct pci_channel *hose, int bus, int dev_fn, int where, u8 *val);
+int early_read_config_word(struct pci_channel *hose, int bus, int dev_fn, int where, u16 *val);
+int early_read_config_dword(struct pci_channel *hose, int bus, int dev_fn, int where, u32 *val);
+int early_write_config_byte(struct pci_channel *hose, int bus, int dev_fn, int where, u8 val);
+int early_write_config_word(struct pci_channel *hose, int bus, int dev_fn, int where, u16 val);
+int early_write_config_dword(struct pci_channel *hose, int bus, int dev_fn, int where, u32 val);
+
+static u32 pciauto_lower_iospc;
+static u32 pciauto_upper_iospc;
+
+static u32 pciauto_lower_memspc;
+static u32 pciauto_upper_memspc;
+
+void __init 
+pciauto_setup_bars(struct pci_channel *hose,
+		   int current_bus,
+		   int pci_devfn)
+{
+	u32 bar_response, bar_size, bar_value;
+	u32 bar, addr_mask, bar_nr = 0;
+	u32 * upper_limit;
+	u32 * lower_limit;
+	int found_mem64 = 0;
+
+	DBG("PCI Autoconfig: Found Bus %d, Device %d, Function %d\n",
+	    current_bus, PCI_SLOT(pci_devfn), PCI_FUNC(pci_devfn) );
+
+	for (bar = PCI_BASE_ADDRESS_0; bar <= PCI_BASE_ADDRESS_5; bar+=4)
+	{
+		/* Tickle the BAR and get the response */
+		early_write_config_dword(hose,
+					 current_bus,
+					 pci_devfn,
+					 bar,
+					 0xffffffff);
+		early_read_config_dword(hose,
+					current_bus,
+					pci_devfn,
+					bar,
+					&bar_response);
+
+		/* If BAR is not implemented go to the next BAR */
+		if (!bar_response)
+			continue;
+
+		/* Check the BAR type and set our address mask */
+		if (bar_response & PCI_BASE_ADDRESS_SPACE)
+		{
+			addr_mask = PCI_BASE_ADDRESS_IO_MASK;
+			upper_limit = &pciauto_upper_iospc;
+			lower_limit = &pciauto_lower_iospc;
+			DBG("PCI Autoconfig: BAR %d, I/O, ", bar_nr);
+		}
+		else
+		{
+			if ( (bar_response & PCI_BASE_ADDRESS_MEM_TYPE_MASK) ==
+			     PCI_BASE_ADDRESS_MEM_TYPE_64)
+				found_mem64 = 1;
+
+			addr_mask = PCI_BASE_ADDRESS_MEM_MASK;		
+			upper_limit = &pciauto_upper_memspc;
+			lower_limit = &pciauto_lower_memspc;
+			DBG("PCI Autoconfig: BAR %d, Mem, ", bar_nr);
+		}
+
+		/* Calculate requested size */
+		bar_size = ~(bar_response & addr_mask) + 1;
+
+		/* Allocate a base address */
+		bar_value = ((*lower_limit - 1) & ~(bar_size - 1)) + bar_size;
+		MIPS_ASSERT(bar_value + bar_size <= *upper_limit);
+
+		/* Write it out and update our limit */
+		early_write_config_dword(hose,
+					 current_bus,
+					 pci_devfn,
+					 bar,
+					 bar_value);
+
+		*lower_limit = bar_value + bar_size;
+
+		/*
+		 * If we are a 64-bit decoder then increment to the
+		 * upper 32 bits of the bar and force it to locate
+		 * in the lower 4GB of memory.
+		 */ 
+		if (found_mem64)
+		{
+			bar += 4;
+			early_write_config_dword(hose,
+						 current_bus,
+						 pci_devfn,
+						 bar,
+						 0x00000000);
+		}
+
+		bar_nr++;
+
+		DBG("size=0x%x, address=0x%x\n",
+		    bar_size, bar_value);
+	}
+
+}
+
+void __init
+pciauto_prescan_setup_bridge(struct pci_channel *hose,
+			     int current_bus,
+			     int pci_devfn,
+			     int sub_bus)
+{
+	int cmdstat;
+
+	/* Configure bus number registers */
+	early_write_config_byte(hose,
+				current_bus,
+				pci_devfn,
+				PCI_PRIMARY_BUS,
+				current_bus);
+	early_write_config_byte(hose,
+				current_bus,
+				pci_devfn,
+				PCI_SECONDARY_BUS,
+				sub_bus + 1);
+	early_write_config_byte(hose,
+				current_bus,
+				pci_devfn,
+				PCI_SUBORDINATE_BUS,
+				0xff);
+
+	/* Round memory allocator to 1MB boundary */
+	pciauto_upper_memspc &= ~(0x100000 - 1);
+
+	/* Round I/O allocator to 4KB boundary */
+	pciauto_upper_iospc &= ~(0x1000 - 1);
+
+	/* Set up memory and I/O filter limits, assume 32-bit I/O space */
+	early_write_config_word(hose,
+				current_bus,
+				pci_devfn,
+				PCI_MEMORY_LIMIT,
+				((pciauto_upper_memspc - 1) & 0xfff00000) >> 16);
+	early_write_config_byte(hose,
+				current_bus,
+				pci_devfn,
+				PCI_IO_LIMIT,
+				((pciauto_upper_iospc - 1) & 0x0000f000) >> 8);
+	early_write_config_word(hose,
+				current_bus,
+				pci_devfn,
+				PCI_IO_LIMIT_UPPER16,
+				((pciauto_upper_iospc - 1) & 0xffff0000) >> 16);
+			
+	/* We don't support prefetchable memory for now, so disable */
+	early_write_config_word(hose,
+				current_bus,
+				pci_devfn,
+				PCI_PREF_MEMORY_BASE,
+				0x1000);
+	early_write_config_word(hose,
+				current_bus,
+				pci_devfn,
+				PCI_PREF_MEMORY_LIMIT,
+				0x1000);
+
+	/* Enable memory and I/O accesses, enable bus master */
+	early_read_config_dword(hose,
+				current_bus,
+				pci_devfn,
+				PCI_COMMAND,
+				&cmdstat);
+	early_write_config_dword(hose,
+				 current_bus,
+				 pci_devfn,
+				 PCI_COMMAND,
+				 cmdstat |
+				 PCI_COMMAND_IO |
+				 PCI_COMMAND_MEMORY |
+				 PCI_COMMAND_MASTER);
+}
+
+void __init
+pciauto_postscan_setup_bridge(struct pci_channel *hose,
+			      int current_bus,
+			      int pci_devfn,
+			      int sub_bus)
+{
+	/* Configure bus number registers */
+	early_write_config_byte(hose,
+				current_bus,
+				pci_devfn,
+				PCI_SUBORDINATE_BUS,
+				sub_bus);
+
+	/* Round memory allocator to 1MB boundary */
+	pciauto_upper_memspc &= ~(0x100000 - 1);
+	early_write_config_word(hose,
+				current_bus,
+				pci_devfn,
+				PCI_MEMORY_BASE,
+				pciauto_upper_memspc >> 16);
+
+	/* Round I/O allocator to 4KB boundary */
+	pciauto_upper_iospc &= ~(0x1000 - 1);
+	early_write_config_byte(hose,
+				current_bus,
+				pci_devfn,
+				PCI_IO_BASE,
+				(pciauto_upper_iospc & 0x0000f000) >> 8);
+	early_write_config_word(hose,
+				current_bus,
+				pci_devfn,
+				PCI_IO_BASE_UPPER16,
+				pciauto_upper_iospc >> 16);
+}
+
+#define      PCIAUTO_IDE_MODE_MASK           0x05
+
+int __init
+pciauto_bus_scan(struct pci_channel *hose, int current_bus)
+{
+	int sub_bus;
+	u32 pci_devfn, pci_class, cmdstat, found_multi=0;
+	unsigned short vid;
+	unsigned char header_type;
+
+	sub_bus = current_bus;
+	
+	for (pci_devfn=0; pci_devfn<0xff; pci_devfn++) {
+
+		if (PCI_FUNC(pci_devfn) && !found_multi)
+			continue;
+
+		early_read_config_byte(hose,
+				       current_bus,
+				       pci_devfn,
+				       PCI_HEADER_TYPE,
+				       &header_type);
+
+		if (!PCI_FUNC(pci_devfn))
+			found_multi = header_type & 0x80;
+
+		early_read_config_word(hose,
+				       current_bus,
+				       pci_devfn,
+				       PCI_VENDOR_ID,
+				       &vid);
+
+		if (vid == 0xffff) continue;
+
+		early_read_config_dword(hose,
+					current_bus,
+					pci_devfn,
+					PCI_CLASS_REVISION, &pci_class);
+		if ( (pci_class >> 16) == PCI_CLASS_BRIDGE_PCI ) {
+			DBG("PCI Autoconfig: Found P2P bridge, device %d\n", PCI_SLOT(pci_devfn));
+			pciauto_prescan_setup_bridge(hose,
+						     current_bus,
+						     pci_devfn,
+						     sub_bus);
+			sub_bus = pciauto_bus_scan(hose, sub_bus+1);
+			pciauto_postscan_setup_bridge(hose,
+						      current_bus,
+						      pci_devfn,
+						      sub_bus);
+
+		} else if ((pci_class >> 16) == PCI_CLASS_STORAGE_IDE) {
+
+			unsigned char prg_iface;
+
+			early_read_config_byte(hose,
+					       current_bus,
+					       pci_devfn,
+					       PCI_CLASS_PROG,
+					       &prg_iface);
+			if (!(prg_iface & PCIAUTO_IDE_MODE_MASK)) {
+				DBG("PCI Autoconfig: Skipping legacy mode IDE controller\n");
+				continue;
+			}
+		}
+
+		/*
+		 * Found a peripheral, enable some standard
+		 * settings
+		 */
+		early_read_config_dword(hose,
+					current_bus,
+					pci_devfn,
+					PCI_COMMAND,
+					&cmdstat);
+		early_write_config_dword(hose,
+					 current_bus,
+					 pci_devfn,
+					 PCI_COMMAND,
+					 cmdstat |
+					 PCI_COMMAND_IO |
+					 PCI_COMMAND_MEMORY |
+					 PCI_COMMAND_MASTER);
+		early_write_config_byte(hose,
+					current_bus,
+					pci_devfn,
+					PCI_LATENCY_TIMER,
+					0x80);
+
+                /* Allocate PCI I/O and/or memory space */
+		pciauto_setup_bars(hose,
+				   current_bus,
+				   pci_devfn);
+	}
+	return sub_bus;
+}
+
+int __init
+pciauto_assign_resources(int busno, struct pci_channel *hose)
+{
+	/* setup resource limits */
+	pciauto_lower_iospc = hose->io_resource->start;
+	pciauto_upper_iospc = hose->io_resource->end + 1;
+	pciauto_lower_memspc = hose->mem_resource->start;
+	pciauto_upper_memspc = hose->mem_resource->end + 1;
+
+	return pciauto_bus_scan(hose, busno);
+}
+
+
+/*
+ * These functions are used early on before PCI scanning is done
+ * and all of the pci_dev and pci_bus structures have been created.
+ */
+static struct pci_dev *
+fake_pci_dev(struct pci_channel *hose, int busnr, int devfn)
+{
+        static struct pci_dev dev;
+        static struct pci_bus bus;
+
+        dev.bus = &bus;
+        dev.sysdata = hose;
+        dev.devfn = devfn;
+        bus.number = busnr;
+        bus.ops = hose->pci_ops;
+        return &dev;
+}
+
+#define EARLY_PCI_OP(rw, size, type)                                    \
+int early_##rw##_config_##size(struct pci_channel *hose, int bus,    \
+                               int devfn, int offset, type value)       \
+{                                                                       \
+        return pci_##rw##_config_##size(fake_pci_dev(hose, bus, devfn), \
+                                        offset, value);                 \
+}
+
+EARLY_PCI_OP(read, byte, u8 *)
+EARLY_PCI_OP(read, word, u16 *)
+EARLY_PCI_OP(read, dword, u32 *)
+EARLY_PCI_OP(write, byte, u8)
+EARLY_PCI_OP(write, word, u16)
+EARLY_PCI_OP(write, dword, u32)
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5xxx/common/prom.c linux/arch/mips/ddb5xxx/common/prom.c
--- v2.4.9/linux/arch/mips/ddb5xxx/common/prom.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ddb5xxx/common/prom.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,58 @@
+/***********************************************************************
+ *
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: jsun@mvista.com or jsun@junsun.net
+ *
+ * arch/mips/ddb5xxx/common/prom.c
+ *     prom.c file.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ ***********************************************************************
+ */
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <linux/bootmem.h>
+
+#include <asm/addrspace.h>
+#include <asm/bootinfo.h>
+#include <asm/ddb5xxx/ddb5xxx.h>
+
+char arcs_cmdline[COMMAND_LINE_SIZE];
+
+/* [jsun@junsun.net] PMON passes arguments in C main() style */
+void __init prom_init(int argc, const char **arg)
+{
+	int i;
+
+	/* arg[0] is "g", the rest is boot parameters */
+	arcs_cmdline[0] = '\0';
+	for (i = 1; i < argc; i++) {
+		if (strlen(arcs_cmdline) + strlen(arg[i] + 1)
+		    >= sizeof(arcs_cmdline))
+			break;
+		strcat(arcs_cmdline, arg[i]);
+		strcat(arcs_cmdline, " ");
+	}
+
+	mips_machgroup = MACH_GROUP_NEC_DDB;
+
+#if defined(CONFIG_DDB5074)
+	mips_machtype = MACH_NEC_DDB5074;
+#elif defined(CONFIG_DDB5476)
+	mips_machtype = MACH_NEC_DDB5476;
+#elif defined(CONFIG_DDB5477)
+	mips_machtype = MACH_NEC_DDB5477;
+#endif
+
+	add_memory_region(0, DDB_SDRAM_SIZE, BOOT_MEM_RAM);
+}
+
+void __init prom_free_prom_memory(void)
+{
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5xxx/common/rtc_ds1386.c linux/arch/mips/ddb5xxx/common/rtc_ds1386.c
--- v2.4.9/linux/arch/mips/ddb5xxx/common/rtc_ds1386.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ddb5xxx/common/rtc_ds1386.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: jsun@mvista.com or jsun@junsun.net
+ *
+ * arch/mips/ddb5xxx/common/rtc_ds1386.c
+ *     low-level RTC hookups for s for Dallas 1396 chip.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+
+/*
+ * This file exports a function, rtc_ds1386_init(), which expects an
+ * uncached base address as the argument.  It will set the two function
+ * pointers expected by the MIPS generic timer code.
+ */
+
+#include <linux/types.h>
+#include <linux/time.h>
+
+#include <asm/time.h>
+#include <asm/addrspace.h>
+
+#include <asm/ddb5xxx/debug.h>
+
+#define	EPOCH		2000
+
+#undef BCD_TO_BIN
+#define BCD_TO_BIN(val) (((val)&15) + ((val)>>4)*10)
+
+#undef BIN_TO_BCD
+#define BIN_TO_BCD(val) ((((val)/10)<<4) + (val)%10)
+
+#define	READ_RTC(x)	*(volatile unsigned char*)(rtc_base+x)
+#define	WRITE_RTC(x, y)	*(volatile unsigned char*)(rtc_base+x) = y
+
+static unsigned long rtc_base;
+
+static unsigned long
+rtc_ds1386_get_time(void)
+{	
+	u8 byte;
+	u8 temp;
+	unsigned int year, month, day, hour, minute, second;
+
+	/* let us freeze external registers */
+	byte = READ_RTC(0xB);
+	byte &= 0x3f;
+	WRITE_RTC(0xB, byte);
+
+	/* read time data */
+	year = BCD_TO_BIN(READ_RTC(0xA)) + EPOCH;
+	month = BCD_TO_BIN(READ_RTC(0x9) & 0x1f);
+	day = BCD_TO_BIN(READ_RTC(0x8));
+	minute = BCD_TO_BIN(READ_RTC(0x2));
+	second = BCD_TO_BIN(READ_RTC(0x1));
+
+	/* hour is special - deal with it later */
+	temp = READ_RTC(0x4);
+
+	/* enable time transfer */
+	byte |= 0x80;
+	WRITE_RTC(0xB, byte);
+
+	/* calc hour */
+	if (temp & 0x40) {
+		/* 12 hour format */
+		hour = BCD_TO_BIN(temp & 0x1f);
+		if (temp & 0x20) hour += 12; 		/* PM */
+	} else {
+		/* 24 hour format */
+		hour = BCD_TO_BIN(temp & 0x3f);
+	}
+
+	return mktime(year, month, day, hour, minute, second);
+}
+
+static int 
+rtc_ds1386_set_time(unsigned long t)
+{
+	struct rtc_time tm;
+	u8 byte;
+	u8 temp;
+	u8 year, month, day, hour, minute, second;
+
+	/* let us freeze external registers */
+	byte = READ_RTC(0xB);
+	byte &= 0x3f;
+	WRITE_RTC(0xB, byte);
+
+	/* convert */
+	to_tm(t, &tm);
+
+	/* check each field one by one */
+	year = BIN_TO_BCD(tm.tm_year - EPOCH);
+	if (year != READ_RTC(0xA)) {
+		WRITE_RTC(0xA, year);
+	}
+
+	temp = READ_RTC(0x9);
+	month = BIN_TO_BCD(tm.tm_mon);
+	if (month != (temp & 0x1f)) {
+		WRITE_RTC( 0x9,
+			   (month & 0x1f) | (temp & ~0x1f) );
+	}
+
+	day = BIN_TO_BCD(tm.tm_mday);
+	if (day != READ_RTC(0x8)) {
+		WRITE_RTC(0x8, day);
+	}
+
+	temp = READ_RTC(0x4);
+	if (temp & 0x40) {
+		/* 12 hour format */
+		hour = 0x40;
+		if (tm.tm_hour > 12) {
+			hour |= 0x20 | (BIN_TO_BCD(hour-12) & 0x1f);
+		} else {
+			hour |= BIN_TO_BCD(tm.tm_hour);
+		}
+	} else {
+		/* 24 hour format */
+		hour = BIN_TO_BCD(tm.tm_hour) & 0x3f;
+	}
+	if (hour != temp) WRITE_RTC(0x4, hour);
+
+	minute = BIN_TO_BCD(tm.tm_min);
+	if (minute != READ_RTC(0x2)) {
+		WRITE_RTC(0x2, minute);
+	}
+
+	second = BIN_TO_BCD(tm.tm_sec);
+	if (second != READ_RTC(0x1)) {
+		WRITE_RTC(0x1, second);
+	}
+	
+	return 0;
+}
+
+void
+rtc_ds1386_init(unsigned long base)
+{
+	unsigned char byte;
+	
+	/* remember the base */
+	rtc_base = base;
+	MIPS_ASSERT((rtc_base & 0xe0000000) == KSEG1);
+
+	/* turn on RTC if it is not on */
+	byte = READ_RTC(0x9);
+	if (byte & 0x80) {
+		byte &= 0x7f;
+		WRITE_RTC(0x9, byte);
+	}
+
+	/* enable time transfer */
+	byte = READ_RTC(0xB);
+	byte |= 0x80;
+	WRITE_RTC(0xB, byte);
+
+	/* set the function pointers */
+	rtc_get_time = rtc_ds1386_get_time;
+	rtc_set_time = rtc_ds1386_set_time;
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5xxx/ddb5477/Makefile linux/arch/mips/ddb5xxx/ddb5477/Makefile
--- v2.4.9/linux/arch/mips/ddb5xxx/ddb5477/Makefile	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ddb5xxx/ddb5477/Makefile	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,22 @@
+#
+# Makefile for NEC DDB-Vrc5477 board
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+
+.S.s:
+	$(CPP) $(CFLAGS) $< -o $*.s
+.S.o:
+	$(CC) $(CFLAGS) -c $< -o $*.o
+
+O_TARGET:= ddb5477.o
+
+obj-y	 += int-handler.o irq.o irq_5477.o setup.o pci.o pci_ops.o
+
+obj-$(CONFIG_LL_DEBUG) 		+= debug.o
+obj-$(CONFIG_REMOTE_DEBUG)	+= kgdb_io.o
+obj-$(CONFIG_BLK_DEV_INITRD)	+= ramdisk.o
+
+include $(TOPDIR)/Rules.make
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5xxx/ddb5477/debug.c linux/arch/mips/ddb5xxx/ddb5477/debug.c
--- v2.4.9/linux/arch/mips/ddb5xxx/ddb5477/debug.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ddb5xxx/ddb5477/debug.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,162 @@
+/***********************************************************************
+ *
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: jsun@mvista.com or jsun@junsun.net
+ *
+ * arch/mips/ddb5xxx/ddb5477/debug.c
+ *     vrc5477 specific debug routines.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ ***********************************************************************
+ */
+
+#include <linux/kernel.h>
+#include <linux/interrupt.h>
+#include <linux/signal.h>		/* SA_INTERRUPT */
+
+#include <asm/mipsregs.h>
+#include <asm/ddb5xxx/ddb5xxx.h>
+
+typedef struct {
+       const char *regname;
+       unsigned regaddr;
+} Register;
+
+void jsun_show_regs(char *name, Register *regs)
+{
+	int i;
+
+	printk("\nshow regs: %s\n", name);
+	for(i=0;regs[i].regname!= NULL; i++) {
+		printk("%-16s= %08x\t\t(@%08x)\n", 
+		       regs[i].regname, 
+		       *(unsigned *)(regs[i].regaddr), 
+		       regs[i].regaddr);
+	}
+}
+
+static Register int_regs[] = {
+	{"DDB_INTCTRL0", DDB_BASE + DDB_INTCTRL0},
+	{"DDB_INTCTRL1", DDB_BASE + DDB_INTCTRL1},
+	{"DDB_INTCTRL2", DDB_BASE + DDB_INTCTRL2},
+	{"DDB_INTCTRL3", DDB_BASE + DDB_INTCTRL3},
+	{"DDB_INT0STAT", DDB_BASE + DDB_INT0STAT},
+	{"DDB_INT1STAT", DDB_BASE + DDB_INT1STAT},
+	{"DDB_INT2STAT", DDB_BASE + DDB_INT2STAT},
+	{"DDB_INT3STAT", DDB_BASE + DDB_INT3STAT},
+	{"DDB_INT4STAT", DDB_BASE + DDB_INT4STAT},
+	{"DDB_NMISTAT", DDB_BASE + DDB_NMISTAT},
+	{"DDB_INTPPES0", DDB_BASE + DDB_INTPPES0},
+	{"DDB_INTPPES1", DDB_BASE + DDB_INTPPES1},
+	{NULL, 0x0}
+};
+
+void vrc5477_show_int_regs()
+{
+	jsun_show_regs("interrupt registers", int_regs);
+	printk("CPU CAUSE = %08x\n", read_32bit_cp0_register(CP0_CAUSE));
+	printk("CPU STATUS = %08x\n", read_32bit_cp0_register(CP0_STATUS));
+}
+static Register pdar_regs[] = {
+        {"DDB_SDRAM0", DDB_BASE + DDB_SDRAM0},
+        {"DDB_SDRAM1", DDB_BASE + DDB_SDRAM1},
+        {"DDB_LDCS0", DDB_BASE + DDB_LDCS0},
+        {"DDB_LDCS1", DDB_BASE + DDB_LDCS1},
+        {"DDB_LDCS2", DDB_BASE + DDB_LDCS2},
+        {"DDB_INTCS", DDB_BASE + DDB_INTCS},
+        {"DDB_BOOTCS", DDB_BASE + DDB_BOOTCS},
+        {"DDB_PCIW0", DDB_BASE + DDB_PCIW0},
+        {"DDB_PCIW1", DDB_BASE + DDB_PCIW1},
+        {"DDB_IOPCIW0", DDB_BASE + DDB_IOPCIW0},
+        {"DDB_IOPCIW1", DDB_BASE + DDB_IOPCIW1},
+        {NULL, 0x0}
+};
+void vrc5477_show_pdar_regs(void)
+{
+        jsun_show_regs("PDAR regs", pdar_regs);
+}
+
+static Register bar_regs[] = {
+        {"DDB_BARC0", DDB_BASE + DDB_BARC0},
+        {"DDB_BARM010", DDB_BASE + DDB_BARM010},
+        {"DDB_BARM230", DDB_BASE + DDB_BARM230},
+        {"DDB_BAR00", DDB_BASE + DDB_BAR00},
+        {"DDB_BAR10", DDB_BASE + DDB_BAR10},
+        {"DDB_BAR20", DDB_BASE + DDB_BAR20},
+        {"DDB_BAR30", DDB_BASE + DDB_BAR30},
+        {"DDB_BAR40", DDB_BASE + DDB_BAR40},
+        {"DDB_BAR50", DDB_BASE + DDB_BAR50},
+        {"DDB_BARB0", DDB_BASE + DDB_BARB0},
+        {"DDB_BARC1", DDB_BASE + DDB_BARC1},
+        {"DDB_BARM011", DDB_BASE + DDB_BARM011},
+        {"DDB_BARM231", DDB_BASE + DDB_BARM231},
+        {"DDB_BAR01", DDB_BASE + DDB_BAR01},
+        {"DDB_BAR11", DDB_BASE + DDB_BAR11},
+        {"DDB_BAR21", DDB_BASE + DDB_BAR21},
+        {"DDB_BAR31", DDB_BASE + DDB_BAR31},
+        {"DDB_BAR41", DDB_BASE + DDB_BAR41},
+        {"DDB_BAR51", DDB_BASE + DDB_BAR51},
+        {"DDB_BARB1", DDB_BASE + DDB_BARB1},
+        {NULL, 0x0}
+};
+void vrc5477_show_bar_regs(void)
+{
+        jsun_show_regs("BAR regs", bar_regs);
+}
+
+static Register pci_regs[] = {
+        {"DDB_PCIW0", DDB_BASE + DDB_PCIW0},
+        {"DDB_PCIW1", DDB_BASE + DDB_PCIW1},
+        {"DDB_PCIINIT00", DDB_BASE + DDB_PCIINIT00},
+        {"DDB_PCIINIT10", DDB_BASE + DDB_PCIINIT10},
+        {"DDB_PCICTL0_L", DDB_BASE + DDB_PCICTL0_L},
+        {"DDB_PCICTL0_H", DDB_BASE + DDB_PCICTL0_H},
+        {"DDB_PCIARB0_L", DDB_BASE + DDB_PCIARB0_L},
+        {"DDB_PCIARB0_H", DDB_BASE + DDB_PCIARB0_H},
+        {"DDB_PCISWP0", DDB_BASE + DDB_PCISWP0},
+        {"DDB_PCIERR0", DDB_BASE + DDB_PCIERR0},
+        {"DDB_IOPCIW0", DDB_BASE + DDB_IOPCIW0},
+        {"DDB_IOPCIW1", DDB_BASE + DDB_IOPCIW1},
+        {"DDB_PCIINIT01", DDB_BASE + DDB_PCIINIT01},
+        {"DDB_PCIINIT11", DDB_BASE + DDB_PCIINIT11},
+        {"DDB_PCICTL1_L", DDB_BASE + DDB_PCICTL1_L},
+        {"DDB_PCICTL1_H", DDB_BASE + DDB_PCICTL1_H},
+        {"DDB_PCIARB1_L", DDB_BASE + DDB_PCIARB1_L},
+        {"DDB_PCIARB1_H", DDB_BASE + DDB_PCIARB1_H},
+        {"DDB_PCISWP1", DDB_BASE + DDB_PCISWP1},
+        {"DDB_PCIERR1", DDB_BASE + DDB_PCIERR1},
+        {NULL, 0x0}
+};
+void vrc5477_show_pci_regs(void)
+{
+        jsun_show_regs("PCI regs", pci_regs);
+}
+
+static Register lb_regs[] = {
+        {"DDB_LCNFG", DDB_BASE + DDB_LCNFG},
+        {"DDB_LCST0", DDB_BASE + DDB_LCST0},
+        {"DDB_LCST1", DDB_BASE + DDB_LCST1},
+        {"DDB_LCST2", DDB_BASE + DDB_LCST2},
+        {"DDB_ERRADR", DDB_BASE + DDB_ERRADR},
+        {"DDB_ERRCS", DDB_BASE + DDB_ERRCS},
+        {"DDB_BTM", DDB_BASE + DDB_BTM},
+        {"DDB_BCST", DDB_BASE + DDB_BCST},
+        {NULL, 0x0}
+};
+void vrc5477_show_lb_regs(void)
+{
+        jsun_show_regs("Local Bus regs", lb_regs);
+}
+
+void vrc5477_show_all_regs(void)
+{
+	vrc5477_show_pdar_regs();
+	vrc5477_show_pci_regs();
+	vrc5477_show_bar_regs();
+	vrc5477_show_int_regs();
+	vrc5477_show_lb_regs();
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5xxx/ddb5477/int-handler.S linux/arch/mips/ddb5xxx/ddb5477/int-handler.S
--- v2.4.9/linux/arch/mips/ddb5xxx/ddb5477/int-handler.S	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ddb5xxx/ddb5477/int-handler.S	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: jsun@mvista.com or jsun@junsun.net
+ *
+ * First-level interrupt dispatcher for ddb5477
+ *
+ * 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 <linux/config.h>
+
+#include <asm/asm.h>
+#include <asm/mipsregs.h>
+#include <asm/addrspace.h>
+#include <asm/regdef.h>
+#include <asm/stackframe.h>
+
+/*
+ * first level interrupt dispatcher for ocelot board -
+ * We check for the timer first, then check PCI ints A and D.
+ * Then check for serial IRQ and fall through.
+ */
+	.align	5
+	NESTED(ddb5477_handle_int, PT_SIZE, sp)
+	SAVE_ALL
+	CLI
+	.set	at
+	.set	noreorder
+	mfc0	t0, CP0_CAUSE  
+	mfc0	t2, CP0_STATUS
+
+	and	t0, t2
+       
+	andi	t1, t0, STATUSF_IP7	/* cpu timer */
+	bnez	t1, ll_cputimer_irq
+	andi	t1, t0, (STATUSF_IP2 | STATUSF_IP3 | STATUSF_IP4 | STATUSF_IP5 | STATUSF_IP6 ) 
+	bnez	t1, ll_vrc5477_irq
+	andi	t1, t0, STATUSF_IP0	/* software int 0 */
+	bnez	t1, ll_cpu_ip0
+	andi	t1, t0, STATUSF_IP1	/* software int 1 */
+	bnez	t1, ll_cpu_ip1
+	nop
+	.set	reorder
+
+	/* wrong alarm or masked ... */
+	j	spurious_interrupt
+	nop
+	END(ddb5477_handle_int)
+
+	.align	5
+
+ll_vrc5477_irq:	
+	move	a0, sp
+	jal	vrc5477_irq_dispatch
+	j	ret_from_irq
+
+ll_cputimer_irq:
+	li	a0, 7
+	move	a1, sp
+	jal	do_IRQ
+	j	ret_from_irq
+
+
+ll_cpu_ip0:	
+	li	a0, 0
+	move	a1, sp
+	jal	do_IRQ
+	j	ret_from_irq
+
+ll_cpu_ip1:	
+	li	a0, 1
+	move	a1, sp
+	jal	do_IRQ
+	j	ret_from_irq
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5xxx/ddb5477/irq.c linux/arch/mips/ddb5xxx/ddb5477/irq.c
--- v2.4.9/linux/arch/mips/ddb5xxx/ddb5477/irq.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ddb5xxx/ddb5477/irq.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
+ *
+ *  arch/mips/ddb5xxx/ddb5477/irq.c
+ *     The irq setup and misc routines for DDB5476.
+ *
+ * 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 <linux/config.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/types.h>
+#include <linux/ptrace.h>
+
+#include <asm/system.h>
+#include <asm/mipsregs.h>
+#include <asm/ddb5xxx/ddb5xxx.h>
+
+/* [jsun] sooner or later we should move this debug stuff to MIPS common */
+#include <asm/ddb5xxx/debug.h>
+
+/*
+ * IRQ mapping
+ *
+ *  0-7: 8 CPU interrupts
+ *	0 -	software interrupt 0
+ *	1 - 	software interrupt 1
+ *	2 - 	most Vrc5477 interrupts are routed to this pin
+ *	3 - 	(optional) some other interrupts routed to this pin for debugg
+ *	4 - 	not used
+ *	5 - 	not used
+ *	6 - 	not used
+ *	7 - 	cpu timer (used by default)
+ *
+ *  8-39: 32 Vrc5477 interrupt sources
+ *	(refer to the Vrc5477 manual)	
+ */
+
+#define	PCI0			DDB_INTPPES0
+#define	PCI1			DDB_INTPPES1
+
+#define	ACTIVE_LOW		1
+#define	ACTIVE_HIGH		0
+
+#define	LEVEL_SENSE		2
+#define	EDGE_TRIGGER		0
+
+#define	INTA			0
+#define	INTB			1
+#define	INTC			2
+#define	INTD			3
+#define	INTE			4
+
+static inline void 
+set_pci_int_attr(u32 pci, u32 intn, u32 active, u32 trigger)
+{
+	u32 reg_value;
+	u32 reg_bitmask;
+
+	reg_value = ddb_in32(pci);
+	reg_bitmask = 0x3 << (intn * 2);
+	
+	reg_value &= ~reg_bitmask;
+	reg_value |= (active | trigger) << (intn * 2);
+	ddb_out32(pci, reg_value);
+}
+
+extern void vrc5477_irq_init(u32 base);
+extern void mips_cpu_irq_init(u32 base);
+extern asmlinkage void ddb5477_handle_int(void);
+
+void
+ddb5477_irq_setup(void)
+{
+	MIPS_DEBUG(printk("ddb5477_irq_setup invoked.\n"));
+
+	/* by default, we disable all interrupts and route all vrc5477 
+	 * interrupts to pin 0 (irq 2) */
+	ddb_out32(DDB_INTCTRL0, 0);
+	ddb_out32(DDB_INTCTRL1, 0);
+	ddb_out32(DDB_INTCTRL2, 0);
+	ddb_out32(DDB_INTCTRL3, 0);
+
+	clear_cp0_status(0xff00);
+	set_cp0_status(0x0400);
+
+	/* setup PCI interrupt attributes */
+	set_pci_int_attr(PCI0, INTA, ACTIVE_LOW, LEVEL_SENSE);
+	set_pci_int_attr(PCI0, INTB, ACTIVE_LOW, LEVEL_SENSE);
+	set_pci_int_attr(PCI0, INTC, ACTIVE_LOW, LEVEL_SENSE);
+	set_pci_int_attr(PCI0, INTD, ACTIVE_LOW, LEVEL_SENSE);
+	set_pci_int_attr(PCI0, INTE, ACTIVE_LOW, LEVEL_SENSE);
+
+	set_pci_int_attr(PCI1, INTA, ACTIVE_LOW, LEVEL_SENSE);
+	set_pci_int_attr(PCI1, INTB, ACTIVE_LOW, LEVEL_SENSE);
+	set_pci_int_attr(PCI1, INTC, ACTIVE_LOW, LEVEL_SENSE);
+	set_pci_int_attr(PCI1, INTD, ACTIVE_LOW, LEVEL_SENSE);
+	set_pci_int_attr(PCI1, INTE, ACTIVE_LOW, LEVEL_SENSE);
+
+	/* 
+	 * for debugging purpose, we enable several error interrupts
+	 * and route them to pin 1. (IP3) 
+	 */
+	/* cpu parity check - 0 */
+	ll_vrc5477_irq_route(0, 1); ll_vrc5477_irq_enable(0);
+	/* cpu no-target decode - 1 */
+	ll_vrc5477_irq_route(1, 1); ll_vrc5477_irq_enable(1);
+	/* local bus read time-out - 7 */
+	ll_vrc5477_irq_route(7, 1); ll_vrc5477_irq_enable(7);
+	/* PCI SERR# - 14 */
+	ll_vrc5477_irq_route(14, 1); ll_vrc5477_irq_enable(14);
+	/* PCI internal error - 15 */
+	ll_vrc5477_irq_route(15, 1); ll_vrc5477_irq_enable(15);
+	/* IOPCI SERR# - 30 */
+	ll_vrc5477_irq_route(30, 1); ll_vrc5477_irq_enable(30);
+	/* IOPCI internal error - 31 */
+	ll_vrc5477_irq_route(31, 1); ll_vrc5477_irq_enable(31);
+
+	/* init all controllers */
+	mips_cpu_irq_init(0);
+	vrc5477_irq_init(8);
+
+	/* hook up the first-level interrupt handler */
+	set_except_vector(0, ddb5477_handle_int);
+}
+
+/*
+ * the first level int-handler will jump here if it is a vrc5477 irq
+ */
+#define	NUM_5477_IRQS	32
+asmlinkage void
+vrc5477_irq_dispatch(struct pt_regs *regs)
+{
+	extern unsigned int do_IRQ(int irq, struct pt_regs *regs);
+
+	u32 intStatus;
+	u32 bitmask;
+	u32 i;
+
+	MIPS_ASSERT(ddb_in32(DDB_INT2STAT) == 0);
+	MIPS_ASSERT(ddb_in32(DDB_INT3STAT) == 0);
+	MIPS_ASSERT(ddb_in32(DDB_INT4STAT) == 0);
+	MIPS_ASSERT(ddb_in32(DDB_NMISTAT) == 0);
+
+	if (ddb_in32(DDB_INT1STAT) != 0) {
+#if defined(CONFIG_LL_DEBUG)
+		vrc5477_show_int_regs();
+#endif
+		panic("error interrupt has happened.\n");
+	}
+
+	intStatus = ddb_in32(DDB_INT0STAT);
+	for (i=0, bitmask=1; i<= NUM_5477_IRQS; bitmask <<=1, i++) {
+		/* do we need to "and" with the int mask? */
+		if (intStatus & bitmask) {
+			do_IRQ(8 + i, regs);
+		}
+	}
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5xxx/ddb5477/irq_5477.c linux/arch/mips/ddb5xxx/ddb5477/irq_5477.c
--- v2.4.9/linux/arch/mips/ddb5xxx/ddb5477/irq_5477.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ddb5xxx/ddb5477/irq_5477.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,179 @@
+/***********************************************************************
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
+ *
+ *  arch/mips/ddb5xxx/ddb5477/irq_5477.c
+ *     This file defines the irq handler for Vrc5477.
+ *
+ * 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.
+ ***********************************************************************
+ */
+
+/*
+ * Vrc5477 defines 32 IRQs.
+ *
+ * This file exports one function:
+ *	vrc5477_irq_init(u32 irq_base);
+ */
+
+#include <linux/irq.h>
+#include <linux/types.h>
+#include <linux/ptrace.h>
+
+#include <asm/ddb5xxx/ddb5xxx.h>
+
+/* [jsun] sooner or later we should move this debug stuff to MIPS common */
+#include <asm/ddb5xxx/debug.h>
+
+/* number of total irqs supported by Vrc5477 */
+#define	NUM_5477_IRQ		32
+
+static int vrc5477_irq_base=-1;
+
+
+static void 
+vrc5477_irq_enable(unsigned int irq)
+{
+	MIPS_ASSERT(vrc5477_irq_base != -1);
+	MIPS_ASSERT(irq >= vrc5477_irq_base);
+	MIPS_ASSERT(irq < vrc5477_irq_base+ NUM_5477_IRQ);
+
+	ll_vrc5477_irq_enable(irq - vrc5477_irq_base);
+}
+
+static void 
+vrc5477_irq_disable(unsigned int irq)
+{
+	MIPS_ASSERT(vrc5477_irq_base != -1);
+	MIPS_ASSERT(irq >= vrc5477_irq_base);
+	MIPS_ASSERT(irq < vrc5477_irq_base + NUM_5477_IRQ);
+
+	ll_vrc5477_irq_disable(irq - vrc5477_irq_base);
+}
+
+static unsigned int vrc5477_irq_startup(unsigned int irq)
+{
+	vrc5477_irq_enable(irq);
+	return 0;
+}
+
+#define	vrc5477_irq_shutdown	vrc5477_irq_disable
+
+static void
+vrc5477_irq_ack(unsigned int irq)
+{
+	MIPS_ASSERT(vrc5477_irq_base != -1);
+	MIPS_ASSERT(irq >= vrc5477_irq_base);
+	MIPS_ASSERT(irq < vrc5477_irq_base+ NUM_5477_IRQ);
+
+	/* clear the interrupt bit */
+	/* some irqs require the driver to clear the sources */
+	ddb_out32(DDB_INTCLR32, 1 << (irq - vrc5477_irq_base));
+
+	/* disable interrupt - some handler will re-enable the irq
+	 * and if the interrupt is leveled, we will have infinite loop
+	 */
+	ll_vrc5477_irq_disable(irq - vrc5477_irq_base);
+}
+
+static void
+vrc5477_irq_end(unsigned int irq)
+{
+	MIPS_ASSERT(vrc5477_irq_base != -1);
+	MIPS_ASSERT(irq >= vrc5477_irq_base);
+	MIPS_ASSERT(irq < vrc5477_irq_base + NUM_5477_IRQ);
+
+	ll_vrc5477_irq_enable( irq - vrc5477_irq_base);
+}
+
+hw_irq_controller vrc5477_irq_controller = {
+	"vrc5477_irq",
+	vrc5477_irq_startup,
+	vrc5477_irq_shutdown,
+	vrc5477_irq_enable,
+	vrc5477_irq_disable,
+	vrc5477_irq_ack,
+	vrc5477_irq_end,
+	NULL			/* no affinity stuff for UP */
+};
+
+void 
+vrc5477_irq_init(u32 irq_base)
+{
+	extern irq_desc_t irq_desc[];
+	u32 i;
+
+	for (i= irq_base; i< irq_base+ NUM_5477_IRQ; i++) {
+		irq_desc[i].status = IRQ_DISABLED;
+		irq_desc[i].action = NULL;
+		irq_desc[i].depth = 1;
+		irq_desc[i].handler = &vrc5477_irq_controller;
+	}
+	
+	vrc5477_irq_base = irq_base;
+}
+
+
+int vrc5477_irq_to_irq(int irq)
+{
+	MIPS_ASSERT(irq >= 0);
+	MIPS_ASSERT(irq < NUM_5477_IRQ);
+
+	return irq + vrc5477_irq_base;
+}
+
+void ll_vrc5477_irq_route(int vrc5477_irq, int ip)
+{
+	u32 reg_value;
+	u32 reg_bitmask;
+	u32 reg_index;
+
+	MIPS_ASSERT(vrc5477_irq >= 0);
+	MIPS_ASSERT(vrc5477_irq < NUM_5477_IRQ);
+	MIPS_ASSERT(ip >= 0);
+	MIPS_ASSERT((ip < 5) || (ip == 6));
+
+	reg_index = DDB_INTCTRL0 + vrc5477_irq/8*4;
+	reg_value = ddb_in32(reg_index);
+	reg_bitmask = 7 << (vrc5477_irq % 8 * 4);
+	reg_value &= ~reg_bitmask;
+	reg_value |= ip << (vrc5477_irq % 8 * 4);
+	ddb_out32(reg_index, reg_value);
+}
+
+void ll_vrc5477_irq_enable(int vrc5477_irq)
+{
+	u32 reg_value;
+	u32 reg_bitmask;
+	u32 reg_index;
+
+	MIPS_ASSERT(vrc5477_irq >= 0);
+	MIPS_ASSERT(vrc5477_irq < NUM_5477_IRQ);
+
+	reg_index = DDB_INTCTRL0 + vrc5477_irq/8*4;
+	reg_value = ddb_in32(reg_index);
+	reg_bitmask = 8 << (vrc5477_irq % 8 * 4);
+	MIPS_ASSERT((reg_value & reg_bitmask) == 0);
+	ddb_out32(reg_index, reg_value | reg_bitmask);
+}
+
+void ll_vrc5477_irq_disable(int vrc5477_irq)
+{
+	u32 reg_value;
+	u32 reg_bitmask;
+	u32 reg_index;
+
+	MIPS_ASSERT(vrc5477_irq >= 0);
+	MIPS_ASSERT(vrc5477_irq < NUM_5477_IRQ);
+
+	reg_index = DDB_INTCTRL0 + vrc5477_irq/8*4;
+	reg_value = ddb_in32(reg_index);
+	reg_bitmask = 8 << (vrc5477_irq % 8 * 4);
+
+	/* we assert that the interrupt is enabled (perhaps over-zealous) */
+	MIPS_ASSERT( (reg_value & reg_bitmask) != 0);
+	ddb_out32(reg_index, reg_value & ~reg_bitmask);
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5xxx/ddb5477/kgdb_io.c linux/arch/mips/ddb5xxx/ddb5477/kgdb_io.c
--- v2.4.9/linux/arch/mips/ddb5xxx/ddb5477/kgdb_io.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ddb5xxx/ddb5477/kgdb_io.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,142 @@
+
+#include <linux/config.h>
+
+#if (defined(CONFIG_DDB5477) && defined(CONFIG_REMOTE_DEBUG))
+
+/* --- CONFIG --- */
+
+/* we need uint32 uint8 */
+/* #include "types.h" */
+typedef unsigned char uint8;
+typedef unsigned int uint32;
+
+/* --- END OF CONFIG --- */
+
+#define         UART16550_BAUD_2400             2400
+#define         UART16550_BAUD_4800             4800
+#define         UART16550_BAUD_9600             9600
+#define         UART16550_BAUD_19200            19200
+#define         UART16550_BAUD_38400            38400
+#define         UART16550_BAUD_57600            57600
+#define         UART16550_BAUD_115200           115200
+
+#define         UART16550_PARITY_NONE           0
+#define         UART16550_PARITY_ODD            0x08
+#define         UART16550_PARITY_EVEN           0x18
+#define         UART16550_PARITY_MARK           0x28
+#define         UART16550_PARITY_SPACE          0x38
+
+#define         UART16550_DATA_5BIT             0x0
+#define         UART16550_DATA_6BIT             0x1
+#define         UART16550_DATA_7BIT             0x2
+#define         UART16550_DATA_8BIT             0x3
+
+#define         UART16550_STOP_1BIT             0x0
+#define         UART16550_STOP_2BIT             0x4
+
+/* ----------------------------------------------------- */
+
+/* === CONFIG === */
+
+/* [jsun] we use the second serial port for kdb */
+#define         BASE                    0xbfa04240
+#define         MAX_BAUD                115200
+#define		REG_OFFSET		8
+
+/* === END OF CONFIG === */
+
+/* register offset */
+#define         OFS_RCV_BUFFER          (0*REG_OFFSET)
+#define         OFS_TRANS_HOLD          (0*REG_OFFSET)
+#define         OFS_SEND_BUFFER         (0*REG_OFFSET)
+#define         OFS_INTR_ENABLE         (1*REG_OFFSET)
+#define         OFS_INTR_ID             (2*REG_OFFSET)
+#define         OFS_DATA_FORMAT         (3*REG_OFFSET)
+#define         OFS_LINE_CONTROL        (3*REG_OFFSET)
+#define         OFS_MODEM_CONTROL       (4*REG_OFFSET)
+#define         OFS_RS232_OUTPUT        (4*REG_OFFSET)
+#define         OFS_LINE_STATUS         (5*REG_OFFSET)
+#define         OFS_MODEM_STATUS        (6*REG_OFFSET)
+#define         OFS_RS232_INPUT         (6*REG_OFFSET)
+#define         OFS_SCRATCH_PAD         (7*REG_OFFSET)
+
+#define         OFS_DIVISOR_LSB         (0*REG_OFFSET)
+#define         OFS_DIVISOR_MSB         (1*REG_OFFSET)
+
+
+/* memory-mapped read/write of the port */
+#define         UART16550_READ(y)    (*((volatile uint8*)(BASE + y)))
+#define         UART16550_WRITE(y, z)  ((*((volatile uint8*)(BASE + y))) = z)
+
+void debugInit(uint32 baud, uint8 data, uint8 parity, uint8 stop)
+{
+	/* disable interrupts */
+	UART16550_WRITE(OFS_INTR_ENABLE, 0);
+
+	/* set up buad rate */
+	{
+		uint32 divisor;
+
+		/* set DIAB bit */
+		UART16550_WRITE(OFS_LINE_CONTROL, 0x80);
+
+		/* set divisor */
+		divisor = MAX_BAUD / baud;
+		UART16550_WRITE(OFS_DIVISOR_LSB, divisor & 0xff);
+		UART16550_WRITE(OFS_DIVISOR_MSB, (divisor & 0xff00) >> 8);
+
+		/* clear DIAB bit */
+		UART16550_WRITE(OFS_LINE_CONTROL, 0x0);
+	}
+
+	/* set data format */
+	UART16550_WRITE(OFS_DATA_FORMAT, data | parity | stop);
+}
+
+static int remoteDebugInitialized = 0;
+
+int debug_state = -1;
+
+uint8 getDebugChar(void)
+{
+	uint8 c;
+	if (!remoteDebugInitialized) {
+		remoteDebugInitialized = 1;
+		debugInit(UART16550_BAUD_38400,
+			  UART16550_DATA_8BIT,
+			  UART16550_PARITY_NONE, UART16550_STOP_1BIT);
+	}
+
+	while ((UART16550_READ(OFS_LINE_STATUS) & 0x1) == 0);
+	c= UART16550_READ(OFS_RCV_BUFFER);
+/*
+	if (state != 1) {
+		state = 1;
+		debug_out("\ngetDebugChar: ", 15);
+	}
+	debug_out(&c, 1);
+*/
+	return c;
+}
+
+
+int putDebugChar(uint8 byte)
+{
+	if (!remoteDebugInitialized) {
+		remoteDebugInitialized = 1;
+		debugInit(UART16550_BAUD_9600,
+			  UART16550_DATA_8BIT,
+			  UART16550_PARITY_NONE, UART16550_STOP_1BIT);
+	}
+
+	while ((UART16550_READ(OFS_LINE_STATUS) & 0x20) == 0);
+	UART16550_WRITE(OFS_SEND_BUFFER, byte);
+	if (debug_state != 2) {
+		debug_state = 2;
+		// debug_out("\nputDebugChar: ", 15);
+	}
+	// debug_out(&byte, 1);
+	return 1;
+}
+
+#endif
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5xxx/ddb5477/pci.c linux/arch/mips/ddb5xxx/ddb5477/pci.c
--- v2.4.9/linux/arch/mips/ddb5xxx/ddb5477/pci.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ddb5xxx/ddb5477/pci.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,147 @@
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+
+#include <asm/ddb5xxx/ddb5xxx.h>
+#include <asm/ddb5xxx/debug.h>
+#include <asm/ddb5xxx/pci.h>
+
+static struct resource extpci_io_resource = {
+	"ext pci IO space", 
+	DDB_PCI0_IO_BASE - DDB_PCI_IO_BASE,
+	DDB_PCI0_IO_BASE - DDB_PCI_IO_BASE + DDB_PCI0_IO_SIZE -1,
+	IORESOURCE_IO};
+
+static struct resource extpci_mem_resource = {
+	"ext pci memory space", 
+	DDB_PCI0_MEM_BASE,
+	DDB_PCI0_MEM_BASE + DDB_PCI0_MEM_SIZE -1,
+	IORESOURCE_MEM};
+
+static struct resource iopci_io_resource = {
+	"io pci IO space", 
+	DDB_PCI1_IO_BASE - DDB_PCI_IO_BASE,
+	DDB_PCI1_IO_BASE - DDB_PCI_IO_BASE + DDB_PCI1_IO_SIZE -1,
+	IORESOURCE_IO};
+
+static struct resource iopci_mem_resource = {
+	"ext pci memory space", 
+	DDB_PCI1_MEM_BASE,
+	DDB_PCI1_MEM_BASE + DDB_PCI1_MEM_SIZE -1,
+	IORESOURCE_MEM};
+
+extern struct pci_ops ddb5477_ext_pci_ops;
+extern struct pci_ops ddb5477_io_pci_ops;
+
+struct pci_channel mips_pci_channels[] = {
+	{ &ddb5477_ext_pci_ops, &extpci_io_resource, &extpci_mem_resource },
+	{ &ddb5477_io_pci_ops, &iopci_io_resource, &iopci_mem_resource },
+	{ NULL, NULL, NULL}
+};
+
+
+/*
+ * we fix up irqs based on the slot number.
+ * The first entry is at AD:11.
+ * Fortunately this works because, although we have two pci buses,
+ * they all have different slot numbers.
+ * 
+ * This does not work for devices on sub-buses.
+ *
+ * Note that the irq number in the array is relative number in vrc5477.
+ * We need to translate it to global irq number.
+ */
+
+/*
+ * irq mapping : PCI int # -> vrc5477 irq #
+ * based on vrc5477 manual page 46
+ */
+#define		PCI_EXT_INTA		8
+#define		PCI_EXT_INTB		9
+#define		PCI_EXT_INTC		10
+#define		PCI_EXT_INTD		11
+#define		PCI_EXT_INTE		12
+
+#define		PCI_IO_INTA		16
+#define		PCI_IO_INTB		17
+#define		PCI_IO_INTC		18
+#define		PCI_IO_INTD		19
+
+/* 
+ * irq mapping : device -> pci int #, 
+ * ddb5477 board manual page 4  and vrc5477 manual page 46
+ */
+#define		INT_ONBOARD_TULIP	PCI_EXT_INTA
+#define		INT_SLOT1		PCI_EXT_INTB
+#define		INT_SLOT2		PCI_EXT_INTC
+#define		INT_SLOT3		PCI_EXT_INTD
+#define		INT_SLOT4		PCI_EXT_INTE
+
+#define		INT_USB_HOST		PCI_IO_INTA
+#define		INT_USB_PERI		PCI_IO_INTB
+#define		INT_AC97		PCI_IO_INTC
+
+/*
+ * based on ddb5477 manual page 11
+ */
+#define		MAX_SLOT_NUM		21
+static unsigned char irq_map[MAX_SLOT_NUM] = {
+	/* AD:11 */ 0xff, 0xff, 0xff, 0xff, 
+	/* AD:15 */ INT_ONBOARD_TULIP, INT_SLOT1, INT_SLOT2, INT_SLOT3,
+	/* AD:19 */ INT_SLOT4, 0xff, 0xff, 0xff,
+	/* AD:23 */ 0xff, 0xff, 0xff, 0xff,
+	/* AD:27 */ 0xff, 0xff, INT_AC97, INT_USB_PERI, 
+	/* AD:31 */ INT_USB_HOST
+};
+
+extern int vrc5477_irq_to_irq(int irq);
+void __init pcibios_fixup_irqs(void)
+{
+        struct pci_dev *dev;
+        int slot_num;
+
+	pci_for_each_dev(dev) {
+		slot_num = PCI_SLOT(dev->devfn);
+		MIPS_ASSERT(slot_num < MAX_SLOT_NUM);
+		MIPS_ASSERT(irq_map[slot_num] != 0xff);
+
+		pci_write_config_byte(dev, 
+				      PCI_INTERRUPT_LINE,
+				      irq_map[slot_num]);
+		dev->irq = vrc5477_irq_to_irq(irq_map[slot_num]);
+	}
+}
+
+#if defined(CONFIG_LL_DEBUG)
+extern void jsun_scan_pci_bus(void);
+extern void jsun_assign_pci_resource(void);
+#endif
+void __init ddb_pci_reset_bus(void)
+{	
+	u32 temp;
+
+	/*
+	 * I am not sure about the "official" procedure, the following
+	 * steps work as far as I know:
+	 * We first set PCI cold reset bit (bit 31) in PCICTRL-H.
+	 * Then we clear the PCI warm reset bit (bit 30) to 0 in PCICTRL-H.
+	 * The same is true for both PCI channels.
+	 */
+	temp = ddb_in32(DDB_PCICTL0_H);
+	temp |= 0x80000000;
+	ddb_out32(DDB_PCICTL0_H, temp);
+	temp &= ~0xc0000000;
+	ddb_out32(DDB_PCICTL0_H, temp);
+
+	temp = ddb_in32(DDB_PCICTL1_H);
+	temp |= 0x80000000;
+	ddb_out32(DDB_PCICTL1_H, temp);
+	temp &= ~0xc0000000;
+	ddb_out32(DDB_PCICTL1_H, temp);
+}
+
+unsigned __init int pcibios_assign_all_busses(void)
+{
+	return 1;
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5xxx/ddb5477/pci_ops.c linux/arch/mips/ddb5xxx/ddb5477/pci_ops.c
--- v2.4.9/linux/arch/mips/ddb5xxx/ddb5477/pci_ops.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ddb5xxx/ddb5477/pci_ops.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,416 @@
+/***********************************************************************
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
+ *
+ * arch/mips/ddb5xxx/ddb5477/pci_ops.c
+ *     Define the pci_ops for DB5477.
+ *
+ * Much of the code is derived from the original DDB5074 port by 
+ * Geert Uytterhoeven <geert@sonycom.com>
+ *
+ * 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.
+ ***********************************************************************
+ */
+
+/*
+ * DDB5477 has two PCI channels, external PCI and IOPIC (internal)
+ * Therefore we provide two sets of pci_ops.
+ */
+
+#include <linux/config.h>
+#include <linux/pci.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+
+#include <asm/addrspace.h>
+#include <asm/ddb5xxx/debug.h>
+#include <asm/ddb5xxx/ddb5xxx.h>
+
+/*
+ * config_swap structure records what set of pdar/pmr are used
+ * to access pci config space.  It also provides a place hold the
+ * original values for future restoring.
+ */
+struct pci_config_swap {
+	u32 	pdar;
+	u32	pmr;
+	u32	config_base;
+	u32	config_size;
+	u32	pdar_backup;
+	u32	pmr_backup;
+};
+
+/*
+ * On DDB5477, we have two sets of swap registers, for ext PCI and IOPCI.
+ */
+struct pci_config_swap ext_pci_swap = {
+	DDB_PCIW0,  
+	DDB_PCIINIT00,
+	DDB_PCI0_CONFIG_BASE,
+	DDB_PCI0_CONFIG_SIZE
+};
+struct pci_config_swap io_pci_swap = {
+	DDB_IOPCIW0,  
+	DDB_PCIINIT01,
+	DDB_PCI1_CONFIG_BASE,
+	DDB_PCI1_CONFIG_SIZE
+};
+
+
+/*
+ * access config space
+ */	
+static inline u32 ddb_access_config_base(struct pci_config_swap *swap,
+					 u32 bus,/* 0 means top level bus */
+					 u32 slot_num)
+{
+	u32 pci_addr = 0;
+	u32 pciinit_offset = 0;
+        u32 virt_addr = swap->config_base;
+	u32 option;
+
+	/* [jsun] hack for testing */
+	// if (slot_num == 4) slot_num = 0;
+
+	/* minimum pdar (window) size is 2MB */
+	MIPS_ASSERT(swap->config_size >= (2 << 20));
+
+	MIPS_ASSERT(slot_num < (1 << 5));
+	MIPS_ASSERT(bus < (1 << 8));
+
+	/* backup registers */
+	swap->pdar_backup = ddb_in32(swap->pdar);
+	swap->pmr_backup = ddb_in32(swap->pmr);
+
+	/* set the pdar (pci window) register */
+	ddb_set_pdar(swap->pdar,
+		     swap->config_base,
+		     swap->config_size,
+		     32,	/* 32 bit wide */
+		     0,		/* not on local memory bus */
+		     0);	/* not visible from PCI bus (N/A) */
+
+	/* 
+	 * calcuate the absolute pci config addr; 
+	 * according to the spec, we start scanning from adr:11 (0x800)
+	 */ 
+	if (bus == 0) {
+		/* type 0 config */
+		pci_addr = 0x800 << slot_num;
+	} else {
+		/* type 1 config */
+		pci_addr = (bus << 16) | (slot_num << 11);
+		panic("ddb_access_config_base: we don't support type 1 config Yet");
+	}
+
+	/*
+	 * if pci_addr is less than pci config window size,  we set
+	 * pciinit_offset to 0 and adjust the virt_address.
+	 * Otherwise we will try to adjust pciinit_offset.
+	 */
+	if (pci_addr < swap->config_size) {
+		virt_addr = KSEG1ADDR(swap->config_base + pci_addr);
+		pciinit_offset = 0;
+	} else {
+		MIPS_ASSERT( (pci_addr & (swap->config_size - 1)) == 0);
+		virt_addr = KSEG1ADDR(swap->config_base);
+		pciinit_offset = pci_addr;
+	}
+
+	/* set the pmr register */
+	option = DDB_PCI_ACCESS_32;
+	if (bus != 0) option |= DDB_PCI_CFGTYPE1;
+	ddb_set_pmr(swap->pmr, DDB_PCICMD_CFG, pciinit_offset, option);
+
+	return virt_addr;
+}
+
+static inline void ddb_close_config_base(struct pci_config_swap *swap)
+{
+	ddb_out32(swap->pdar, swap->pdar_backup);
+	ddb_out32(swap->pmr, swap->pmr_backup);
+}
+
+static int read_config_dword(struct pci_config_swap *swap,
+			     struct pci_dev *dev,
+			     u32 where,
+			     u32 *val)
+{
+	u32 bus, slot_num, func_num;
+	u32 base;
+
+	MIPS_ASSERT((where & 3) == 0);
+	MIPS_ASSERT(where < (1 << 8));
+
+	/* check if the bus is top-level */
+	if (dev->bus->parent != NULL) {
+		bus = dev->bus->number;
+		MIPS_ASSERT(bus != 0);
+	} else {
+		bus = 0;
+	}
+
+	slot_num = PCI_SLOT(dev->devfn);
+	func_num = PCI_FUNC(dev->devfn);
+	base = ddb_access_config_base(swap, bus, slot_num);
+	*val = *(volatile u32*) (base + (func_num << 8) + where);
+	ddb_close_config_base(swap);
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int read_config_word(struct pci_config_swap *swap,
+			    struct pci_dev *dev,
+			    u32 where,
+			    u16 *val)
+{
+        int status;
+        u32 result;
+
+	MIPS_ASSERT((where & 1) == 0);
+
+        status = read_config_dword(swap, dev, where & ~3, &result);
+        if (where & 2) result >>= 16;
+        *val = result & 0xffff;
+        return status;
+}
+
+static int read_config_byte(struct pci_config_swap *swap,
+			    struct pci_dev *dev,
+			    u32 where,
+			    u8 *val)
+{
+        int status;
+        u32 result;
+
+        status = read_config_dword(swap, dev, where & ~3, &result);
+        if (where & 1) result >>= 8;
+        if (where & 2) result >>= 16;
+        *val = result & 0xff;
+        return status;
+}
+
+static int write_config_dword(struct pci_config_swap *swap,
+			      struct pci_dev *dev,
+			      u32 where,
+			      u32 val)
+{
+	u32 bus, slot_num, func_num;
+	u32 base;
+
+	MIPS_ASSERT((where & 3) == 0);
+	MIPS_ASSERT(where < (1 << 8));
+
+	/* check if the bus is top-level */
+	if (dev->bus->parent != NULL) {
+		bus = dev->bus->number;
+		MIPS_ASSERT(bus != 0);
+	} else {
+		bus = 0;
+	}
+
+	slot_num = PCI_SLOT(dev->devfn);
+	func_num = PCI_FUNC(dev->devfn);
+	base = ddb_access_config_base(swap, bus, slot_num);
+	*(volatile u32*) (base + (func_num << 8) + where) = val; 
+	ddb_close_config_base(swap);
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int write_config_word(struct pci_config_swap *swap,
+			     struct pci_dev *dev,
+			     u32 where,
+			     u16 val)
+{
+	int status, shift=0;
+	u32 result;
+
+	MIPS_ASSERT((where & 1) == 0);
+
+	status = read_config_dword(swap, dev, where & ~3, &result);
+	if (status != PCIBIOS_SUCCESSFUL) return status;
+
+        if (where & 2)
+                shift += 16;
+        result &= ~(0xffff << shift);
+        result |= val << shift;
+        return write_config_dword(swap, dev, where & ~3, result);
+}
+
+static int write_config_byte(struct pci_config_swap *swap,
+			     struct pci_dev *dev,
+			     u32 where,
+			     u8 val)
+{
+	int status, shift=0;
+	u32 result;
+
+	status = read_config_dword(swap, dev, where & ~3, &result);
+	if (status != PCIBIOS_SUCCESSFUL) return status;
+
+        if (where & 2)
+                shift += 16;
+        if (where & 1)
+                shift += 8;
+        result &= ~(0xff << shift);
+        result |= val << shift;
+        return write_config_dword(swap, dev, where & ~3, result);
+}
+
+#define	MAKE_PCI_OPS(prefix, rw, unitname, unittype, pciswap) \
+static int prefix##_##rw##_config_##unitname(struct pci_dev *dev, int where, unittype val) \
+{ \
+     return rw##_config_##unitname(pciswap, \
+                                   dev, \
+                                   where, \
+                                   val); \
+}
+
+MAKE_PCI_OPS(extpci, read, byte, u8 *, &ext_pci_swap)
+MAKE_PCI_OPS(extpci, read, word, u16 *, &ext_pci_swap)
+MAKE_PCI_OPS(extpci, read, dword, u32 *, &ext_pci_swap)
+
+MAKE_PCI_OPS(iopci, read, byte, u8 *, &io_pci_swap)
+MAKE_PCI_OPS(iopci, read, word, u16 *, &io_pci_swap)
+MAKE_PCI_OPS(iopci, read, dword, u32 *, &io_pci_swap)
+
+MAKE_PCI_OPS(extpci, write, byte, u8, &ext_pci_swap)
+MAKE_PCI_OPS(extpci, write, word, u16, &ext_pci_swap)
+MAKE_PCI_OPS(extpci, write, dword, u32, &ext_pci_swap)
+
+MAKE_PCI_OPS(iopci, write, byte, u8, &io_pci_swap)
+MAKE_PCI_OPS(iopci, write, word, u16, &io_pci_swap)
+MAKE_PCI_OPS(iopci, write, dword, u32, &io_pci_swap)
+
+struct pci_ops ddb5477_ext_pci_ops ={
+	extpci_read_config_byte,
+	extpci_read_config_word,
+	extpci_read_config_dword,
+	extpci_write_config_byte,
+	extpci_write_config_word,
+	extpci_write_config_dword
+};
+
+
+struct pci_ops ddb5477_io_pci_ops ={
+	iopci_read_config_byte,
+	iopci_read_config_word,
+	iopci_read_config_dword,
+	iopci_write_config_byte,
+	iopci_write_config_word,
+	iopci_write_config_dword
+};
+
+#if defined(CONFIG_LL_DEBUG)
+void jsun_scan_pci_bus(void)
+{
+	struct pci_bus bus;
+	struct pci_dev dev;
+	unsigned int devfn;
+	int j;
+
+	bus.parent = NULL;	/* we scan the top level only */
+	dev.bus = &bus;
+	dev.sysdata = NULL;
+
+	/* scan ext pci bus and io pci bus*/
+	for (j=0; j< 2; j++) {
+		if (j ==  0) {
+			printk("scan ddb5477 external PCI bus:\n");
+			bus.ops = &ddb5477_ext_pci_ops;
+		} else {
+			printk("scan ddb5477 IO PCI bus:\n");
+			bus.ops = &ddb5477_io_pci_ops;
+		}
+	
+		for (devfn = 0; devfn < 0x100; devfn += 8) {
+			u32 temp;
+			u16 temp16;
+			u8 temp8;
+			int i;
+
+			dev.devfn = devfn;
+			MIPS_VERIFY(pci_read_config_dword(&dev, 0, &temp),
+				    == PCIBIOS_SUCCESSFUL);
+			if (temp == 0xffffffff) continue;
+
+			printk("slot %d: (addr %d) \n", devfn/8, 11+devfn/8);
+
+			/* verify read word and byte */
+			MIPS_VERIFY(pci_read_config_word(&dev, 2, &temp16),
+				    == PCIBIOS_SUCCESSFUL);
+			MIPS_ASSERT(temp16 == (temp >> 16));
+			MIPS_VERIFY(pci_read_config_byte(&dev, 3, &temp8),
+				    == PCIBIOS_SUCCESSFUL);
+			MIPS_ASSERT(temp8 == (temp >> 24));
+			MIPS_VERIFY(pci_read_config_byte(&dev, 1, &temp8),
+				    == PCIBIOS_SUCCESSFUL);
+			MIPS_ASSERT(temp8 == ((temp >> 8) & 0xff));
+
+			for (i=0; i < 16; i++) {
+				MIPS_VERIFY(pci_read_config_dword(&dev, i*4, &temp),
+					    == PCIBIOS_SUCCESSFUL);
+				printk("\t%08X", temp);
+				if ((i%4) == 3) printk("\n");
+			}
+		}
+	}
+}
+
+
+static void jsun_hardcode_pci_resources_eepro(void)
+{
+	struct pci_bus bus;
+	struct pci_dev dev;
+	u32 temp;
+
+	bus.parent = NULL;	/* we scan the top level only */
+	bus.ops = &ddb5477_ext_pci_ops;
+	dev.bus = &bus;
+	dev.sysdata = NULL;
+
+	/* for slot 5 (ext pci 1) eepro card */
+	dev.devfn = 5*8;
+	pci_read_config_dword(&dev, 0, &temp);
+	MIPS_ASSERT(temp == 0x12298086);
+
+	pci_write_config_dword(&dev, PCI_BASE_ADDRESS_0, DDB_PCI0_MEM_BASE);
+	pci_write_config_dword(&dev, PCI_BASE_ADDRESS_1, 0);
+	pci_write_config_dword(&dev, PCI_BASE_ADDRESS_2, DDB_PCI0_MEM_BASE+0x100000);
+	pci_write_config_dword(&dev, PCI_INTERRUPT_LINE, 17);
+}
+
+static void jsun_hardcode_pci_resources_onboard_tulip(void)
+{
+	struct pci_bus bus;
+	struct pci_dev dev;
+	u32 temp;
+
+	bus.parent = NULL;	/* we scan the top level only */
+	bus.ops = &ddb5477_ext_pci_ops;
+	dev.bus = &bus;
+	dev.sysdata = NULL;
+
+	/* for slot 4 on board ether chip */
+	dev.devfn = 4*8;
+	pci_read_config_dword(&dev, 0, &temp);
+	MIPS_ASSERT(temp == 0x00191011);
+
+	pci_write_config_dword(&dev, PCI_BASE_ADDRESS_0, 0x1000);
+	pci_write_config_dword(&dev, PCI_BASE_ADDRESS_1, DDB_PCI0_MEM_BASE);
+	pci_write_config_dword(&dev, PCI_INTERRUPT_LINE, 16);
+}
+
+static void jsun_hardcode_pci_resources(void)
+{
+	jsun_hardcode_pci_resources_onboard_tulip();
+}
+
+void jsun_assign_pci_resource(void)
+{
+	jsun_hardcode_pci_resources();
+}
+
+#endif
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ddb5xxx/ddb5477/setup.c linux/arch/mips/ddb5xxx/ddb5477/setup.c
--- v2.4.9/linux/arch/mips/ddb5xxx/ddb5477/setup.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ddb5xxx/ddb5477/setup.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,251 @@
+/***********************************************************************
+ *
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: jsun@mvista.com or jsun@junsun.net
+ *
+ * arch/mips/ddb5xxx/ddb5477/setup.c
+ *     Setup file for DDB5477.
+ *
+ * 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 <linux/config.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/kdev_t.h>
+#include <linux/types.h>
+#include <linux/console.h>
+#include <linux/sched.h>
+#include <linux/pci.h>
+#include <linux/ide.h>
+#include <linux/fs.h>		/* for ROOT_DEV */
+#include <linux/ioport.h>
+#include <linux/param.h>	/* for HZ */
+
+#include <asm/addrspace.h>
+#include <asm/time.h>
+#include <asm/bcache.h>
+#include <asm/irq.h>
+#include <asm/reboot.h>
+#include <asm/gdb-stub.h>
+
+#include <asm/ddb5xxx/ddb5xxx.h>
+
+
+
+#define	USE_CPU_COUNTER_TIMER	/* whether we use cpu counter */
+
+#ifdef USE_CPU_COUNTER_TIMER
+#define	CPU_COUNTER_FREQUENCY		83000000
+#else
+/* otherwise we use special timer 1 */
+#define	SP_TIMER_FREQUENCY		83000000
+#define	SP_TIMER_BASE			DDB_SPT1CTRL_L
+#define	SP_TIMER_IRQ			(8 + 6)
+#endif
+
+static void ddb_machine_restart(char *command)
+{
+	static void (*back_to_prom) (void) = (void (*)(void)) 0xbfc00000;
+
+	u32 t;
+
+	/* PCI cold reset */
+	ddb_pci_reset_bus();
+
+	/* CPU cold reset */
+	t = ddb_in32(DDB_CPUSTAT);
+	MIPS_ASSERT((t&1));
+	ddb_out32(DDB_CPUSTAT, t);
+
+	/* Call the PROM */
+	back_to_prom();
+}
+
+static void ddb_machine_halt(void)
+{
+	printk("DDB Vrc-5477 halted.\n");
+	while (1);
+}
+
+static void ddb_machine_power_off(void)
+{
+	printk("DDB Vrc-5477 halted. Please turn off the power.\n");
+	while (1);
+}
+
+extern void rtc_ds1386_init(unsigned long base);
+static void __init ddb_time_init(void)
+{
+#if defined(USE_CPU_COUNTER_TIMER)
+	mips_counter_frequency = CPU_COUNTER_FREQUENCY;
+#endif
+
+	/* we have ds1396 RTC chip */
+	rtc_ds1386_init(KSEG1ADDR(DDB_LCS1_BASE));
+}
+
+#if defined(CONFIG_LL_DEBUG)
+int  board_init_done_flag = 0;
+#endif
+
+extern int setup_irq(unsigned int irq, struct irqaction *irqaction);
+static void __init ddb_timer_setup(struct irqaction *irq)
+{
+#if defined(USE_CPU_COUNTER_TIMER)
+	unsigned int count;
+
+        /* we are using the cpu counter for timer interrupts */
+	setup_irq(7, irq);
+
+        /* to generate the first timer interrupt */
+        count = read_32bit_cp0_register(CP0_COUNT);
+        write_32bit_cp0_register(CP0_COMPARE, count + 1000);
+
+#else
+
+	/* if we don't use Special purpose timer 1 */
+	ddb_out32(SP_TIMER_BASE, SP_TIMER_FREQUENCY/HZ);
+	ddb_out32(SP_TIMER_BASE+4, 0x1);
+	setup_irq(SP_TIMER_IRQ, irq);
+
+#endif
+	
+	/* this is the last board dependent code */
+	MIPS_DEBUG(board_init_done_flag = 1);
+}
+
+static void ddb5477_board_init(void);
+extern void ddb5477_irq_setup(void);
+
+#if defined(CONFIG_BLK_DEV_INITRD)
+extern unsigned long __rd_start, __rd_end, initrd_start, initrd_end;
+#endif 
+
+void __init ddb_setup(void)
+{
+	extern int panic_timeout;
+
+	irq_setup = ddb5477_irq_setup;
+	mips_io_port_base = KSEG1ADDR(DDB_PCI_IO_BASE);
+
+	board_time_init = ddb_time_init;
+	board_timer_setup = ddb_timer_setup;
+
+	_machine_restart = ddb_machine_restart;
+	_machine_halt = ddb_machine_halt;
+	_machine_power_off = ddb_machine_power_off;
+
+	/* setup resource limits */
+	ioport_resource.end = DDB_PCI0_IO_SIZE + DDB_PCI1_IO_SIZE - 1;
+	iomem_resource.end = 0xffffffff;
+	
+	/* Reboot on panic */
+	panic_timeout = 180;
+
+	/* initialize board - we don't trust the loader */
+	ddb5477_board_init();
+
+#if defined(CONFIG_BLK_DEV_INITRD)
+	ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);
+	initrd_start = (unsigned long)&__rd_start;
+	initrd_end = (unsigned long)&__rd_end;
+#endif
+
+}
+
+static void __init ddb5477_board_init()
+{
+	/* ----------- setup PDARs ------------ */
+
+	/* SDRAM should have been set */
+	MIPS_ASSERT(ddb_in32(DDB_SDRAM0) == 
+		    ddb_calc_pdar(DDB_SDRAM_BASE, DDB_SDRAM_SIZE, 32, 0, 1));
+
+	/* SDRAM1 should be turned off.  What is this for anyway ? */
+	MIPS_ASSERT( (ddb_in32(DDB_SDRAM1) & 0xf) == 0);
+
+	/* Set LDCSs */
+	/* flash */
+	ddb_set_pdar(DDB_LCS0, DDB_LCS0_BASE, DDB_LCS0_SIZE, 16, 0, 0);
+	/* misc */
+	ddb_set_pdar(DDB_LCS1, DDB_LCS1_BASE, DDB_LCS1_SIZE, 8, 0, 0);
+	/* mezzanie (?) */
+	ddb_set_pdar(DDB_LCS2, DDB_LCS2_BASE, DDB_LCS2_SIZE, 16, 0, 0);
+
+	/* verify VRC5477 base addr */
+	MIPS_ASSERT(ddb_in32(DDB_VRC5477) == 
+		    ddb_calc_pdar(DDB_VRC5477_BASE, DDB_VRC5477_SIZE, 32, 0, 1));
+	
+	/* verify BOOT ROM addr */
+	MIPS_ASSERT(ddb_in32(DDB_BOOTCS) == 
+		    ddb_calc_pdar(DDB_BOOTCS_BASE, DDB_BOOTCS_SIZE, 8, 0, 0));
+
+	/* setup PCI windows - window0 for MEM/config, window1 for IO */
+	ddb_set_pdar(DDB_PCIW0, DDB_PCI0_MEM_BASE, DDB_PCI0_MEM_SIZE, 32, 0, 1);
+	ddb_set_pdar(DDB_PCIW1, DDB_PCI0_IO_BASE, DDB_PCI0_IO_SIZE, 32, 0, 1);
+	ddb_set_pdar(DDB_IOPCIW0, DDB_PCI1_MEM_BASE, DDB_PCI1_MEM_SIZE, 32, 0, 1);
+	ddb_set_pdar(DDB_IOPCIW1, DDB_PCI1_IO_BASE, DDB_PCI1_IO_SIZE, 32, 0, 1);
+
+	/* ------------ reset PCI bus and BARs ----------------- */
+	ddb_pci_reset_bus();
+
+	ddb_out32(DDB_BARM010, 0x00000008);
+	ddb_out32(DDB_BARM011, 0x00000008);
+
+	ddb_out32(DDB_BARC0, 0xffffffff);
+	ddb_out32(DDB_BARM230, 0xffffffff);
+	ddb_out32(DDB_BAR00, 0xffffffff);
+	ddb_out32(DDB_BAR10, 0xffffffff);
+	ddb_out32(DDB_BAR20, 0xffffffff);
+	ddb_out32(DDB_BAR30, 0xffffffff);
+	ddb_out32(DDB_BAR40, 0xffffffff);
+	ddb_out32(DDB_BAR50, 0xffffffff);
+	ddb_out32(DDB_BARB0, 0xffffffff);
+
+	ddb_out32(DDB_BARC1, 0xffffffff);
+	ddb_out32(DDB_BARM231, 0xffffffff);
+	ddb_out32(DDB_BAR01, 0xffffffff);
+	ddb_out32(DDB_BAR11, 0xffffffff);
+	ddb_out32(DDB_BAR21, 0xffffffff);
+	ddb_out32(DDB_BAR31, 0xffffffff);
+	ddb_out32(DDB_BAR41, 0xffffffff);
+	ddb_out32(DDB_BAR51, 0xffffffff);
+	ddb_out32(DDB_BARB1, 0xffffffff);
+
+	/* 
+	 * We use pci master register 0  for memory space / config space
+	 * And we use register 1 for IO space.
+	 * Note that for memory space, we bump up the pci base address
+	 * so that we have 1:1 mapping between PCI memory and cpu physical.
+	 * For PCI IO space, it starts from 0 in PCI IO space but with
+	 * DDB_xx_IO_BASE in CPU physical address space.
+	 */
+	ddb_set_pmr(DDB_PCIINIT00, DDB_PCICMD_MEM, DDB_PCI0_MEM_BASE, 
+		    DDB_PCI_ACCESS_32);
+	ddb_set_pmr(DDB_PCIINIT10, DDB_PCICMD_IO, 0, DDB_PCI_ACCESS_32);
+
+	ddb_set_pmr(DDB_PCIINIT01, DDB_PCICMD_MEM, DDB_PCI1_MEM_BASE, 
+		    DDB_PCI_ACCESS_32);
+	ddb_set_pmr(DDB_PCIINIT11, DDB_PCICMD_IO, DDB_PCI0_IO_SIZE, 
+                    DDB_PCI_ACCESS_32);
+
+	
+	/* PCI cross window should be set properly */
+	ddb_set_pdar(DDB_BARP00, DDB_PCI1_MEM_BASE, DDB_PCI1_MEM_SIZE, 32, 0, 1);
+	ddb_set_pdar(DDB_BARP10, DDB_PCI1_IO_BASE, DDB_PCI1_IO_SIZE, 32, 0, 1);
+	ddb_set_pdar(DDB_BARP01, DDB_PCI0_MEM_BASE, DDB_PCI0_MEM_SIZE, 32, 0, 1);
+	ddb_set_pdar(DDB_BARP11, DDB_PCI0_IO_BASE, DDB_PCI0_IO_SIZE, 32, 0, 1);
+
+	/* enable USB input buffers */
+	ddb_out32(DDB_PIBMISC, 0x00000007);
+
+	/* For dual-function pins, make them all non-GPIO */
+	ddb_out32(DDB_GIUFUNSEL, 0x0);
+	// ddb_out32(DDB_GIUFUNSEL, 0xfe0fcfff);  /* NEC recommanded value */
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/dec/Makefile linux/arch/mips/dec/Makefile
--- v2.4.9/linux/arch/mips/dec/Makefile	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/dec/Makefile	Sun Sep  9 10:43:01 2001
@@ -19,7 +19,6 @@
 obj-y	 := int-handler.o setup.o irq.o time.o reset.o rtc-dec.o wbflush.o
 
 obj-$(CONFIG_PROM_CONSOLE)	+= promcon.o
-obj-$(CONFIG_SERIAL)		+= serial.o
 
 int-handler.o:	int-handler.S
 
diff -u --recursive --new-file v2.4.9/linux/arch/mips/dec/int-handler.S linux/arch/mips/dec/int-handler.S
--- v2.4.9/linux/arch/mips/dec/int-handler.S	Fri Jun 25 17:40:12 1999
+++ linux/arch/mips/dec/int-handler.S	Sun Sep  9 10:43:01 2001
@@ -2,6 +2,7 @@
  * arch/mips/dec/int-handler.S
  *
  * Copyright (C) 1995, 1996, 1997 Paul M. Antoine and Harald Koerfgen
+ * Copyright (C) 2000  Maciej W. Rozycki
  *
  * Written by Ralf Baechle and Andreas Busse, modified for DECStation
  * support by Paul Antoine and Harald Koerfgen.
@@ -16,6 +17,11 @@
 #include <asm/stackframe.h>
 #include <asm/addrspace.h>
 
+#include <asm/dec/kn01.h>
+#include <asm/dec/kn02.h>
+#include <asm/dec/kn02xa.h>
+#include <asm/dec/kn03.h>
+#include <asm/dec/ioasic_addrs.h>
 #include <asm/dec/interrupts.h>
 
 
@@ -24,8 +30,6 @@
 /*
  * decstation_handle_int: Interrupt handler for DECStations
  *
- * FIXME: Detection of spurious interrupts not yet implemented!
- *
  * We follow the model in the Indy interrupt code by David Miller, where he
  * says: a lot of complication here is taken away because:
  *
@@ -139,12 +143,12 @@
 		la	t1,cpu_mask_tbl
 		and	t0,t2			# isolate allowed ones
 
-		/* insert detection of spurious interrupts here */
+		beqz	t0,spurious
 
 		/*
 		 * Find irq with highest priority
 		 */
-1:		lw	t2,(t1)
+1:		 lw	t2,(t1)
 		move	t3,t0
 		and	t3,t2
 		beq	t3,zero,1b
@@ -156,18 +160,18 @@
 		lw	a0,%lo(cpu_irq_nr-cpu_mask_tbl-PTRSIZE)(t1)
 		lw	t0,%lo(cpu_ivec_tbl-cpu_mask_tbl-PTRSIZE)(t1)
 		bgez	a0, handle_it		# irq_nr >= 0?
-						# irq_nr < 0: a0 contains an address
-		nop
+						# irq_nr < 0: t0 contains an address
+		 nop
 		jr	t0
 		 nop				# delay slot
 
 /*
  * Handle "IRQ Controller" Interrupts
  * Masked Interrupts are still visible and have to be masked "by hand".
- * %hi(KN02_CSR_ADDR) does not work so all addresses are hardcoded :-(.
  */
 		EXPORT(kn02_io_int)
-kn02_io_int:	lui	t0,0xbff0		# get interrupt status and mask
+kn02_io_int:					# 3max
+		lui	t0,KN02_CSR_ADDR>>16	# get interrupt status and mask
 		lw	t0,(t0)
 		la	t1,asic_mask_tbl
 		move	t3,t0
@@ -176,27 +180,32 @@
 		 and	t0,t3			# mask out allowed ones
 
 		EXPORT(kn03_io_int)
-kn03_io_int:	lui	t2,0xbf84		# upper part of IOASIC Address
-		lw	t0,0x0110(t2)		# get status: IOASIC isr
-		lw	t3,0x0120(t2)		# get mask:   IOASIC isrm
+kn03_io_int:					# 3max+
+		lui	t2,KN03_IOASIC_BASE>>16	# upper part of IOASIC Address
+		lw	t0,SIR(t2)		# get status: IOASIC isr
+		lw	t3,SIMR(t2)		# get mask:   IOASIC isrm
 		la	t1,asic_mask_tbl
 		b	find_int
 		 and	t0,t3			# mask out allowed ones
 
-		EXPORT(kn02ba_io_int)
-kn02ba_io_int:	lui	t2,0xbc04		
-		lw	t0,0x0110(t2)		# IOASIC isr, works for maxine also
-		lw	t3,0x0120(t2)		# IOASIC isrm
+		EXPORT(kn02xa_io_int)
+kn02xa_io_int:					# 3min/maxine
+		lui	t2,KN02XA_IOASIC_BASE>>16		
+						# upper part of IOASIC Address
+		lw	t0,SIR(t2)		# get status: IOASIC isr
+		lw	t3,SIMR(t2)		# get mask:   IOASIC isrm
 		la	t1,asic_mask_tbl
 		and	t0,t3
 
 		/*
 		 * Find irq with highest priority
 		 */
-find_int:	lw	t2,(t1)
+find_int:	beqz	t0,spurious
+
+1:		 lw	t2,(t1)
 		move	t3,t0
 		and	t3,t2
-		beq	zero,t3,find_int
+		beq	zero,t3,1b
 		 addu	t1,PTRSIZE		# delay slot
 
 		/*
@@ -209,7 +218,10 @@
 		 move	a1,sp
 		j	ret_from_irq
 		 nop
-		
+
+spurious:
+		j	spurious_interrupt
+		 nop
 		END(decstation_handle_int)
 /*
   * Interrupt routines common to all DECStations first.
@@ -218,14 +230,6 @@
 dec_intr_fpu:	PANIC("Unimplemented FPU interrupt handler")
 
 /*
- * Halt interrupt
- */
-		EXPORT(intr_halt)
-intr_halt:	la	k0,0xbc000000
-		jr	k0
-		 nop
-
-/*
  * Generic unimplemented interrupt routines - ivec_tbl is initialised to
  * point all interrupts here.  The table is then filled in by machine-specific
  * initialisation in dec_setup().
@@ -358,5 +362,3 @@
 		.word	0
 		.word	0
 		.word	0xffffffff		# EOL
-
-
diff -u --recursive --new-file v2.4.9/linux/arch/mips/dec/irq.c linux/arch/mips/dec/irq.c
--- v2.4.9/linux/arch/mips/dec/irq.c	Fri Feb  9 11:29:44 2001
+++ linux/arch/mips/dec/irq.c	Sun Sep  9 10:43:01 2001
@@ -2,9 +2,7 @@
  * Code to handle DECstation IRQs plus some generic interrupt stuff.
  *
  * Copyright (C) 1992 Linus Torvalds
- * Copyright (C) 1994, 1995, 1996, 1997 Ralf Baechle
- *
- * $Id: irq.c,v 1.6 2000/02/04 07:40:23 ralf Exp $
+ * Copyright (C) 1994, 1995, 1996, 1997, 2000 Ralf Baechle
  */
 #include <linux/errno.h>
 #include <linux/init.h>
@@ -27,9 +25,14 @@
 
 #include <asm/dec/interrupts.h>
 
-extern volatile unsigned int *isr;	/* address of the interrupt status register     */
-extern volatile unsigned int *imr;	/* address of the interrupt mask register       */
-extern decint_t dec_interrupt[NR_INTS];
+extern void dec_init_kn01(void);
+extern void dec_init_kn230(void);
+extern void dec_init_kn02(void);
+extern void dec_init_kn02ba(void);
+extern void dec_init_kn02ca(void);
+extern void dec_init_kn03(void);
+
+extern asmlinkage void decstation_handle_int(void);
 
 unsigned long spurious_count = 0;
 
@@ -42,7 +45,7 @@
 	dummy = *imr;
 	dummy = *imr;
     } else			/* This is a cpu interrupt        */
-	set_cp0_status(ST0_IM, read_32bit_cp0_register(CP0_STATUS) & ~dec_interrupt[irq_nr].cpu_mask);
+	change_cp0_status(ST0_IM, read_32bit_cp0_register(CP0_STATUS) & ~dec_interrupt[irq_nr].cpu_mask);
 }
 
 static inline void unmask_irq(unsigned int irq_nr)
@@ -54,7 +57,7 @@
 	dummy = *imr;
 	dummy = *imr;
     }
-    set_cp0_status(ST0_IM, read_32bit_cp0_register(CP0_STATUS) | dec_interrupt[irq_nr].cpu_mask);
+    change_cp0_status(ST0_IM, read_32bit_cp0_register(CP0_STATUS) | dec_interrupt[irq_nr].cpu_mask);
 }
 
 void disable_irq(unsigned int irq_nr)
@@ -125,7 +128,7 @@
     int do_random, cpu;
 
     cpu = smp_processor_id();
-    irq_enter(cpu);
+    irq_enter(cpu, irq);
     kstat.irqs[cpu][irq]++;
 
     mask_irq(irq);
@@ -142,10 +145,10 @@
 	} while (action);
 	if (do_random & SA_SAMPLE_RANDOM)
 	    add_interrupt_randomness(irq);
-	unmask_irq(irq);
 	__cli();
+	unmask_irq(irq);
     }
-    irq_exit(cpu);
+    irq_exit(cpu, irq);
 
     /* unmasking and bottom half handling is done magically for us. */
 }
@@ -261,5 +264,34 @@
 
 void __init init_IRQ(void)
 {
-    irq_setup();
+    switch (mips_machtype) {
+    case MACH_DS23100:
+	dec_init_kn01();
+	break;
+    case MACH_DS5100:		/*  DS5100 MIPSMATE */
+	dec_init_kn230();
+	break;
+    case MACH_DS5000_200:	/* DS5000 3max */
+	dec_init_kn02();
+	break;
+    case MACH_DS5000_1XX:	/* DS5000/100 3min */
+	dec_init_kn02ba();
+	break;
+    case MACH_DS5000_2X0:	/* DS5000/240 3max+ */
+	dec_init_kn03();
+	break;
+    case MACH_DS5000_XX:	/* Personal DS5000/2x */
+	dec_init_kn02ca();
+	break;
+    case MACH_DS5800:		/* DS5800 Isis */
+	panic("Don't know how to set this up!");
+	break;
+    case MACH_DS5400:		/* DS5400 MIPSfair */
+	panic("Don't know how to set this up!");
+	break;
+    case MACH_DS5500:		/* DS5500 MIPSfair-2 */
+	panic("Don't know how to set this up!");
+	break;
+    }
+    set_except_vector(0, decstation_handle_int);
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips/dec/prom/cmdline.c linux/arch/mips/dec/prom/cmdline.c
--- v2.4.9/linux/arch/mips/dec/prom/cmdline.c	Mon Feb 28 07:18:20 2000
+++ linux/arch/mips/dec/prom/cmdline.c	Sun Sep  9 10:43:01 2001
@@ -2,8 +2,6 @@
  * cmdline.c: read the command line passed to us by the PROM.
  *
  * Copyright (C) 1998 Harald Koerfgen
- *
- * $Id: cmdline.c,v 1.2 1999/10/09 00:00:57 ralf Exp $
  */
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -19,7 +17,7 @@
 extern int (*prom_printf)(char *, ...);
 #endif
 
-char arcs_cmdline[CL_SIZE];
+char arcs_cmdline[COMMAND_LINE_SIZE];
 
 void __init prom_init_cmdline(int argc, char **argv, unsigned long magic)
 {
diff -u --recursive --new-file v2.4.9/linux/arch/mips/dec/prom/init.c linux/arch/mips/dec/prom/init.c
--- v2.4.9/linux/arch/mips/dec/prom/init.c	Sat May 13 08:29:14 2000
+++ linux/arch/mips/dec/prom/init.c	Sun Sep  9 10:43:01 2001
@@ -2,12 +2,11 @@
  * init.c: PROM library initialisation code.
  *
  * Copyright (C) 1998 Harald Koerfgen
- *
- * $Id: init.c,v 1.3 1999/08/09 19:43:13 harald Exp $
  */
 #include <linux/init.h>
 #include <linux/config.h>
 #include <asm/bootinfo.h>
+#include <asm/cpu.h>
 #include "prom.h"
 
 /*
@@ -93,15 +92,17 @@
 
 	/* Were we compiled with the right CPU option? */
 #if defined(CONFIG_CPU_R3000)
-	if ((mips_cputype == CPU_R4000SC) || (mips_cputype == CPU_R4400SC)) {
+	if ((mips_cpu.cputype == CPU_R4000SC) ||
+	    (mips_cpu.cputype == CPU_R4400SC)) {
 		prom_printf("Sorry, this kernel is compiled for the wrong CPU type!\n");
 		prom_printf("Please recompile with \"CONFIG_CPU_R4x00 = y\"\n");
 		dec_machine_halt();
 	}
 #endif
 
-#if defined(CONFIG_CPU_R4x00)
-	if ((mips_cputype == CPU_R3000) || (mips_cputype == CPU_R3000A)) {
+#if defined(CONFIG_CPU_R4X00)
+	if ((mips_cpu.cputype == CPU_R3000) ||
+	    (mips_cpu.cputype == CPU_R3000A)) {
 		prom_printf("Sorry, this kernel is compiled for the wrong CPU type!\n");
 		prom_printf("Please recompile with \"CONFIG_CPU_R3000 = y\"\n");
 		dec_machine_halt();
@@ -114,3 +115,4 @@
 
 	return 0;
 }
+
diff -u --recursive --new-file v2.4.9/linux/arch/mips/dec/prom/memory.c linux/arch/mips/dec/prom/memory.c
--- v2.4.9/linux/arch/mips/dec/prom/memory.c	Tue Mar  6 19:44:36 2001
+++ linux/arch/mips/dec/prom/memory.c	Sun Sep  9 10:43:01 2001
@@ -2,6 +2,7 @@
  * memory.c: memory initialisation code.
  *
  * Copyright (C) 1998 Harald Koerfgen, Frieder Streffer and Paul M. Antoine
+ * Copyright (C) 2000 Maciej W. Rozycki
  *
  * $Id: memory.c,v 1.3 1999/10/09 00:00:58 ralf Exp $
  */
@@ -14,6 +15,8 @@
 #include <asm/addrspace.h>
 #include <asm/page.h>
 
+#include <asm/bootinfo.h>
+
 #include <asm/dec/machtype.h>
 
 #include "prom.h"
@@ -33,11 +36,6 @@
 
 volatile unsigned long mem_err = 0;	/* So we know an error occurred */
 
-extern char _end;
-
-#define PFN_UP(x)	(((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
-#define PFN_ALIGN(x)	(((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
-
 /*
  * Probe memory in 4MB chunks, waiting for an error to tell us we've fallen
  * off the end of real memory.  Only suitable for the 2100/3100's (PMAX).
@@ -45,7 +43,7 @@
 
 #define CHUNK_SIZE 0x400000
 
-unsigned long __init pmax_get_memory_size(void)
+static void __init pmax_setup_memory_region(void)
 {
 	volatile unsigned char *memory_page, dummy;
 	char	old_handler[0x80];
@@ -66,17 +64,19 @@
 		dummy = *memory_page;
 	}
 	memcpy((void *)(KSEG0 + 0x80), &old_handler, 0x80);
-	return (unsigned long)memory_page - KSEG1 - CHUNK_SIZE;
+
+	add_memory_region(0, (unsigned long)memory_page - KSEG1 - CHUNK_SIZE,
+			  BOOT_MEM_RAM);
 }
 
 /*
  * Use the REX prom calls to get hold of the memory bitmap, and thence
  * determine memory size.
  */
-unsigned long __init rex_get_memory_size(void)
+static void __init rex_setup_memory_region(void)
 {
 	int i, bitmap_size;
-	unsigned long mem_size = 0;
+	unsigned long mem_start = 0, mem_size = 0;
 	memmap *bm;
 
 	/* some free 64k */
@@ -88,46 +88,30 @@
 		/* FIXME: very simplistically only add full sets of pages */
 		if (bm->bitmap[i] == 0xff)
 			mem_size += (8 * bm->pagesize);
+		else if (!mem_size)
+			mem_start += (8 * bm->pagesize);
+		else {
+			add_memory_region(mem_start, mem_size, BOOT_MEM_RAM);
+			mem_start += mem_size + (8 * bm->pagesize);
+			mem_size = 0;
+		}
 	}
-
-	return (mem_size);
+	if (mem_size)
+		add_memory_region(mem_start, mem_size, BOOT_MEM_RAM);
 }
 
 void __init prom_meminit(unsigned int magic)
 {
-	unsigned long free_start, free_end, start_pfn, bootmap_size;
-	unsigned long mem_size = 0;
-
 	if (magic != REX_PROM_MAGIC)
-		mem_size = pmax_get_memory_size();
+		pmax_setup_memory_region();
 	else
-		mem_size = rex_get_memory_size();
-
-	free_start = PHYSADDR(PFN_ALIGN(&_end));
-	free_end = mem_size;
-	start_pfn = PFN_UP((unsigned long)&_end);
-
-#ifdef PROM_DEBUG
-	prom_printf("free_start: 0x%08x\n", free_start);
-	prom_printf("free_end: 0x%08x\n", free_end);
-	prom_printf("start_pfn: 0x%08x\n", start_pfn);
-#endif
-
-	/* Register all the contiguous memory with the bootmem allocator
-	   and free it.  Be careful about the bootmem freemap.  */
-	bootmap_size = init_bootmem(start_pfn, mem_size >> PAGE_SHIFT);
-	free_bootmem(free_start + bootmap_size, free_end - free_start - bootmap_size);
-}
-
-int __init page_is_ram(unsigned long pagenr)
-{
-        return 1;
+		rex_setup_memory_region();
 }
 
-void prom_free_prom_memory (void)
+void __init prom_free_prom_memory (void)
 {
 	unsigned long addr, end;
-	extern	char _ftext;
+	extern char _ftext;
 
 	/*
 	 * Free everything below the kernel itself but leave
@@ -142,16 +126,16 @@
 	 * XXX: save this address for use in dec_lance.c?
 	 */
 	if (IOASIC)
-		end = PHYSADDR(&_ftext) - 0x00020000;
+		end = __pa(&_ftext) - 0x00020000;
 	else
 #endif
-		end = PHYSADDR(&_ftext);
+		end = __pa(&_ftext);
 
 	addr = PAGE_SIZE;
 	while (addr < end) {
-		ClearPageReserved(virt_to_page(addr));
-		set_page_count(virt_to_page(addr), 1);
-		free_page(addr);
+		ClearPageReserved(virt_to_page(__va(addr)));
+		set_page_count(virt_to_page(__va(addr)), 1);
+		free_page((unsigned long)__va(addr));
 		addr += PAGE_SIZE;
 	}
 
diff -u --recursive --new-file v2.4.9/linux/arch/mips/dec/reset.c linux/arch/mips/dec/reset.c
--- v2.4.9/linux/arch/mips/dec/reset.c	Sat May 13 08:29:14 2000
+++ linux/arch/mips/dec/reset.c	Sun Sep  9 10:43:01 2001
@@ -23,3 +23,7 @@
 	back_to_prom();
 }
 
+void dec_intr_halt(int irq, void *dev_id, struct pt_regs *regs)
+{
+	dec_machine_halt();
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/dec/rtc-dec.c linux/arch/mips/dec/rtc-dec.c
--- v2.4.9/linux/arch/mips/dec/rtc-dec.c	Sat May 13 08:29:14 2000
+++ linux/arch/mips/dec/rtc-dec.c	Sun Sep  9 10:43:01 2001
@@ -1,13 +1,12 @@
-
-/* $Id: rtc-jazz.c,v 1.2 1998/06/25 20:19:14 ralf Exp $
-
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * RTC routines for DECstation style attached Dallas chip.
  *
- * Copyright (C) 1998 by Ralf Baechle, Harald Koerfgen
+ * Copyright (C) 1998, 2001 by Ralf Baechle
+ * Copyright (C) 1998 by Harald Koerfgen
  */
 #include <linux/mc146818rtc.h>
 
diff -u --recursive --new-file v2.4.9/linux/arch/mips/dec/serial.c linux/arch/mips/dec/serial.c
--- v2.4.9/linux/arch/mips/dec/serial.c	Sat May 13 08:29:14 2000
+++ linux/arch/mips/dec/serial.c	Wed Dec 31 16:00:00 1969
@@ -1,98 +0,0 @@
-/*
- * sercons.c
- *      choose the right serial device at boot time
- *
- * triemer 6-SEP-1998
- *      sercons.c is designed to allow the three different kinds 
- *      of serial devices under the decstation world to co-exist
- *      in the same kernel.  The idea here is to abstract 
- *      the pieces of the drivers that are common to this file
- *      so that they do not clash at compile time and runtime.
- *
- * HK 16-SEP-1998 v0.002
- *      removed the PROM console as this is not a real serial
- *      device. Added support for PROM console in drivers/char/tty_io.c
- *      instead. Although it may work to enable more than one 
- *      console device I strongly recommend to use only one.
- */
-
-#include <linux/config.h>
-#include <linux/init.h>
-#include <asm/dec/machtype.h>
-
-#ifdef CONFIG_ZS
-extern int zs_init(void);
-#endif
-
-#ifdef CONFIG_DZ
-extern int dz_init(void);
-#endif
-
-#ifdef CONFIG_SERIAL_CONSOLE
-
-#ifdef CONFIG_ZS
-extern void zs_serial_console_init(void);
-#endif
-
-#ifdef CONFIG_DZ
-extern void dz_serial_console_init(void);
-#endif
-
-#endif
-
-/* rs_init - starts up the serial interface -
-   handle normal case of starting up the serial interface */
-
-#ifdef CONFIG_SERIAL
-
-int __init rs_init(void)
-{
-
-#if defined(CONFIG_ZS) && defined(CONFIG_DZ)
-    if (IOASIC)
-	return zs_init();
-    else
-	return dz_init();
-#else
-
-#ifdef CONFIG_ZS
-    return zs_init();
-#endif
-
-#ifdef CONFIG_DZ
-    return dz_init();
-#endif
-
-#endif
-}
-
-__initcall(rs_init);
-
-#endif
-
-#ifdef CONFIG_SERIAL_CONSOLE
-
-/* serial_console_init handles the special case of starting
- *   up the console on the serial port
- */
-void __init serial_console_init(void)
-{
-#if defined(CONFIG_ZS) && defined(CONFIG_DZ)
-    if (IOASIC)
-	zs_serial_console_init();
-    else
-	dz_serial_console_init();
-#else
-
-#ifdef CONFIG_ZS
-    zs_serial_console_init();
-#endif
-
-#ifdef CONFIG_DZ
-    dz_serial_console_init();
-#endif
-
-#endif
-}
-
-#endif
diff -u --recursive --new-file v2.4.9/linux/arch/mips/dec/setup.c linux/arch/mips/dec/setup.c
--- v2.4.9/linux/arch/mips/dec/setup.c	Thu Aug 26 12:42:31 1999
+++ linux/arch/mips/dec/setup.c	Sun Sep  9 10:43:01 2001
@@ -6,11 +6,13 @@
  * for more details.
  *
  * Copyright (C) 1998 Harald Koerfgen
+ * Copyright (C) 2000 Maciej W. Rozycki
  */
 #include <linux/sched.h>
 #include <linux/interrupt.h>
 #include <linux/mc146818rtc.h>
 #include <linux/param.h>
+#include <linux/console.h>
 #include <asm/mipsregs.h>
 #include <asm/bootinfo.h>
 #include <linux/init.h>
@@ -22,25 +24,19 @@
 #include <asm/dec/kn02.h>
 #include <asm/dec/kn02xa.h>
 #include <asm/dec/kn03.h>
+#include <asm/dec/ioasic.h>
+#include <asm/dec/ioasic_addrs.h>
 #include <asm/dec/ioasic_ints.h>
 
-extern asmlinkage void decstation_handle_int(void);
 
-void dec_init_kn01(void);
-void dec_init_kn230(void);
-void dec_init_kn02(void);
-void dec_init_kn02ba(void);
-void dec_init_kn02ca(void);
-void dec_init_kn03(void);
+char *dec_rtc_base = (void *) KN01_RTC_BASE;	/* Assume DS2100/3100 initially */
 
-char *dec_rtc_base = (char *) KN01_RTC_BASE;	/* Assume DS2100/3100 initially */
+volatile unsigned int *ioasic_base;
 
 decint_t dec_interrupt[NR_INTS];
 
-/* 
+/*
  * Information regarding the IRQ Controller
- *
- * isr and imr are also hardcoded for different machines in int_handler.S
  */
 
 volatile unsigned int *isr = 0L;	/* address of the interrupt status register     */
@@ -49,50 +45,17 @@
 extern void dec_machine_restart(char *command);
 extern void dec_machine_halt(void);
 extern void dec_machine_power_off(void);
+extern void dec_intr_halt(int irq, void *dev_id, struct pt_regs *regs);
 
 extern void wbflush_setup(void);
 
 extern struct rtc_ops dec_rtc_ops;
 
-extern void intr_halt(void);
-
 extern int setup_dec_irq(int, struct irqaction *);
 
 void (*board_time_init) (struct irqaction * irq);
 
-static void __init dec_irq_setup(void)
-{
-    switch (mips_machtype) {
-    case MACH_DS23100:
-	dec_init_kn01();
-	break;
-    case MACH_DS5100:		/*  DS5100 MIPSMATE */
-	dec_init_kn230();
-	break;
-    case MACH_DS5000_200:	/* DS5000 3max */
-	dec_init_kn02();
-	break;
-    case MACH_DS5000_1XX:	/* DS5000/100 3min */
-	dec_init_kn02ba();
-	break;
-    case MACH_DS5000_2X0:	/* DS5000/240 3max+ */
-	dec_init_kn03();
-	break;
-    case MACH_DS5000_XX:	/* Personal DS5000/2x */
-	dec_init_kn02ca();
-	break;
-    case MACH_DS5800:		/* DS5800 Isis */
-	panic("Don't know how to set this up!");
-	break;
-    case MACH_DS5400:		/* DS5400 MIPSfair */
-	panic("Don't know how to set this up!");
-	break;
-    case MACH_DS5500:		/* DS5500 MIPSfair-2 */
-	panic("Don't know how to set this up!");
-	break;
-    }
-    set_except_vector(0, decstation_handle_int);
-}
+static struct irqaction irq10 = {dec_intr_halt, 0, 0, "halt", NULL, NULL};
 
 /*
  * enable the periodic interrupts
@@ -112,9 +75,16 @@
     setup_dec_irq(CLOCK, irq);
 }
 
+/*
+ * Enable the halt interrupt.
+ */
+static void __init dec_halt_init(struct irqaction *irq)
+{
+    setup_dec_irq(HALT, irq);
+}
+
 void __init decstation_setup(void)
 {
-    irq_setup = dec_irq_setup;
     board_time_init = dec_time_init;
 
     wbflush_setup();
@@ -123,6 +93,10 @@
     _machine_halt = dec_machine_halt;
     _machine_power_off = dec_machine_power_off;
 
+#ifdef CONFIG_FB
+    conswitchp = &dummy_con;
+#endif
+
     rtc_ops = &dec_rtc_ops;
 }
 
@@ -206,8 +180,8 @@
      * Setup some memory addresses. FIXME: probably incomplete!
      */
     dec_rtc_base = (char *) KN02_RTC_BASE;
-    isr = (volatile unsigned int *) KN02_CSR_ADDR;
-    imr = (volatile unsigned int *) KN02_CSR_ADDR;
+    isr = (void *) KN02_CSR_ADDR;
+    imr = (void *) KN02_CSR_ADDR;
 
     /*
      * Setup IOASIC interrupt
@@ -275,16 +249,17 @@
     /*
      * Setup some memory addresses.
      */
+    ioasic_base = (void *) KN02XA_IOASIC_BASE;
     dec_rtc_base = (char *) KN02XA_RTC_BASE;
-    isr = (volatile unsigned int *) KN02XA_SIR_ADDR;
-    imr = (volatile unsigned int *) KN02XA_SIRM_ADDR;
+    isr = (void *) KN02XA_IOASIC_REG(SIR);
+    imr = (void *) KN02XA_IOASIC_REG(SIMR);
 
     /*
      * Setup IOASIC interrupt
      */
     cpu_mask_tbl[0] = IE_IRQ3;
     cpu_irq_nr[0] = -1;
-    cpu_ivec_tbl[0] = kn02ba_io_int;
+    cpu_ivec_tbl[0] = kn02xa_io_int;
     *imr = 0;
 
     /*
@@ -345,6 +320,7 @@
     cpu_mask_tbl[5] = IE_IRQ5;
     cpu_irq_nr[5] = FPU;
 
+    dec_halt_init(&irq10);
 }				/* dec_init_kn02ba */
 
 /*
@@ -355,14 +331,15 @@
     /*
      * Setup some memory addresses. FIXME: probably incomplete!
      */
+    ioasic_base = (void *) KN02XA_IOASIC_BASE;
     dec_rtc_base = (char *) KN02XA_RTC_BASE;
-    isr = (volatile unsigned int *) KN02XA_SIR_ADDR;
-    imr = (volatile unsigned int *) KN02XA_SIRM_ADDR;
+    isr = (void *) KN02XA_IOASIC_REG(SIR);
+    imr = (void *) KN02XA_IOASIC_REG(SIMR);
 
     /*
      * Setup IOASIC interrupt
      */
-    cpu_ivec_tbl[1] = kn02ba_io_int;
+    cpu_ivec_tbl[1] = kn02xa_io_int;
     cpu_irq_nr[1] = -1;
     cpu_mask_tbl[1] = IE_IRQ3;
     *imr = 0;
@@ -420,6 +397,7 @@
     cpu_mask_tbl[4] = IE_IRQ5;
     cpu_irq_nr[4] = FPU;
 
+    dec_halt_init(&irq10);
 }				/* dec_init_kn02ca */
 
 /*
@@ -430,9 +408,10 @@
     /*
      * Setup some memory addresses. FIXME: probably incomplete!
      */
+    ioasic_base = (void *) KN03_IOASIC_BASE;
     dec_rtc_base = (char *) KN03_RTC_BASE;
-    isr = (volatile unsigned int *) KN03_SIR_ADDR;
-    imr = (volatile unsigned int *) KN03_SIRM_ADDR;
+    isr = (void *) KN03_IOASIC_REG(SIR);
+    imr = (void *) KN03_IOASIC_REG(SIMR);
 
     /*
      * Setup IOASIC interrupt
@@ -500,4 +479,5 @@
     cpu_mask_tbl[4] = IE_IRQ5;
     cpu_irq_nr[4] = FPU;
 
+    dec_halt_init(&irq10);
 }				/* dec_init_kn03 */
diff -u --recursive --new-file v2.4.9/linux/arch/mips/dec/time.c linux/arch/mips/dec/time.c
--- v2.4.9/linux/arch/mips/dec/time.c	Mon Oct 16 12:58:51 2000
+++ linux/arch/mips/dec/time.c	Sun Sep  9 10:43:01 2001
@@ -1,8 +1,8 @@
-
 /*
- *  linux/arch/mips/kernel/time.c
+ *  linux/arch/mips/dec/time.c
  *
  *  Copyright (C) 1991, 1992, 1995  Linus Torvalds
+ *  Copyright (C) 2000  Maciej W. Rozycki
  *
  * This file contains the time handling details for PC-style clocks as
  * found in some MIPS systems.
@@ -17,14 +17,22 @@
 #include <linux/mm.h>
 #include <linux/interrupt.h>
 
+#include <asm/cpu.h>
 #include <asm/bootinfo.h>
 #include <asm/mipsregs.h>
 #include <asm/io.h>
 #include <asm/irq.h>
+#include <asm/dec/machtype.h>
+#include <asm/dec/ioasic.h>
+#include <asm/dec/ioasic_addrs.h>
 
 #include <linux/mc146818rtc.h>
 #include <linux/timex.h>
 
+#include <asm/div64.h>
+
+extern void (*board_time_init)(struct irqaction *irq);
+
 extern volatile unsigned long wall_jiffies;
 extern rwlock_t xtime_lock;
 
@@ -36,12 +44,22 @@
 
 /* This is for machines which generate the exact clock. */
 #define USECS_PER_JIFFY (1000000/HZ)
+#define USECS_PER_JIFFY_FRAC ((1000000ULL << 32) / HZ & 0xffffffff)
 
 /* Cycle counter value at the previous timer interrupt.. */
 
 static unsigned int timerhi, timerlo;
 
 /*
+ * Cached "1/(clocks per usec)*2^32" value.
+ * It has to be recalculated once each jiffy.
+ */
+static unsigned long cached_quotient = 0;
+
+/* Last jiffy when do_fast_gettimeoffset() was called. */
+static unsigned long last_jiffies = 0;
+
+/*
  * On MIPS only R4000 and better have a cycle counter.
  *
  * FIXME: Does playing with the RP bit in c0_status interfere with this code?
@@ -50,45 +68,34 @@
 {
 	u32 count;
 	unsigned long res, tmp;
-
-	/* Last jiffy when do_fast_gettimeoffset() was called. */
-	static unsigned long last_jiffies = 0;
 	unsigned long quotient;
 
-	/*
-	 * Cached "1/(clocks per usec)*2^32" value.
-	 * It has to be recalculated once each jiffy.
-	 */
-	static unsigned long cached_quotient = 0;
-
 	tmp = jiffies;
 
 	quotient = cached_quotient;
 
-	if (tmp && last_jiffies != tmp) {
-		last_jiffies = tmp;
-		__asm__(".set\tnoreorder\n\t"
-			".set\tnoat\n\t"
-			".set\tmips3\n\t"
-			"lwu\t%0,%2\n\t"
-			"dsll32\t$1,%1,0\n\t"
-			"or\t$1,$1,%0\n\t"
-			"ddivu\t$0,$1,%3\n\t"
-			"mflo\t$1\n\t"
-			"dsll32\t%0,%4,0\n\t"
-			"nop\n\t"
-			"ddivu\t$0,%0,$1\n\t"
-			"mflo\t%0\n\t"
-			".set\tmips0\n\t"
-			".set\tat\n\t"
-			".set\treorder"
-			:"=&r"(quotient)
-			:"r"(timerhi),
-			"m"(timerlo),
-			"r"(tmp),
-			"r"(USECS_PER_JIFFY)
-			:"$1");
+	if (last_jiffies != tmp) {
+	    last_jiffies = tmp;
+	    if (last_jiffies != 0) {
+		unsigned long r0;
+		__asm__(".set	push\n\t"
+			".set	mips3\n\t"
+			"lwu	%0,%3\n\t"
+			"dsll32	%1,%2,0\n\t"
+			"or	%1,%1,%0\n\t"
+			"ddivu	$0,%1,%4\n\t"
+			"mflo	%1\n\t"
+			"dsll32	%0,%5,0\n\t"
+			"or	%0,%0,%6\n\t"
+			"ddivu	$0,%0,%1\n\t"
+			"mflo	%0\n\t"
+			".set	pop"
+			: "=&r" (quotient), "=&r" (r0)
+			: "r" (timerhi), "m" (timerlo),
+			  "r" (tmp), "r" (USECS_PER_JIFFY),
+			  "r" (USECS_PER_JIFFY_FRAC));
 		cached_quotient = quotient;
+	    }
 	}
 	/* Get last timer tick in absolute kernel time */
 	count = read_32bit_cp0_register(CP0_COUNT);
@@ -97,11 +104,9 @@
 	count -= timerlo;
 //printk("count: %08lx, %08lx:%08lx\n", count, timerhi, timerlo);
 
-	__asm__("multu\t%1,%2\n\t"
-		"mfhi\t%0"
-		:"=r"(res)
-		:"r"(count),
-		"r"(quotient));
+	__asm__("multu	%2,%3"
+		: "=l" (tmp), "=h" (res)
+		: "r" (count), "r" (quotient));
 
 	/*
 	 * Due to possible jiffies inconsistencies, we need to check 
@@ -113,6 +118,47 @@
 	return res;
 }
 
+static unsigned long do_ioasic_gettimeoffset(void)
+{
+	u32 count;
+	unsigned long res, tmp;
+	unsigned long quotient;
+
+	tmp = jiffies;
+
+	quotient = cached_quotient;
+
+	if (last_jiffies != tmp) {
+		last_jiffies = tmp;
+		if (last_jiffies != 0) {
+			unsigned long r0;
+			do_div64_32(r0, timerhi, timerlo, tmp);
+			do_div64_32(quotient, USECS_PER_JIFFY,
+				    USECS_PER_JIFFY_FRAC, r0);
+			cached_quotient = quotient;
+		}
+	}
+	/* Get last timer tick in absolute kernel time */
+	count = ioasic_read(FCTR);
+
+	/* .. relative to previous jiffy (32 bits is enough) */
+	count -= timerlo;
+//printk("count: %08x, %08x:%08x\n", count, timerhi, timerlo);
+
+	__asm__("multu	%2,%3"
+		: "=l" (tmp), "=h" (res)
+		: "r" (count), "r" (quotient));
+
+	/*
+	 * Due to possible jiffies inconsistencies, we need to check
+	 * the result so that we'll get a timer that is monotonic.
+	 */
+	if (res >= USECS_PER_JIFFY)
+        	res = USECS_PER_JIFFY - 1;
+
+	return res;
+}
+
 /* This function must be called with interrupts disabled 
  * It was inspired by Steve McCanne's microtime-i386 for BSD.  -- jrs
  * 
@@ -170,8 +216,8 @@
 	tv->tv_usec += do_gettimeoffset();
 
 	/*
-	 * xtime is atomically updated in timer_bh. lost_ticks is
-	 * nonzero if the timer bottom half hasnt executed yet.
+	 * xtime is atomically updated in timer_bh. jiffies - wall_jiffies
+	 * is nonzero if the timer bottom half hasnt executed yet.
 	 */
 	if (jiffies - wall_jiffies)
 		tv->tv_usec += USECS_PER_JIFFY;
@@ -187,6 +233,7 @@
 void do_settimeofday(struct timeval *tv)
 {
 	write_lock_irq(&xtime_lock);
+
 	/* This is revolting. We need to set the xtime.tv_usec
 	 * correctly. However, the value in this location is
 	 * is value at the last tick.
@@ -199,10 +246,13 @@
 		tv->tv_usec += 1000000;
 		tv->tv_sec--;
 	}
+
 	xtime = *tv;
-	time_state = TIME_BAD;
-	time_maxerror = MAXPHASE;
-	time_esterror = MAXPHASE;
+	time_adjust = 0;		/* stop active adjtime() */
+	time_status |= STA_UNSYNC;
+	time_maxerror = NTP_PHASE_LIMIT;
+	time_esterror = NTP_PHASE_LIMIT;
+
 	write_unlock_irq(&xtime_lock);
 }
 
@@ -307,13 +357,16 @@
 	 * called as close as possible to 500 ms before the new second starts.
 	 */
 	read_lock(&xtime_lock);
-	if (time_state != TIME_BAD && xtime.tv_sec > last_rtc_update + 660 &&
-	    xtime.tv_usec > 500000 - (tick >> 1) &&
-	    xtime.tv_usec < 500000 + (tick >> 1))
+	if ((time_status & STA_UNSYNC) == 0
+	    && xtime.tv_sec > last_rtc_update + 660
+	    && xtime.tv_usec >= 500000 - tick / 2
+	    && xtime.tv_usec <= 500000 + tick / 2) {
 		if (set_rtc_mmss(xtime.tv_sec) == 0)
 			last_rtc_update = xtime.tv_sec;
 		else
-			last_rtc_update = xtime.tv_sec - 600;	/* do it again in 60 s */
+			/* do it again in 60 s */
+			last_rtc_update = xtime.tv_sec - 600;
+	}
 	/* As we return to user mode fire off the other CPU schedulers.. this is
 	   basically because we don't yet share IRQ's around. This message is
 	   rigged to be safe on the 386 - basically it's a hack, so don't look
@@ -334,66 +387,50 @@
 	timerhi += (count < timerlo);	/* Wrap around */
 	timerlo = count;
 
-	timer_interrupt(irq, dev_id, regs);
-
-	if (!jiffies) {
+	if (jiffies == ~0) {
 		/*
-		 * If jiffies has overflowed in this timer_interrupt we must
+		 * If jiffies is to overflow in this timer_interrupt we must
 		 * update the timer[hi]/[lo] to make do_fast_gettimeoffset()
 		 * quotient calc still valid. -arca
 		 */
+		write_32bit_cp0_register(CP0_COUNT, 0);
 		timerhi = timerlo = 0;
 	}
-}
 
-char cyclecounter_available;
+	timer_interrupt(irq, dev_id, regs);
+}
 
-static inline void init_cycle_counter(void)
+static void ioasic_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	switch (mips_cputype) {
-	case CPU_UNKNOWN:
-	case CPU_R2000:
-	case CPU_R3000:
-	case CPU_R3000A:
-	case CPU_R3041:
-	case CPU_R3051:
-	case CPU_R3052:
-	case CPU_R3081:
-	case CPU_R3081E:
-	case CPU_R6000:
-	case CPU_R6000A:
-	case CPU_R8000:	/* Not shure about that one, play safe */
-		cyclecounter_available = 0;
-		break;
-	case CPU_R4000PC:
-	case CPU_R4000SC:
-	case CPU_R4000MC:
-	case CPU_R4200:
-	case CPU_R4400PC:
-	case CPU_R4400SC:
-	case CPU_R4400MC:
-	case CPU_R4600:
-	case CPU_R10000:
-	case CPU_R4300:
-	case CPU_R4650:
-	case CPU_R4700:
-	case CPU_R5000:
-	case CPU_R5000A:
-	case CPU_R4640:
-	case CPU_NEVADA:
-		cyclecounter_available = 1;
-		break;
+	unsigned int count;
+
+	/*
+	 * The free-running counter is 32 bit which is good for about
+	 * 2 minutes, 50 seconds at possible count rates of upto 25MHz.
+	 */
+	count = ioasic_read(FCTR);
+	timerhi += (count < timerlo);	/* Wrap around */
+	timerlo = count;
+
+	if (jiffies == ~0) {
+		/*
+		 * If jiffies is to overflow in this timer_interrupt we must
+		 * update the timer[hi]/[lo] to make do_fast_gettimeoffset()
+		 * quotient calc still valid. -arca
+		 */
+		ioasic_write(FCTR, 0);
+		timerhi = timerlo = 0;
 	}
+
+	timer_interrupt(irq, dev_id, regs);
 }
 
 struct irqaction irq0 = {timer_interrupt, SA_INTERRUPT, 0,
 			 "timer", NULL, NULL};
 
-void (*board_time_init) (struct irqaction * irq);
-
 void __init time_init(void)
 {
-	unsigned int year, mon, day, hour, min, sec;
+	unsigned int year, mon, day, hour, min, sec, real_year;
 	int i;
 
 	/* The Linux interpretation of the CMOS clock register contents:
@@ -425,23 +462,26 @@
 		BCD_TO_BIN(year);
 	}
 	/*
-	 * The DECstation RTC is used as a TOY (Time Of Year).
-	 * The PROM will reset the year to either '70, '71 or '72.
-	 * This hack will only work until Dec 31 2001.
+	 * The PROM will reset the year to either '72 or '73.
+	 * Therefore we store the real year separately, in one
+	 * of unused BBU RAM locations.
 	 */
-	year += 1928;
+	real_year = CMOS_READ(RTC_DEC_YEAR);
+	year += real_year - 72 + 2000;
 
 	write_lock_irq(&xtime_lock);
 	xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
 	xtime.tv_usec = 0;
 	write_unlock_irq(&xtime_lock);
 
-	init_cycle_counter();
-
-	if (cyclecounter_available) {
+	if (mips_cpu.options & MIPS_CPU_COUNTER) {
 		write_32bit_cp0_register(CP0_COUNT, 0);
 		do_gettimeoffset = do_fast_gettimeoffset;
 		irq0.handler = r4k_timer_interrupt;
-	}
+	} else if (IOASIC) {
+		ioasic_write(FCTR, 0);
+		do_gettimeoffset = do_ioasic_gettimeoffset;
+		irq0.handler = ioasic_timer_interrupt;
+        }
 	board_time_init(&irq0);
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips/defconfig linux/arch/mips/defconfig
--- v2.4.9/linux/arch/mips/defconfig	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/defconfig	Sun Sep  9 10:43:02 2001
@@ -1,6 +1,8 @@
 #
 # Automatically generated make config: don't edit
 #
+CONFIG_MIPS=y
+# CONFIG_SMP is not set
 
 #
 # Code maturity level options
@@ -13,21 +15,37 @@
 # CONFIG_ACER_PICA_61 is not set
 # CONFIG_ALGOR_P4032 is not set
 # CONFIG_BAGET_MIPS is not set
-# CONFIG_COBALT_MICRO_SERVER is not set
 # CONFIG_DECSTATION is not set
 # CONFIG_DDB5074 is not set
+# CONFIG_MIPS_EV96100 is not set
+# CONFIG_MIPS_EV64120 is not set
+# CONFIG_MIPS_ATLAS is not set
+# CONFIG_MIPS_MALTA is not set
+# CONFIG_NINO is not set
 # CONFIG_MIPS_MAGNUM_4000 is not set
+# CONFIG_MOMENCO_OCELOT is not set
+# CONFIG_DDB5476 is not set
+# CONFIG_DDB5477 is not set
 # CONFIG_OLIVETTI_M700 is not set
 CONFIG_SGI_IP22=y
 # CONFIG_SNI_RM200_PCI is not set
+# CONFIG_MIPS_ITE8172 is not set
+# CONFIG_MIPS_IVR is not set
+# CONFIG_MIPS_PB1000 is not set
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
 # CONFIG_MCA is not set
 # CONFIG_SBUS is not set
 CONFIG_ARC32=y
+CONFIG_BOARD_SCACHE=y
 CONFIG_PC_KEYB=y
 CONFIG_SGI=y
+CONFIG_NEW_IRQ=y
+CONFIG_OLD_TIME_C=y
 # CONFIG_ISA is not set
 # CONFIG_EISA is not set
 # CONFIG_PCI is not set
+# CONFIG_I8259 is not set
 
 #
 # Loadable module support
@@ -41,14 +59,20 @@
 #
 # CONFIG_CPU_R3000 is not set
 # CONFIG_CPU_R6000 is not set
+# CONFIG_CPU_VR41XX is not set
 # CONFIG_CPU_R4300 is not set
 # CONFIG_CPU_R4X00 is not set
 CONFIG_CPU_R5000=y
+# CONFIG_CPU_R5432 is not set
+# CONFIG_CPU_RM7000 is not set
 # CONFIG_CPU_NEVADA is not set
-# CONFIG_CPU_R8000 is not set
 # CONFIG_CPU_R10000 is not set
+# CONFIG_CPU_SB1 is not set
+# CONFIG_CPU_MIPS32 is not set
+# CONFIG_CPU_MIPS64 is not set
 # CONFIG_CPU_ADVANCED is not set
 CONFIG_CPU_HAS_LLSC=y
+CONFIG_CPU_HAS_LLDSCD=y
 # CONFIG_CPU_HAS_WB is not set
 
 #
@@ -59,24 +83,26 @@
 CONFIG_ELF_KERNEL=y
 CONFIG_BINFMT_IRIX=y
 CONFIG_FORWARD_KEYBOARD=y
+# CONFIG_ARC_CONSOLE is not set
 # CONFIG_BINFMT_AOUT is not set
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 CONFIG_NET=y
+# CONFIG_HOTPLUG is not set
+# CONFIG_PCMCIA is not set
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
 
 #
-# Parallel port support
+# Memory Technology Devices (MTD)
 #
-# CONFIG_PARPORT is not set
-# CONFIG_PCMCIA is not set
+# CONFIG_MTD is not set
 
 #
-# Memory Technology Devices (MTD)
+# Parallel port support
 #
-# CONFIG_MTD is not set
+# CONFIG_PARPORT is not set
 
 #
 # Block devices
@@ -107,19 +133,24 @@
 # Networking options
 #
 CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK is not set
+CONFIG_PACKET_MMAP=y
+CONFIG_NETLINK=y
+CONFIG_RTNETLINK=y
+CONFIG_NETLINK_DEV=y
 # CONFIG_NETFILTER is not set
 # CONFIG_FILTER is not set
 CONFIG_UNIX=y
 CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
+CONFIG_IP_MULTICAST=y
 # CONFIG_IP_ADVANCED_ROUTER is not set
 CONFIG_IP_PNP=y
+# CONFIG_IP_PNP_DHCP is not set
 CONFIG_IP_PNP_BOOTP=y
 # CONFIG_IP_PNP_RARP is not set
 # CONFIG_NET_IPIP is not set
 # CONFIG_NET_IPGRE is not set
+# CONFIG_IP_MROUTE is not set
+# CONFIG_ARPD is not set
 # CONFIG_INET_ECN is not set
 # CONFIG_SYN_COOKIES is not set
 # CONFIG_IPV6 is not set
@@ -148,6 +179,13 @@
 # CONFIG_NET_SCHED is not set
 
 #
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+# CONFIG_PHONE_IXJ is not set
+# CONFIG_PHONE_IXJ_PCMCIA is not set
+
+#
 # SCSI support
 #
 CONFIG_SCSI=y
@@ -175,7 +213,7 @@
 #
 # SCSI low-level drivers
 #
-CONFIG_SCSI_SGIWD93=y
+CONFIG_SGIWD93_SCSI=y
 # CONFIG_SCSI_7000FASST is not set
 # CONFIG_SCSI_ACARD is not set
 # CONFIG_SCSI_AHA152X is not set
@@ -183,6 +221,7 @@
 # CONFIG_SCSI_AHA1740 is not set
 # CONFIG_SCSI_AIC7XXX is not set
 # CONFIG_SCSI_AIC7XXX_OLD is not set
+# CONFIG_SCSI_DPT_I2O is not set
 # CONFIG_SCSI_ADVANSYS is not set
 # CONFIG_SCSI_IN2000 is not set
 # CONFIG_SCSI_AM53C974 is not set
@@ -199,6 +238,7 @@
 # CONFIG_SCSI_INITIO is not set
 # CONFIG_SCSI_INIA100 is not set
 # CONFIG_SCSI_NCR53C406A is not set
+# CONFIG_SCSI_NCR_D700 is not set
 # CONFIG_SCSI_NCR53C7xx is not set
 # CONFIG_SCSI_PAS16 is not set
 # CONFIG_SCSI_PCI2000 is not set
@@ -215,20 +255,159 @@
 # Network device support
 #
 CONFIG_NETDEVICES=y
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
 # CONFIG_DUMMY is not set
-# CONFIG_SLIP is not set
-# CONFIG_PPP is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+# CONFIG_ETHERTAP is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+# CONFIG_SUNLANCE is not set
+# CONFIG_SUNBMAC is not set
+# CONFIG_SUNQE is not set
+# CONFIG_SUNLANCE is not set
+# CONFIG_SUNGEM is not set
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_LANCE is not set
+# CONFIG_NET_VENDOR_SMC is not set
+# CONFIG_NET_VENDOR_RACAL is not set
+# CONFIG_NET_ISA is not set
+# CONFIG_NET_PCI is not set
+# CONFIG_NET_POCKET is not set
 CONFIG_SGISEEQ=y
 
 #
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_MYRI_SBUS is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_SK98LIN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PLIP is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+# CONFIG_NET_FC is not set
+# CONFIG_RCPCI is not set
+# CONFIG_SHAPER is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+
+#
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# IrDA (infrared) support
+#
+# CONFIG_IRDA is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Old CD-ROM drivers (not SCSI, not IDE)
+#
+# CONFIG_CD_NO_IDESCSI is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+# CONFIG_SERIAL is not set
+# CONFIG_SERIAL_EXTENDED is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Mice
+#
+# CONFIG_BUSMOUSE is not set
+# CONFIG_MOUSE is not set
+
+#
+# Joysticks
+#
+# CONFIG_INPUT_GAMEPORT is not set
+
+#
+# Input core support is needed for gameports
+#
+
+#
+# Input core support is needed for joysticks
+#
+# CONFIG_QIC02_TAPE is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_INTEL_RNG is not set
+# CONFIG_NVRAM is not set
+# CONFIG_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+# CONFIG_SONYPI is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_FTAPE is not set
+# CONFIG_AGP is not set
+# CONFIG_DRM is not set
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
 # SGI Character devices
 #
 CONFIG_VT=y
 CONFIG_VT_CONSOLE=y
 CONFIG_SGI_NEWPORT_CONSOLE=y
 CONFIG_FONT_8x16=y
-# CONFIG_SGI_PROM_CONSOLE is not set
-# CONFIG_UNIX98_PTYS is not set
+# CONFIG_PSMOUSE is not set
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
 
 #
 # File systems
@@ -238,22 +417,30 @@
 CONFIG_AUTOFS4_FS=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
 # CONFIG_ADFS_FS is not set
 # CONFIG_ADFS_FS_RW is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
 # CONFIG_BFS_FS is not set
+# CONFIG_CMS_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_JBD_DEBUG is not set
 # CONFIG_FAT_FS is not set
 # CONFIG_MSDOS_FS is not set
 # CONFIG_UMSDOS_FS is not set
 # CONFIG_VFAT_FS is not set
 # CONFIG_EFS_FS is not set
 # CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
 # CONFIG_CRAMFS is not set
+# CONFIG_TMPFS is not set
 # CONFIG_RAMFS is not set
 CONFIG_ISO9660_FS=y
 # CONFIG_JOLIET is not set
 # CONFIG_MINIX_FS is not set
+# CONFIG_FREEVXFS_FS is not set
 # CONFIG_NTFS_FS is not set
 # CONFIG_NTFS_RW is not set
 # CONFIG_HPFS_FS is not set
@@ -261,13 +448,12 @@
 # CONFIG_DEVFS_FS is not set
 # CONFIG_DEVFS_MOUNT is not set
 # CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS is not set
+CONFIG_DEVPTS_FS=y
 # CONFIG_QNX4FS_FS is not set
 # CONFIG_QNX4FS_RW is not set
 # CONFIG_ROMFS_FS is not set
 CONFIG_EXT2_FS=y
 # CONFIG_SYSV_FS is not set
-# CONFIG_SYSV_FS_WRITE is not set
 # CONFIG_UDF_FS is not set
 # CONFIG_UDF_RW is not set
 # CONFIG_UFS_FS is not set
@@ -277,6 +463,7 @@
 # Network File Systems
 #
 # CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
 CONFIG_NFS_FS=y
 # CONFIG_NFS_V3 is not set
 CONFIG_ROOT_NFS=y
@@ -309,6 +496,7 @@
 # CONFIG_MINIX_SUBPARTITION is not set
 # CONFIG_SOLARIS_X86_PARTITION is not set
 # CONFIG_UNIXWARE_DISKLABEL is not set
+# CONFIG_LDM_PARTITION is not set
 CONFIG_SGI_PARTITION=y
 # CONFIG_ULTRIX_PARTITION is not set
 # CONFIG_SUN_PARTITION is not set
@@ -319,7 +507,7 @@
 # Console drivers
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_FB is not set
+# CONFIG_MDA_CONSOLE is not set
 
 #
 # Frame-buffer support
@@ -345,13 +533,111 @@
 # CONFIG_USB is not set
 
 #
+# USB Controllers
+#
+# CONFIG_USB_UHCI is not set
+# CONFIG_USB_UHCI_ALT is not set
+# CONFIG_USB_OHCI is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_BLUETOOTH is not set
+# CONFIG_USB_STORAGE is not set
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+
+#
+# USB Human Interface Devices (HID)
+#
+
+#
+#   Input core support is needed for USB HID
+#
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_DC2XX is not set
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_SCANNER is not set
+# CONFIG_USB_MICROTEK is not set
+# CONFIG_USB_HPUSBSCSI is not set
+
+#
+# USB Multimedia devices
+#
+
+#
+#   Video4Linux support is needed for USB Multimedia device support
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# USB Network adaptors
+#
+# CONFIG_USB_PLUSB is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_CDCETHER is not set
+# CONFIG_USB_USBNET is not set
+
+#
+# USB port drivers
+#
+# CONFIG_USB_USS720 is not set
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+# CONFIG_USB_SERIAL_GENERIC is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+
+#
+# Miscellaneous USB drivers
+#
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_ID75 is not set
+
+#
 # Input core support
 #
 # CONFIG_INPUT is not set
+# CONFIG_INPUT_KEYBDEV is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
 
 #
 # Kernel hacking
 #
 CONFIG_CROSSCOMPILE=y
-# CONFIG_MIPS_FPE_MODULE is not set
 # CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_MIPS_UNCACHED is not set
diff -u --recursive --new-file v2.4.9/linux/arch/mips/defconfig-atlas linux/arch/mips/defconfig-atlas
--- v2.4.9/linux/arch/mips/defconfig-atlas	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/defconfig-atlas	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,604 @@
+#
+# Automatically generated make config: don't edit
+#
+CONFIG_MIPS=y
+# CONFIG_SMP is not set
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+
+#
+# Machine selection
+#
+# CONFIG_ACER_PICA_61 is not set
+# CONFIG_ALGOR_P4032 is not set
+# CONFIG_BAGET_MIPS is not set
+# CONFIG_DECSTATION is not set
+# CONFIG_DDB5074 is not set
+# CONFIG_MIPS_EV96100 is not set
+# CONFIG_MIPS_EV64120 is not set
+CONFIG_MIPS_ATLAS=y
+# CONFIG_MIPS_MALTA is not set
+# CONFIG_NINO is not set
+# CONFIG_MIPS_MAGNUM_4000 is not set
+# CONFIG_MOMENCO_OCELOT is not set
+# CONFIG_DDB5476 is not set
+# CONFIG_DDB5477 is not set
+# CONFIG_OLIVETTI_M700 is not set
+# CONFIG_SGI_IP22 is not set
+# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_MIPS_ITE8172 is not set
+# CONFIG_MIPS_IVR is not set
+# CONFIG_MIPS_PB1000 is not set
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+# CONFIG_MCA is not set
+# CONFIG_SBUS is not set
+CONFIG_PCI=y
+CONFIG_SWAP_IO_SPACE=y
+# CONFIG_ISA is not set
+# CONFIG_EISA is not set
+# CONFIG_I8259 is not set
+
+#
+# Loadable module support
+#
+# CONFIG_MODULES is not set
+
+#
+# CPU selection
+#
+# CONFIG_CPU_R3000 is not set
+# CONFIG_CPU_R6000 is not set
+# CONFIG_CPU_VR41XX is not set
+# CONFIG_CPU_R4300 is not set
+# CONFIG_CPU_R4X00 is not set
+CONFIG_CPU_R5000=y
+# CONFIG_CPU_R5432 is not set
+# CONFIG_CPU_RM7000 is not set
+# CONFIG_CPU_NEVADA is not set
+# CONFIG_CPU_R10000 is not set
+# CONFIG_CPU_SB1 is not set
+# CONFIG_CPU_MIPS32 is not set
+# CONFIG_CPU_MIPS64 is not set
+# CONFIG_CPU_ADVANCED is not set
+CONFIG_CPU_HAS_LLSC=y
+CONFIG_CPU_HAS_LLDSCD=y
+# CONFIG_CPU_HAS_WB is not set
+
+#
+# General setup
+#
+# CONFIG_CPU_LITTLE_ENDIAN is not set
+CONFIG_KCORE_ELF=y
+CONFIG_ELF_KERNEL=y
+CONFIG_BINFMT_IRIX=y
+# CONFIG_FORWARD_KEYBOARD is not set
+# CONFIG_BINFMT_AOUT is not set
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_MISC is not set
+CONFIG_NET=y
+# CONFIG_PCI_NAMES is not set
+# CONFIG_HOTPLUG is not set
+# CONFIG_PCMCIA is not set
+CONFIG_SYSVIPC=y
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_SYSCTL is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_DEV_XD is not set
+# CONFIG_PARIDE is not set
+# CONFIG_BLK_CPQ_DA is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_LOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=4096
+# CONFIG_BLK_DEV_INITRD is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+# CONFIG_BLK_DEV_MD is not set
+# CONFIG_MD_LINEAR is not set
+# CONFIG_MD_RAID0 is not set
+# CONFIG_MD_RAID1 is not set
+# CONFIG_MD_RAID5 is not set
+# CONFIG_BLK_DEV_LVM is not set
+
+#
+# Networking options
+#
+# CONFIG_PACKET is not set
+# CONFIG_NETLINK is not set
+# CONFIG_NETFILTER is not set
+# CONFIG_FILTER is not set
+CONFIG_UNIX=y
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_PNP=y
+# CONFIG_IP_PNP_DHCP is not set
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_INET_ECN is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_IPV6 is not set
+# CONFIG_KHTTPD is not set
+# CONFIG_ATM is not set
+
+#
+#  
+#
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_DECNET is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_LLC is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_FASTROUTE is not set
+# CONFIG_NET_HW_FLOWCONTROL is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+# CONFIG_PHONE_IXJ is not set
+# CONFIG_PHONE_IXJ_PCMCIA is not set
+
+#
+# ATA/IDE/MFM/RLL support
+#
+# CONFIG_IDE is not set
+# CONFIG_BLK_DEV_IDE_MODES is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI support
+#
+CONFIG_SCSI=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+CONFIG_SD_EXTRA_DEVS=40
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_CHR_DEV_OSST is not set
+# CONFIG_BLK_DEV_SR is not set
+# CONFIG_CHR_DEV_SG is not set
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_DEBUG_QUEUES is not set
+# CONFIG_SCSI_MULTI_LUN is not set
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
+# CONFIG_SCSI_7000FASST is not set
+# CONFIG_SCSI_ACARD is not set
+# CONFIG_SCSI_AHA152X is not set
+# CONFIG_SCSI_AHA1542 is not set
+# CONFIG_SCSI_AHA1740 is not set
+# CONFIG_SCSI_AIC7XXX is not set
+# CONFIG_SCSI_AIC7XXX_OLD is not set
+# CONFIG_SCSI_DPT_I2O is not set
+# CONFIG_SCSI_ADVANSYS is not set
+# CONFIG_SCSI_IN2000 is not set
+# CONFIG_SCSI_AM53C974 is not set
+# CONFIG_SCSI_MEGARAID is not set
+# CONFIG_SCSI_BUSLOGIC is not set
+# CONFIG_SCSI_CPQFCTS is not set
+# CONFIG_SCSI_DMX3191D is not set
+# CONFIG_SCSI_DTC3280 is not set
+# CONFIG_SCSI_EATA is not set
+# CONFIG_SCSI_EATA_DMA is not set
+# CONFIG_SCSI_EATA_PIO is not set
+# CONFIG_SCSI_FUTURE_DOMAIN is not set
+# CONFIG_SCSI_GDTH is not set
+# CONFIG_SCSI_GENERIC_NCR5380 is not set
+# CONFIG_SCSI_INITIO is not set
+# CONFIG_SCSI_INIA100 is not set
+# CONFIG_SCSI_NCR53C406A is not set
+# CONFIG_SCSI_NCR_D700 is not set
+# CONFIG_SCSI_NCR53C7xx is not set
+# CONFIG_SCSI_NCR53C8XX is not set
+# CONFIG_SCSI_SYM53C8XX is not set
+# CONFIG_SCSI_PAS16 is not set
+# CONFIG_SCSI_PCI2000 is not set
+# CONFIG_SCSI_PCI2220I is not set
+# CONFIG_SCSI_PSI240I is not set
+# CONFIG_SCSI_QLOGIC_FAS is not set
+# CONFIG_SCSI_QLOGIC_ISP is not set
+# CONFIG_SCSI_QLOGIC_FC is not set
+# CONFIG_SCSI_QLOGIC_1280 is not set
+# CONFIG_SCSI_SIM710 is not set
+# CONFIG_SCSI_SYM53C416 is not set
+# CONFIG_SCSI_DC390T is not set
+# CONFIG_SCSI_T128 is not set
+# CONFIG_SCSI_U14_34F is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# Network device support
+#
+CONFIG_NETDEVICES=y
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+# CONFIG_SUNLANCE is not set
+# CONFIG_HAPPYMEAL is not set
+# CONFIG_SUNBMAC is not set
+# CONFIG_SUNQE is not set
+# CONFIG_SUNLANCE is not set
+# CONFIG_SUNGEM is not set
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_LANCE is not set
+# CONFIG_NET_VENDOR_SMC is not set
+# CONFIG_NET_VENDOR_RACAL is not set
+# CONFIG_HP100 is not set
+# CONFIG_NET_ISA is not set
+# CONFIG_NET_PCI is not set
+# CONFIG_NET_POCKET is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_MYRI_SBUS is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_SK98LIN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PLIP is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+# CONFIG_NET_FC is not set
+# CONFIG_RCPCI is not set
+# CONFIG_SHAPER is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+
+#
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# IrDA (infrared) support
+#
+# CONFIG_IRDA is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Old CD-ROM drivers (not SCSI, not IDE)
+#
+# CONFIG_CD_NO_IDESCSI is not set
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+CONFIG_SERIAL=y
+CONFIG_SERIAL_CONSOLE=y
+# CONFIG_SERIAL_EXTENDED is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Mice
+#
+# CONFIG_BUSMOUSE is not set
+# CONFIG_MOUSE is not set
+
+#
+# Joysticks
+#
+# CONFIG_INPUT_GAMEPORT is not set
+
+#
+# Input core support is needed for gameports
+#
+
+#
+# Input core support is needed for joysticks
+#
+# CONFIG_QIC02_TAPE is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_INTEL_RNG is not set
+# CONFIG_NVRAM is not set
+CONFIG_RTC=y
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+# CONFIG_SONYPI is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_FTAPE is not set
+# CONFIG_AGP is not set
+# CONFIG_DRM is not set
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# File systems
+#
+# CONFIG_QUOTA is not set
+CONFIG_AUTOFS_FS=y
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_ADFS_FS is not set
+# CONFIG_ADFS_FS_RW is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_CMS_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_JBD_DEBUG is not set
+# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_UMSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+CONFIG_EFS_FS=y
+# CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_TMPFS is not set
+# CONFIG_RAMFS is not set
+# CONFIG_ISO9660_FS is not set
+# CONFIG_JOLIET is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_FREEVXFS_FS is not set
+# CONFIG_NTFS_FS is not set
+# CONFIG_NTFS_RW is not set
+# CONFIG_HPFS_FS is not set
+CONFIG_PROC_FS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVFS_MOUNT is not set
+# CONFIG_DEVFS_DEBUG is not set
+CONFIG_DEVPTS_FS=y
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_QNX4FS_RW is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_EXT2_FS=y
+# CONFIG_SYSV_FS is not set
+# CONFIG_UDF_FS is not set
+# CONFIG_UDF_RW is not set
+# CONFIG_UFS_FS is not set
+# CONFIG_UFS_FS_WRITE is not set
+
+#
+# Network File Systems
+#
+# CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
+CONFIG_NFS_FS=y
+# CONFIG_NFS_V3 is not set
+CONFIG_ROOT_NFS=y
+# CONFIG_NFSD is not set
+# CONFIG_NFSD_V3 is not set
+CONFIG_SUNRPC=y
+CONFIG_LOCKD=y
+# CONFIG_SMB_FS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_NCPFS_PACKET_SIGNING is not set
+# CONFIG_NCPFS_IOCTL_LOCKING is not set
+# CONFIG_NCPFS_STRONG is not set
+# CONFIG_NCPFS_NFS_NS is not set
+# CONFIG_NCPFS_OS2_NS is not set
+# CONFIG_NCPFS_SMALLDOS is not set
+# CONFIG_NCPFS_NLS is not set
+# CONFIG_NCPFS_EXTRAS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+# CONFIG_SMB_NLS is not set
+# CONFIG_NLS is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB is not set
+
+#
+# USB Controllers
+#
+# CONFIG_USB_UHCI is not set
+# CONFIG_USB_UHCI_ALT is not set
+# CONFIG_USB_OHCI is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_BLUETOOTH is not set
+# CONFIG_USB_STORAGE is not set
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+
+#
+# USB Human Interface Devices (HID)
+#
+
+#
+#   Input core support is needed for USB HID
+#
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_DC2XX is not set
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_SCANNER is not set
+# CONFIG_USB_MICROTEK is not set
+# CONFIG_USB_HPUSBSCSI is not set
+
+#
+# USB Multimedia devices
+#
+
+#
+#   Video4Linux support is needed for USB Multimedia device support
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# USB Network adaptors
+#
+# CONFIG_USB_PLUSB is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_CDCETHER is not set
+# CONFIG_USB_USBNET is not set
+
+#
+# USB port drivers
+#
+# CONFIG_USB_USS720 is not set
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+# CONFIG_USB_SERIAL_GENERIC is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+
+#
+# Miscellaneous USB drivers
+#
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_ID75 is not set
+
+#
+# Input core support
+#
+# CONFIG_INPUT is not set
+# CONFIG_INPUT_KEYBDEV is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+
+#
+# Kernel hacking
+#
+CONFIG_CROSSCOMPILE=y
+# CONFIG_REMOTE_DEBUG is not set
+# CONFIG_GDB_CONSOLE is not set
+# CONFIG_LL_DEBUG is not set
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_MIPS_UNCACHED is not set
diff -u --recursive --new-file v2.4.9/linux/arch/mips/defconfig-cobalt linux/arch/mips/defconfig-cobalt
--- v2.4.9/linux/arch/mips/defconfig-cobalt	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/defconfig-cobalt	Wed Dec 31 16:00:00 1969
@@ -1,598 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-
-#
-# Machine selection
-#
-# CONFIG_ACER_PICA_61 is not set
-# CONFIG_ALGOR_P4032 is not set
-# CONFIG_BAGET_MIPS is not set
-CONFIG_COBALT_MICRO_SERVER=y
-CONFIG_COBALT_28=y
-# CONFIG_DECSTATION is not set
-# CONFIG_DDB5074 is not set
-# CONFIG_MIPS_MAGNUM_4000 is not set
-# CONFIG_OLIVETTI_M700 is not set
-# CONFIG_SGI_IP22 is not set
-# CONFIG_SNI_RM200_PCI is not set
-# CONFIG_MCA is not set
-# CONFIG_SBUS is not set
-CONFIG_COBALT_27=y
-CONFIG_COBALT_LCD=y
-CONFIG_COBALT_SERIAL=y
-CONFIG_PCI=y
-# CONFIG_ISA is not set
-# CONFIG_EISA is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODVERSIONS=y
-CONFIG_KMOD=y
-
-#
-# CPU selection
-#
-# CONFIG_CPU_R3000 is not set
-# CONFIG_CPU_R6000 is not set
-# CONFIG_CPU_R4300 is not set
-# CONFIG_CPU_R4X00 is not set
-# CONFIG_CPU_R5000 is not set
-CONFIG_CPU_NEVADA=y
-# CONFIG_CPU_R8000 is not set
-# CONFIG_CPU_R10000 is not set
-# CONFIG_CPU_ADVANCED is not set
-CONFIG_CPU_HAS_LLSC=y
-# CONFIG_CPU_HAS_WB is not set
-
-#
-# General setup
-#
-CONFIG_CPU_LITTLE_ENDIAN=y
-CONFIG_KCORE_ELF=y
-CONFIG_ELF_KERNEL=y
-# CONFIG_BINFMT_AOUT is not set
-CONFIG_BINFMT_ELF=y
-CONFIG_BINFMT_MISC=m
-CONFIG_NET=y
-CONFIG_PCI_NAMES=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-# CONFIG_PCMCIA is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_DEV_XD is not set
-# CONFIG_PARIDE is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-CONFIG_BLK_DEV_LOOP=m
-# CONFIG_BLK_DEV_NBD is not set
-CONFIG_BLK_DEV_RAM=m
-CONFIG_BLK_DEV_RAM_SIZE=4096
-# CONFIG_BLK_DEV_INITRD is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-# CONFIG_BLK_DEV_MD is not set
-# CONFIG_MD_LINEAR is not set
-# CONFIG_MD_RAID0 is not set
-# CONFIG_MD_RAID1 is not set
-# CONFIG_MD_RAID5 is not set
-# CONFIG_BLK_DEV_LVM is not set
-
-#
-# Networking options
-#
-# CONFIG_PACKET is not set
-# CONFIG_NETLINK is not set
-# CONFIG_NETFILTER is not set
-# CONFIG_FILTER is not set
-# CONFIG_UNIX is not set
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-# CONFIG_IP_ADVANCED_ROUTER is not set
-# CONFIG_IP_PNP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-CONFIG_IP_MROUTE=y
-# CONFIG_IP_PIMSM_V1 is not set
-# CONFIG_IP_PIMSM_V2 is not set
-# CONFIG_INET_ECN is not set
-CONFIG_SYN_COOKIES=y
-# CONFIG_IPV6 is not set
-# CONFIG_KHTTPD is not set
-# CONFIG_ATM is not set
-
-#
-#  
-#
-CONFIG_IPX=m
-# CONFIG_IPX_INTERN is not set
-CONFIG_ATALK=m
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_LLC is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_FASTROUTE is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-# CONFIG_PHONE_IXJ is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-# CONFIG_IDE is not set
-# CONFIG_BLK_DEV_IDE_MODES is not set
-# CONFIG_BLK_DEV_HD is not set
-
-#
-# SCSI support
-#
-CONFIG_SCSI=y
-
-#
-# SCSI support type (disk, tape, CD-ROM)
-#
-CONFIG_BLK_DEV_SD=y
-CONFIG_SD_EXTRA_DEVS=40
-CONFIG_CHR_DEV_ST=m
-# CONFIG_CHR_DEV_OSST is not set
-CONFIG_BLK_DEV_SR=m
-# CONFIG_BLK_DEV_SR_VENDOR is not set
-CONFIG_SR_EXTRA_DEVS=2
-CONFIG_CHR_DEV_SG=m
-
-#
-# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
-#
-# CONFIG_SCSI_DEBUG_QUEUES is not set
-CONFIG_SCSI_MULTI_LUN=y
-CONFIG_SCSI_CONSTANTS=y
-# CONFIG_SCSI_LOGGING is not set
-
-#
-# SCSI low-level drivers
-#
-# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
-# CONFIG_SCSI_7000FASST is not set
-# CONFIG_SCSI_ACARD is not set
-# CONFIG_SCSI_AHA152X is not set
-# CONFIG_SCSI_AHA1542 is not set
-# CONFIG_SCSI_AHA1740 is not set
-CONFIG_SCSI_AIC7XXX=y
-CONFIG_AIC7XXX_CMDS_PER_DEVICE=8
-CONFIG_AIC7XXX_RESET_DELAY=5
-# CONFIG_SCSI_ADVANSYS is not set
-# CONFIG_SCSI_IN2000 is not set
-# CONFIG_SCSI_AM53C974 is not set
-# CONFIG_SCSI_MEGARAID is not set
-# CONFIG_SCSI_BUSLOGIC is not set
-# CONFIG_SCSI_CPQFCTS is not set
-# CONFIG_SCSI_DMX3191D is not set
-# CONFIG_SCSI_DTC3280 is not set
-# CONFIG_SCSI_EATA is not set
-# CONFIG_SCSI_EATA_DMA is not set
-# CONFIG_SCSI_EATA_PIO is not set
-# CONFIG_SCSI_FUTURE_DOMAIN is not set
-# CONFIG_SCSI_GDTH is not set
-# CONFIG_SCSI_GENERIC_NCR5380 is not set
-# CONFIG_SCSI_INITIO is not set
-# CONFIG_SCSI_INIA100 is not set
-# CONFIG_SCSI_NCR53C406A is not set
-# CONFIG_SCSI_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=4
-CONFIG_SCSI_NCR53C8XX_SYNC=5
-# CONFIG_SCSI_NCR53C8XX_PROFILE is not set
-CONFIG_SCSI_NCR53C8XX_IOMAPPED=y
-# CONFIG_SCSI_NCR53C8XX_SYMBIOS_COMPAT is not set
-# CONFIG_SCSI_PAS16 is not set
-# CONFIG_SCSI_PCI2000 is not set
-# CONFIG_SCSI_PCI2220I is not set
-# CONFIG_SCSI_PSI240I is not set
-# CONFIG_SCSI_QLOGIC_FAS is not set
-# CONFIG_SCSI_QLOGIC_ISP is not set
-# CONFIG_SCSI_QLOGIC_FC is not set
-# CONFIG_SCSI_QLOGIC_1280 is not set
-# CONFIG_SCSI_SIM710 is not set
-# CONFIG_SCSI_SYM53C416 is not set
-# CONFIG_SCSI_DC390T is not set
-# CONFIG_SCSI_T128 is not set
-# CONFIG_SCSI_U14_34F is not set
-# CONFIG_SCSI_DEBUG is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-# CONFIG_I2O_PCI is not set
-# CONFIG_I2O_BLOCK is not set
-# CONFIG_I2O_LAN is not set
-# CONFIG_I2O_SCSI is not set
-# CONFIG_I2O_PROC is not set
-
-#
-# Network device support
-#
-CONFIG_NETDEVICES=y
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-
-#
-# Appletalk devices
-#
-# CONFIG_APPLETALK is not set
-CONFIG_DUMMY=m
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_NET_SB1000 is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_NET_VENDOR_3COM is not set
-# CONFIG_LANCE is not set
-# CONFIG_NET_VENDOR_SMC is not set
-# CONFIG_NET_VENDOR_RACAL is not set
-# CONFIG_AT1700 is not set
-# CONFIG_DEPCA is not set
-# CONFIG_HP100 is not set
-# CONFIG_NET_ISA is not set
-# CONFIG_NET_PCI is not set
-# CONFIG_NET_POCKET is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-CONFIG_PPP=m
-# CONFIG_PPP_MULTILINK is not set
-# CONFIG_PPP_ASYNC is not set
-# CONFIG_PPP_SYNC_TTY is not set
-# CONFIG_PPP_DEFLATE is not set
-# CONFIG_PPP_BSDCOMP is not set
-# CONFIG_PPPOE is not set
-CONFIG_SLIP=m
-CONFIG_SLIP_COMPRESSED=y
-CONFIG_SLIP_SMART=y
-# CONFIG_SLIP_MODE_SLIP6 is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-# CONFIG_NET_FC is not set
-# CONFIG_RCPCI is not set
-# CONFIG_SHAPER is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-
-#
-# ISDN subsystem
-#
-CONFIG_ISDN=m
-CONFIG_ISDN_PPP=y
-CONFIG_ISDN_PPP_VJ=y
-CONFIG_ISDN_MPP=y
-# CONFIG_ISDN_PPP_BSDCOMP is not set
-CONFIG_ISDN_AUDIO=y
-# CONFIG_ISDN_TTY_FAX is not set
-
-#
-# ISDN feature submodules
-#
-# CONFIG_ISDN_DRV_LOOP is not set
-# CONFIG_ISDN_DIVERSION is not set
-
-#
-# low-level hardware drivers
-#
-
-#
-# Passive ISDN cards
-#
-CONFIG_ISDN_DRV_HISAX=m
-
-#
-#   D-channel protocol features
-#
-CONFIG_HISAX_EURO=y
-CONFIG_DE_AOC=y
-# CONFIG_HISAX_NO_SENDCOMPLETE is not set
-# CONFIG_HISAX_NO_LLC is not set
-# CONFIG_HISAX_NO_KEYPAD is not set
-CONFIG_HISAX_1TR6=y
-# CONFIG_HISAX_NI1 is not set
-
-#
-#   HiSax supported cards
-#
-# CONFIG_HISAX_16_0 is not set
-# CONFIG_HISAX_16_3 is not set
-# CONFIG_HISAX_TELESPCI is not set
-# CONFIG_HISAX_S0BOX is not set
-# CONFIG_HISAX_AVM_A1 is not set
-# CONFIG_HISAX_FRITZPCI is not set
-# CONFIG_HISAX_AVM_A1_PCMCIA is not set
-CONFIG_HISAX_ELSA=y
-# CONFIG_HISAX_IX1MICROR2 is not set
-# CONFIG_HISAX_DIEHLDIVA is not set
-# CONFIG_HISAX_ASUSCOM is not set
-# CONFIG_HISAX_TELEINT is not set
-# CONFIG_HISAX_HFCS is not set
-# CONFIG_HISAX_SEDLBAUER is not set
-# CONFIG_HISAX_SPORTSTER is not set
-# CONFIG_HISAX_MIC is not set
-# CONFIG_HISAX_NETJET is not set
-# CONFIG_HISAX_NETJET_U is not set
-# CONFIG_HISAX_NICCY is not set
-# CONFIG_HISAX_ISURF is not set
-# CONFIG_HISAX_HSTSAPHIR is not set
-# CONFIG_HISAX_BKM_A4T is not set
-# CONFIG_HISAX_SCT_QUADRO is not set
-# CONFIG_HISAX_GAZEL is not set
-# CONFIG_HISAX_HFC_PCI is not set
-# CONFIG_HISAX_W6692 is not set
-# CONFIG_HISAX_HFC_SX is not set
-# CONFIG_HISAX_SEDLBAUER_CS is not set
-
-#
-# Active ISDN cards
-#
-# CONFIG_ISDN_DRV_ICN is not set
-# CONFIG_ISDN_DRV_PCBIT is not set
-# CONFIG_ISDN_DRV_SC is not set
-# CONFIG_ISDN_DRV_ACT2000 is not set
-# CONFIG_ISDN_DRV_EICON is not set
-# CONFIG_ISDN_CAPI is not set
-# CONFIG_HYSDN is not set
-# CONFIG_HYSDN_CAPI is not set
-
-#
-# Old CD-ROM drivers (not SCSI, not IDE)
-#
-# CONFIG_CD_NO_IDESCSI is not set
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-# CONFIG_SERIAL is not set
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-# CONFIG_UNIX98_PTYS is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_MOUSE is not set
-
-#
-# Joysticks
-#
-# CONFIG_JOYSTICK is not set
-
-#
-# Input core support is needed for joysticks
-#
-# CONFIG_QIC02_TAPE is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_INTEL_RNG is not set
-# CONFIG_NVRAM is not set
-CONFIG_RTC=y
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# File systems
-#
-CONFIG_QUOTA=y
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_REISERFS_CHECK is not set
-# CONFIG_ADFS_FS is not set
-# CONFIG_ADFS_FS_RW is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_BFS_FS is not set
-CONFIG_FAT_FS=m
-CONFIG_MSDOS_FS=m
-# CONFIG_UMSDOS_FS is not set
-CONFIG_VFAT_FS=m
-# CONFIG_EFS_FS is not set
-# CONFIG_JFFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_RAMFS is not set
-CONFIG_ISO9660_FS=m
-# CONFIG_JOLIET is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_NTFS_FS is not set
-# CONFIG_NTFS_RW is not set
-# CONFIG_HPFS_FS is not set
-CONFIG_PROC_FS=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_DEVFS_MOUNT is not set
-# CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_QNX4FS_RW is not set
-# CONFIG_ROMFS_FS is not set
-CONFIG_EXT2_FS=y
-# CONFIG_SYSV_FS is not set
-# CONFIG_SYSV_FS_WRITE is not set
-# CONFIG_UDF_FS is not set
-# CONFIG_UDF_RW is not set
-# CONFIG_UFS_FS is not set
-# CONFIG_UFS_FS_WRITE is not set
-
-#
-# Network File Systems
-#
-# CONFIG_CODA_FS is not set
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_ROOT_NFS is not set
-# CONFIG_NFSD is not set
-# CONFIG_NFSD_V3 is not set
-CONFIG_SUNRPC=y
-CONFIG_LOCKD=y
-CONFIG_SMB_FS=m
-# CONFIG_SMB_NLS_DEFAULT is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_NCPFS_PACKET_SIGNING is not set
-# CONFIG_NCPFS_IOCTL_LOCKING is not set
-# CONFIG_NCPFS_STRONG is not set
-# CONFIG_NCPFS_NFS_NS is not set
-# CONFIG_NCPFS_OS2_NS is not set
-# CONFIG_NCPFS_SMALLDOS is not set
-# CONFIG_NCPFS_NLS is not set
-# CONFIG_NCPFS_EXTRAS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-CONFIG_SMB_NLS=y
-CONFIG_NLS=y
-
-#
-# Native Language Support
-#
-CONFIG_NLS_DEFAULT="iso8859-1"
-CONFIG_NLS_CODEPAGE_437=m
-CONFIG_NLS_CODEPAGE_737=m
-CONFIG_NLS_CODEPAGE_775=m
-CONFIG_NLS_CODEPAGE_850=m
-CONFIG_NLS_CODEPAGE_852=m
-CONFIG_NLS_CODEPAGE_855=m
-CONFIG_NLS_CODEPAGE_857=m
-CONFIG_NLS_CODEPAGE_860=m
-CONFIG_NLS_CODEPAGE_861=m
-CONFIG_NLS_CODEPAGE_862=m
-CONFIG_NLS_CODEPAGE_863=m
-CONFIG_NLS_CODEPAGE_864=m
-CONFIG_NLS_CODEPAGE_865=m
-CONFIG_NLS_CODEPAGE_866=m
-CONFIG_NLS_CODEPAGE_869=m
-CONFIG_NLS_CODEPAGE_874=m
-CONFIG_NLS_CODEPAGE_932=m
-CONFIG_NLS_CODEPAGE_936=m
-CONFIG_NLS_CODEPAGE_949=m
-CONFIG_NLS_CODEPAGE_950=m
-CONFIG_NLS_ISO8859_1=m
-CONFIG_NLS_ISO8859_2=m
-CONFIG_NLS_ISO8859_3=m
-CONFIG_NLS_ISO8859_4=m
-CONFIG_NLS_ISO8859_5=m
-CONFIG_NLS_ISO8859_6=m
-CONFIG_NLS_ISO8859_7=m
-CONFIG_NLS_ISO8859_8=m
-CONFIG_NLS_ISO8859_9=m
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-CONFIG_NLS_KOI8_R=m
-CONFIG_NLS_UTF8=m
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# Input core support
-#
-# CONFIG_INPUT is not set
-
-#
-# Kernel hacking
-#
-# CONFIG_CROSSCOMPILE is not set
-# CONFIG_MIPS_FPE_MODULE is not set
-# CONFIG_MAGIC_SYSRQ is not set
diff -u --recursive --new-file v2.4.9/linux/arch/mips/defconfig-ddb5476 linux/arch/mips/defconfig-ddb5476
--- v2.4.9/linux/arch/mips/defconfig-ddb5476	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/defconfig-ddb5476	Sun Sep  9 10:43:01 2001
@@ -25,19 +25,25 @@
 # CONFIG_MIPS_MAGNUM_4000 is not set
 # CONFIG_MOMENCO_OCELOT is not set
 CONFIG_DDB5476=y
+# CONFIG_DDB5477 is not set
 # CONFIG_OLIVETTI_M700 is not set
 # CONFIG_SGI_IP22 is not set
 # CONFIG_SNI_RM200_PCI is not set
 # CONFIG_MIPS_ITE8172 is not set
 # CONFIG_MIPS_IVR is not set
+# CONFIG_MIPS_PB1000 is not set
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
 # CONFIG_MCA is not set
 # CONFIG_SBUS is not set
-CONFIG_I8259=y
 CONFIG_ISA=y
 CONFIG_PCI=y
 CONFIG_PC_KEYB=y
 CONFIG_ROTTEN_IRQ=y
+CONFIG_HAVE_STD_PC_SERIAL_PORT=y
+CONFIG_NEW_TIME_C=y
 CONFIG_EISA=y
+# CONFIG_I8259 is not set
 
 #
 # Loadable module support
@@ -48,26 +54,27 @@
 # CPU selection
 #
 # CONFIG_CPU_R3000 is not set
-# CONFIG_CPU_R3912 is not set
 # CONFIG_CPU_R6000 is not set
+# CONFIG_CPU_VR41XX is not set
 # CONFIG_CPU_R4300 is not set
 # CONFIG_CPU_R4X00 is not set
 # CONFIG_CPU_R5000 is not set
 CONFIG_CPU_R5432=y
 # CONFIG_CPU_RM7000 is not set
 # CONFIG_CPU_NEVADA is not set
-# CONFIG_CPU_R8000 is not set
 # CONFIG_CPU_R10000 is not set
+# CONFIG_CPU_SB1 is not set
 # CONFIG_CPU_MIPS32 is not set
+# CONFIG_CPU_MIPS64 is not set
 # CONFIG_CPU_ADVANCED is not set
 CONFIG_CPU_HAS_LLSC=y
+CONFIG_CPU_HAS_LLDSCD=y
 # CONFIG_CPU_HAS_WB is not set
 
 #
 # General setup
 #
 CONFIG_CPU_LITTLE_ENDIAN=y
-CONFIG_MIPS_FPU_EMULATOR=y
 CONFIG_KCORE_ELF=y
 CONFIG_ELF_KERNEL=y
 # CONFIG_BINFMT_AOUT is not set
@@ -75,21 +82,18 @@
 # CONFIG_BINFMT_MISC is not set
 CONFIG_NET=y
 # CONFIG_PCI_NAMES is not set
+# CONFIG_HOTPLUG is not set
+# CONFIG_PCMCIA is not set
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
 
 #
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
 # Plug and Play configuration
 #
 # CONFIG_PNP is not set
 # CONFIG_ISAPNP is not set
-# CONFIG_PCMCIA is not set
+# CONFIG_PNPBIOS is not set
 
 #
 # Memory Technology Devices (MTD)
@@ -97,6 +101,11 @@
 # CONFIG_MTD is not set
 
 #
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
 # Block devices
 #
 # CONFIG_BLK_DEV_FD is not set
@@ -134,6 +143,7 @@
 # CONFIG_IP_MULTICAST is not set
 # CONFIG_IP_ADVANCED_ROUTER is not set
 CONFIG_IP_PNP=y
+# CONFIG_IP_PNP_DHCP is not set
 CONFIG_IP_PNP_BOOTP=y
 # CONFIG_IP_PNP_RARP is not set
 # CONFIG_NET_IPIP is not set
@@ -170,6 +180,7 @@
 #
 # CONFIG_PHONE is not set
 # CONFIG_PHONE_IXJ is not set
+# CONFIG_PHONE_IXJ_PCMCIA is not set
 
 #
 # ATA/IDE/MFM/RLL support
@@ -213,6 +224,7 @@
 CONFIG_BLK_DEV_IDEPCI=y
 # CONFIG_IDEPCI_SHARE_IRQ is not set
 # CONFIG_BLK_DEV_IDEDMA_PCI is not set
+# CONFIG_BLK_DEV_ADMA is not set
 # CONFIG_BLK_DEV_OFFBOARD is not set
 # CONFIG_IDEDMA_PCI_AUTO is not set
 # CONFIG_BLK_DEV_IDEDMA is not set
@@ -222,8 +234,8 @@
 # CONFIG_AEC62XX_TUNING is not set
 # CONFIG_BLK_DEV_ALI15X3 is not set
 # CONFIG_WDC_ALI15X3 is not set
-# CONFIG_BLK_DEV_AMD7409 is not set
-# CONFIG_AMD7409_OVERRIDE is not set
+# CONFIG_BLK_DEV_AMD74XX is not set
+# CONFIG_AMD74XX_OVERRIDE is not set
 # CONFIG_BLK_DEV_CMD64X is not set
 # CONFIG_BLK_DEV_CY82C693 is not set
 # CONFIG_BLK_DEV_CS5530 is not set
@@ -234,7 +246,8 @@
 # CONFIG_BLK_DEV_OPTI621 is not set
 # CONFIG_BLK_DEV_PDC202XX is not set
 # CONFIG_PDC202XX_BURST is not set
-# CONFIG_BLK_DEV_OSB4 is not set
+# CONFIG_PDC202XX_FORCE is not set
+# CONFIG_BLK_DEV_SVWKS is not set
 # CONFIG_BLK_DEV_SIS5513 is not set
 # CONFIG_BLK_DEV_SLC90E66 is not set
 # CONFIG_BLK_DEV_TRM290 is not set
@@ -243,6 +256,9 @@
 # CONFIG_IDEDMA_AUTO is not set
 # CONFIG_DMA_NONPCI is not set
 # CONFIG_BLK_DEV_IDE_MODES is not set
+# CONFIG_BLK_DEV_ATARAID is not set
+# CONFIG_BLK_DEV_ATARAID_PDC is not set
+# CONFIG_BLK_DEV_ATARAID_HPT is not set
 
 #
 # SCSI support
@@ -250,16 +266,6 @@
 # CONFIG_SCSI is not set
 
 #
-# I2O device support
-#
-# CONFIG_I2O is not set
-# CONFIG_I2O_PCI is not set
-# CONFIG_I2O_BLOCK is not set
-# CONFIG_I2O_LAN is not set
-# CONFIG_I2O_SCSI is not set
-# CONFIG_I2O_PROC is not set
-
-#
 # Network device support
 #
 CONFIG_NETDEVICES=y
@@ -272,12 +278,17 @@
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
-# CONFIG_NET_SB1000 is not set
 
 #
 # Ethernet (10 or 100Mbit)
 #
 CONFIG_NET_ETHERNET=y
+# CONFIG_SUNLANCE is not set
+# CONFIG_HAPPYMEAL is not set
+# CONFIG_SUNBMAC is not set
+# CONFIG_SUNQE is not set
+# CONFIG_SUNLANCE is not set
+# CONFIG_SUNGEM is not set
 # CONFIG_NET_VENDOR_3COM is not set
 # CONFIG_LANCE is not set
 # CONFIG_NET_VENDOR_SMC is not set
@@ -293,25 +304,28 @@
 # CONFIG_APRICOT is not set
 # CONFIG_CS89x0 is not set
 CONFIG_TULIP=y
+# CONFIG_TULIP_MWI is not set
+# CONFIG_TULIP_MMIO is not set
 # CONFIG_DE4X5 is not set
 # CONFIG_DGRS is not set
 # CONFIG_DM9102 is not set
 CONFIG_EEPRO100=y
-# CONFIG_EEPRO100_PM is not set
 # CONFIG_LNE390 is not set
+# CONFIG_FEALNX is not set
 # CONFIG_NATSEMI is not set
 CONFIG_NE2K_PCI=y
 # CONFIG_NE3210 is not set
 # CONFIG_ES3210 is not set
 # CONFIG_8139TOO is not set
-# CONFIG_RTL8129 is not set
+# CONFIG_8139TOO_PIO is not set
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+# CONFIG_8139TOO_8129 is not set
 # CONFIG_SIS900 is not set
 # CONFIG_EPIC100 is not set
 # CONFIG_SUNDANCE is not set
 # CONFIG_TLAN is not set
 # CONFIG_VIA_RHINE is not set
 # CONFIG_WINBOND_840 is not set
-# CONFIG_HAPPYMEAL is not set
 # CONFIG_LAN_SAA9730 is not set
 # CONFIG_NET_POCKET is not set
 
@@ -319,11 +333,15 @@
 # Ethernet (1000 Mbit)
 #
 # CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_MYRI_SBUS is not set
+# CONFIG_NS83820 is not set
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
 # CONFIG_SK98LIN is not set
 # CONFIG_FDDI is not set
 # CONFIG_HIPPI is not set
+# CONFIG_PLIP is not set
 # CONFIG_PPP is not set
 # CONFIG_SLIP is not set
 
@@ -346,6 +364,16 @@
 # CONFIG_WAN is not set
 
 #
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# IrDA (infrared) support
+#
+# CONFIG_IRDA is not set
+
+#
 # ISDN subsystem
 #
 # CONFIG_ISDN is not set
@@ -364,7 +392,8 @@
 CONFIG_SERIAL_CONSOLE=y
 # CONFIG_SERIAL_EXTENDED is not set
 # CONFIG_SERIAL_NONSTANDARD is not set
-# CONFIG_UNIX98_PTYS is not set
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
 
 #
 # I2C support
@@ -383,7 +412,11 @@
 #
 # Joysticks
 #
-# CONFIG_JOYSTICK is not set
+# CONFIG_INPUT_GAMEPORT is not set
+
+#
+# Input core support is needed for gameports
+#
 
 #
 # Input core support is needed for joysticks
@@ -400,6 +433,7 @@
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 # CONFIG_APPLICOM is not set
+# CONFIG_SONYPI is not set
 
 #
 # Ftape, the floppy tape device driver
@@ -421,22 +455,30 @@
 # CONFIG_AUTOFS4_FS is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
 # CONFIG_ADFS_FS is not set
 # CONFIG_ADFS_FS_RW is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
 # CONFIG_BFS_FS is not set
+# CONFIG_CMS_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_JBD_DEBUG is not set
 # CONFIG_FAT_FS is not set
 # CONFIG_MSDOS_FS is not set
 # CONFIG_UMSDOS_FS is not set
 # CONFIG_VFAT_FS is not set
 # CONFIG_EFS_FS is not set
 # CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
 # CONFIG_CRAMFS is not set
+# CONFIG_TMPFS is not set
 # CONFIG_RAMFS is not set
 # CONFIG_ISO9660_FS is not set
 # CONFIG_JOLIET is not set
 # CONFIG_MINIX_FS is not set
+# CONFIG_FREEVXFS_FS is not set
 # CONFIG_NTFS_FS is not set
 # CONFIG_NTFS_RW is not set
 # CONFIG_HPFS_FS is not set
@@ -444,13 +486,12 @@
 # CONFIG_DEVFS_FS is not set
 # CONFIG_DEVFS_MOUNT is not set
 # CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS is not set
+CONFIG_DEVPTS_FS=y
 # CONFIG_QNX4FS_FS is not set
 # CONFIG_QNX4FS_RW is not set
 # CONFIG_ROMFS_FS is not set
 CONFIG_EXT2_FS=y
 # CONFIG_SYSV_FS is not set
-# CONFIG_SYSV_FS_WRITE is not set
 # CONFIG_UDF_FS is not set
 # CONFIG_UDF_RW is not set
 # CONFIG_UFS_FS is not set
@@ -460,6 +501,7 @@
 # Network File Systems
 #
 # CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
 CONFIG_NFS_FS=y
 # CONFIG_NFS_V3 is not set
 CONFIG_ROOT_NFS=y
@@ -490,7 +532,7 @@
 # Console drivers
 #
 # CONFIG_VGA_CONSOLE is not set
-CONFIG_FB=y
+# CONFIG_MDA_CONSOLE is not set
 
 #
 # Frame-buffer support
@@ -501,11 +543,13 @@
 # CONFIG_FB_CLGEN is not set
 # CONFIG_FB_PM2 is not set
 # CONFIG_FB_CYBER2000 is not set
+# CONFIG_FB_E1355 is not set
 # CONFIG_FB_MATROX is not set
 # CONFIG_FB_ATY is not set
+# CONFIG_FB_RADEON is not set
 # CONFIG_FB_ATY128 is not set
-CONFIG_FB_3DFX=y
 # CONFIG_FB_SIS is not set
+CONFIG_FB_3DFX=y
 # CONFIG_FB_VIRTUAL is not set
 # CONFIG_FBCON_ADVANCED is not set
 CONFIG_FBCON_CFB8=y
@@ -527,15 +571,114 @@
 # CONFIG_USB is not set
 
 #
+# USB Controllers
+#
+# CONFIG_USB_UHCI is not set
+# CONFIG_USB_UHCI_ALT is not set
+# CONFIG_USB_OHCI is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_BLUETOOTH is not set
+# CONFIG_USB_STORAGE is not set
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+
+#
+# USB Human Interface Devices (HID)
+#
+
+#
+#   Input core support is needed for USB HID
+#
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_DC2XX is not set
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_SCANNER is not set
+# CONFIG_USB_MICROTEK is not set
+# CONFIG_USB_HPUSBSCSI is not set
+
+#
+# USB Multimedia devices
+#
+
+#
+#   Video4Linux support is needed for USB Multimedia device support
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# USB Network adaptors
+#
+# CONFIG_USB_PLUSB is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_CDCETHER is not set
+# CONFIG_USB_USBNET is not set
+
+#
+# USB port drivers
+#
+# CONFIG_USB_USS720 is not set
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+# CONFIG_USB_SERIAL_GENERIC is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+
+#
+# Miscellaneous USB drivers
+#
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_ID75 is not set
+
+#
 # Input core support
 #
 # CONFIG_INPUT is not set
+# CONFIG_INPUT_KEYBDEV is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
 
 #
 # Kernel hacking
 #
 CONFIG_CROSSCOMPILE=y
 # CONFIG_REMOTE_DEBUG is not set
+# CONFIG_GDB_CONSOLE is not set
 # CONFIG_LL_DEBUG is not set
 # CONFIG_MAGIC_SYSRQ is not set
 # CONFIG_MIPS_UNCACHED is not set
diff -u --recursive --new-file v2.4.9/linux/arch/mips/defconfig-ddb5477 linux/arch/mips/defconfig-ddb5477
--- v2.4.9/linux/arch/mips/defconfig-ddb5477	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/defconfig-ddb5477	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,565 @@
+#
+# Automatically generated make config: don't edit
+#
+CONFIG_MIPS=y
+# CONFIG_SMP is not set
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+
+#
+# Machine selection
+#
+# CONFIG_ACER_PICA_61 is not set
+# CONFIG_ALGOR_P4032 is not set
+# CONFIG_BAGET_MIPS is not set
+# CONFIG_DECSTATION is not set
+# CONFIG_DDB5074 is not set
+# CONFIG_MIPS_EV96100 is not set
+# CONFIG_MIPS_EV64120 is not set
+# CONFIG_MIPS_ATLAS is not set
+# CONFIG_MIPS_MALTA is not set
+# CONFIG_NINO is not set
+# CONFIG_MIPS_MAGNUM_4000 is not set
+# CONFIG_MOMENCO_OCELOT is not set
+# CONFIG_DDB5476 is not set
+CONFIG_DDB5477=y
+# CONFIG_OLIVETTI_M700 is not set
+# CONFIG_SGI_IP22 is not set
+# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_MIPS_ITE8172 is not set
+# CONFIG_MIPS_IVR is not set
+# CONFIG_MIPS_PB1000 is not set
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+# CONFIG_MCA is not set
+# CONFIG_SBUS is not set
+CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_PCI=y
+CONFIG_NEW_TIME_C=y
+CONFIG_NEW_IRQ=y
+# CONFIG_ISA is not set
+# CONFIG_EISA is not set
+# CONFIG_I8259 is not set
+
+#
+# Loadable module support
+#
+# CONFIG_MODULES is not set
+
+#
+# CPU selection
+#
+# CONFIG_CPU_R3000 is not set
+# CONFIG_CPU_R6000 is not set
+# CONFIG_CPU_VR41XX is not set
+# CONFIG_CPU_R4300 is not set
+# CONFIG_CPU_R4X00 is not set
+# CONFIG_CPU_R5000 is not set
+CONFIG_CPU_R5432=y
+# CONFIG_CPU_RM7000 is not set
+# CONFIG_CPU_NEVADA is not set
+# CONFIG_CPU_R10000 is not set
+# CONFIG_CPU_SB1 is not set
+# CONFIG_CPU_MIPS32 is not set
+# CONFIG_CPU_MIPS64 is not set
+# CONFIG_CPU_ADVANCED is not set
+CONFIG_CPU_HAS_LLSC=y
+CONFIG_CPU_HAS_LLDSCD=y
+# CONFIG_CPU_HAS_WB is not set
+
+#
+# General setup
+#
+CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_KCORE_ELF=y
+CONFIG_ELF_KERNEL=y
+# CONFIG_BINFMT_AOUT is not set
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_MISC is not set
+CONFIG_NET=y
+# CONFIG_PCI_NAMES is not set
+# CONFIG_HOTPLUG is not set
+# CONFIG_PCMCIA is not set
+CONFIG_SYSVIPC=y
+# CONFIG_BSD_PROCESS_ACCT is not set
+CONFIG_SYSCTL=y
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_DEV_XD is not set
+# CONFIG_PARIDE is not set
+# CONFIG_BLK_CPQ_DA is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_LOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_RAM is not set
+# CONFIG_BLK_DEV_INITRD is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+# CONFIG_BLK_DEV_MD is not set
+# CONFIG_MD_LINEAR is not set
+# CONFIG_MD_RAID0 is not set
+# CONFIG_MD_RAID1 is not set
+# CONFIG_MD_RAID5 is not set
+# CONFIG_BLK_DEV_LVM is not set
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+# CONFIG_NETLINK is not set
+# CONFIG_NETFILTER is not set
+# CONFIG_FILTER is not set
+CONFIG_UNIX=y
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_PNP=y
+# CONFIG_IP_PNP_DHCP is not set
+CONFIG_IP_PNP_BOOTP=y
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_INET_ECN is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_IPV6 is not set
+# CONFIG_KHTTPD is not set
+# CONFIG_ATM is not set
+
+#
+#  
+#
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_DECNET is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_LLC is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_FASTROUTE is not set
+# CONFIG_NET_HW_FLOWCONTROL is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+# CONFIG_PHONE_IXJ is not set
+# CONFIG_PHONE_IXJ_PCMCIA is not set
+
+#
+# ATA/IDE/MFM/RLL support
+#
+# CONFIG_IDE is not set
+# CONFIG_BLK_DEV_IDE_MODES is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI support
+#
+# CONFIG_SCSI is not set
+
+#
+# Network device support
+#
+CONFIG_NETDEVICES=y
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+# CONFIG_SUNLANCE is not set
+# CONFIG_HAPPYMEAL is not set
+# CONFIG_SUNBMAC is not set
+# CONFIG_SUNQE is not set
+# CONFIG_SUNLANCE is not set
+# CONFIG_SUNGEM is not set
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_LANCE is not set
+# CONFIG_NET_VENDOR_SMC is not set
+# CONFIG_NET_VENDOR_RACAL is not set
+# CONFIG_HP100 is not set
+# CONFIG_NET_ISA is not set
+CONFIG_NET_PCI=y
+# CONFIG_PCNET32 is not set
+# CONFIG_ADAPTEC_STARFIRE is not set
+# CONFIG_APRICOT is not set
+# CONFIG_CS89x0 is not set
+CONFIG_TULIP=y
+# CONFIG_TULIP_MWI is not set
+# CONFIG_TULIP_MMIO is not set
+# CONFIG_DE4X5 is not set
+# CONFIG_DGRS is not set
+# CONFIG_DM9102 is not set
+# CONFIG_EEPRO100 is not set
+# CONFIG_LNE390 is not set
+# CONFIG_FEALNX is not set
+# CONFIG_NATSEMI is not set
+# CONFIG_NE2K_PCI is not set
+# CONFIG_NE3210 is not set
+# CONFIG_ES3210 is not set
+# CONFIG_8139TOO is not set
+# CONFIG_8139TOO_PIO is not set
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+# CONFIG_8139TOO_8129 is not set
+# CONFIG_SIS900 is not set
+# CONFIG_EPIC100 is not set
+# CONFIG_SUNDANCE is not set
+# CONFIG_TLAN is not set
+# CONFIG_VIA_RHINE is not set
+# CONFIG_WINBOND_840 is not set
+# CONFIG_LAN_SAA9730 is not set
+# CONFIG_NET_POCKET is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_MYRI_SBUS is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_SK98LIN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PLIP is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+# CONFIG_NET_FC is not set
+# CONFIG_RCPCI is not set
+# CONFIG_SHAPER is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+
+#
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# IrDA (infrared) support
+#
+# CONFIG_IRDA is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Old CD-ROM drivers (not SCSI, not IDE)
+#
+# CONFIG_CD_NO_IDESCSI is not set
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+CONFIG_SERIAL=y
+CONFIG_SERIAL_CONSOLE=y
+# CONFIG_SERIAL_EXTENDED is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+# CONFIG_UNIX98_PTYS is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Mice
+#
+# CONFIG_BUSMOUSE is not set
+# CONFIG_MOUSE is not set
+
+#
+# Joysticks
+#
+# CONFIG_INPUT_GAMEPORT is not set
+
+#
+# Input core support is needed for gameports
+#
+
+#
+# Input core support is needed for joysticks
+#
+# CONFIG_QIC02_TAPE is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_INTEL_RNG is not set
+# CONFIG_NVRAM is not set
+# CONFIG_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+# CONFIG_SONYPI is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_FTAPE is not set
+# CONFIG_AGP is not set
+# CONFIG_DRM is not set
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# File systems
+#
+# CONFIG_QUOTA is not set
+CONFIG_AUTOFS_FS=y
+CONFIG_AUTOFS4_FS=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_ADFS_FS is not set
+# CONFIG_ADFS_FS_RW is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_CMS_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_JBD_DEBUG is not set
+# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_UMSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_TMPFS is not set
+# CONFIG_RAMFS is not set
+# CONFIG_ISO9660_FS is not set
+# CONFIG_JOLIET is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_FREEVXFS_FS is not set
+# CONFIG_NTFS_FS is not set
+# CONFIG_NTFS_RW is not set
+# CONFIG_HPFS_FS is not set
+CONFIG_PROC_FS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVFS_MOUNT is not set
+# CONFIG_DEVFS_DEBUG is not set
+# CONFIG_DEVPTS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_QNX4FS_RW is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_EXT2_FS=y
+# CONFIG_SYSV_FS is not set
+# CONFIG_UDF_FS is not set
+# CONFIG_UDF_RW is not set
+# CONFIG_UFS_FS is not set
+# CONFIG_UFS_FS_WRITE is not set
+
+#
+# Network File Systems
+#
+# CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
+CONFIG_NFS_FS=y
+# CONFIG_NFS_V3 is not set
+CONFIG_ROOT_NFS=y
+CONFIG_NFSD=y
+# CONFIG_NFSD_V3 is not set
+CONFIG_SUNRPC=y
+CONFIG_LOCKD=y
+# CONFIG_SMB_FS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_NCPFS_PACKET_SIGNING is not set
+# CONFIG_NCPFS_IOCTL_LOCKING is not set
+# CONFIG_NCPFS_STRONG is not set
+# CONFIG_NCPFS_NFS_NS is not set
+# CONFIG_NCPFS_OS2_NS is not set
+# CONFIG_NCPFS_SMALLDOS is not set
+# CONFIG_NCPFS_NLS is not set
+# CONFIG_NCPFS_EXTRAS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+# CONFIG_SMB_NLS is not set
+# CONFIG_NLS is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB is not set
+
+#
+# USB Controllers
+#
+# CONFIG_USB_UHCI is not set
+# CONFIG_USB_UHCI_ALT is not set
+# CONFIG_USB_OHCI is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_BLUETOOTH is not set
+# CONFIG_USB_STORAGE is not set
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+
+#
+# USB Human Interface Devices (HID)
+#
+
+#
+#   Input core support is needed for USB HID
+#
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_DC2XX is not set
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_SCANNER is not set
+# CONFIG_USB_MICROTEK is not set
+# CONFIG_USB_HPUSBSCSI is not set
+
+#
+# USB Multimedia devices
+#
+
+#
+#   Video4Linux support is needed for USB Multimedia device support
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# USB Network adaptors
+#
+# CONFIG_USB_PLUSB is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_CDCETHER is not set
+# CONFIG_USB_USBNET is not set
+
+#
+# USB port drivers
+#
+# CONFIG_USB_USS720 is not set
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+# CONFIG_USB_SERIAL_GENERIC is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+
+#
+# Miscellaneous USB drivers
+#
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_ID75 is not set
+
+#
+# Input core support
+#
+# CONFIG_INPUT is not set
+# CONFIG_INPUT_KEYBDEV is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+
+#
+# Kernel hacking
+#
+CONFIG_CROSSCOMPILE=y
+# CONFIG_REMOTE_DEBUG is not set
+# CONFIG_GDB_CONSOLE is not set
+CONFIG_LL_DEBUG=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_MIPS_UNCACHED is not set
diff -u --recursive --new-file v2.4.9/linux/arch/mips/defconfig-decstation linux/arch/mips/defconfig-decstation
--- v2.4.9/linux/arch/mips/defconfig-decstation	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/defconfig-decstation	Sun Sep  9 10:43:01 2001
@@ -1,6 +1,8 @@
 #
 # Automatically generated make config: don't edit
 #
+CONFIG_MIPS=y
+# CONFIG_SMP is not set
 
 #
 # Code maturity level options
@@ -13,18 +15,31 @@
 # CONFIG_ACER_PICA_61 is not set
 # CONFIG_ALGOR_P4032 is not set
 # CONFIG_BAGET_MIPS is not set
-# CONFIG_COBALT_MICRO_SERVER is not set
 CONFIG_DECSTATION=y
 # CONFIG_DDB5074 is not set
+# CONFIG_MIPS_EV96100 is not set
+# CONFIG_MIPS_EV64120 is not set
+# CONFIG_MIPS_ATLAS is not set
+# CONFIG_MIPS_MALTA is not set
+# CONFIG_NINO is not set
 # CONFIG_MIPS_MAGNUM_4000 is not set
+# CONFIG_MOMENCO_OCELOT is not set
+# CONFIG_DDB5476 is not set
+# CONFIG_DDB5477 is not set
 # CONFIG_OLIVETTI_M700 is not set
 # CONFIG_SGI_IP22 is not set
 # CONFIG_SNI_RM200_PCI is not set
+# CONFIG_MIPS_ITE8172 is not set
+# CONFIG_MIPS_IVR is not set
+# CONFIG_MIPS_PB1000 is not set
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
 # CONFIG_MCA is not set
 # CONFIG_SBUS is not set
 # CONFIG_ISA is not set
 # CONFIG_EISA is not set
 # CONFIG_PCI is not set
+# CONFIG_I8259 is not set
 
 #
 # Loadable module support
@@ -38,15 +53,21 @@
 #
 CONFIG_CPU_R3000=y
 # CONFIG_CPU_R6000 is not set
+# CONFIG_CPU_VR41XX is not set
 # CONFIG_CPU_R4300 is not set
 # CONFIG_CPU_R4X00 is not set
 # CONFIG_CPU_R5000 is not set
+# CONFIG_CPU_R5432 is not set
+# CONFIG_CPU_RM7000 is not set
 # CONFIG_CPU_NEVADA is not set
-# CONFIG_CPU_R8000 is not set
 # CONFIG_CPU_R10000 is not set
+# CONFIG_CPU_SB1 is not set
+# CONFIG_CPU_MIPS32 is not set
+# CONFIG_CPU_MIPS64 is not set
 # CONFIG_CPU_ADVANCED is not set
 # CONFIG_CPU_HAS_LLSC is not set
-CONFIG_CPU_HAS_WB=y
+# CONFIG_CPU_HAS_LLDSCD is not set
+# CONFIG_CPU_HAS_WB is not set
 
 #
 # General setup
@@ -58,16 +79,12 @@
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 CONFIG_NET=y
+# CONFIG_HOTPLUG is not set
+# CONFIG_PCMCIA is not set
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
 CONFIG_TC=y
-# CONFIG_PCMCIA is not set
 
 #
 # Memory Technology Devices (MTD)
@@ -75,6 +92,11 @@
 # CONFIG_MTD is not set
 
 #
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
 # Block devices
 #
 # CONFIG_BLK_DEV_FD is not set
@@ -112,6 +134,7 @@
 # CONFIG_IP_MULTICAST is not set
 # CONFIG_IP_ADVANCED_ROUTER is not set
 CONFIG_IP_PNP=y
+# CONFIG_IP_PNP_DHCP is not set
 CONFIG_IP_PNP_BOOTP=y
 # CONFIG_IP_PNP_RARP is not set
 # CONFIG_NET_IPIP is not set
@@ -144,6 +167,13 @@
 # CONFIG_NET_SCHED is not set
 
 #
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+# CONFIG_PHONE_IXJ is not set
+# CONFIG_PHONE_IXJ_PCMCIA is not set
+
+#
 # SCSI support
 #
 CONFIG_SCSI=y
@@ -178,6 +208,7 @@
 # CONFIG_SCSI_AHA1740 is not set
 # CONFIG_SCSI_AIC7XXX is not set
 # CONFIG_SCSI_AIC7XXX_OLD is not set
+# CONFIG_SCSI_DPT_I2O is not set
 # CONFIG_SCSI_ADVANSYS is not set
 # CONFIG_SCSI_IN2000 is not set
 # CONFIG_SCSI_AM53C974 is not set
@@ -194,6 +225,7 @@
 # CONFIG_SCSI_INITIO is not set
 # CONFIG_SCSI_INIA100 is not set
 # CONFIG_SCSI_NCR53C406A is not set
+# CONFIG_SCSI_NCR_D700 is not set
 # CONFIG_SCSI_NCR53C7xx is not set
 # CONFIG_SCSI_PAS16 is not set
 # CONFIG_SCSI_PCI2000 is not set
@@ -210,12 +242,149 @@
 # Network device support
 #
 CONFIG_NETDEVICES=y
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
 # CONFIG_DUMMY is not set
-# CONFIG_SLIP is not set
-# CONFIG_PPP is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+# CONFIG_SUNLANCE is not set
+# CONFIG_SUNBMAC is not set
+# CONFIG_SUNQE is not set
+# CONFIG_SUNLANCE is not set
+# CONFIG_SUNGEM is not set
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_LANCE is not set
+# CONFIG_NET_VENDOR_SMC is not set
+# CONFIG_NET_VENDOR_RACAL is not set
+# CONFIG_NET_ISA is not set
+# CONFIG_NET_PCI is not set
+# CONFIG_NET_POCKET is not set
 CONFIG_DECLANCE=y
 
 #
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_MYRI_SBUS is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_SK98LIN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PLIP is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+# CONFIG_NET_FC is not set
+# CONFIG_RCPCI is not set
+# CONFIG_SHAPER is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+
+#
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# IrDA (infrared) support
+#
+# CONFIG_IRDA is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Old CD-ROM drivers (not SCSI, not IDE)
+#
+# CONFIG_CD_NO_IDESCSI is not set
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+CONFIG_SERIAL=y
+CONFIG_SERIAL_CONSOLE=y
+# CONFIG_SERIAL_EXTENDED is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Mice
+#
+# CONFIG_BUSMOUSE is not set
+# CONFIG_MOUSE is not set
+
+#
+# Joysticks
+#
+# CONFIG_INPUT_GAMEPORT is not set
+
+#
+# Input core support is needed for gameports
+#
+
+#
+# Input core support is needed for joysticks
+#
+# CONFIG_QIC02_TAPE is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_INTEL_RNG is not set
+# CONFIG_NVRAM is not set
+# CONFIG_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+# CONFIG_SONYPI is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_FTAPE is not set
+# CONFIG_AGP is not set
+# CONFIG_DRM is not set
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
 # DECStation Character devices
 #
 # CONFIG_VT is not set
@@ -223,7 +392,8 @@
 # CONFIG_DZ is not set
 CONFIG_ZS=y
 CONFIG_SERIAL_CONSOLE=y
-# CONFIG_UNIX98_PTYS is not set
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
 # CONFIG_RTC is not set
 
 #
@@ -234,22 +404,30 @@
 # CONFIG_AUTOFS4_FS is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
 # CONFIG_ADFS_FS is not set
 # CONFIG_ADFS_FS_RW is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
 # CONFIG_BFS_FS is not set
+# CONFIG_CMS_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_JBD_DEBUG is not set
 # CONFIG_FAT_FS is not set
 # CONFIG_MSDOS_FS is not set
 # CONFIG_UMSDOS_FS is not set
 # CONFIG_VFAT_FS is not set
 # CONFIG_EFS_FS is not set
 # CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
 # CONFIG_CRAMFS is not set
+# CONFIG_TMPFS is not set
 # CONFIG_RAMFS is not set
 # CONFIG_ISO9660_FS is not set
 # CONFIG_JOLIET is not set
 # CONFIG_MINIX_FS is not set
+# CONFIG_FREEVXFS_FS is not set
 # CONFIG_NTFS_FS is not set
 # CONFIG_NTFS_RW is not set
 # CONFIG_HPFS_FS is not set
@@ -257,13 +435,12 @@
 # CONFIG_DEVFS_FS is not set
 # CONFIG_DEVFS_MOUNT is not set
 # CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS is not set
+CONFIG_DEVPTS_FS=y
 # CONFIG_QNX4FS_FS is not set
 # CONFIG_QNX4FS_RW is not set
 # CONFIG_ROMFS_FS is not set
 CONFIG_EXT2_FS=y
 # CONFIG_SYSV_FS is not set
-# CONFIG_SYSV_FS_WRITE is not set
 # CONFIG_UDF_FS is not set
 # CONFIG_UDF_RW is not set
 # CONFIG_UFS_FS is not set
@@ -273,6 +450,7 @@
 # Network File Systems
 #
 # CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
 # CONFIG_NFS_FS is not set
 # CONFIG_NFS_V3 is not set
 # CONFIG_ROOT_NFS is not set
@@ -305,6 +483,7 @@
 # CONFIG_MINIX_SUBPARTITION is not set
 # CONFIG_SOLARIS_X86_PARTITION is not set
 # CONFIG_UNIXWARE_DISKLABEL is not set
+# CONFIG_LDM_PARTITION is not set
 # CONFIG_SGI_PARTITION is not set
 CONFIG_ULTRIX_PARTITION=y
 # CONFIG_SUN_PARTITION is not set
@@ -317,14 +496,114 @@
 # CONFIG_USB is not set
 
 #
+# USB Controllers
+#
+# CONFIG_USB_UHCI is not set
+# CONFIG_USB_UHCI_ALT is not set
+# CONFIG_USB_OHCI is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_BLUETOOTH is not set
+# CONFIG_USB_STORAGE is not set
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+
+#
+# USB Human Interface Devices (HID)
+#
+
+#
+#   Input core support is needed for USB HID
+#
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_DC2XX is not set
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_SCANNER is not set
+# CONFIG_USB_MICROTEK is not set
+# CONFIG_USB_HPUSBSCSI is not set
+
+#
+# USB Multimedia devices
+#
+
+#
+#   Video4Linux support is needed for USB Multimedia device support
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# USB Network adaptors
+#
+# CONFIG_USB_PLUSB is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_CDCETHER is not set
+# CONFIG_USB_USBNET is not set
+
+#
+# USB port drivers
+#
+# CONFIG_USB_USS720 is not set
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+# CONFIG_USB_SERIAL_GENERIC is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+
+#
+# Miscellaneous USB drivers
+#
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_ID75 is not set
+
+#
 # Input core support
 #
 # CONFIG_INPUT is not set
+# CONFIG_INPUT_KEYBDEV is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
 
 #
 # Kernel hacking
 #
 CONFIG_CROSSCOMPILE=y
-# CONFIG_MIPS_FPE_MODULE is not set
 # CONFIG_REMOTE_DEBUG is not set
+# CONFIG_GDB_CONSOLE is not set
+# CONFIG_LL_DEBUG is not set
 # CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_MIPS_UNCACHED is not set
diff -u --recursive --new-file v2.4.9/linux/arch/mips/defconfig-ip22 linux/arch/mips/defconfig-ip22
--- v2.4.9/linux/arch/mips/defconfig-ip22	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/defconfig-ip22	Sun Sep  9 10:43:02 2001
@@ -1,6 +1,8 @@
 #
 # Automatically generated make config: don't edit
 #
+CONFIG_MIPS=y
+# CONFIG_SMP is not set
 
 #
 # Code maturity level options
@@ -13,21 +15,37 @@
 # CONFIG_ACER_PICA_61 is not set
 # CONFIG_ALGOR_P4032 is not set
 # CONFIG_BAGET_MIPS is not set
-# CONFIG_COBALT_MICRO_SERVER is not set
 # CONFIG_DECSTATION is not set
 # CONFIG_DDB5074 is not set
+# CONFIG_MIPS_EV96100 is not set
+# CONFIG_MIPS_EV64120 is not set
+# CONFIG_MIPS_ATLAS is not set
+# CONFIG_MIPS_MALTA is not set
+# CONFIG_NINO is not set
 # CONFIG_MIPS_MAGNUM_4000 is not set
+# CONFIG_MOMENCO_OCELOT is not set
+# CONFIG_DDB5476 is not set
+# CONFIG_DDB5477 is not set
 # CONFIG_OLIVETTI_M700 is not set
 CONFIG_SGI_IP22=y
 # CONFIG_SNI_RM200_PCI is not set
+# CONFIG_MIPS_ITE8172 is not set
+# CONFIG_MIPS_IVR is not set
+# CONFIG_MIPS_PB1000 is not set
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
 # CONFIG_MCA is not set
 # CONFIG_SBUS is not set
 CONFIG_ARC32=y
+CONFIG_BOARD_SCACHE=y
 CONFIG_PC_KEYB=y
 CONFIG_SGI=y
+CONFIG_NEW_IRQ=y
+CONFIG_OLD_TIME_C=y
 # CONFIG_ISA is not set
 # CONFIG_EISA is not set
 # CONFIG_PCI is not set
+# CONFIG_I8259 is not set
 
 #
 # Loadable module support
@@ -41,14 +59,20 @@
 #
 # CONFIG_CPU_R3000 is not set
 # CONFIG_CPU_R6000 is not set
+# CONFIG_CPU_VR41XX is not set
 # CONFIG_CPU_R4300 is not set
 # CONFIG_CPU_R4X00 is not set
 CONFIG_CPU_R5000=y
+# CONFIG_CPU_R5432 is not set
+# CONFIG_CPU_RM7000 is not set
 # CONFIG_CPU_NEVADA is not set
-# CONFIG_CPU_R8000 is not set
 # CONFIG_CPU_R10000 is not set
+# CONFIG_CPU_SB1 is not set
+# CONFIG_CPU_MIPS32 is not set
+# CONFIG_CPU_MIPS64 is not set
 # CONFIG_CPU_ADVANCED is not set
 CONFIG_CPU_HAS_LLSC=y
+CONFIG_CPU_HAS_LLDSCD=y
 # CONFIG_CPU_HAS_WB is not set
 
 #
@@ -59,24 +83,26 @@
 CONFIG_ELF_KERNEL=y
 CONFIG_BINFMT_IRIX=y
 CONFIG_FORWARD_KEYBOARD=y
+# CONFIG_ARC_CONSOLE is not set
 # CONFIG_BINFMT_AOUT is not set
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 CONFIG_NET=y
+# CONFIG_HOTPLUG is not set
+# CONFIG_PCMCIA is not set
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
 
 #
-# Parallel port support
+# Memory Technology Devices (MTD)
 #
-# CONFIG_PARPORT is not set
-# CONFIG_PCMCIA is not set
+# CONFIG_MTD is not set
 
 #
-# Memory Technology Devices (MTD)
+# Parallel port support
 #
-# CONFIG_MTD is not set
+# CONFIG_PARPORT is not set
 
 #
 # Block devices
@@ -107,19 +133,24 @@
 # Networking options
 #
 CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK is not set
+CONFIG_PACKET_MMAP=y
+CONFIG_NETLINK=y
+CONFIG_RTNETLINK=y
+CONFIG_NETLINK_DEV=y
 # CONFIG_NETFILTER is not set
 # CONFIG_FILTER is not set
 CONFIG_UNIX=y
 CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
+CONFIG_IP_MULTICAST=y
 # CONFIG_IP_ADVANCED_ROUTER is not set
 CONFIG_IP_PNP=y
+# CONFIG_IP_PNP_DHCP is not set
 CONFIG_IP_PNP_BOOTP=y
 # CONFIG_IP_PNP_RARP is not set
 # CONFIG_NET_IPIP is not set
 # CONFIG_NET_IPGRE is not set
+# CONFIG_IP_MROUTE is not set
+# CONFIG_ARPD is not set
 # CONFIG_INET_ECN is not set
 # CONFIG_SYN_COOKIES is not set
 # CONFIG_IPV6 is not set
@@ -148,6 +179,13 @@
 # CONFIG_NET_SCHED is not set
 
 #
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+# CONFIG_PHONE_IXJ is not set
+# CONFIG_PHONE_IXJ_PCMCIA is not set
+
+#
 # SCSI support
 #
 CONFIG_SCSI=y
@@ -175,7 +213,7 @@
 #
 # SCSI low-level drivers
 #
-CONFIG_SCSI_SGIWD93=y
+CONFIG_SGIWD93_SCSI=y
 # CONFIG_SCSI_7000FASST is not set
 # CONFIG_SCSI_ACARD is not set
 # CONFIG_SCSI_AHA152X is not set
@@ -183,6 +221,7 @@
 # CONFIG_SCSI_AHA1740 is not set
 # CONFIG_SCSI_AIC7XXX is not set
 # CONFIG_SCSI_AIC7XXX_OLD is not set
+# CONFIG_SCSI_DPT_I2O is not set
 # CONFIG_SCSI_ADVANSYS is not set
 # CONFIG_SCSI_IN2000 is not set
 # CONFIG_SCSI_AM53C974 is not set
@@ -199,6 +238,7 @@
 # CONFIG_SCSI_INITIO is not set
 # CONFIG_SCSI_INIA100 is not set
 # CONFIG_SCSI_NCR53C406A is not set
+# CONFIG_SCSI_NCR_D700 is not set
 # CONFIG_SCSI_NCR53C7xx is not set
 # CONFIG_SCSI_PAS16 is not set
 # CONFIG_SCSI_PCI2000 is not set
@@ -215,20 +255,159 @@
 # Network device support
 #
 CONFIG_NETDEVICES=y
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
 # CONFIG_DUMMY is not set
-# CONFIG_SLIP is not set
-# CONFIG_PPP is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+# CONFIG_ETHERTAP is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+# CONFIG_SUNLANCE is not set
+# CONFIG_SUNBMAC is not set
+# CONFIG_SUNQE is not set
+# CONFIG_SUNLANCE is not set
+# CONFIG_SUNGEM is not set
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_LANCE is not set
+# CONFIG_NET_VENDOR_SMC is not set
+# CONFIG_NET_VENDOR_RACAL is not set
+# CONFIG_NET_ISA is not set
+# CONFIG_NET_PCI is not set
+# CONFIG_NET_POCKET is not set
 CONFIG_SGISEEQ=y
 
 #
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_MYRI_SBUS is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_SK98LIN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PLIP is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+# CONFIG_NET_FC is not set
+# CONFIG_RCPCI is not set
+# CONFIG_SHAPER is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+
+#
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# IrDA (infrared) support
+#
+# CONFIG_IRDA is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Old CD-ROM drivers (not SCSI, not IDE)
+#
+# CONFIG_CD_NO_IDESCSI is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+# CONFIG_SERIAL is not set
+# CONFIG_SERIAL_EXTENDED is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Mice
+#
+# CONFIG_BUSMOUSE is not set
+# CONFIG_MOUSE is not set
+
+#
+# Joysticks
+#
+# CONFIG_INPUT_GAMEPORT is not set
+
+#
+# Input core support is needed for gameports
+#
+
+#
+# Input core support is needed for joysticks
+#
+# CONFIG_QIC02_TAPE is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_INTEL_RNG is not set
+# CONFIG_NVRAM is not set
+# CONFIG_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+# CONFIG_SONYPI is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_FTAPE is not set
+# CONFIG_AGP is not set
+# CONFIG_DRM is not set
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
 # SGI Character devices
 #
 CONFIG_VT=y
 CONFIG_VT_CONSOLE=y
 CONFIG_SGI_NEWPORT_CONSOLE=y
 CONFIG_FONT_8x16=y
-# CONFIG_SGI_PROM_CONSOLE is not set
-# CONFIG_UNIX98_PTYS is not set
+# CONFIG_PSMOUSE is not set
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
 
 #
 # File systems
@@ -238,22 +417,30 @@
 CONFIG_AUTOFS4_FS=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
 # CONFIG_ADFS_FS is not set
 # CONFIG_ADFS_FS_RW is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
 # CONFIG_BFS_FS is not set
+# CONFIG_CMS_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_JBD_DEBUG is not set
 # CONFIG_FAT_FS is not set
 # CONFIG_MSDOS_FS is not set
 # CONFIG_UMSDOS_FS is not set
 # CONFIG_VFAT_FS is not set
 # CONFIG_EFS_FS is not set
 # CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
 # CONFIG_CRAMFS is not set
+# CONFIG_TMPFS is not set
 # CONFIG_RAMFS is not set
 CONFIG_ISO9660_FS=y
 # CONFIG_JOLIET is not set
 # CONFIG_MINIX_FS is not set
+# CONFIG_FREEVXFS_FS is not set
 # CONFIG_NTFS_FS is not set
 # CONFIG_NTFS_RW is not set
 # CONFIG_HPFS_FS is not set
@@ -261,13 +448,12 @@
 # CONFIG_DEVFS_FS is not set
 # CONFIG_DEVFS_MOUNT is not set
 # CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS is not set
+CONFIG_DEVPTS_FS=y
 # CONFIG_QNX4FS_FS is not set
 # CONFIG_QNX4FS_RW is not set
 # CONFIG_ROMFS_FS is not set
 CONFIG_EXT2_FS=y
 # CONFIG_SYSV_FS is not set
-# CONFIG_SYSV_FS_WRITE is not set
 # CONFIG_UDF_FS is not set
 # CONFIG_UDF_RW is not set
 # CONFIG_UFS_FS is not set
@@ -277,6 +463,7 @@
 # Network File Systems
 #
 # CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
 CONFIG_NFS_FS=y
 # CONFIG_NFS_V3 is not set
 CONFIG_ROOT_NFS=y
@@ -309,6 +496,7 @@
 # CONFIG_MINIX_SUBPARTITION is not set
 # CONFIG_SOLARIS_X86_PARTITION is not set
 # CONFIG_UNIXWARE_DISKLABEL is not set
+# CONFIG_LDM_PARTITION is not set
 CONFIG_SGI_PARTITION=y
 # CONFIG_ULTRIX_PARTITION is not set
 # CONFIG_SUN_PARTITION is not set
@@ -319,7 +507,7 @@
 # Console drivers
 #
 # CONFIG_VGA_CONSOLE is not set
-# CONFIG_FB is not set
+# CONFIG_MDA_CONSOLE is not set
 
 #
 # Frame-buffer support
@@ -345,13 +533,111 @@
 # CONFIG_USB is not set
 
 #
+# USB Controllers
+#
+# CONFIG_USB_UHCI is not set
+# CONFIG_USB_UHCI_ALT is not set
+# CONFIG_USB_OHCI is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_BLUETOOTH is not set
+# CONFIG_USB_STORAGE is not set
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+
+#
+# USB Human Interface Devices (HID)
+#
+
+#
+#   Input core support is needed for USB HID
+#
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_DC2XX is not set
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_SCANNER is not set
+# CONFIG_USB_MICROTEK is not set
+# CONFIG_USB_HPUSBSCSI is not set
+
+#
+# USB Multimedia devices
+#
+
+#
+#   Video4Linux support is needed for USB Multimedia device support
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# USB Network adaptors
+#
+# CONFIG_USB_PLUSB is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_CDCETHER is not set
+# CONFIG_USB_USBNET is not set
+
+#
+# USB port drivers
+#
+# CONFIG_USB_USS720 is not set
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+# CONFIG_USB_SERIAL_GENERIC is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+
+#
+# Miscellaneous USB drivers
+#
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_ID75 is not set
+
+#
 # Input core support
 #
 # CONFIG_INPUT is not set
+# CONFIG_INPUT_KEYBDEV is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
 
 #
 # Kernel hacking
 #
 CONFIG_CROSSCOMPILE=y
-# CONFIG_MIPS_FPE_MODULE is not set
 # CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_MIPS_UNCACHED is not set
diff -u --recursive --new-file v2.4.9/linux/arch/mips/defconfig-it8172 linux/arch/mips/defconfig-it8172
--- v2.4.9/linux/arch/mips/defconfig-it8172	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/defconfig-it8172	Sun Sep  9 10:43:02 2001
@@ -25,6 +25,7 @@
 # CONFIG_MIPS_MAGNUM_4000 is not set
 # CONFIG_MOMENCO_OCELOT is not set
 # CONFIG_DDB5476 is not set
+# CONFIG_DDB5477 is not set
 # CONFIG_OLIVETTI_M700 is not set
 # CONFIG_SGI_IP22 is not set
 # CONFIG_SNI_RM200_PCI is not set
@@ -35,11 +36,16 @@
 # CONFIG_IT8172_SCR0 is not set
 # CONFIG_IT8172_SCR1 is not set
 # CONFIG_MIPS_IVR is not set
+# CONFIG_MIPS_PB1000 is not set
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
 # CONFIG_MCA is not set
 # CONFIG_SBUS is not set
 CONFIG_PCI=y
 CONFIG_IT8712=y
 CONFIG_PC_KEYB=y
+CONFIG_NEW_PCI=y
+CONFIG_PCI_AUTO=y
 # CONFIG_ISA is not set
 # CONFIG_EISA is not set
 # CONFIG_I8259 is not set
@@ -55,26 +61,27 @@
 # CPU selection
 #
 # CONFIG_CPU_R3000 is not set
-# CONFIG_CPU_R3912 is not set
 # CONFIG_CPU_R6000 is not set
+# CONFIG_CPU_VR41XX is not set
 # CONFIG_CPU_R4300 is not set
 # CONFIG_CPU_R4X00 is not set
 # CONFIG_CPU_R5000 is not set
 # CONFIG_CPU_R5432 is not set
 # CONFIG_CPU_RM7000 is not set
 CONFIG_CPU_NEVADA=y
-# CONFIG_CPU_R8000 is not set
 # CONFIG_CPU_R10000 is not set
+# CONFIG_CPU_SB1 is not set
 # CONFIG_CPU_MIPS32 is not set
+# CONFIG_CPU_MIPS64 is not set
 # CONFIG_CPU_ADVANCED is not set
 CONFIG_CPU_HAS_LLSC=y
+CONFIG_CPU_HAS_LLDSCD=y
 # CONFIG_CPU_HAS_WB is not set
 
 #
 # General setup
 #
 CONFIG_CPU_LITTLE_ENDIAN=y
-CONFIG_MIPS_FPU_EMULATOR=y
 CONFIG_KCORE_ELF=y
 CONFIG_ELF_KERNEL=y
 # CONFIG_BINFMT_AOUT is not set
@@ -82,68 +89,87 @@
 # CONFIG_BINFMT_MISC is not set
 CONFIG_NET=y
 CONFIG_PCI_NAMES=y
+# CONFIG_HOTPLUG is not set
+# CONFIG_PCMCIA is not set
 CONFIG_SYSVIPC=y
 CONFIG_BSD_PROCESS_ACCT=y
 CONFIG_SYSCTL=y
 
 #
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-# CONFIG_PCMCIA is not set
-
-#
 # Memory Technology Devices (MTD)
 #
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_PARTITIONS is not set
+# CONFIG_MTD_REDBOOT_PARTS is not set
+# CONFIG_MTD_BOOTLDR_PARTS is not set
 
 #
-# Disk-On-Chip Device Drivers
-#
-# CONFIG_MTD_DOC1000 is not set
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOCPROBE is not set
-
+# User Modules And Translation Layers
 #
-# RAM/ROM Device Drivers
-#
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_MTDRAM is not set
+CONFIG_MTD_CHAR=y
+# CONFIG_MTD_BLOCK is not set
+# CONFIG_MTD_BLOCK_RO is not set
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
 
 #
-# Linearly Mapped Flash Device Drivers
+# RAM/ROM/Flash chip drivers
 #
 CONFIG_MTD_CFI=y
+# CONFIG_MTD_CFI_VIRTUAL_ER is not set
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
 CONFIG_MTD_CFI_INTELEXT=y
 # CONFIG_MTD_CFI_AMDSTD is not set
+# CONFIG_MTD_AMDSTD is not set
+# CONFIG_MTD_SHARP is not set
 # CONFIG_MTD_RAM is not set
 # CONFIG_MTD_ROM is not set
 # CONFIG_MTD_JEDEC is not set
+
+#
+# Mapping drivers for chip access
+#
 CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_PHYSMAP_START=8000000
 CONFIG_MTD_PHYSMAP_LEN=2000000
 CONFIG_MTD_PHYSMAP_BUSWIDTH=4
-
-#
-# Drivers for chip mappings
-#
-# CONFIG_MTD_MIXMEM is not set
-# CONFIG_MTD_NORA is not set
-# CONFIG_MTD_OCTAGON is not set
 # CONFIG_MTD_PNC2000 is not set
 # CONFIG_MTD_RPXLITE is not set
+# CONFIG_MTD_SBC_GXX is not set
+# CONFIG_MTD_ELAN_104NC is not set
+# CONFIG_MTD_DBOX2 is not set
+# CONFIG_MTD_CSTM_MIPS_IXX is not set
+# CONFIG_MTD_CFI_FLAGADM is not set
+# CONFIG_MTD_MIXMEM is not set
+# CONFIG_MTD_OCTAGON is not set
 # CONFIG_MTD_VMAX is not set
+# CONFIG_MTD_OCELOT is not set
 
 #
-# User modules and translation layers for MTD devices
+# Self-contained MTD device drivers
 #
-CONFIG_MTD_CHAR=y
-# CONFIG_MTD_BLOCK is not set
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
+# CONFIG_MTD_PMC551 is not set
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC1000 is not set
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOCPROBE is not set
+
+#
+# NAND Flash Device Drivers
+#
+# CONFIG_MTD_NAND is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
 
 #
 # Block devices
@@ -182,6 +208,7 @@
 # CONFIG_IP_MULTICAST is not set
 # CONFIG_IP_ADVANCED_ROUTER is not set
 CONFIG_IP_PNP=y
+# CONFIG_IP_PNP_DHCP is not set
 CONFIG_IP_PNP_BOOTP=y
 # CONFIG_IP_PNP_RARP is not set
 # CONFIG_NET_IPIP is not set
@@ -218,6 +245,7 @@
 #
 # CONFIG_PHONE is not set
 # CONFIG_PHONE_IXJ is not set
+# CONFIG_PHONE_IXJ_PCMCIA is not set
 
 #
 # ATA/IDE/MFM/RLL support
@@ -261,6 +289,7 @@
 CONFIG_BLK_DEV_IDEPCI=y
 CONFIG_IDEPCI_SHARE_IRQ=y
 CONFIG_BLK_DEV_IDEDMA_PCI=y
+CONFIG_BLK_DEV_ADMA=y
 # CONFIG_BLK_DEV_OFFBOARD is not set
 CONFIG_IDEDMA_PCI_AUTO=y
 CONFIG_BLK_DEV_IDEDMA=y
@@ -270,8 +299,8 @@
 # CONFIG_AEC62XX_TUNING is not set
 # CONFIG_BLK_DEV_ALI15X3 is not set
 # CONFIG_WDC_ALI15X3 is not set
-# CONFIG_BLK_DEV_AMD7409 is not set
-# CONFIG_AMD7409_OVERRIDE is not set
+# CONFIG_BLK_DEV_AMD74XX is not set
+# CONFIG_AMD74XX_OVERRIDE is not set
 # CONFIG_BLK_DEV_CMD64X is not set
 # CONFIG_BLK_DEV_CY82C693 is not set
 # CONFIG_BLK_DEV_CS5530 is not set
@@ -280,11 +309,14 @@
 # CONFIG_BLK_DEV_HPT366 is not set
 CONFIG_BLK_DEV_IT8172=y
 CONFIG_IT8172_TUNING=y
+CONFIG_BLK_DEV_IT8172=y
+CONFIG_IT8172_TUNING=y
 # CONFIG_BLK_DEV_NS87415 is not set
 # CONFIG_BLK_DEV_OPTI621 is not set
 # CONFIG_BLK_DEV_PDC202XX is not set
 # CONFIG_PDC202XX_BURST is not set
-# CONFIG_BLK_DEV_OSB4 is not set
+# CONFIG_PDC202XX_FORCE is not set
+# CONFIG_BLK_DEV_SVWKS is not set
 # CONFIG_BLK_DEV_SIS5513 is not set
 # CONFIG_BLK_DEV_SLC90E66 is not set
 # CONFIG_BLK_DEV_TRM290 is not set
@@ -299,12 +331,15 @@
 # CONFIG_BLK_DEV_DTC2278 is not set
 # CONFIG_BLK_DEV_HT6560B is not set
 # CONFIG_BLK_DEV_PDC4030 is not set
-# CONFIG_BLK_DEV_QD6580 is not set
+# CONFIG_BLK_DEV_QD65XX is not set
 # CONFIG_BLK_DEV_UMC8672 is not set
 CONFIG_IDEDMA_AUTO=y
 # CONFIG_IDEDMA_IVB is not set
 # CONFIG_DMA_NONPCI is not set
 CONFIG_BLK_DEV_IDE_MODES=y
+# CONFIG_BLK_DEV_ATARAID is not set
+# CONFIG_BLK_DEV_ATARAID_PDC is not set
+# CONFIG_BLK_DEV_ATARAID_HPT is not set
 
 #
 # SCSI support
@@ -312,16 +347,6 @@
 # CONFIG_SCSI is not set
 
 #
-# I2O device support
-#
-# CONFIG_I2O is not set
-# CONFIG_I2O_PCI is not set
-# CONFIG_I2O_BLOCK is not set
-# CONFIG_I2O_LAN is not set
-# CONFIG_I2O_SCSI is not set
-# CONFIG_I2O_PROC is not set
-
-#
 # Network device support
 #
 CONFIG_NETDEVICES=y
@@ -334,18 +359,21 @@
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
-# CONFIG_NET_SB1000 is not set
 
 #
 # Ethernet (10 or 100Mbit)
 #
 CONFIG_NET_ETHERNET=y
+# CONFIG_SUNLANCE is not set
+# CONFIG_HAPPYMEAL is not set
+# CONFIG_SUNBMAC is not set
+# CONFIG_SUNQE is not set
+# CONFIG_SUNLANCE is not set
+# CONFIG_SUNGEM is not set
 # CONFIG_NET_VENDOR_3COM is not set
 # CONFIG_LANCE is not set
 # CONFIG_NET_VENDOR_SMC is not set
 # CONFIG_NET_VENDOR_RACAL is not set
-# CONFIG_AT1700 is not set
-# CONFIG_DEPCA is not set
 # CONFIG_HP100 is not set
 # CONFIG_NET_ISA is not set
 CONFIG_NET_PCI=y
@@ -354,25 +382,28 @@
 # CONFIG_APRICOT is not set
 # CONFIG_CS89x0 is not set
 CONFIG_TULIP=y
+# CONFIG_TULIP_MWI is not set
+# CONFIG_TULIP_MMIO is not set
 # CONFIG_DE4X5 is not set
 # CONFIG_DGRS is not set
 # CONFIG_DM9102 is not set
 # CONFIG_EEPRO100 is not set
-# CONFIG_EEPRO100_PM is not set
 # CONFIG_LNE390 is not set
+# CONFIG_FEALNX is not set
 # CONFIG_NATSEMI is not set
 # CONFIG_NE2K_PCI is not set
 # CONFIG_NE3210 is not set
 # CONFIG_ES3210 is not set
 CONFIG_8139TOO=y
-# CONFIG_RTL8129 is not set
+# CONFIG_8139TOO_PIO is not set
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+# CONFIG_8139TOO_8129 is not set
 # CONFIG_SIS900 is not set
 # CONFIG_EPIC100 is not set
 # CONFIG_SUNDANCE is not set
 # CONFIG_TLAN is not set
 # CONFIG_VIA_RHINE is not set
 # CONFIG_WINBOND_840 is not set
-# CONFIG_HAPPYMEAL is not set
 # CONFIG_LAN_SAA9730 is not set
 # CONFIG_NET_POCKET is not set
 
@@ -380,11 +411,15 @@
 # Ethernet (1000 Mbit)
 #
 # CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_MYRI_SBUS is not set
+# CONFIG_NS83820 is not set
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
 # CONFIG_SK98LIN is not set
 # CONFIG_FDDI is not set
 # CONFIG_HIPPI is not set
+# CONFIG_PLIP is not set
 # CONFIG_PPP is not set
 # CONFIG_SLIP is not set
 
@@ -407,6 +442,16 @@
 # CONFIG_WAN is not set
 
 #
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# IrDA (infrared) support
+#
+# CONFIG_IRDA is not set
+
+#
 # ISDN subsystem
 #
 # CONFIG_ISDN is not set
@@ -424,7 +469,12 @@
 CONFIG_SERIAL_CONSOLE=y
 # CONFIG_SERIAL_EXTENDED is not set
 # CONFIG_SERIAL_NONSTANDARD is not set
-# CONFIG_UNIX98_PTYS is not set
+CONFIG_QTRONIX_KEYBOARD=y
+CONFIG_IT8172_CIR=y
+# CONFIG_IT8172_SCR0 is not set
+# CONFIG_IT8172_SCR1 is not set
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
 
 #
 # I2C support
@@ -440,7 +490,11 @@
 #
 # Joysticks
 #
-# CONFIG_JOYSTICK is not set
+# CONFIG_INPUT_GAMEPORT is not set
+
+#
+# Input core support is needed for gameports
+#
 
 #
 # Input core support is needed for joysticks
@@ -457,6 +511,7 @@
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 # CONFIG_APPLICOM is not set
+# CONFIG_SONYPI is not set
 
 #
 # Ftape, the floppy tape device driver
@@ -464,6 +519,7 @@
 # CONFIG_FTAPE is not set
 # CONFIG_AGP is not set
 # CONFIG_DRM is not set
+# CONFIG_ITE_GPIO is not set
 
 #
 # Multimedia devices
@@ -478,22 +534,30 @@
 # CONFIG_AUTOFS4_FS is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
 # CONFIG_ADFS_FS is not set
 # CONFIG_ADFS_FS_RW is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
 # CONFIG_BFS_FS is not set
+# CONFIG_CMS_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_JBD_DEBUG is not set
 # CONFIG_FAT_FS is not set
 # CONFIG_MSDOS_FS is not set
 # CONFIG_UMSDOS_FS is not set
 # CONFIG_VFAT_FS is not set
 # CONFIG_EFS_FS is not set
 # CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
 # CONFIG_CRAMFS is not set
+# CONFIG_TMPFS is not set
 # CONFIG_RAMFS is not set
 # CONFIG_ISO9660_FS is not set
 # CONFIG_JOLIET is not set
 # CONFIG_MINIX_FS is not set
+# CONFIG_FREEVXFS_FS is not set
 # CONFIG_NTFS_FS is not set
 # CONFIG_NTFS_RW is not set
 # CONFIG_HPFS_FS is not set
@@ -501,13 +565,12 @@
 # CONFIG_DEVFS_FS is not set
 # CONFIG_DEVFS_MOUNT is not set
 # CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS is not set
+CONFIG_DEVPTS_FS=y
 # CONFIG_QNX4FS_FS is not set
 # CONFIG_QNX4FS_RW is not set
 # CONFIG_ROMFS_FS is not set
 CONFIG_EXT2_FS=y
 # CONFIG_SYSV_FS is not set
-# CONFIG_SYSV_FS_WRITE is not set
 # CONFIG_UDF_FS is not set
 # CONFIG_UDF_RW is not set
 # CONFIG_UFS_FS is not set
@@ -517,6 +580,7 @@
 # Network File Systems
 #
 # CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
 CONFIG_NFS_FS=y
 # CONFIG_NFS_V3 is not set
 CONFIG_ROOT_NFS=y
@@ -554,16 +618,114 @@
 # CONFIG_USB is not set
 
 #
+# USB Controllers
+#
+# CONFIG_USB_UHCI is not set
+# CONFIG_USB_UHCI_ALT is not set
+# CONFIG_USB_OHCI is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_BLUETOOTH is not set
+# CONFIG_USB_STORAGE is not set
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+
+#
+# USB Human Interface Devices (HID)
+#
+
+#
+#   Input core support is needed for USB HID
+#
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_DC2XX is not set
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_SCANNER is not set
+# CONFIG_USB_MICROTEK is not set
+# CONFIG_USB_HPUSBSCSI is not set
+
+#
+# USB Multimedia devices
+#
+
+#
+#   Video4Linux support is needed for USB Multimedia device support
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# USB Network adaptors
+#
+# CONFIG_USB_PLUSB is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_CDCETHER is not set
+# CONFIG_USB_USBNET is not set
+
+#
+# USB port drivers
+#
+# CONFIG_USB_USS720 is not set
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+# CONFIG_USB_SERIAL_GENERIC is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+
+#
+# Miscellaneous USB drivers
+#
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_ID75 is not set
+
+#
 # Input core support
 #
 # CONFIG_INPUT is not set
+# CONFIG_INPUT_KEYBDEV is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
 
 #
 # Kernel hacking
 #
 CONFIG_CROSSCOMPILE=y
-# CONFIG_MIPS_FPE_MODULE is not set
 # CONFIG_REMOTE_DEBUG is not set
+# CONFIG_GDB_CONSOLE is not set
 # CONFIG_LL_DEBUG is not set
 # CONFIG_MAGIC_SYSRQ is not set
 # CONFIG_MIPS_UNCACHED is not set
diff -u --recursive --new-file v2.4.9/linux/arch/mips/defconfig-malta linux/arch/mips/defconfig-malta
--- v2.4.9/linux/arch/mips/defconfig-malta	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/defconfig-malta	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,630 @@
+#
+# Automatically generated make config: don't edit
+#
+CONFIG_MIPS=y
+# CONFIG_SMP is not set
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+
+#
+# Machine selection
+#
+# CONFIG_ACER_PICA_61 is not set
+# CONFIG_ALGOR_P4032 is not set
+# CONFIG_BAGET_MIPS is not set
+# CONFIG_DECSTATION is not set
+# CONFIG_DDB5074 is not set
+# CONFIG_MIPS_EV96100 is not set
+# CONFIG_MIPS_EV64120 is not set
+# CONFIG_MIPS_ATLAS is not set
+CONFIG_MIPS_MALTA=y
+# CONFIG_NINO is not set
+# CONFIG_MIPS_MAGNUM_4000 is not set
+# CONFIG_MOMENCO_OCELOT is not set
+# CONFIG_DDB5476 is not set
+# CONFIG_DDB5477 is not set
+# CONFIG_OLIVETTI_M700 is not set
+# CONFIG_SGI_IP22 is not set
+# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_MIPS_ITE8172 is not set
+# CONFIG_MIPS_IVR is not set
+# CONFIG_MIPS_PB1000 is not set
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+# CONFIG_MCA is not set
+# CONFIG_SBUS is not set
+CONFIG_I8259=y
+CONFIG_PCI=y
+CONFIG_HAVE_STD_PC_SERIAL_PORT=y
+CONFIG_NEW_IRQ=y
+CONFIG_SWAP_IO_SPACE=y
+# CONFIG_ISA is not set
+# CONFIG_EISA is not set
+
+#
+# Loadable module support
+#
+# CONFIG_MODULES is not set
+
+#
+# CPU selection
+#
+# CONFIG_CPU_R3000 is not set
+# CONFIG_CPU_R6000 is not set
+# CONFIG_CPU_VR41XX is not set
+# CONFIG_CPU_R4300 is not set
+# CONFIG_CPU_R4X00 is not set
+# CONFIG_CPU_R5000 is not set
+# CONFIG_CPU_R5432 is not set
+# CONFIG_CPU_RM7000 is not set
+# CONFIG_CPU_NEVADA is not set
+# CONFIG_CPU_R10000 is not set
+# CONFIG_CPU_SB1 is not set
+CONFIG_CPU_MIPS32=y
+# CONFIG_CPU_MIPS64 is not set
+# CONFIG_CPU_ADVANCED is not set
+CONFIG_CPU_HAS_LLSC=y
+# CONFIG_CPU_HAS_LLDSCD is not set
+# CONFIG_CPU_HAS_WB is not set
+
+#
+# General setup
+#
+CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_KCORE_ELF=y
+CONFIG_ELF_KERNEL=y
+# CONFIG_BINFMT_AOUT is not set
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_MISC is not set
+CONFIG_NET=y
+# CONFIG_PCI_NAMES is not set
+# CONFIG_HOTPLUG is not set
+# CONFIG_PCMCIA is not set
+CONFIG_SYSVIPC=y
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_SYSCTL is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Block devices
+#
+CONFIG_BLK_DEV_FD=y
+# CONFIG_BLK_DEV_XD is not set
+# CONFIG_PARIDE is not set
+# CONFIG_BLK_CPQ_DA is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_LOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=4096
+# CONFIG_BLK_DEV_INITRD is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+# CONFIG_BLK_DEV_MD is not set
+# CONFIG_MD_LINEAR is not set
+# CONFIG_MD_RAID0 is not set
+# CONFIG_MD_RAID1 is not set
+# CONFIG_MD_RAID5 is not set
+# CONFIG_BLK_DEV_LVM is not set
+
+#
+# Networking options
+#
+# CONFIG_PACKET is not set
+# CONFIG_NETLINK is not set
+# CONFIG_NETFILTER is not set
+# CONFIG_FILTER is not set
+CONFIG_UNIX=y
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_PNP=y
+# CONFIG_IP_PNP_DHCP is not set
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_INET_ECN is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_IPV6 is not set
+# CONFIG_KHTTPD is not set
+# CONFIG_ATM is not set
+
+#
+#  
+#
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_DECNET is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_LLC is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_FASTROUTE is not set
+# CONFIG_NET_HW_FLOWCONTROL is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+# CONFIG_PHONE_IXJ is not set
+# CONFIG_PHONE_IXJ_PCMCIA is not set
+
+#
+# ATA/IDE/MFM/RLL support
+#
+# CONFIG_IDE is not set
+# CONFIG_BLK_DEV_IDE_MODES is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI support
+#
+CONFIG_SCSI=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+CONFIG_SD_EXTRA_DEVS=40
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_CHR_DEV_OSST is not set
+# CONFIG_BLK_DEV_SR is not set
+# CONFIG_CHR_DEV_SG is not set
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_DEBUG_QUEUES is not set
+# CONFIG_SCSI_MULTI_LUN is not set
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
+# CONFIG_SCSI_7000FASST is not set
+# CONFIG_SCSI_ACARD is not set
+# CONFIG_SCSI_AHA152X is not set
+# CONFIG_SCSI_AHA1542 is not set
+# CONFIG_SCSI_AHA1740 is not set
+# CONFIG_SCSI_AIC7XXX is not set
+# CONFIG_SCSI_AIC7XXX_OLD is not set
+# CONFIG_SCSI_DPT_I2O is not set
+# CONFIG_SCSI_ADVANSYS is not set
+# CONFIG_SCSI_IN2000 is not set
+# CONFIG_SCSI_AM53C974 is not set
+# CONFIG_SCSI_MEGARAID is not set
+# CONFIG_SCSI_BUSLOGIC is not set
+# CONFIG_SCSI_CPQFCTS is not set
+# CONFIG_SCSI_DMX3191D is not set
+# CONFIG_SCSI_DTC3280 is not set
+# CONFIG_SCSI_EATA is not set
+# CONFIG_SCSI_EATA_DMA is not set
+# CONFIG_SCSI_EATA_PIO is not set
+# CONFIG_SCSI_FUTURE_DOMAIN is not set
+# CONFIG_SCSI_GDTH is not set
+# CONFIG_SCSI_GENERIC_NCR5380 is not set
+# CONFIG_SCSI_INITIO is not set
+# CONFIG_SCSI_INIA100 is not set
+# CONFIG_SCSI_NCR53C406A is not set
+# CONFIG_SCSI_NCR_D700 is not set
+# CONFIG_SCSI_NCR53C7xx is not set
+# CONFIG_SCSI_NCR53C8XX is not set
+# CONFIG_SCSI_SYM53C8XX is not set
+# CONFIG_SCSI_PAS16 is not set
+# CONFIG_SCSI_PCI2000 is not set
+# CONFIG_SCSI_PCI2220I is not set
+# CONFIG_SCSI_PSI240I is not set
+# CONFIG_SCSI_QLOGIC_FAS is not set
+# CONFIG_SCSI_QLOGIC_ISP is not set
+# CONFIG_SCSI_QLOGIC_FC is not set
+# CONFIG_SCSI_QLOGIC_1280 is not set
+# CONFIG_SCSI_SIM710 is not set
+# CONFIG_SCSI_SYM53C416 is not set
+# CONFIG_SCSI_DC390T is not set
+# CONFIG_SCSI_T128 is not set
+# CONFIG_SCSI_U14_34F is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# Network device support
+#
+CONFIG_NETDEVICES=y
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+# CONFIG_SUNLANCE is not set
+# CONFIG_HAPPYMEAL is not set
+# CONFIG_SUNBMAC is not set
+# CONFIG_SUNQE is not set
+# CONFIG_SUNLANCE is not set
+# CONFIG_SUNGEM is not set
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_LANCE is not set
+# CONFIG_NET_VENDOR_SMC is not set
+# CONFIG_NET_VENDOR_RACAL is not set
+# CONFIG_HP100 is not set
+# CONFIG_NET_ISA is not set
+CONFIG_NET_PCI=y
+CONFIG_PCNET32=y
+# CONFIG_ADAPTEC_STARFIRE is not set
+# CONFIG_APRICOT is not set
+# CONFIG_CS89x0 is not set
+# CONFIG_TULIP is not set
+# CONFIG_DE4X5 is not set
+# CONFIG_DGRS is not set
+# CONFIG_DM9102 is not set
+# CONFIG_EEPRO100 is not set
+# CONFIG_LNE390 is not set
+# CONFIG_FEALNX is not set
+# CONFIG_NATSEMI is not set
+# CONFIG_NE2K_PCI is not set
+# CONFIG_NE3210 is not set
+# CONFIG_ES3210 is not set
+# CONFIG_8139TOO is not set
+# CONFIG_8139TOO_PIO is not set
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+# CONFIG_8139TOO_8129 is not set
+# CONFIG_SIS900 is not set
+# CONFIG_EPIC100 is not set
+# CONFIG_SUNDANCE is not set
+# CONFIG_TLAN is not set
+# CONFIG_VIA_RHINE is not set
+# CONFIG_WINBOND_840 is not set
+# CONFIG_LAN_SAA9730 is not set
+# CONFIG_NET_POCKET is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_MYRI_SBUS is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_SK98LIN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PLIP is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+# CONFIG_NET_FC is not set
+# CONFIG_RCPCI is not set
+# CONFIG_SHAPER is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+
+#
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# IrDA (infrared) support
+#
+# CONFIG_IRDA is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Old CD-ROM drivers (not SCSI, not IDE)
+#
+# CONFIG_CD_NO_IDESCSI is not set
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+CONFIG_SERIAL=y
+CONFIG_SERIAL_CONSOLE=y
+# CONFIG_SERIAL_EXTENDED is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Mice
+#
+# CONFIG_BUSMOUSE is not set
+# CONFIG_MOUSE is not set
+
+#
+# Joysticks
+#
+# CONFIG_INPUT_GAMEPORT is not set
+
+#
+# Input core support is needed for gameports
+#
+
+#
+# Input core support is needed for joysticks
+#
+# CONFIG_QIC02_TAPE is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_INTEL_RNG is not set
+# CONFIG_NVRAM is not set
+CONFIG_RTC=y
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+# CONFIG_SONYPI is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_FTAPE is not set
+# CONFIG_AGP is not set
+# CONFIG_DRM is not set
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# File systems
+#
+# CONFIG_QUOTA is not set
+CONFIG_AUTOFS_FS=y
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_ADFS_FS is not set
+# CONFIG_ADFS_FS_RW is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_CMS_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_JBD_DEBUG is not set
+# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_UMSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+CONFIG_EFS_FS=y
+# CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_TMPFS is not set
+# CONFIG_RAMFS is not set
+# CONFIG_ISO9660_FS is not set
+# CONFIG_JOLIET is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_FREEVXFS_FS is not set
+# CONFIG_NTFS_FS is not set
+# CONFIG_NTFS_RW is not set
+# CONFIG_HPFS_FS is not set
+CONFIG_PROC_FS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVFS_MOUNT is not set
+# CONFIG_DEVFS_DEBUG is not set
+CONFIG_DEVPTS_FS=y
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_QNX4FS_RW is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_EXT2_FS=y
+# CONFIG_SYSV_FS is not set
+# CONFIG_UDF_FS is not set
+# CONFIG_UDF_RW is not set
+# CONFIG_UFS_FS is not set
+# CONFIG_UFS_FS_WRITE is not set
+
+#
+# Network File Systems
+#
+# CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
+CONFIG_NFS_FS=y
+# CONFIG_NFS_V3 is not set
+CONFIG_ROOT_NFS=y
+# CONFIG_NFSD is not set
+# CONFIG_NFSD_V3 is not set
+CONFIG_SUNRPC=y
+CONFIG_LOCKD=y
+# CONFIG_SMB_FS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_NCPFS_PACKET_SIGNING is not set
+# CONFIG_NCPFS_IOCTL_LOCKING is not set
+# CONFIG_NCPFS_STRONG is not set
+# CONFIG_NCPFS_NFS_NS is not set
+# CONFIG_NCPFS_OS2_NS is not set
+# CONFIG_NCPFS_SMALLDOS is not set
+# CONFIG_NCPFS_NLS is not set
+# CONFIG_NCPFS_EXTRAS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+# CONFIG_SMB_NLS is not set
+# CONFIG_NLS is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB is not set
+
+#
+# USB Controllers
+#
+# CONFIG_USB_UHCI is not set
+# CONFIG_USB_UHCI_ALT is not set
+# CONFIG_USB_OHCI is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_BLUETOOTH is not set
+# CONFIG_USB_STORAGE is not set
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+
+#
+# USB Human Interface Devices (HID)
+#
+
+#
+#   Input core support is needed for USB HID
+#
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_DC2XX is not set
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_SCANNER is not set
+# CONFIG_USB_MICROTEK is not set
+# CONFIG_USB_HPUSBSCSI is not set
+
+#
+# USB Multimedia devices
+#
+
+#
+#   Video4Linux support is needed for USB Multimedia device support
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# USB Network adaptors
+#
+# CONFIG_USB_PLUSB is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_CDCETHER is not set
+# CONFIG_USB_USBNET is not set
+
+#
+# USB port drivers
+#
+# CONFIG_USB_USS720 is not set
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+# CONFIG_USB_SERIAL_GENERIC is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+
+#
+# Miscellaneous USB drivers
+#
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_ID75 is not set
+
+#
+# Input core support
+#
+# CONFIG_INPUT is not set
+# CONFIG_INPUT_KEYBDEV is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+
+#
+# Kernel hacking
+#
+CONFIG_CROSSCOMPILE=y
+# CONFIG_REMOTE_DEBUG is not set
+# CONFIG_GDB_CONSOLE is not set
+# CONFIG_LL_DEBUG is not set
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_MIPS_UNCACHED is not set
diff -u --recursive --new-file v2.4.9/linux/arch/mips/defconfig-nino linux/arch/mips/defconfig-nino
--- v2.4.9/linux/arch/mips/defconfig-nino	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/defconfig-nino	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,415 @@
+#
+# Automatically generated make config: don't edit
+#
+CONFIG_MIPS=y
+# CONFIG_SMP is not set
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+
+#
+# Machine selection
+#
+# CONFIG_ACER_PICA_61 is not set
+# CONFIG_ALGOR_P4032 is not set
+# CONFIG_BAGET_MIPS is not set
+# CONFIG_DECSTATION is not set
+# CONFIG_DDB5074 is not set
+# CONFIG_MIPS_EV96100 is not set
+# CONFIG_MIPS_EV64120 is not set
+# CONFIG_MIPS_ATLAS is not set
+# CONFIG_MIPS_MALTA is not set
+CONFIG_NINO=y
+# CONFIG_NINO_4MB is not set
+CONFIG_NINO_8MB=y
+# CONFIG_NINO_16MB is not set
+# CONFIG_MIPS_MAGNUM_4000 is not set
+# CONFIG_MOMENCO_OCELOT is not set
+# CONFIG_DDB5476 is not set
+# CONFIG_DDB5477 is not set
+# CONFIG_OLIVETTI_M700 is not set
+# CONFIG_SGI_IP22 is not set
+# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_MIPS_ITE8172 is not set
+# CONFIG_MIPS_IVR is not set
+# CONFIG_MIPS_PB1000 is not set
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+# CONFIG_MCA is not set
+# CONFIG_SBUS is not set
+CONFIG_PC_KEYB=y
+# CONFIG_ISA is not set
+# CONFIG_EISA is not set
+# CONFIG_PCI is not set
+# CONFIG_I8259 is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+# CONFIG_MODVERSIONS is not set
+CONFIG_KMOD=y
+
+#
+# CPU selection
+#
+CONFIG_CPU_R3000=y
+# CONFIG_CPU_R6000 is not set
+# CONFIG_CPU_VR41XX is not set
+# CONFIG_CPU_R4300 is not set
+# CONFIG_CPU_R4X00 is not set
+# CONFIG_CPU_R5000 is not set
+# CONFIG_CPU_R5432 is not set
+# CONFIG_CPU_RM7000 is not set
+# CONFIG_CPU_NEVADA is not set
+# CONFIG_CPU_R10000 is not set
+# CONFIG_CPU_SB1 is not set
+# CONFIG_CPU_MIPS32 is not set
+# CONFIG_CPU_MIPS64 is not set
+# CONFIG_CPU_ADVANCED is not set
+# CONFIG_CPU_HAS_LLSC is not set
+# CONFIG_CPU_HAS_LLDSCD is not set
+# CONFIG_CPU_HAS_WB is not set
+
+#
+# General setup
+#
+CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_KCORE_ELF=y
+CONFIG_ELF_KERNEL=y
+# CONFIG_BINFMT_AOUT is not set
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_MISC=y
+# CONFIG_NET is not set
+# CONFIG_HOTPLUG is not set
+# CONFIG_PCMCIA is not set
+CONFIG_SYSVIPC=y
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_SYSCTL is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_DEV_XD is not set
+# CONFIG_PARIDE is not set
+# CONFIG_BLK_CPQ_DA is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_LOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=2048
+CONFIG_BLK_DEV_INITRD=y
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+# CONFIG_BLK_DEV_MD is not set
+# CONFIG_MD_LINEAR is not set
+# CONFIG_MD_RAID0 is not set
+# CONFIG_MD_RAID1 is not set
+# CONFIG_MD_RAID5 is not set
+# CONFIG_BLK_DEV_LVM is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+# CONFIG_PHONE_IXJ is not set
+# CONFIG_PHONE_IXJ_PCMCIA is not set
+
+#
+# ATA/IDE/MFM/RLL support
+#
+# CONFIG_IDE is not set
+# CONFIG_BLK_DEV_IDE_MODES is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI support
+#
+# CONFIG_SCSI is not set
+
+#
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# ISDN subsystem
+#
+
+#
+# Old CD-ROM drivers (not SCSI, not IDE)
+#
+# CONFIG_CD_NO_IDESCSI is not set
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+# CONFIG_SERIAL is not set
+# CONFIG_SERIAL_EXTENDED is not set
+CONFIG_SERIAL_NONSTANDARD=y
+# CONFIG_COMPUTONE is not set
+# CONFIG_ROCKETPORT is not set
+# CONFIG_CYCLADES is not set
+# CONFIG_DIGIEPCA is not set
+# CONFIG_DIGI is not set
+# CONFIG_ESPSERIAL is not set
+# CONFIG_MOXA_INTELLIO is not set
+# CONFIG_MOXA_SMARTIO is not set
+# CONFIG_ISI is not set
+# CONFIG_SYNCLINK is not set
+# CONFIG_N_HDLC is not set
+# CONFIG_RISCOM8 is not set
+# CONFIG_SPECIALIX is not set
+# CONFIG_SX is not set
+# CONFIG_RIO is not set
+# CONFIG_STALDRV is not set
+CONFIG_SERIAL_TX3912=y
+CONFIG_SERIAL_TX3912_CONSOLE=y
+# CONFIG_AU1000_UART is not set
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Mice
+#
+# CONFIG_BUSMOUSE is not set
+# CONFIG_MOUSE is not set
+
+#
+# Joysticks
+#
+# CONFIG_INPUT_GAMEPORT is not set
+
+#
+# Input core support is needed for gameports
+#
+
+#
+# Input core support is needed for joysticks
+#
+# CONFIG_QIC02_TAPE is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_INTEL_RNG is not set
+# CONFIG_NVRAM is not set
+# CONFIG_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+# CONFIG_SONYPI is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_FTAPE is not set
+# CONFIG_AGP is not set
+# CONFIG_DRM is not set
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# File systems
+#
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_ADFS_FS is not set
+# CONFIG_ADFS_FS_RW is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_CMS_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_JBD_DEBUG is not set
+# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_UMSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_TMPFS is not set
+# CONFIG_RAMFS is not set
+# CONFIG_ISO9660_FS is not set
+# CONFIG_JOLIET is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_FREEVXFS_FS is not set
+# CONFIG_NTFS_FS is not set
+# CONFIG_NTFS_RW is not set
+# CONFIG_HPFS_FS is not set
+CONFIG_PROC_FS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVFS_MOUNT is not set
+# CONFIG_DEVFS_DEBUG is not set
+CONFIG_DEVPTS_FS=y
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_QNX4FS_RW is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_EXT2_FS=y
+# CONFIG_SYSV_FS is not set
+# CONFIG_UDF_FS is not set
+# CONFIG_UDF_RW is not set
+# CONFIG_UFS_FS is not set
+# CONFIG_UFS_FS_WRITE is not set
+# CONFIG_NCPFS_NLS is not set
+# CONFIG_SMB_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+# CONFIG_SMB_NLS is not set
+# CONFIG_NLS is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB is not set
+
+#
+# USB Controllers
+#
+# CONFIG_USB_UHCI is not set
+# CONFIG_USB_UHCI_ALT is not set
+# CONFIG_USB_OHCI is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_BLUETOOTH is not set
+# CONFIG_USB_STORAGE is not set
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+
+#
+# USB Human Interface Devices (HID)
+#
+
+#
+#   Input core support is needed for USB HID
+#
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_DC2XX is not set
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_SCANNER is not set
+# CONFIG_USB_MICROTEK is not set
+# CONFIG_USB_HPUSBSCSI is not set
+
+#
+# USB Multimedia devices
+#
+
+#
+#   Video4Linux support is needed for USB Multimedia device support
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# USB Network adaptors
+#
+
+#
+#   Networking support is needed for USB Networking device support
+#
+
+#
+# USB port drivers
+#
+# CONFIG_USB_USS720 is not set
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+# CONFIG_USB_SERIAL_GENERIC is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+
+#
+# Miscellaneous USB drivers
+#
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_ID75 is not set
+
+#
+# Input core support
+#
+# CONFIG_INPUT is not set
+# CONFIG_INPUT_KEYBDEV is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+
+#
+# Kernel hacking
+#
+CONFIG_CROSSCOMPILE=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_MIPS_UNCACHED is not set
diff -u --recursive --new-file v2.4.9/linux/arch/mips/defconfig-ocelot linux/arch/mips/defconfig-ocelot
--- v2.4.9/linux/arch/mips/defconfig-ocelot	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/defconfig-ocelot	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,566 @@
+#
+# Automatically generated make config: don't edit
+#
+CONFIG_MIPS=y
+# CONFIG_SMP is not set
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+
+#
+# Machine selection
+#
+# CONFIG_ACER_PICA_61 is not set
+# CONFIG_ALGOR_P4032 is not set
+# CONFIG_BAGET_MIPS is not set
+# CONFIG_DECSTATION is not set
+# CONFIG_DDB5074 is not set
+# CONFIG_MIPS_EV96100 is not set
+# CONFIG_MIPS_EV64120 is not set
+# CONFIG_MIPS_ATLAS is not set
+# CONFIG_MIPS_MALTA is not set
+# CONFIG_NINO is not set
+# CONFIG_MIPS_MAGNUM_4000 is not set
+CONFIG_MOMENCO_OCELOT=y
+# CONFIG_DDB5476 is not set
+# CONFIG_DDB5477 is not set
+# CONFIG_OLIVETTI_M700 is not set
+# CONFIG_SGI_IP22 is not set
+# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_MIPS_ITE8172 is not set
+# CONFIG_MIPS_IVR is not set
+# CONFIG_MIPS_PB1000 is not set
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+# CONFIG_MCA is not set
+# CONFIG_SBUS is not set
+CONFIG_PCI=y
+CONFIG_SYSCLK_100=y
+CONFIG_SWAP_IO_SPACE=y
+CONFIG_NEW_IRQ=y
+CONFIG_OLD_TIME_C=y
+# CONFIG_ISA is not set
+# CONFIG_EISA is not set
+# CONFIG_I8259 is not set
+
+#
+# Loadable module support
+#
+# CONFIG_MODULES is not set
+
+#
+# CPU selection
+#
+# CONFIG_CPU_R3000 is not set
+# CONFIG_CPU_R6000 is not set
+# CONFIG_CPU_VR41XX is not set
+# CONFIG_CPU_R4300 is not set
+# CONFIG_CPU_R4X00 is not set
+# CONFIG_CPU_R5000 is not set
+# CONFIG_CPU_R5432 is not set
+CONFIG_CPU_RM7000=y
+# CONFIG_CPU_NEVADA is not set
+# CONFIG_CPU_R10000 is not set
+# CONFIG_CPU_SB1 is not set
+# CONFIG_CPU_MIPS32 is not set
+# CONFIG_CPU_MIPS64 is not set
+# CONFIG_CPU_ADVANCED is not set
+CONFIG_CPU_HAS_LLSC=y
+CONFIG_CPU_HAS_LLDSCD=y
+# CONFIG_CPU_HAS_WB is not set
+
+#
+# General setup
+#
+# CONFIG_CPU_LITTLE_ENDIAN is not set
+CONFIG_KCORE_ELF=y
+CONFIG_ELF_KERNEL=y
+# CONFIG_BINFMT_IRIX is not set
+# CONFIG_FORWARD_KEYBOARD is not set
+# CONFIG_BINFMT_AOUT is not set
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_MISC is not set
+CONFIG_NET=y
+CONFIG_PCI_NAMES=y
+# CONFIG_HOTPLUG is not set
+# CONFIG_PCMCIA is not set
+CONFIG_SYSVIPC=y
+# CONFIG_BSD_PROCESS_ACCT is not set
+CONFIG_SYSCTL=y
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_DEV_XD is not set
+# CONFIG_PARIDE is not set
+# CONFIG_BLK_CPQ_DA is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_LOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_RAM is not set
+# CONFIG_BLK_DEV_INITRD is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+# CONFIG_BLK_DEV_MD is not set
+# CONFIG_MD_LINEAR is not set
+# CONFIG_MD_RAID0 is not set
+# CONFIG_MD_RAID1 is not set
+# CONFIG_MD_RAID5 is not set
+# CONFIG_BLK_DEV_LVM is not set
+
+#
+# Networking options
+#
+# CONFIG_PACKET is not set
+# CONFIG_NETLINK is not set
+# CONFIG_NETFILTER is not set
+# CONFIG_FILTER is not set
+CONFIG_UNIX=y
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_PNP=y
+# CONFIG_IP_PNP_DHCP is not set
+CONFIG_IP_PNP_BOOTP=y
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_INET_ECN is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_IPV6 is not set
+# CONFIG_KHTTPD is not set
+# CONFIG_ATM is not set
+
+#
+#  
+#
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_DECNET is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_LLC is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_FASTROUTE is not set
+# CONFIG_NET_HW_FLOWCONTROL is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+# CONFIG_PHONE_IXJ is not set
+# CONFIG_PHONE_IXJ_PCMCIA is not set
+
+#
+# ATA/IDE/MFM/RLL support
+#
+# CONFIG_IDE is not set
+# CONFIG_BLK_DEV_IDE_MODES is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI support
+#
+# CONFIG_SCSI is not set
+
+#
+# Network device support
+#
+CONFIG_NETDEVICES=y
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+# CONFIG_SUNLANCE is not set
+# CONFIG_HAPPYMEAL is not set
+# CONFIG_SUNBMAC is not set
+# CONFIG_SUNQE is not set
+# CONFIG_SUNLANCE is not set
+# CONFIG_SUNGEM is not set
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_LANCE is not set
+# CONFIG_NET_VENDOR_SMC is not set
+# CONFIG_NET_VENDOR_RACAL is not set
+# CONFIG_HP100 is not set
+# CONFIG_NET_ISA is not set
+CONFIG_NET_PCI=y
+# CONFIG_PCNET32 is not set
+# CONFIG_ADAPTEC_STARFIRE is not set
+# CONFIG_APRICOT is not set
+# CONFIG_CS89x0 is not set
+# CONFIG_TULIP is not set
+# CONFIG_DE4X5 is not set
+# CONFIG_DGRS is not set
+# CONFIG_DM9102 is not set
+CONFIG_EEPRO100=y
+# CONFIG_LNE390 is not set
+# CONFIG_FEALNX is not set
+# CONFIG_NATSEMI is not set
+# CONFIG_NE2K_PCI is not set
+# CONFIG_NE3210 is not set
+# CONFIG_ES3210 is not set
+# CONFIG_8139TOO is not set
+# CONFIG_8139TOO_PIO is not set
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+# CONFIG_8139TOO_8129 is not set
+# CONFIG_SIS900 is not set
+# CONFIG_EPIC100 is not set
+# CONFIG_SUNDANCE is not set
+# CONFIG_TLAN is not set
+# CONFIG_VIA_RHINE is not set
+# CONFIG_WINBOND_840 is not set
+# CONFIG_LAN_SAA9730 is not set
+# CONFIG_NET_POCKET is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_MYRI_SBUS is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_SK98LIN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PLIP is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+# CONFIG_NET_FC is not set
+# CONFIG_RCPCI is not set
+# CONFIG_SHAPER is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+
+#
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# IrDA (infrared) support
+#
+# CONFIG_IRDA is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Old CD-ROM drivers (not SCSI, not IDE)
+#
+# CONFIG_CD_NO_IDESCSI is not set
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+CONFIG_SERIAL=y
+CONFIG_SERIAL_CONSOLE=y
+# CONFIG_SERIAL_EXTENDED is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Mice
+#
+# CONFIG_BUSMOUSE is not set
+# CONFIG_MOUSE is not set
+
+#
+# Joysticks
+#
+# CONFIG_INPUT_GAMEPORT is not set
+
+#
+# Input core support is needed for gameports
+#
+
+#
+# Input core support is needed for joysticks
+#
+# CONFIG_QIC02_TAPE is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_INTEL_RNG is not set
+# CONFIG_NVRAM is not set
+# CONFIG_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+# CONFIG_SONYPI is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_FTAPE is not set
+# CONFIG_AGP is not set
+# CONFIG_DRM is not set
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# File systems
+#
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_ADFS_FS is not set
+# CONFIG_ADFS_FS_RW is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_CMS_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_JBD_DEBUG is not set
+# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_UMSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_TMPFS is not set
+# CONFIG_RAMFS is not set
+# CONFIG_ISO9660_FS is not set
+# CONFIG_JOLIET is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_FREEVXFS_FS is not set
+# CONFIG_NTFS_FS is not set
+# CONFIG_NTFS_RW is not set
+# CONFIG_HPFS_FS is not set
+CONFIG_PROC_FS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVFS_MOUNT is not set
+# CONFIG_DEVFS_DEBUG is not set
+CONFIG_DEVPTS_FS=y
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_QNX4FS_RW is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_EXT2_FS=y
+# CONFIG_SYSV_FS is not set
+# CONFIG_UDF_FS is not set
+# CONFIG_UDF_RW is not set
+# CONFIG_UFS_FS is not set
+# CONFIG_UFS_FS_WRITE is not set
+
+#
+# Network File Systems
+#
+# CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
+CONFIG_NFS_FS=y
+# CONFIG_NFS_V3 is not set
+CONFIG_ROOT_NFS=y
+CONFIG_NFSD=y
+# CONFIG_NFSD_V3 is not set
+CONFIG_SUNRPC=y
+CONFIG_LOCKD=y
+# CONFIG_SMB_FS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_NCPFS_PACKET_SIGNING is not set
+# CONFIG_NCPFS_IOCTL_LOCKING is not set
+# CONFIG_NCPFS_STRONG is not set
+# CONFIG_NCPFS_NFS_NS is not set
+# CONFIG_NCPFS_OS2_NS is not set
+# CONFIG_NCPFS_SMALLDOS is not set
+# CONFIG_NCPFS_NLS is not set
+# CONFIG_NCPFS_EXTRAS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+# CONFIG_SMB_NLS is not set
+# CONFIG_NLS is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB is not set
+
+#
+# USB Controllers
+#
+# CONFIG_USB_UHCI is not set
+# CONFIG_USB_UHCI_ALT is not set
+# CONFIG_USB_OHCI is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_BLUETOOTH is not set
+# CONFIG_USB_STORAGE is not set
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+
+#
+# USB Human Interface Devices (HID)
+#
+
+#
+#   Input core support is needed for USB HID
+#
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_DC2XX is not set
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_SCANNER is not set
+# CONFIG_USB_MICROTEK is not set
+# CONFIG_USB_HPUSBSCSI is not set
+
+#
+# USB Multimedia devices
+#
+
+#
+#   Video4Linux support is needed for USB Multimedia device support
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# USB Network adaptors
+#
+# CONFIG_USB_PLUSB is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_CDCETHER is not set
+# CONFIG_USB_USBNET is not set
+
+#
+# USB port drivers
+#
+# CONFIG_USB_USS720 is not set
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+# CONFIG_USB_SERIAL_GENERIC is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+
+#
+# Miscellaneous USB drivers
+#
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_ID75 is not set
+
+#
+# Input core support
+#
+# CONFIG_INPUT is not set
+# CONFIG_INPUT_KEYBDEV is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+
+#
+# Kernel hacking
+#
+CONFIG_CROSSCOMPILE=y
+# CONFIG_REMOTE_DEBUG is not set
+# CONFIG_GDB_CONSOLE is not set
+# CONFIG_LL_DEBUG is not set
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_MIPS_UNCACHED is not set
diff -u --recursive --new-file v2.4.9/linux/arch/mips/defconfig-orion linux/arch/mips/defconfig-orion
--- v2.4.9/linux/arch/mips/defconfig-orion	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/defconfig-orion	Wed Dec 31 16:00:00 1969
@@ -1,304 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-
-#
-# Machine selection
-#
-# CONFIG_ACER_PICA_61 is not set
-# CONFIG_ALGOR_P4032 is not set
-# CONFIG_BAGET_MIPS is not set
-# CONFIG_COBALT_MICRO_SERVER is not set
-# CONFIG_DECSTATION is not set
-# CONFIG_DDB5074 is not set
-# CONFIG_MIPS_MAGNUM_4000 is not set
-# CONFIG_OLIVETTI_M700 is not set
-# CONFIG_SGI_IP22 is not set
-# CONFIG_SNI_RM200_PCI is not set
-# CONFIG_MCA is not set
-# CONFIG_SBUS is not set
-# CONFIG_ISA is not set
-# CONFIG_EISA is not set
-# CONFIG_PCI is not set
-
-#
-# Loadable module support
-#
-# CONFIG_MODULES is not set
-
-#
-# CPU selection
-#
-# CONFIG_CPU_R3000 is not set
-# CONFIG_CPU_R6000 is not set
-# CONFIG_CPU_R4300 is not set
-# CONFIG_CPU_R4X00 is not set
-CONFIG_CPU_R5000=y
-# CONFIG_CPU_NEVADA is not set
-# CONFIG_CPU_R8000 is not set
-# CONFIG_CPU_R10000 is not set
-# CONFIG_CPU_ADVANCED is not set
-CONFIG_CPU_HAS_LLSC=y
-# CONFIG_CPU_HAS_WB is not set
-
-#
-# General setup
-#
-# CONFIG_CPU_LITTLE_ENDIAN is not set
-CONFIG_KCORE_ELF=y
-CONFIG_ELF_KERNEL=y
-# CONFIG_BINFMT_IRIX is not set
-# CONFIG_FORWARD_KEYBOARD is not set
-# CONFIG_BINFMT_AOUT is not set
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_NET=y
-# CONFIG_SYSVIPC is not set
-# CONFIG_BSD_PROCESS_ACCT is not set
-# CONFIG_SYSCTL is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-# CONFIG_PCMCIA is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_DEV_XD is not set
-# CONFIG_PARIDE is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_LOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_INITRD=y
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-# CONFIG_BLK_DEV_MD is not set
-# CONFIG_MD_LINEAR is not set
-# CONFIG_MD_RAID0 is not set
-# CONFIG_MD_RAID1 is not set
-# CONFIG_MD_RAID5 is not set
-# CONFIG_BLK_DEV_LVM is not set
-
-#
-# Networking options
-#
-# CONFIG_PACKET is not set
-# CONFIG_NETLINK is not set
-# CONFIG_NETFILTER is not set
-# CONFIG_FILTER is not set
-# CONFIG_UNIX is not set
-# CONFIG_INET is not set
-# CONFIG_ATM is not set
-
-#
-#  
-#
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_LLC is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET_AUNUDP is not set
-# CONFIG_ECONET_NATIVE is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_FASTROUTE is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-# CONFIG_PHONE_IXJ is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-# CONFIG_IDE is not set
-# CONFIG_BLK_DEV_IDE_MODES is not set
-# CONFIG_BLK_DEV_HD is not set
-
-#
-# SCSI support
-#
-# CONFIG_SCSI is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-# CONFIG_I2O_BLOCK is not set
-# CONFIG_I2O_LAN is not set
-# CONFIG_I2O_SCSI is not set
-# CONFIG_I2O_PROC is not set
-
-#
-# Network device support
-#
-# CONFIG_NETDEVICES is not set
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-# CONFIG_SERIAL is not set
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-# CONFIG_UNIX98_PTYS is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_MOUSE is not set
-
-#
-# Joysticks
-#
-# CONFIG_JOYSTICK is not set
-
-#
-# Input core support is needed for joysticks
-#
-# CONFIG_QIC02_TAPE is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_INTEL_RNG is not set
-# CONFIG_NVRAM is not set
-# CONFIG_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# File systems
-#
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_REISERFS_CHECK is not set
-# CONFIG_ADFS_FS is not set
-# CONFIG_ADFS_FS_RW is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_FAT_FS is not set
-# CONFIG_MSDOS_FS is not set
-# CONFIG_UMSDOS_FS is not set
-# CONFIG_VFAT_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_JFFS_FS is not set
-# CONFIG_CRAMFS is not set
-CONFIG_RAMFS=y
-# CONFIG_ISO9660_FS is not set
-# CONFIG_JOLIET is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_NTFS_FS is not set
-# CONFIG_NTFS_RW is not set
-# CONFIG_HPFS_FS is not set
-CONFIG_PROC_FS=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_DEVFS_MOUNT is not set
-# CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_QNX4FS_RW is not set
-# CONFIG_ROMFS_FS is not set
-CONFIG_EXT2_FS=y
-# CONFIG_SYSV_FS is not set
-# CONFIG_SYSV_FS_WRITE is not set
-# CONFIG_UDF_FS is not set
-# CONFIG_UDF_RW is not set
-# CONFIG_UFS_FS is not set
-# CONFIG_UFS_FS_WRITE is not set
-
-#
-# Network File Systems
-#
-# CONFIG_CODA_FS is not set
-# CONFIG_NFS_FS is not set
-# CONFIG_NFS_V3 is not set
-# CONFIG_ROOT_NFS is not set
-# CONFIG_NFSD is not set
-# CONFIG_NFSD_V3 is not set
-# CONFIG_SUNRPC is not set
-# CONFIG_LOCKD is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_NCPFS_NLS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-# CONFIG_SMB_NLS is not set
-# CONFIG_NLS is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# Input core support
-#
-# CONFIG_INPUT is not set
-
-#
-# Kernel hacking
-#
-CONFIG_CROSSCOMPILE=y
-# CONFIG_MAGIC_SYSRQ is not set
diff -u --recursive --new-file v2.4.9/linux/arch/mips/defconfig-pb1000 linux/arch/mips/defconfig-pb1000
--- v2.4.9/linux/arch/mips/defconfig-pb1000	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/defconfig-pb1000	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,565 @@
+#
+# Automatically generated make config: don't edit
+#
+CONFIG_MIPS=y
+# CONFIG_SMP is not set
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+
+#
+# Machine selection
+#
+# CONFIG_ACER_PICA_61 is not set
+# CONFIG_ALGOR_P4032 is not set
+# CONFIG_BAGET_MIPS is not set
+# CONFIG_DECSTATION is not set
+# CONFIG_DDB5074 is not set
+# CONFIG_MIPS_EV96100 is not set
+# CONFIG_MIPS_EV64120 is not set
+# CONFIG_MIPS_ATLAS is not set
+# CONFIG_MIPS_MALTA is not set
+# CONFIG_NINO is not set
+# CONFIG_MIPS_MAGNUM_4000 is not set
+# CONFIG_MOMENCO_OCELOT is not set
+# CONFIG_DDB5476 is not set
+# CONFIG_DDB5477 is not set
+# CONFIG_OLIVETTI_M700 is not set
+# CONFIG_SGI_IP22 is not set
+# CONFIG_SNI_RM200_PCI is not set
+# CONFIG_MIPS_ITE8172 is not set
+# CONFIG_MIPS_IVR is not set
+CONFIG_MIPS_PB1000=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+# CONFIG_MCA is not set
+# CONFIG_SBUS is not set
+CONFIG_MIPS_AU1000=y
+CONFIG_NEW_IRQ=y
+# CONFIG_ISA is not set
+# CONFIG_EISA is not set
+# CONFIG_PCI is not set
+# CONFIG_I8259 is not set
+
+#
+# Loadable module support
+#
+# CONFIG_MODULES is not set
+
+#
+# CPU selection
+#
+# CONFIG_CPU_R3000 is not set
+# CONFIG_CPU_R6000 is not set
+# CONFIG_CPU_VR41XX is not set
+# CONFIG_CPU_R4300 is not set
+# CONFIG_CPU_R4X00 is not set
+# CONFIG_CPU_R5000 is not set
+# CONFIG_CPU_R5432 is not set
+# CONFIG_CPU_RM7000 is not set
+# CONFIG_CPU_NEVADA is not set
+# CONFIG_CPU_R10000 is not set
+# CONFIG_CPU_SB1 is not set
+CONFIG_CPU_MIPS32=y
+# CONFIG_CPU_MIPS64 is not set
+CONFIG_CPU_ADVANCED=y
+CONFIG_CPU_HAS_LLSC=y
+# CONFIG_CPU_HAS_LLDSCD is not set
+CONFIG_CPU_HAS_WB=y
+
+#
+# General setup
+#
+CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_KCORE_ELF=y
+CONFIG_ELF_KERNEL=y
+# CONFIG_BINFMT_AOUT is not set
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_MISC is not set
+CONFIG_NET=y
+# CONFIG_HOTPLUG is not set
+# CONFIG_PCMCIA is not set
+CONFIG_SYSVIPC=y
+# CONFIG_BSD_PROCESS_ACCT is not set
+CONFIG_SYSCTL=y
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_DEV_XD is not set
+# CONFIG_PARIDE is not set
+# CONFIG_BLK_CPQ_DA is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_LOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_RAM is not set
+# CONFIG_BLK_DEV_INITRD is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+# CONFIG_BLK_DEV_MD is not set
+# CONFIG_MD_LINEAR is not set
+# CONFIG_MD_RAID0 is not set
+# CONFIG_MD_RAID1 is not set
+# CONFIG_MD_RAID5 is not set
+# CONFIG_BLK_DEV_LVM is not set
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+# CONFIG_NETLINK is not set
+# CONFIG_NETFILTER is not set
+# CONFIG_FILTER is not set
+CONFIG_UNIX=y
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_PNP=y
+# CONFIG_IP_PNP_DHCP is not set
+CONFIG_IP_PNP_BOOTP=y
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_INET_ECN is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_IPV6 is not set
+# CONFIG_KHTTPD is not set
+# CONFIG_ATM is not set
+
+#
+#  
+#
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_DECNET is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_LLC is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_FASTROUTE is not set
+# CONFIG_NET_HW_FLOWCONTROL is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+# CONFIG_PHONE_IXJ is not set
+# CONFIG_PHONE_IXJ_PCMCIA is not set
+
+#
+# ATA/IDE/MFM/RLL support
+#
+# CONFIG_IDE is not set
+# CONFIG_BLK_DEV_IDE_MODES is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI support
+#
+# CONFIG_SCSI is not set
+
+#
+# Network device support
+#
+CONFIG_NETDEVICES=y
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MIPS_AU1000_ENET=y
+# CONFIG_SUNLANCE is not set
+# CONFIG_SUNBMAC is not set
+# CONFIG_SUNQE is not set
+# CONFIG_SUNLANCE is not set
+# CONFIG_SUNGEM is not set
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_LANCE is not set
+# CONFIG_NET_VENDOR_SMC is not set
+# CONFIG_NET_VENDOR_RACAL is not set
+# CONFIG_NET_ISA is not set
+# CONFIG_NET_PCI is not set
+# CONFIG_NET_POCKET is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_MYRI_SBUS is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_SK98LIN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PLIP is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+# CONFIG_NET_FC is not set
+# CONFIG_RCPCI is not set
+# CONFIG_SHAPER is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+
+#
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# IrDA (infrared) support
+#
+# CONFIG_IRDA is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Old CD-ROM drivers (not SCSI, not IDE)
+#
+# CONFIG_CD_NO_IDESCSI is not set
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+# CONFIG_SERIAL is not set
+# CONFIG_SERIAL_EXTENDED is not set
+CONFIG_SERIAL_NONSTANDARD=y
+# CONFIG_COMPUTONE is not set
+# CONFIG_ROCKETPORT is not set
+# CONFIG_CYCLADES is not set
+# CONFIG_DIGIEPCA is not set
+# CONFIG_DIGI is not set
+# CONFIG_ESPSERIAL is not set
+# CONFIG_MOXA_INTELLIO is not set
+# CONFIG_MOXA_SMARTIO is not set
+# CONFIG_SYNCLINK is not set
+# CONFIG_N_HDLC is not set
+# CONFIG_RISCOM8 is not set
+# CONFIG_SPECIALIX is not set
+# CONFIG_SX is not set
+# CONFIG_RIO is not set
+# CONFIG_STALDRV is not set
+# CONFIG_SERIAL_TX3912 is not set
+# CONFIG_SERIAL_TX3912_CONSOLE is not set
+CONFIG_AU1000_UART=y
+CONFIG_AU1000_SERIAL_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Mice
+#
+# CONFIG_BUSMOUSE is not set
+# CONFIG_MOUSE is not set
+
+#
+# Joysticks
+#
+# CONFIG_INPUT_GAMEPORT is not set
+
+#
+# Input core support is needed for gameports
+#
+
+#
+# Input core support is needed for joysticks
+#
+# CONFIG_QIC02_TAPE is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_INTEL_RNG is not set
+# CONFIG_NVRAM is not set
+# CONFIG_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+# CONFIG_SONYPI is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_FTAPE is not set
+# CONFIG_AGP is not set
+# CONFIG_DRM is not set
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# File systems
+#
+# CONFIG_QUOTA is not set
+CONFIG_AUTOFS_FS=y
+CONFIG_AUTOFS4_FS=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_ADFS_FS is not set
+# CONFIG_ADFS_FS_RW is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_CMS_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_JBD_DEBUG is not set
+# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_UMSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_TMPFS is not set
+# CONFIG_RAMFS is not set
+CONFIG_ISO9660_FS=y
+# CONFIG_JOLIET is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_FREEVXFS_FS is not set
+# CONFIG_NTFS_FS is not set
+# CONFIG_NTFS_RW is not set
+# CONFIG_HPFS_FS is not set
+CONFIG_PROC_FS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVFS_MOUNT is not set
+# CONFIG_DEVFS_DEBUG is not set
+# CONFIG_DEVPTS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_QNX4FS_RW is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_EXT2_FS=y
+# CONFIG_SYSV_FS is not set
+# CONFIG_UDF_FS is not set
+# CONFIG_UDF_RW is not set
+# CONFIG_UFS_FS is not set
+# CONFIG_UFS_FS_WRITE is not set
+
+#
+# Network File Systems
+#
+# CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
+CONFIG_NFS_FS=y
+# CONFIG_NFS_V3 is not set
+CONFIG_ROOT_NFS=y
+# CONFIG_NFSD is not set
+# CONFIG_NFSD_V3 is not set
+CONFIG_SUNRPC=y
+CONFIG_LOCKD=y
+# CONFIG_SMB_FS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_NCPFS_PACKET_SIGNING is not set
+# CONFIG_NCPFS_IOCTL_LOCKING is not set
+# CONFIG_NCPFS_STRONG is not set
+# CONFIG_NCPFS_NFS_NS is not set
+# CONFIG_NCPFS_OS2_NS is not set
+# CONFIG_NCPFS_SMALLDOS is not set
+# CONFIG_NCPFS_NLS is not set
+# CONFIG_NCPFS_EXTRAS is not set
+
+#
+# Partition Types
+#
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ACORN_PARTITION is not set
+# CONFIG_OSF_PARTITION is not set
+# CONFIG_AMIGA_PARTITION is not set
+# CONFIG_ATARI_PARTITION is not set
+# CONFIG_MAC_PARTITION is not set
+CONFIG_MSDOS_PARTITION=y
+# CONFIG_BSD_DISKLABEL is not set
+# CONFIG_MINIX_SUBPARTITION is not set
+# CONFIG_SOLARIS_X86_PARTITION is not set
+# CONFIG_UNIXWARE_DISKLABEL is not set
+# CONFIG_LDM_PARTITION is not set
+CONFIG_SGI_PARTITION=y
+# CONFIG_ULTRIX_PARTITION is not set
+# CONFIG_SUN_PARTITION is not set
+# CONFIG_SMB_NLS is not set
+# CONFIG_NLS is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB is not set
+
+#
+# USB Controllers
+#
+# CONFIG_USB_UHCI is not set
+# CONFIG_USB_UHCI_ALT is not set
+# CONFIG_USB_OHCI is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_BLUETOOTH is not set
+# CONFIG_USB_STORAGE is not set
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+
+#
+# USB Human Interface Devices (HID)
+#
+
+#
+#   Input core support is needed for USB HID
+#
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_DC2XX is not set
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_SCANNER is not set
+# CONFIG_USB_MICROTEK is not set
+# CONFIG_USB_HPUSBSCSI is not set
+
+#
+# USB Multimedia devices
+#
+
+#
+#   Video4Linux support is needed for USB Multimedia device support
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# USB Network adaptors
+#
+# CONFIG_USB_PLUSB is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_CDCETHER is not set
+# CONFIG_USB_USBNET is not set
+
+#
+# USB port drivers
+#
+# CONFIG_USB_USS720 is not set
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+# CONFIG_USB_SERIAL_GENERIC is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+
+#
+# Miscellaneous USB drivers
+#
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_ID75 is not set
+
+#
+# Input core support
+#
+# CONFIG_INPUT is not set
+# CONFIG_INPUT_KEYBDEV is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+
+#
+# Kernel hacking
+#
+CONFIG_CROSSCOMPILE=y
+# CONFIG_REMOTE_DEBUG is not set
+# CONFIG_GDB_CONSOLE is not set
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_MIPS_UNCACHED is not set
diff -u --recursive --new-file v2.4.9/linux/arch/mips/defconfig-rm200 linux/arch/mips/defconfig-rm200
--- v2.4.9/linux/arch/mips/defconfig-rm200	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/defconfig-rm200	Sun Sep  9 10:43:02 2001
@@ -1,6 +1,8 @@
 #
 # Automatically generated make config: don't edit
 #
+CONFIG_MIPS=y
+# CONFIG_SMP is not set
 
 #
 # Code maturity level options
@@ -13,19 +15,34 @@
 # CONFIG_ACER_PICA_61 is not set
 # CONFIG_ALGOR_P4032 is not set
 # CONFIG_BAGET_MIPS is not set
-# CONFIG_COBALT_MICRO_SERVER is not set
 # CONFIG_DECSTATION is not set
 # CONFIG_DDB5074 is not set
+# CONFIG_MIPS_EV96100 is not set
+# CONFIG_MIPS_EV64120 is not set
+# CONFIG_MIPS_ATLAS is not set
+# CONFIG_MIPS_MALTA is not set
+# CONFIG_NINO is not set
 # CONFIG_MIPS_MAGNUM_4000 is not set
+# CONFIG_MOMENCO_OCELOT is not set
+# CONFIG_DDB5476 is not set
+# CONFIG_DDB5477 is not set
 # CONFIG_OLIVETTI_M700 is not set
 # CONFIG_SGI_IP22 is not set
 CONFIG_SNI_RM200_PCI=y
+# CONFIG_MIPS_ITE8172 is not set
+# CONFIG_MIPS_IVR is not set
+# CONFIG_MIPS_PB1000 is not set
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
 # CONFIG_MCA is not set
 # CONFIG_SBUS is not set
 CONFIG_ARC32=y
-CONFIG_PCI=y
+CONFIG_I8259=y
 CONFIG_ISA=y
 CONFIG_PC_KEYB=y
+CONFIG_PCI=y
+CONFIG_ROTTEN_IRQ=y
+CONFIG_OLD_TIME_C=y
 CONFIG_EISA=y
 
 #
@@ -40,14 +57,20 @@
 #
 # CONFIG_CPU_R3000 is not set
 # CONFIG_CPU_R6000 is not set
+# CONFIG_CPU_VR41XX is not set
 # CONFIG_CPU_R4300 is not set
 # CONFIG_CPU_R4X00 is not set
 CONFIG_CPU_R5000=y
+# CONFIG_CPU_R5432 is not set
+# CONFIG_CPU_RM7000 is not set
 # CONFIG_CPU_NEVADA is not set
-# CONFIG_CPU_R8000 is not set
 # CONFIG_CPU_R10000 is not set
+# CONFIG_CPU_SB1 is not set
+# CONFIG_CPU_MIPS32 is not set
+# CONFIG_CPU_MIPS64 is not set
 # CONFIG_CPU_ADVANCED is not set
 CONFIG_CPU_HAS_LLSC=y
+CONFIG_CPU_HAS_LLDSCD=y
 # CONFIG_CPU_HAS_WB is not set
 
 #
@@ -56,26 +79,24 @@
 CONFIG_CPU_LITTLE_ENDIAN=y
 CONFIG_KCORE_ELF=y
 CONFIG_ELF_KERNEL=y
+# CONFIG_ARC_CONSOLE is not set
 # CONFIG_BINFMT_AOUT is not set
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 CONFIG_NET=y
 # CONFIG_PCI_NAMES is not set
+# CONFIG_HOTPLUG is not set
+# CONFIG_PCMCIA is not set
 # CONFIG_SYSVIPC is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_SYSCTL=y
 
 #
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
 # Plug and Play configuration
 #
 # CONFIG_PNP is not set
 # CONFIG_ISAPNP is not set
-# CONFIG_PCMCIA is not set
+# CONFIG_PNPBIOS is not set
 
 #
 # Memory Technology Devices (MTD)
@@ -83,6 +104,11 @@
 # CONFIG_MTD is not set
 
 #
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
 # Block devices
 #
 CONFIG_BLK_DEV_FD=y
@@ -154,6 +180,7 @@
 #
 # CONFIG_PHONE is not set
 # CONFIG_PHONE_IXJ is not set
+# CONFIG_PHONE_IXJ_PCMCIA is not set
 
 #
 # ATA/IDE/MFM/RLL support
@@ -168,19 +195,19 @@
 # CONFIG_SCSI is not set
 
 #
-# I2O device support
+# Network device support
 #
-# CONFIG_I2O is not set
-# CONFIG_I2O_PCI is not set
-# CONFIG_I2O_BLOCK is not set
-# CONFIG_I2O_LAN is not set
-# CONFIG_I2O_SCSI is not set
-# CONFIG_I2O_PROC is not set
+# CONFIG_NETDEVICES is not set
 
 #
-# Network device support
+# Amateur Radio support
 #
-# CONFIG_NETDEVICES is not set
+# CONFIG_HAMRADIO is not set
+
+#
+# IrDA (infrared) support
+#
+# CONFIG_IRDA is not set
 
 #
 # ISDN subsystem
@@ -200,7 +227,8 @@
 # CONFIG_SERIAL is not set
 # CONFIG_SERIAL_EXTENDED is not set
 # CONFIG_SERIAL_NONSTANDARD is not set
-# CONFIG_UNIX98_PTYS is not set
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
 
 #
 # I2C support
@@ -216,7 +244,11 @@
 #
 # Joysticks
 #
-# CONFIG_JOYSTICK is not set
+# CONFIG_INPUT_GAMEPORT is not set
+
+#
+# Input core support is needed for gameports
+#
 
 #
 # Input core support is needed for joysticks
@@ -233,6 +265,7 @@
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 # CONFIG_APPLICOM is not set
+# CONFIG_SONYPI is not set
 
 #
 # Ftape, the floppy tape device driver
@@ -254,22 +287,30 @@
 # CONFIG_AUTOFS4_FS is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
 # CONFIG_ADFS_FS is not set
 # CONFIG_ADFS_FS_RW is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
 # CONFIG_BFS_FS is not set
+# CONFIG_CMS_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_JBD_DEBUG is not set
 # CONFIG_FAT_FS is not set
 # CONFIG_MSDOS_FS is not set
 # CONFIG_UMSDOS_FS is not set
 # CONFIG_VFAT_FS is not set
 # CONFIG_EFS_FS is not set
 # CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
 # CONFIG_CRAMFS is not set
+# CONFIG_TMPFS is not set
 # CONFIG_RAMFS is not set
 # CONFIG_ISO9660_FS is not set
 # CONFIG_JOLIET is not set
 # CONFIG_MINIX_FS is not set
+# CONFIG_FREEVXFS_FS is not set
 # CONFIG_NTFS_FS is not set
 # CONFIG_NTFS_RW is not set
 # CONFIG_HPFS_FS is not set
@@ -277,13 +318,12 @@
 # CONFIG_DEVFS_FS is not set
 # CONFIG_DEVFS_MOUNT is not set
 # CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS is not set
+CONFIG_DEVPTS_FS=y
 # CONFIG_QNX4FS_FS is not set
 # CONFIG_QNX4FS_RW is not set
 # CONFIG_ROMFS_FS is not set
 CONFIG_EXT2_FS=y
 # CONFIG_SYSV_FS is not set
-# CONFIG_SYSV_FS_WRITE is not set
 # CONFIG_UDF_FS is not set
 # CONFIG_UDF_RW is not set
 # CONFIG_UFS_FS is not set
@@ -293,6 +333,7 @@
 # Network File Systems
 #
 # CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
 # CONFIG_NFS_FS is not set
 # CONFIG_NFS_V3 is not set
 # CONFIG_ROOT_NFS is not set
@@ -325,6 +366,7 @@
 # CONFIG_MINIX_SUBPARTITION is not set
 # CONFIG_SOLARIS_X86_PARTITION is not set
 # CONFIG_UNIXWARE_DISKLABEL is not set
+# CONFIG_LDM_PARTITION is not set
 CONFIG_SGI_PARTITION=y
 # CONFIG_ULTRIX_PARTITION is not set
 # CONFIG_SUN_PARTITION is not set
@@ -335,7 +377,7 @@
 # Console drivers
 #
 CONFIG_VGA_CONSOLE=y
-# CONFIG_FB is not set
+# CONFIG_MDA_CONSOLE is not set
 
 #
 # Frame-buffer support
@@ -353,13 +395,111 @@
 # CONFIG_USB is not set
 
 #
+# USB Controllers
+#
+# CONFIG_USB_UHCI is not set
+# CONFIG_USB_UHCI_ALT is not set
+# CONFIG_USB_OHCI is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_BLUETOOTH is not set
+# CONFIG_USB_STORAGE is not set
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+
+#
+# USB Human Interface Devices (HID)
+#
+
+#
+#   Input core support is needed for USB HID
+#
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_DC2XX is not set
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_SCANNER is not set
+# CONFIG_USB_MICROTEK is not set
+# CONFIG_USB_HPUSBSCSI is not set
+
+#
+# USB Multimedia devices
+#
+
+#
+#   Video4Linux support is needed for USB Multimedia device support
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# USB Network adaptors
+#
+# CONFIG_USB_PLUSB is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_CDCETHER is not set
+# CONFIG_USB_USBNET is not set
+
+#
+# USB port drivers
+#
+# CONFIG_USB_USS720 is not set
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+# CONFIG_USB_SERIAL_GENERIC is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+
+#
+# Miscellaneous USB drivers
+#
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_ID75 is not set
+
+#
 # Input core support
 #
 # CONFIG_INPUT is not set
+# CONFIG_INPUT_KEYBDEV is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
 
 #
 # Kernel hacking
 #
 CONFIG_CROSSCOMPILE=y
-# CONFIG_MIPS_FPE_MODULE is not set
 # CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_MIPS_UNCACHED is not set
diff -u --recursive --new-file v2.4.9/linux/arch/mips/gt64120/common/Makefile linux/arch/mips/gt64120/common/Makefile
--- v2.4.9/linux/arch/mips/gt64120/common/Makefile	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/gt64120/common/Makefile	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,18 @@
+#
+# Makefile for common code of gt64120-based boards.
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+
+.S.s:
+	$(CPP) $(CFLAGS) $< -o $*.s
+.S.o:
+	$(CC) $(CFLAGS) -c $< -o $*.o
+
+O_TARGET:= gt64120.o
+
+obj-y	 := gt_irq.o pci.o
+
+include $(TOPDIR)/Rules.make
diff -u --recursive --new-file v2.4.9/linux/arch/mips/gt64120/common/gt_irq.c linux/arch/mips/gt64120/common/gt_irq.c
--- v2.4.9/linux/arch/mips/gt64120/common/gt_irq.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/gt64120/common/gt_irq.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,250 @@
+/*
+ *
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: jsun@mvista.com or jsun@junsun.net
+ *
+ * arch/mips/gt64120/common/gt_irq.c
+ *     Interrupt routines for gt64120.  Currently it only handles timer irq.
+ *
+ * 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 <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <asm/ptrace.h>
+#include <linux/config.h>
+#include <linux/sched.h>
+#include <linux/kernel_stat.h>
+#include <asm/io.h>
+#include <asm/gt64120/gt64120.h>
+
+/*
+ * These are interrupt handlers for the GT on-chip interrupts.  They
+ * all come in to the MIPS on a single interrupt line, and have to
+ * be handled and ack'ed differently than other MIPS interrupts.
+ */
+
+#if CURRENTLY_UNUSED
+
+struct tq_struct irq_handlers[MAX_CAUSE_REGS][MAX_CAUSE_REG_WIDTH];
+void hook_irq_handler(int int_cause, int bit_num, void *isr_ptr);
+
+/*
+ * Hooks IRQ handler to the system. When the system is interrupted
+ * the interrupt service routine is called.
+ *
+ * Inputs :
+ * int_cause - The interrupt cause number. In EVB64120 two parameters 
+ *             are declared, INT_CAUSE_MAIN and INT_CAUSE_HIGH. 
+ * bit_num   - Indicates which bit number in the cause register
+ * isr_ptr   - Pointer to the interrupt service routine
+ */
+void hook_irq_handler(int int_cause, int bit_num, void *isr_ptr)
+{
+	irq_handlers[int_cause][bit_num].routine = isr_ptr;
+}
+
+
+/*
+ * Enables the IRQ on Galileo Chip
+ *
+ * Inputs :
+ * int_cause - The interrupt cause number. In EVB64120 two parameters 
+ *             are declared, INT_CAUSE_MAIN and INT_CAUSE_HIGH.
+ * bit_num   - Indicates which bit number in the cause register
+ *
+ * Outputs :
+ * 1 if succesful, 0 if failure
+ */
+int enable_galileo_irq(int int_cause, int bit_num)
+{
+	if (int_cause == INT_CAUSE_MAIN)
+		SET_REG_BITS(CPU_INTERRUPT_MASK_REGISTER, (1 << bit_num));
+	else if (int_cause == INT_CAUSE_HIGH)
+		SET_REG_BITS(CPU_HIGH_INTERRUPT_MASK_REGISTER,
+			     (1 << bit_num));
+	else
+		return 0;
+
+	return 1;
+}
+
+/*
+ * Disables the IRQ on Galileo Chip
+ *
+ * Inputs :
+ * int_cause - The interrupt cause number. In EVB64120 two parameters 
+ *             are declared, INT_CAUSE_MAIN and INT_CAUSE_HIGH.
+ * bit_num   - Indicates which bit number in the cause register
+ *
+ * Outputs :
+ * 1 if succesful, 0 if failure
+ */
+int disable_galileo_irq(int int_cause, int bit_num)
+{
+	if (int_cause == INT_CAUSE_MAIN)
+		RESET_REG_BITS(CPU_INTERRUPT_MASK_REGISTER,
+			       (1 << bit_num));
+	else if (int_cause == INT_CAUSE_HIGH)
+		RESET_REG_BITS(CPU_HIGH_INTERRUPT_MASK_REGISTER,
+			       (1 << bit_num));
+	else
+		return 0;
+	return 1;
+}
+#endif				/*  UNUSED  */
+
+/*
+ * Interrupt handler for interrupts coming from the Galileo chip.
+ * It could be timer interrupt, built in ethernet ports etc...
+ */
+static void gt64120_irq(int irq, void *dev_id, struct pt_regs *regs)
+{
+	unsigned int irq_src, int_high_src, irq_src_mask,
+	    int_high_src_mask;
+	int handled;
+
+	GT_READ(GT_INTRCAUSE_OFS, &irq_src);
+	GT_READ(GT_INTRMASK_OFS, &irq_src_mask);
+	GT_READ(GT_HINTRCAUSE_OFS, &int_high_src);
+	GT_READ(GT_HINTRMASK_OFS, &int_high_src_mask);
+	irq_src = irq_src & irq_src_mask;
+	int_high_src = int_high_src & int_high_src_mask;
+
+	handled = 0;
+
+	/* Execute all interrupt handlers */
+	/* Check for timer interrupt */
+	if (irq_src & 0x00000800) {
+		handled = 1;
+		irq_src &= ~0x00000800;
+		//    RESET_REG_BITS (INTERRUPT_CAUSE_REGISTER,BIT8);
+		do_timer(regs);
+	}
+
+	if (irq_src) {
+		printk(KERN_INFO
+		       "Other Galileo interrupt received irq_src %x\n",
+		       irq_src);
+#if CURRENTLY_UNUSED
+		for (count = 0; count < MAX_CAUSE_REG_WIDTH; count++) {
+			if (irq_src & (1 << count)) {
+				if (irq_handlers[INT_CAUSE_MAIN][count].
+				    routine) {
+					queue_task(&irq_handlers
+						   [INT_CAUSE_MAIN][count],
+						   &tq_immediate);
+					mark_bh(IMMEDIATE_BH);
+					handled = 1;
+				}
+			}
+		}
+#endif				/*  UNUSED  */
+	}
+	GT_WRITE(GT_INTRCAUSE_OFS, 0);
+	GT_WRITE(GT_HINTRCAUSE_OFS, 0);
+
+#undef GALILEO_I2O
+#ifdef GALILEO_I2O
+	/*
+	 * Future I2O support.  We currently attach I2O interrupt handlers to
+	 * the Galileo interrupt (int 4) and handle them in do_IRQ.
+	 */
+	if (isInBoundDoorBellInterruptSet()) {
+		printk(KERN_INFO "I2O doorbell interrupt received.\n");
+		handled = 1;
+	}
+
+	if (isInBoundPostQueueInterruptSet()) {
+		printk(KERN_INFO "I2O Queue interrupt received.\n");
+		handled = 1;
+	}
+
+	/*
+	 * This normally would be outside of the ifdef, but since we're
+	 * handling I2O outside of this handler, this printk shows up every
+	 * time we get a valid I2O interrupt.  So turn this off for now.
+	 */
+	if (handled == 0) {
+		if (counter < 50) {
+			printk("Spurious Galileo interrupt...\n");
+			counter++;
+		}
+	}
+#endif
+}
+
+/*
+ * Initializes timer using galileo's built in timer.
+ */
+#ifdef CONFIG_SYSCLK_100
+#define Sys_clock (100 * 1000000)	// 100 MHz
+#endif
+#ifdef CONFIG_SYSCLK_83
+#define Sys_clock (83.333 * 1000000)	// 83.333 MHz
+#endif
+#ifdef CONFIG_SYSCLK_75
+#define Sys_clock (75 * 1000000)	// 75 MHz
+#endif
+
+/*
+ * This will ignore the standard MIPS timer interrupt handler
+ * that is passed in as *irq (=irq0 in ../kernel/time.c).
+ * We will do our own timer interrupt handling.
+ */
+void gt64120_time_init(void)
+{
+	extern irq_desc_t irq_desc[NR_IRQS];
+	static struct irqaction timer;
+
+	/* Disable timer first */
+	GT_WRITE(GT_TC_CONTROL_OFS, 0);
+	/* Load timer value for 100 Hz */
+	GT_WRITE(GT_TC3_OFS, Sys_clock / 100);
+
+	/*
+	 * Create the IRQ structure entry for the timer.  Since we're too early
+	 * in the boot process to use the "request_irq()" call, we'll hard-code
+	 * the values to the correct interrupt line.
+	 */
+	timer.handler = &gt64120_irq;
+	timer.flags = SA_SHIRQ | SA_INTERRUPT;
+	timer.name = "timer";
+	timer.dev_id = NULL;
+	timer.next = NULL;
+	timer.mask = 0;
+	irq_desc[TIMER].action = &timer;
+
+	enable_irq(TIMER);
+
+	/* Enable timer ints */
+	GT_WRITE(GT_TC_CONTROL_OFS, 0xc0);
+	/* clear Cause register first */
+	GT_WRITE(GT_INTRCAUSE_OFS, 0x0);
+	/* Unmask timer int */
+	GT_WRITE(GT_INTRMASK_OFS, 0x800);
+	/* Clear High int register */
+	GT_WRITE(GT_HINTRCAUSE_OFS, 0x0);
+	/* Mask All interrupts at High cause interrupt */
+	GT_WRITE(GT_HINTRMASK_OFS, 0x0);
+}
+
+void gt64120_irq_init(void)
+{
+#if CURRENTLY_UNUSED
+	int i, j;
+
+	/* Reset irq handlers pointers to NULL */
+	for (i = 0; i < MAX_CAUSE_REGS; i++) {
+		for (j = 0; j < MAX_CAUSE_REG_WIDTH; j++) {
+			irq_handlers[i][j].next = NULL;
+			irq_handlers[i][j].sync = 0;
+			irq_handlers[i][j].routine = NULL;
+			irq_handlers[i][j].data = NULL;
+		}
+	}
+#endif
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/gt64120/common/pci.c linux/arch/mips/gt64120/common/pci.c
--- v2.4.9/linux/arch/mips/gt64120/common/pci.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/gt64120/common/pci.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,1145 @@
+/*
+ * BRIEF MODULE DESCRIPTION
+ * Galileo Evaluation Boards PCI support.
+ *
+ * The general-purpose functions to read/write and configure the GT64120A's
+ * PCI registers (function names start with pci0 or pci1) are either direct
+ * copies of functions written by Galileo Technology, or are modifications
+ * of their functions to work with Linux 2.4 vs Linux 2.2.  These functions
+ * are Copyright - Galileo Technology.
+ *
+ * Other functions are derived from other MIPS PCI implementations, or were
+ * written by RidgeRun, Inc,  Copyright (C) 2000 RidgeRun, Inc.
+ *   glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
+ *
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/version.h>
+#include <asm/pci.h>
+#include <asm/io.h>
+#include <asm/gt64120/gt64120.h>
+
+#include <linux/init.h>
+
+#ifdef CONFIG_PCI
+
+#define SELF 0
+
+/*
+ * These functions and structures provide the BIOS scan and mapping of the PCI
+ * devices.
+ */
+
+#define MAX_PCI_DEVS 10
+
+struct pci_device {
+	u32 slot;
+	u32 BARtype[6];
+	u32 BARsize[6];
+};
+
+static void __init scan_and_initialize_pci(void);
+static u32 __init scan_pci_bus(struct pci_device *pci_devices);
+static void __init allocate_pci_space(struct pci_device *pci_devices);
+
+/*
+ * The functions that actually read and write to the controller.
+ *
+ *  Copied from or modified from Galileo Technology code.
+ */
+static unsigned int pci0ReadConfigReg(int offset, struct pci_dev *device);
+static void pci0WriteConfigReg(unsigned int offset,
+			       struct pci_dev *device, unsigned int data);
+static unsigned int pci1ReadConfigReg(int offset, struct pci_dev *device);
+static void pci1WriteConfigReg(unsigned int offset,
+			       struct pci_dev *device, unsigned int data);
+
+static void pci0MapIOspace(unsigned int pci0IoBase,
+			   unsigned int pci0IoLength);
+static void pci1MapIOspace(unsigned int pci1IoBase,
+			   unsigned int pci1IoLength);
+static void pci0MapMemory0space(unsigned int pci0Mem0Base,
+				unsigned int pci0Mem0Length);
+static void pci1MapMemory0space(unsigned int pci1Mem0Base,
+				unsigned int pci1Mem0Length);
+static void pci0MapMemory1space(unsigned int pci0Mem1Base,
+				unsigned int pci0Mem1Length);
+static void pci1MapMemory1space(unsigned int pci1Mem1Base,
+				unsigned int pci1Mem1Length);
+static unsigned int pci0GetIOspaceBase(void);
+static unsigned int pci0GetIOspaceSize(void);
+static unsigned int pci0GetMemory0Base(void);
+static unsigned int pci0GetMemory0Size(void);
+static unsigned int pci0GetMemory1Base(void);
+static unsigned int pci0GetMemory1Size(void);
+static unsigned int pci1GetIOspaceBase(void);
+static unsigned int pci1GetIOspaceSize(void);
+static unsigned int pci1GetMemory0Base(void);
+static unsigned int pci1GetMemory0Size(void);
+static unsigned int pci1GetMemory1Base(void);
+static unsigned int pci1GetMemory1Size(void);
+
+
+/*  Functions to implement "pci ops"  */
+static int galileo_pcibios_read_config_word(struct pci_dev *dev,
+					    int offset, u16 * val);
+static int galileo_pcibios_read_config_byte(struct pci_dev *dev,
+					    int offset, u8 * val);
+static int galileo_pcibios_read_config_dword(struct pci_dev *dev,
+					     int offset, u32 * val);
+static int galileo_pcibios_write_config_byte(struct pci_dev *dev,
+					     int offset, u8 val);
+static int galileo_pcibios_write_config_word(struct pci_dev *dev,
+					     int offset, u16 val);
+static int galileo_pcibios_write_config_dword(struct pci_dev *dev,
+					      int offset, u32 val);
+static void galileo_pcibios_set_master(struct pci_dev *dev);
+
+/*
+ *  General-purpose PCI functions.
+ */
+
+/*
+ * pci0MapIOspace - Maps PCI0 IO space for the master.
+ * Inputs: base and length of pci0Io
+ */
+
+static void pci0MapIOspace(unsigned int pci0IoBase,
+			   unsigned int pci0IoLength)
+{
+	unsigned int pci0IoTop =
+	    (unsigned int) (pci0IoBase + pci0IoLength);
+
+	if (pci0IoLength == 0)
+		pci0IoTop++;
+
+	pci0IoBase = (unsigned int) (pci0IoBase >> 21);
+	pci0IoTop = (unsigned int) (((pci0IoTop - 1) & 0x0fffffff) >> 21);
+	GT_WRITE(GT_PCI0IOLD_OFS, pci0IoBase);
+	GT_WRITE(GT_PCI0IOHD_OFS, pci0IoTop);
+}
+
+/*
+ * pci1MapIOspace - Maps PCI1 IO space for the master.
+ * Inputs: base and length of pci1Io
+ */
+
+static void pci1MapIOspace(unsigned int pci1IoBase,
+			   unsigned int pci1IoLength)
+{
+	unsigned int pci1IoTop =
+	    (unsigned int) (pci1IoBase + pci1IoLength);
+
+	if (pci1IoLength == 0)
+		pci1IoTop++;
+
+	pci1IoBase = (unsigned int) (pci1IoBase >> 21);
+	pci1IoTop = (unsigned int) (((pci1IoTop - 1) & 0x0fffffff) >> 21);
+	GT_WRITE(GT_PCI1IOLD_OFS, pci1IoBase);
+	GT_WRITE(GT_PCI1IOHD_OFS, pci1IoTop);
+}
+
+/*
+ * pci0MapMemory0space - Maps PCI0 memory0 space for the master.
+ * Inputs: base and length of pci0Mem0
+ */
+
+static void pci0MapMemory0space(unsigned int pci0Mem0Base,
+				unsigned int pci0Mem0Length)
+{
+	unsigned int pci0Mem0Top = pci0Mem0Base + pci0Mem0Length;
+
+	if (pci0Mem0Length == 0)
+		pci0Mem0Top++;
+
+	pci0Mem0Base = pci0Mem0Base >> 21;
+	pci0Mem0Top = ((pci0Mem0Top - 1) & 0x0fffffff) >> 21;
+	GT_WRITE(GT_PCI0M0LD_OFS, pci0Mem0Base);
+	GT_WRITE(GT_PCI0M0HD_OFS, pci0Mem0Top);
+}
+
+/*
+ * pci1MapMemory0space - Maps PCI1 memory0 space for the master.
+ * Inputs: base and length of pci1Mem0
+ */
+
+static void pci1MapMemory0space(unsigned int pci1Mem0Base,
+				unsigned int pci1Mem0Length)
+{
+	unsigned int pci1Mem0Top = pci1Mem0Base + pci1Mem0Length;
+
+	if (pci1Mem0Length == 0)
+		pci1Mem0Top++;
+
+	pci1Mem0Base = pci1Mem0Base >> 21;
+	pci1Mem0Top = ((pci1Mem0Top - 1) & 0x0fffffff) >> 21;
+	GT_WRITE(GT_PCI1M0LD_OFS, pci1Mem0Base);
+	GT_WRITE(GT_PCI1M0HD_OFS, pci1Mem0Top);
+}
+
+/*
+ * pci0MapMemory1space - Maps PCI0 memory1 space for the master.
+ * Inputs: base and length of pci0Mem1
+ */
+
+static void pci0MapMemory1space(unsigned int pci0Mem1Base,
+				unsigned int pci0Mem1Length)
+{
+	unsigned int pci0Mem1Top = pci0Mem1Base + pci0Mem1Length;
+
+	if (pci0Mem1Length == 0)
+		pci0Mem1Top++;
+
+	pci0Mem1Base = pci0Mem1Base >> 21;
+	pci0Mem1Top = ((pci0Mem1Top - 1) & 0x0fffffff) >> 21;
+	GT_WRITE(GT_PCI0M1LD_OFS, pci0Mem1Base);
+	GT_WRITE(GT_PCI0M1HD_OFS, pci0Mem1Top);
+
+}
+
+/*
+ * pci1MapMemory1space - Maps PCI1 memory1 space for the master.
+ * Inputs: base and length of pci1Mem1
+ */
+
+static void pci1MapMemory1space(unsigned int pci1Mem1Base,
+				unsigned int pci1Mem1Length)
+{
+	unsigned int pci1Mem1Top = pci1Mem1Base + pci1Mem1Length;
+
+	if (pci1Mem1Length == 0)
+		pci1Mem1Top++;
+
+	pci1Mem1Base = pci1Mem1Base >> 21;
+	pci1Mem1Top = ((pci1Mem1Top - 1) & 0x0fffffff) >> 21;
+	GT_WRITE(GT_PCI1M1LD_OFS, pci1Mem1Base);
+	GT_WRITE(GT_PCI1M1HD_OFS, pci1Mem1Top);
+}
+
+/*
+ * pci0GetIOspaceBase - Return PCI0 IO Base Address.
+ * Inputs: N/A
+ * Returns: PCI0 IO Base Address.
+ */
+
+static unsigned int pci0GetIOspaceBase(void)
+{
+	unsigned int base;
+	GT_READ(GT_PCI0IOLD_OFS, &base);
+	base = base << 21;
+	return base;
+}
+
+/*
+ * pci0GetIOspaceSize - Return PCI0 IO Bar Size.
+ * Inputs: N/A
+ * Returns: PCI0 IO Bar Size.
+ */
+
+static unsigned int pci0GetIOspaceSize(void)
+{
+	unsigned int top, base, size;
+	GT_READ(GT_PCI0IOLD_OFS, &base);
+	base = base << 21;
+	GT_READ(GT_PCI0IOHD_OFS, &top);
+	top = (top << 21);
+	size = ((top - base) & 0xfffffff);
+	size = size | 0x1fffff;
+	return (size + 1);
+}
+
+/*
+ * pci0GetMemory0Base - Return PCI0 Memory 0 Base Address.
+ * Inputs: N/A
+ * Returns: PCI0 Memory 0 Base Address.
+ */
+
+static unsigned int pci0GetMemory0Base(void)
+{
+	unsigned int base;
+	GT_READ(GT_PCI0M0LD_OFS, &base);
+	base = base << 21;
+	return base;
+}
+
+/*
+ * pci0GetMemory0Size - Return PCI0 Memory 0 Bar Size.
+ * Inputs: N/A
+ * Returns: PCI0 Memory 0 Bar Size.
+ */
+
+static unsigned int pci0GetMemory0Size(void)
+{
+	unsigned int top, base, size;
+	GT_READ(GT_PCI0M0LD_OFS, &base);
+	base = base << 21;
+	GT_READ(GT_PCI0M0HD_OFS, &top);
+	top = (top << 21);
+	size = ((top - base) & 0xfffffff);
+	size = size | 0x1fffff;
+	return (size + 1);
+}
+
+/*
+ * pci0GetMemory1Base - Return PCI0 Memory 1 Base Address.
+ * Inputs: N/A
+ * Returns: PCI0 Memory 1 Base Address.
+ */
+
+static unsigned int pci0GetMemory1Base(void)
+{
+	unsigned int base;
+	GT_READ(GT_PCI0M1LD_OFS, &base);
+	base = base << 21;
+	return base;
+}
+
+/*
+ * pci0GetMemory1Size - Return PCI0 Memory 1 Bar Size.
+ * Inputs: N/A
+ * Returns: PCI0 Memory 1 Bar Size.
+ */
+
+static unsigned int pci0GetMemory1Size(void)
+{
+	unsigned int top, base, size;
+	GT_READ(GT_PCI0M1LD_OFS, &base);
+	base = base << 21;
+	GT_READ(GT_PCI0M1HD_OFS, &top);
+	top = (top << 21);
+	size = ((top - base) & 0xfffffff);
+	size = size | 0x1fffff;
+	return (size + 1);
+}
+
+/*
+ * pci1GetIOspaceBase - Return PCI1 IO Base Address.
+ * Inputs: N/A
+ * Returns: PCI1 IO Base Address.
+ */
+
+static unsigned int pci1GetIOspaceBase(void)
+{
+	unsigned int base;
+	GT_READ(GT_PCI1IOLD_OFS, &base);
+	base = base << 21;
+	return base;
+}
+
+/*
+ * pci1GetIOspaceSize - Return PCI1 IO Bar Size.
+ * Inputs: N/A
+ * Returns: PCI1 IO Bar Size.
+ */
+
+static unsigned int pci1GetIOspaceSize(void)
+{
+	unsigned int top, base, size;
+	GT_READ(GT_PCI1IOLD_OFS, &base);
+	base = base << 21;
+	GT_READ(GT_PCI1IOHD_OFS, &top);
+	top = (top << 21);
+	size = ((top - base) & 0xfffffff);
+	size = size | 0x1fffff;
+	return (size + 1);
+}
+
+/*
+ * pci1GetMemory0Base - Return PCI1 Memory 0 Base Address.
+ * Inputs: N/A
+ * Returns: PCI1 Memory 0 Base Address.
+ */
+
+static unsigned int pci1GetMemory0Base(void)
+{
+	unsigned int base;
+	GT_READ(GT_PCI1M0LD_OFS, &base);
+	base = base << 21;
+	return base;
+}
+
+/*
+ * pci1GetMemory0Size - Return PCI1 Memory 0 Bar Size.
+ * Inputs: N/A
+ * Returns: PCI1 Memory 0 Bar Size.
+ */
+
+static unsigned int pci1GetMemory0Size(void)
+{
+	unsigned int top, base, size;
+	GT_READ(GT_PCI1M1LD_OFS, &base);
+	base = base << 21;
+	GT_READ(GT_PCI1M1HD_OFS, &top);
+	top = (top << 21);
+	size = ((top - base) & 0xfffffff);
+	size = size | 0x1fffff;
+	return (size + 1);
+}
+
+/*
+ * pci1GetMemory1Base - Return PCI1 Memory 1 Base Address.
+ * Inputs: N/A
+ * Returns: PCI1 Memory 1 Base Address.
+ */
+
+static unsigned int pci1GetMemory1Base(void)
+{
+	unsigned int base;
+	GT_READ(GT_PCI1M1LD_OFS, &base);
+	base = base << 21;
+	return base;
+}
+
+/*
+ * pci1GetMemory1Size - Return PCI1 Memory 1 Bar Size.
+ * Inputs: N/A
+ * Returns: PCI1 Memory 1 Bar Size.
+ */
+
+static unsigned int pci1GetMemory1Size(void)
+{
+	unsigned int top, base, size;
+	GT_READ(GT_PCI1M1LD_OFS, &base);
+	base = base << 21;
+	GT_READ(GT_PCI1M1HD_OFS, &top);
+	top = (top << 21);
+	size = ((top - base) & 0xfffffff);
+	size = size | 0x1fffff;
+	return (size + 1);
+}
+
+
+
+/*
+ * pci_range_ck -
+ *
+ * Check if the pci device that are trying to access does really exists
+ * on the evaluation board.  
+ *
+ * Inputs :
+ * bus - bus number (0 for PCI 0 ; 1 for PCI 1)
+ * dev - number of device on the specific pci bus
+ *
+ * Outpus :
+ * 0 - if OK , 1 - if failure
+ */
+static __inline__ int pci_range_ck(unsigned char bus, unsigned char dev)
+{
+	/*
+	 * We don't even pretend to handle other busses than bus 0 correctly.
+	 * Accessing device 31 crashes the CP7000 for some reason.
+	 */
+	if ((bus == 0) && (dev != 31))
+		return 0;
+	return -1;
+}
+
+/*
+ * pciXReadConfigReg  - Read from a PCI configuration register
+ *                    - Make sure the GT is configured as a master before 
+ *                      reading from another device on the PCI.
+ *                   - The function takes care of Big/Little endian conversion.
+ * INPUTS:   regOffset: The register offset as it apears in the GT spec (or PCI
+ *                        spec)
+ *           pciDevNum: The device number needs to be addressed.                
+ * RETURNS: data , if the data == 0xffffffff check the master abort bit in the 
+ *                 cause register to make sure the data is valid
+ *
+ *  Configuration Address 0xCF8:
+ *
+ *       31 30    24 23  16 15  11 10     8 7      2  0     <=bit Number
+ *  |congif|Reserved|  Bus |Device|Function|Register|00|
+ *  |Enable|        |Number|Number| Number | Number |  |    <=field Name
+ *
+ */
+static unsigned int pci0ReadConfigReg(int offset, struct pci_dev *device)
+{
+	unsigned int DataForRegCf8;
+	unsigned int data;
+
+	DataForRegCf8 = ((PCI_SLOT(device->devfn) << 11) |
+			 (PCI_FUNC(device->devfn) << 8) |
+			 (offset & ~0x3)) | 0x80000000;
+	GT_WRITE(GT_PCI0_CFGADDR_OFS, DataForRegCf8);
+
+	/*
+	 * The casual observer might wonder why the READ is duplicated here,
+	 * rather than immediately following the WRITE, and just have the swap
+	 * in the "if".  That's because there is a latency problem with trying
+	 * to read immediately after setting up the address register.  The "if"
+	 * check gives enough time for the address to stabilize, so the READ
+	 * can work.
+	 */
+	if (PCI_SLOT(device->devfn) == SELF) {	/* This board */
+		GT_READ(GT_PCI0_CFGDATA_OFS, &data);
+		return data;
+	} else { /* The PCI is working in LE Mode so swap the Data. */
+		GT_READ(GT_PCI0_CFGDATA_OFS, &data);
+		return cpu_to_le32(data);
+	}
+}
+
+static unsigned int pci1ReadConfigReg(int offset, struct pci_dev *device)
+{
+	unsigned int DataForRegCf8;
+	unsigned int data;
+
+	DataForRegCf8 = ((PCI_SLOT(device->devfn) << 11) |
+			 (PCI_FUNC(device->devfn) << 8) |
+			 (offset & ~0x3)) | 0x80000000;
+	/*
+	 * The casual observer might wonder why the READ is duplicated here,
+	 * rather than immediately following the WRITE, and just have the
+	 * swap in the "if".  That's because there is a latency problem
+	 * with trying to read immediately after setting up the address
+	 * register.  The "if" check gives enough time for the address
+	 * to stabilize, so the READ can work.
+	 */
+	if (PCI_SLOT(device->devfn) == SELF) {	/* This board */
+		/* when configurating our own PCI 1 L-unit the access is through  
+		   the PCI 0 interface with reg number = reg number + 0x80 */
+		DataForRegCf8 |= 0x80;
+		GT_WRITE(GT_PCI0_CFGADDR_OFS, DataForRegCf8);
+	} else {		/* The PCI is working in LE Mode so swap the Data. */
+		GT_WRITE(GT_PCI1_CFGADDR_OFS, DataForRegCf8);
+	}
+	if (PCI_SLOT(device->devfn) == SELF) {	/* This board */
+		GT_READ(GT_PCI0_CFGDATA_OFS, &data);
+		return data;
+	} else {
+		GT_READ(GT_PCI1_CFGDATA_OFS, &data);
+		return cpu_to_le32(data);
+	}
+}
+
+
+
+/*
+ * pciXWriteConfigReg - Write to a PCI configuration register
+ *                    - Make sure the GT is configured as a master before 
+ *                      writingto another device on the PCI.
+ *                    - The function takes care of Big/Little endian conversion.
+ * Inputs:   unsigned int regOffset: The register offset as it apears in the
+ *           GT spec 
+ *                   (or any other PCI device spec)
+ *           pciDevNum: The device number needs to be addressed.                
+ *
+ *  Configuration Address 0xCF8:
+ *
+ *       31 30    24 23  16 15  11 10     8 7      2  0     <=bit Number
+ *  |congif|Reserved|  Bus |Device|Function|Register|00|
+ *  |Enable|        |Number|Number| Number | Number |  |    <=field Name
+ *
+ */
+static void pci0WriteConfigReg(unsigned int offset,
+			       struct pci_dev *device, unsigned int data)
+{
+	unsigned int DataForRegCf8;
+
+	DataForRegCf8 = ((PCI_SLOT(device->devfn) << 11) |
+			 (PCI_FUNC(device->devfn) << 8) |
+			 (offset & ~0x3)) | 0x80000000;
+	GT_WRITE(GT_PCI0_CFGADDR_OFS, DataForRegCf8);
+	if (PCI_SLOT(device->devfn) == SELF) {	/* This board */
+		GT_WRITE(GT_PCI0_CFGDATA_OFS, data);
+	} else {		/* configuration Transaction over the pci. */
+		/* The PCI is working in LE Mode so swap the Data. */
+		GT_WRITE(GT_PCI0_CFGDATA_OFS, le32_to_cpu(data));
+	}
+}
+
+static void pci1WriteConfigReg(unsigned int offset,
+			       struct pci_dev *device, unsigned int data)
+{
+	unsigned int DataForRegCf8;
+
+	DataForRegCf8 = ((PCI_SLOT(device->devfn) << 11) |
+			 (PCI_FUNC(device->devfn) << 8) |
+			 (offset & ~0x3)) | 0x80000000;
+	/*
+	 * There is a latency problem
+	 * with trying to read immediately after setting up the address
+	 * register.  The "if" check gives enough time for the address
+	 * to stabilize, so the WRITE can work.
+	 */
+	if (PCI_SLOT(device->devfn) == SELF) {	/* This board */
+		/*
+		 * when configurating our own PCI 1 L-unit the access is through
+		 * the PCI 0 interface with reg number = reg number + 0x80
+		 */
+		DataForRegCf8 |= 0x80;
+		GT_WRITE(GT_PCI0_CFGADDR_OFS, DataForRegCf8);
+	} else {	/* configuration Transaction over the pci. */
+		/* The PCI is working in LE Mode so swap the Data. */
+		GT_WRITE(GT_PCI1_CFGADDR_OFS, DataForRegCf8);
+	}
+	if (PCI_SLOT(device->devfn) == SELF) {	/* This board */
+		GT_WRITE(GT_PCI0_CFGDATA_OFS, data);
+	} else {		/* configuration Transaction over the pci. */
+		GT_WRITE(GT_PCI1_CFGADDR_OFS, le32_to_cpu(data));
+	}
+}
+
+
+/*
+ * galileo_pcibios_(read/write)_config_(dword/word/byte) -
+ *
+ * reads/write a dword/word/byte register from the configuration space
+ * of a device.
+ *
+ * Inputs :
+ * bus - bus number
+ * dev - device number
+ * offset - register offset in the configuration space
+ * val - value to be written / read
+ *
+ * Outputs :
+ * PCIBIOS_SUCCESSFUL when operation was succesfull
+ * PCIBIOS_DEVICE_NOT_FOUND when the bus or dev is errorneous
+ * PCIBIOS_BAD_REGISTER_NUMBER when accessing non aligned
+ */
+
+static int galileo_pcibios_read_config_dword(struct pci_dev *device,
+					     int offset, u32 * val)
+{
+	int dev, bus;
+	bus = device->bus->number;
+	dev = PCI_SLOT(device->devfn);
+
+	if (pci_range_ck(bus, dev)) {
+		*val = 0xffffffff;
+		return PCIBIOS_DEVICE_NOT_FOUND;
+	}
+	if (offset & 0x3)
+		return PCIBIOS_BAD_REGISTER_NUMBER;
+	if (bus == 0)
+		*val = pci0ReadConfigReg(offset, device);
+
+	/*  This is so that the upper PCI layer will get the correct return value if
+	   we're not attached to anything.  */
+	if ((offset == 0) && (*val == 0xffffffff)) {
+		return PCIBIOS_DEVICE_NOT_FOUND;
+	}
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int galileo_pcibios_read_config_word(struct pci_dev *device,
+					    int offset, u16 * val)
+{
+	int dev, bus;
+
+	bus = device->bus->number;
+	dev = PCI_SLOT(device->devfn);
+
+	if (pci_range_ck(bus, dev)) {
+		*val = 0xffff;
+		return PCIBIOS_DEVICE_NOT_FOUND;
+	}
+	if (offset & 0x1)
+		return PCIBIOS_BAD_REGISTER_NUMBER;
+
+	if (bus == 0)
+		*val =
+		    (unsigned short) (pci0ReadConfigReg(offset, device) >>
+				      ((offset & ~0x3) * 8));
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int galileo_pcibios_read_config_byte(struct pci_dev *device,
+					    int offset, u8 * val)
+{
+	int dev, bus;
+
+	bus = device->bus->number;
+	dev = PCI_SLOT(device->devfn);
+
+	if (pci_range_ck(bus, dev)) {
+		*val = 0xff;
+		return PCIBIOS_DEVICE_NOT_FOUND;
+	}
+
+	if (bus == 0)
+		*val =
+		    (unsigned char) (pci0ReadConfigReg(offset, device) >>
+				     ((offset & ~0x3) * 8));
+
+	/*
+	 *  This is so that the upper PCI layer will get the correct return
+	 * value if we're not attached to anything.
+	 */
+	if ((offset == 0xe) && (*val == 0xff)) {
+		u32 MasterAbort;
+		GT_READ(GT_INTRCAUSE_OFS, &MasterAbort);
+		if (MasterAbort & 0x40000) {
+			GT_WRITE(GT_INTRCAUSE_OFS,
+				 (MasterAbort & 0xfffbffff));
+			return PCIBIOS_DEVICE_NOT_FOUND;
+		}
+	}
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int galileo_pcibios_write_config_dword(struct pci_dev *device,
+					      int offset, u32 val)
+{
+	int dev, bus;
+
+	bus = device->bus->number;
+	dev = PCI_SLOT(device->devfn);
+
+	if (pci_range_ck(bus, dev))
+		return PCIBIOS_DEVICE_NOT_FOUND;
+	if (offset & 0x3)
+		return PCIBIOS_BAD_REGISTER_NUMBER;
+	if (bus == 0)
+		pci0WriteConfigReg(offset, device, val);
+//  if (bus == 1) pci1WriteConfigReg (offset,device,val);
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+
+static int galileo_pcibios_write_config_word(struct pci_dev *device,
+					     int offset, u16 val)
+{
+	int dev, bus;
+	unsigned long tmp;
+
+	bus = device->bus->number;
+	dev = PCI_SLOT(device->devfn);
+
+	if (pci_range_ck(bus, dev))
+		return PCIBIOS_DEVICE_NOT_FOUND;
+	if (offset & 0x1)
+		return PCIBIOS_BAD_REGISTER_NUMBER;
+	if (bus == 0)
+		tmp = pci0ReadConfigReg(offset, device);
+//  if (bus == 1) tmp = pci1ReadConfigReg (offset,device);
+
+	if ((offset % 4) == 0)
+		tmp = (tmp & 0xffff0000) | (val & 0xffff);
+	if ((offset % 4) == 2)
+		tmp = (tmp & 0x0000ffff) | ((val & 0xffff) << 16);
+
+	if (bus == 0)
+		pci0WriteConfigReg(offset, device, tmp);
+//  if (bus == 1) pci1WriteConfigReg (offset,device,tmp);
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int galileo_pcibios_write_config_byte(struct pci_dev *device,
+					     int offset, u8 val)
+{
+	int dev, bus;
+	unsigned long tmp;
+
+	bus = device->bus->number;
+	dev = PCI_SLOT(device->devfn);
+
+	if (pci_range_ck(bus, dev))
+		return PCIBIOS_DEVICE_NOT_FOUND;
+	if (bus == 0)
+		tmp = pci0ReadConfigReg(offset, device);
+//  if (bus == 1) tmp = pci1ReadConfigReg (offset,device);
+
+	if ((offset % 4) == 0)
+		tmp = (tmp & 0xffffff00) | (val & 0xff);
+	if ((offset % 4) == 1)
+		tmp = (tmp & 0xffff00ff) | ((val & 0xff) << 8);
+	if ((offset % 4) == 2)
+		tmp = (tmp & 0xff00ffff) | ((val & 0xff) << 16);
+	if ((offset % 4) == 3)
+		tmp = (tmp & 0x00ffffff) | ((val & 0xff) << 24);
+
+	if (bus == 0)
+		pci0WriteConfigReg(offset, device, tmp);
+//  if (bus == 1) pci1WriteConfigReg (offset,device,tmp);
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static void galileo_pcibios_set_master(struct pci_dev *dev)
+{
+	u16 cmd;
+
+	galileo_pcibios_read_config_word(dev, PCI_COMMAND, &cmd);
+	cmd |= PCI_COMMAND_MASTER;
+	galileo_pcibios_write_config_word(dev, PCI_COMMAND, cmd);
+}
+
+/*  Externally-expected functions.  Do not change function names  */
+
+int pcibios_enable_resources(struct pci_dev *dev)
+{
+	u16 cmd, old_cmd;
+	u8 tmp1;
+	int idx;
+	struct resource *r;
+
+	galileo_pcibios_read_config_word(dev, PCI_COMMAND, &cmd);
+	old_cmd = cmd;
+	for (idx = 0; idx < 6; idx++) {
+		r = &dev->resource[idx];
+		if (!r->start && r->end) {
+			printk(KERN_ERR
+			       "PCI: Device %s not available because of "
+			       "resource collisions\n", dev->slot_name);
+			return -EINVAL;
+		}
+		if (r->flags & IORESOURCE_IO)
+			cmd |= PCI_COMMAND_IO;
+		if (r->flags & IORESOURCE_MEM)
+			cmd |= PCI_COMMAND_MEMORY;
+	}
+	if (cmd != old_cmd) {
+		galileo_pcibios_write_config_word(dev, PCI_COMMAND, cmd);
+	}
+
+	/*
+	 * Let's fix up the latency timer and cache line size here.  Cache
+	 * line size = 32 bytes / sizeof dword (4) = 8.
+	 * Latency timer must be > 8.  32 is random but appears to work.
+	 */
+	galileo_pcibios_read_config_byte(dev, PCI_CACHE_LINE_SIZE, &tmp1);
+	if (tmp1 != 8) {
+		printk(KERN_WARNING "PCI setting cache line size to 8 from "
+		       "%d\n", tmp1);
+		galileo_pcibios_write_config_byte(dev, PCI_CACHE_LINE_SIZE,
+						  8);
+	}
+	galileo_pcibios_read_config_byte(dev, PCI_LATENCY_TIMER, &tmp1);
+	if (tmp1 < 32) {
+		printk(KERN_WARNING "PCI setting latency timer to 32 from %d\n",
+		       tmp1);
+		galileo_pcibios_write_config_byte(dev, PCI_LATENCY_TIMER,
+						  32);
+	}
+
+	return 0;
+}
+
+int pcibios_enable_device(struct pci_dev *dev)
+{
+	return pcibios_enable_resources(dev);
+}
+
+void pcibios_update_resource(struct pci_dev *dev, struct resource *root,
+			     struct resource *res, int resource)
+{
+	u32 new, check;
+	int reg;
+
+	return;
+
+	new = res->start | (res->flags & PCI_REGION_FLAG_MASK);
+	if (resource < 6) {
+		reg = PCI_BASE_ADDRESS_0 + 4 * resource;
+	} else if (resource == PCI_ROM_RESOURCE) {
+		res->flags |= PCI_ROM_ADDRESS_ENABLE;
+		reg = dev->rom_base_reg;
+	} else {
+		/*
+		 * Somebody might have asked allocation of a non-standard
+		 * resource
+		 */
+		return;
+	}
+
+	pci_write_config_dword(dev, reg, new);
+	pci_read_config_dword(dev, reg, &check);
+	if ((new ^ check) &
+	    ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK :
+	     PCI_BASE_ADDRESS_MEM_MASK)) {
+		printk(KERN_ERR "PCI: Error while updating region "
+		       "%s/%d (%08x != %08x)\n", dev->slot_name, resource,
+		       new, check);
+	}
+}
+
+void pcibios_align_resource(void *data, struct resource *res,
+			    unsigned long size)
+{
+	struct pci_dev *dev = data;
+
+	if (res->flags & IORESOURCE_IO) {
+		unsigned long start = res->start;
+
+		/* We need to avoid collisions with `mirrored' VGA ports
+		   and other strange ISA hardware, so we always want the
+		   addresses kilobyte aligned.  */
+		if (size > 0x100) {
+			printk(KERN_ERR "PCI: I/O Region %s/%d too large"
+			       " (%ld bytes)\n", dev->slot_name,
+			        dev->resource - res, size);
+		}
+
+		start = (start + 1024 - 1) & ~(1024 - 1);
+		res->start = start;
+	}
+}
+
+struct pci_ops galileo_pci_ops = {
+	galileo_pcibios_read_config_byte,
+	galileo_pcibios_read_config_word,
+	galileo_pcibios_read_config_dword,
+	galileo_pcibios_write_config_byte,
+	galileo_pcibios_write_config_word,
+	galileo_pcibios_write_config_dword
+};
+
+struct pci_fixup pcibios_fixups[] = {
+	{0}
+};
+
+void __init pcibios_fixup_bus(struct pci_bus *c)
+{
+	gt64120_board_pcibios_fixup_bus(c);
+}
+
+/*
+ * This code was derived from Galileo Technology's example
+ * and significantly reworked.
+ *
+ * This is very simple.  It does not scan multiple function devices.  It does
+ * not scan behind bridges.  Those would be simple to implement, but we don't
+ * currently need this.
+ */
+
+static void __init scan_and_initialize_pci(void)
+{
+	struct pci_device pci_devices[MAX_PCI_DEVS];
+
+	if (scan_pci_bus(pci_devices)) {
+		allocate_pci_space(pci_devices);
+	}
+}
+
+/*
+ * This is your basic PCI scan.  It goes through each slot and checks to
+ * see if there's something that responds.  If so, then get the size and
+ * type of each of the responding BARs.  Save them for later.
+ */
+
+static u32 __init scan_pci_bus(struct pci_device *pci_devices)
+{
+	u32 arrayCounter = 0;
+	u32 memType;
+	u32 memSize;
+	u32 pci_slot, bar;
+	u32 id;
+	u32 c18RegValue;
+	struct pci_dev device;
+
+	/*
+	 * According to PCI REV 2.1 MAX agents on the bus are 21.
+	 * We don't bother scanning ourselves (slot 0).
+	 */
+	for (pci_slot = 1; pci_slot < 22; pci_slot++) {
+
+		device.devfn = PCI_DEVFN(pci_slot, 0);
+		id = pci0ReadConfigReg(PCI_VENDOR_ID, &device);
+
+		/*
+		 *  Check for a PCI Master Abort (nothing responds in the
+		 * slot)
+		 */
+		GT_READ(GT_INTRCAUSE_OFS, &c18RegValue);
+		/*
+		 * Clearing bit 18 of in the Cause Register 0xc18 by
+		 * writting 0.
+		 */
+		GT_WRITE(GT_INTRCAUSE_OFS, (c18RegValue & 0xfffbffff));
+		if ((id != 0xffffffff) && !(c18RegValue & 0x40000)) {
+			pci_devices[arrayCounter].slot = pci_slot;
+			for (bar = 0; bar < 6; bar++) {
+				memType =
+				    pci0ReadConfigReg(PCI_BASE_ADDRESS_0 +
+						      (bar * 4), &device);
+				pci_devices[arrayCounter].BARtype[bar] =
+				    memType & 1;
+				pci0WriteConfigReg(PCI_BASE_ADDRESS_0 +
+						   (bar * 4), &device,
+						   0xffffffff);
+				memSize =
+				    pci0ReadConfigReg(PCI_BASE_ADDRESS_0 +
+						      (bar * 4), &device);
+				if (memType & 1) {	/*  IO space  */
+					pci_devices[arrayCounter].
+					    BARsize[bar] =
+					    ~(memSize & 0xfffffffc) + 1;
+				} else {	/*  memory space */
+					pci_devices[arrayCounter].
+					    BARsize[bar] =
+					    ~(memSize & 0xfffffff0) + 1;
+				}
+			}	/*  BAR counter  */
+
+			arrayCounter++;
+		}
+		/*  found a device  */
+	} /*  slot counter  */
+
+	if (arrayCounter < MAX_PCI_DEVS)
+		pci_devices[arrayCounter].slot = -1;
+
+	return arrayCounter;
+}
+
+#define ALIGN(val,align)        (((val) + ((align) - 1)) & ~((align) - 1))
+#define MAX(val1, val2) ((val1) > (val2) ? (val1) : (val2))
+
+/*
+ * This function goes through the list of devices and allocates the BARs in
+ * either IO or MEM space.  It does it in order of size, which will limit the
+ * amount of fragmentation we have in the IO and MEM spaces.
+ */
+
+static void __init allocate_pci_space(struct pci_device *pci_devices)
+{
+	u32 count, maxcount, bar;
+	u32 maxSize, maxDevice, maxBAR;
+	u32 alignto;
+	u32 base;
+	u32 pci0_mem_base = pci0GetMemory0Base();
+	u32 pci0_io_base = pci0GetIOspaceBase();
+	struct pci_dev device;
+
+	/*  How many PCI devices do we have?  */
+	maxcount = MAX_PCI_DEVS;
+	for (count = 0; count < MAX_PCI_DEVS; count++) {
+		if (pci_devices[count].slot == -1) {
+			maxcount = count;
+			break;
+		}
+	}
+
+	do {
+		/*  Find the largest size BAR we need to allocate  */
+		maxSize = 0;
+		for (count = 0; count < maxcount; count++) {
+			for (bar = 0; bar < 6; bar++) {
+				if (pci_devices[count].BARsize[bar] >
+				    maxSize) {
+					maxSize =
+					    pci_devices[count].
+					    BARsize[bar];
+					maxDevice = count;
+					maxBAR = bar;
+				}
+			}
+		}
+
+		/*
+		 * We've found the largest BAR.  Allocate it into IO or
+		 * mem space.  We don't idiot check the bases to make
+		 * sure they haven't overflowed the current size for that
+		 * aperture.  
+		 * Don't bother to enable the device's IO or MEM space here.
+		 * That will be done in pci_enable_resources if the device is
+		 * activated by a driver.
+		 */
+		if (maxSize) {
+			device.devfn =
+			    PCI_DEVFN(pci_devices[maxDevice].slot, 0);
+			if (pci_devices[maxDevice].BARtype[maxBAR] == 1) {
+				alignto = MAX(0x1000, maxSize);
+				base = ALIGN(pci0_io_base, alignto);
+				pci0WriteConfigReg(PCI_BASE_ADDRESS_0 +
+						   (maxBAR * 4), &device,
+						   base | 0x1);
+				pci0_io_base = base + alignto;
+			} else {
+				alignto = MAX(0x1000, maxSize);
+				base = ALIGN(pci0_mem_base, alignto);
+				pci0WriteConfigReg(PCI_BASE_ADDRESS_0 +
+						   (maxBAR * 4), &device,
+						   base);
+				pci0_mem_base = base + alignto;
+			}
+			/*
+			 * This entry is finished.  Remove it from the list
+			 * we'll scan.
+			 */
+			pci_devices[maxDevice].BARsize[maxBAR] = 0;
+		}
+	} while (maxSize);
+}
+
+void __init pcibios_init(void)
+{
+	u32 tmp;
+	struct pci_dev controller;
+
+	controller.devfn = SELF;
+
+	GT_READ(GT_PCI0_CMD_OFS, &tmp);
+	GT_READ(GT_PCI0_BARE_OFS, &tmp);
+
+	/*
+	 * You have to enable bus mastering to configure any other
+	 * card on the bus.
+	 */
+	tmp = pci0ReadConfigReg(PCI_COMMAND, &controller);
+	tmp |= PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_SERR;
+	pci0WriteConfigReg(PCI_COMMAND, &controller, tmp);
+
+	/*  This scans the PCI bus and sets up initial values.  */
+	scan_and_initialize_pci();
+
+	/*
+	 *  Reset PCI I/O and PCI MEM values to ones supported by EVM.
+	 */
+	ioport_resource.start = GT_PCI_IO_BASE;
+	ioport_resource.end   = GT_PCI_IO_BASE + GT_PCI_IO_SIZE - 1;
+	iomem_resource.start  = GT_PCI_MEM_BASE;
+	iomem_resource.end    = GT_PCI_MEM_BASE + GT_PCI_MEM_BASE - 1;
+
+	pci_scan_bus(0, &galileo_pci_ops, NULL);
+}
+
+/*
+ * for parsing "pci=" kernel boot arguments.
+ */
+char *pcibios_setup(char *str)
+{
+        printk(KERN_INFO "rr: pcibios_setup\n");
+        /* Nothing to do for now.  */
+
+        return str;
+}
+
+unsigned __init int pcibios_assign_all_busses(void)
+{
+	return 1;
+}
+
+#endif	/* CONFIG_PCI */
diff -u --recursive --new-file v2.4.9/linux/arch/mips/gt64120/momenco_ocelot/Makefile linux/arch/mips/gt64120/momenco_ocelot/Makefile
--- v2.4.9/linux/arch/mips/gt64120/momenco_ocelot/Makefile	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/gt64120/momenco_ocelot/Makefile	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,20 @@
+#
+# Makefile for Momentum's Ocelot board.
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+
+.S.s:
+	$(CPP) $(CFLAGS) $< -o $*.s
+.S.o:
+	$(CC) $(CFLAGS) -c $< -o $*.o
+
+O_TARGET:= momenco_ocelot.o
+
+obj-y	 += int-handler.o irq.o pci.o prom.o reset.o setup.o
+
+obj-$(CONFIG_REMOTE_DEBUG) += dbg_io.o
+
+include $(TOPDIR)/Rules.make
diff -u --recursive --new-file v2.4.9/linux/arch/mips/gt64120/momenco_ocelot/dbg_io.c linux/arch/mips/gt64120/momenco_ocelot/dbg_io.c
--- v2.4.9/linux/arch/mips/gt64120/momenco_ocelot/dbg_io.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/gt64120/momenco_ocelot/dbg_io.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,124 @@
+#include <linux/config.h>
+
+#if defined(CONFIG_REMOTE_DEBUG)
+
+/* --- CONFIG --- */
+
+typedef unsigned char uint8;
+typedef unsigned int uint32;
+
+/* --- END OF CONFIG --- */
+
+#define         UART16550_BAUD_2400             2400
+#define         UART16550_BAUD_4800             4800
+#define         UART16550_BAUD_9600             9600
+#define         UART16550_BAUD_19200            19200
+#define         UART16550_BAUD_38400            38400
+#define         UART16550_BAUD_57600            57600
+#define         UART16550_BAUD_115200           115200
+
+#define         UART16550_PARITY_NONE           0
+#define         UART16550_PARITY_ODD            0x08
+#define         UART16550_PARITY_EVEN           0x18
+#define         UART16550_PARITY_MARK           0x28
+#define         UART16550_PARITY_SPACE          0x38
+
+#define         UART16550_DATA_5BIT             0x0
+#define         UART16550_DATA_6BIT             0x1
+#define         UART16550_DATA_7BIT             0x2
+#define         UART16550_DATA_8BIT             0x3
+
+#define         UART16550_STOP_1BIT             0x0
+#define         UART16550_STOP_2BIT             0x4
+
+/* ----------------------------------------------------- */
+
+/* === CONFIG === */
+
+/* [jsun] we use the second serial port for kdb */
+#define         BASE                    0xbd000020
+#define         MAX_BAUD                115200
+
+/* === END OF CONFIG === */
+
+#define         REG_OFFSET              4
+
+/* register offset */
+#define         OFS_RCV_BUFFER          0
+#define         OFS_TRANS_HOLD          0
+#define         OFS_SEND_BUFFER         0
+#define         OFS_INTR_ENABLE         (1*REG_OFFSET)
+#define         OFS_INTR_ID             (2*REG_OFFSET)
+#define         OFS_DATA_FORMAT         (3*REG_OFFSET)
+#define         OFS_LINE_CONTROL        (3*REG_OFFSET)
+#define         OFS_MODEM_CONTROL       (4*REG_OFFSET)
+#define         OFS_RS232_OUTPUT        (4*REG_OFFSET)
+#define         OFS_LINE_STATUS         (5*REG_OFFSET)
+#define         OFS_MODEM_STATUS        (6*REG_OFFSET)
+#define         OFS_RS232_INPUT         (6*REG_OFFSET)
+#define         OFS_SCRATCH_PAD         (7*REG_OFFSET)
+
+#define         OFS_DIVISOR_LSB         (0*REG_OFFSET)
+#define         OFS_DIVISOR_MSB         (1*REG_OFFSET)
+
+
+/* memory-mapped read/write of the port */
+#define         UART16550_READ(y)    (*((volatile uint8*)(BASE + y)))
+#define         UART16550_WRITE(y, z)  ((*((volatile uint8*)(BASE + y))) = z)
+
+void debugInit(uint32 baud, uint8 data, uint8 parity, uint8 stop)
+{
+	/* disable interrupts */
+	UART16550_WRITE(OFS_INTR_ENABLE, 0);
+
+	/* set up buad rate */
+	{
+		uint32 divisor;
+
+		/* set DIAB bit */
+		UART16550_WRITE(OFS_LINE_CONTROL, 0x80);
+
+		/* set divisor */
+		divisor = MAX_BAUD / baud;
+		UART16550_WRITE(OFS_DIVISOR_LSB, divisor & 0xff);
+		UART16550_WRITE(OFS_DIVISOR_MSB, (divisor & 0xff00) >> 8);
+
+		/* clear DIAB bit */
+		UART16550_WRITE(OFS_LINE_CONTROL, 0x0);
+	}
+
+	/* set data format */
+	UART16550_WRITE(OFS_DATA_FORMAT, data | parity | stop);
+}
+
+static int remoteDebugInitialized = 0;
+
+uint8 getDebugChar(void)
+{
+	if (!remoteDebugInitialized) {
+		remoteDebugInitialized = 1;
+		debugInit(UART16550_BAUD_38400,
+			  UART16550_DATA_8BIT,
+			  UART16550_PARITY_NONE, UART16550_STOP_1BIT);
+	}
+
+	while ((UART16550_READ(OFS_LINE_STATUS) & 0x1) == 0);
+	return UART16550_READ(OFS_RCV_BUFFER);
+}
+
+
+int putDebugChar(uint8 byte)
+{
+	if (!remoteDebugInitialized) {
+		remoteDebugInitialized = 1;
+		debugInit(UART16550_BAUD_9600,
+			  UART16550_DATA_8BIT,
+			  UART16550_PARITY_NONE, UART16550_STOP_1BIT);
+	}
+
+	while ((UART16550_READ(OFS_LINE_STATUS) & 0x20) == 0);
+	UART16550_WRITE(OFS_SEND_BUFFER, byte);
+	return 1;
+}
+
+#endif
diff -u --recursive --new-file v2.4.9/linux/arch/mips/gt64120/momenco_ocelot/int-handler.S linux/arch/mips/gt64120/momenco_ocelot/int-handler.S
--- v2.4.9/linux/arch/mips/gt64120/momenco_ocelot/int-handler.S	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/gt64120/momenco_ocelot/int-handler.S	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: jsun@mvista.com or jsun@junsun.net
+ *
+ * First-level interrupt dispatcher for ocelot board.
+ *
+ * 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 <linux/config.h>
+#include <asm/asm.h>
+#include <asm/mipsregs.h>
+#include <asm/addrspace.h>
+#include <asm/regdef.h>
+#include <asm/stackframe.h>
+
+/*
+ * first level interrupt dispatcher for ocelot board -
+ * We check for the timer first, then check PCI ints A and D.
+ * Then check for serial IRQ and fall through.
+ */
+		.align	5
+		NESTED(ocelot_handle_int, PT_SIZE, sp)
+		SAVE_ALL
+		CLI
+		.set	at
+		mfc0	t0, CP0_CAUSE  
+		mfc0	t2, CP0_STATUS
+
+		and	t0, t2
+        
+		 andi	t1, t0, STATUSF_IP2	/* int0 hardware line */
+		bnez	t1, ll_pri_enet_irq
+		 andi	t1, t0, STATUSF_IP3	/* int1 hardware line */
+		bnez	t1, ll_sec_enet_irq
+		 andi	t1, t0, STATUSF_IP4	/* int2 hardware line */
+		bnez	t1, ll_uart1_irq
+		 andi	t1, t0, STATUSF_IP5	/* int3 hardware line */
+		bnez	t1, ll_cpci_irq
+		 andi	t1, t0, STATUSF_IP6	/* int4 hardware line */
+		bnez	t1, ll_galileo_irq
+		 andi	t1, t0, STATUSF_IP7	/* cpu timer */
+		bnez	t1, ll_cputimer_irq
+
+                /* now look at the extended interrupts */
+		mfc0	t0, CP0_CAUSE  
+		cfc0	t1, CP0_S1_INTCONTROL
+
+		/* shift the mask 8 bits left to line up the bits */
+		 sll	t2, t1, 8
+
+		 and	t0, t2
+		 srl	t0, t0, 16
+
+		 andi	t1, t0, STATUSF_IP8	/* int6 hardware line */
+		bnez	t1, ll_pmc1_irq
+		 andi	t1, t0, STATUSF_IP9	/* int7 hardware line */
+		bnez	t1, ll_pmc2_irq
+		 andi	t1, t0, STATUSF_IP10	/* int8 hardware line */
+		bnez	t1, ll_cpci_abcd_irq
+		 andi	t1, t0, STATUSF_IP11	/* int9 hardware line */
+		bnez	t1, ll_uart2_irq
+
+		.set	reorder
+
+		/* wrong alarm or masked ... */
+		j	spurious_interrupt
+		nop
+		END(ocelot_handle_int)
+
+		.align	5
+ll_pri_enet_irq:
+		li	a0, 2
+		move	a1, sp
+		jal	do_IRQ
+		j	ret_from_irq
+
+ll_sec_enet_irq:
+		li	a0, 3
+		move	a1, sp
+		jal	do_IRQ
+		j	ret_from_irq
+
+ll_uart1_irq:
+		li	a0, 4
+		move	a1, sp
+		jal	do_IRQ
+		j	ret_from_irq
+	
+ll_cpci_irq:
+		li	a0, 5
+		move	a1, sp
+		jal	do_IRQ
+		j	ret_from_irq
+
+ll_galileo_irq:
+		li	a0, 6
+		move	a1, sp
+		jal	do_IRQ
+		j	ret_from_irq
+
+ll_cputimer_irq:
+		li	a0, 7
+		move	a1, sp
+		jal	do_IRQ
+		j	ret_from_irq
+	
+ll_pmc1_irq:
+		li	a0, 8
+		move	a1, sp
+		jal	do_IRQ
+		j	ret_from_irq
+
+ll_pmc2_irq:
+		li	a0, 9
+		move	a1, sp
+		jal	do_IRQ
+		j	ret_from_irq
+
+ll_cpci_abcd_irq:
+		li	a0, 10
+		move	a1, sp
+		jal	do_IRQ
+		j	ret_from_irq
+
+ll_uart2_irq:
+		li	a0, 11
+		move	a1, sp
+		jal	do_IRQ
+		j	ret_from_irq
diff -u --recursive --new-file v2.4.9/linux/arch/mips/gt64120/momenco_ocelot/irq.c linux/arch/mips/gt64120/momenco_ocelot/irq.c
--- v2.4.9/linux/arch/mips/gt64120/momenco_ocelot/irq.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/gt64120/momenco_ocelot/irq.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,173 @@
+/*
+ * Copyright (C) 2000 RidgeRun, Inc.
+ * Author: RidgeRun, Inc.
+ *   glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
+ *
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
+ * Copyright (C) 2000, 2001 Ralf Baechle (ralf@gnu.org)
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kernel_stat.h>
+#include <linux/module.h>
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/ioport.h>
+#include <linux/timex.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+#include <linux/irq.h>
+#include <asm/bitops.h>
+#include <asm/bootinfo.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/mipsregs.h>
+#include <asm/system.h>
+
+
+static spinlock_t rm7000_irq_lock = SPIN_LOCK_UNLOCKED;
+
+/* Function for careful CP0 interrupt mask access */
+static inline void modify_cp0_intmask(unsigned clr_mask_in, unsigned set_mask_in)
+{
+	unsigned long status;
+	unsigned clr_mask;
+	unsigned set_mask;
+
+	/* do the low 8 bits first */
+	clr_mask = 0xff & clr_mask_in;
+	set_mask = 0xff & set_mask_in;
+	status = read_32bit_cp0_register(CP0_STATUS);
+	status &= ~((clr_mask & 0xFF) << 8);
+	status |= (set_mask & 0xFF) << 8;
+	write_32bit_cp0_register(CP0_STATUS, status);
+
+	/* do the high 8 bits */
+	clr_mask = 0xff & (clr_mask_in >> 8);
+	set_mask = 0xff & (set_mask_in >> 8);
+	status = read_32bit_cp0_set1_register(CP0_S1_INTCONTROL);
+	status &= ~((clr_mask & 0xFF) << 8);
+	status |= (set_mask & 0xFF) << 8;
+	write_32bit_cp0_set1_register(CP0_S1_INTCONTROL, status);
+}
+
+static inline void mask_irq(unsigned int irq)
+{
+	modify_cp0_intmask(irq, 0);
+}
+
+static inline void unmask_irq(unsigned int irq)
+{
+	modify_cp0_intmask(0, irq);
+}
+
+static void enable_cp7000_irq(unsigned int irq)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&rm7000_irq_lock, flags);
+	unmask_irq(1 << irq);
+	spin_unlock_irqrestore(&rm7000_irq_lock, flags);
+}
+
+static unsigned int startup_cp7000_irq(unsigned int irq)
+{
+	enable_cp7000_irq(irq);
+
+	return 0;				/* never anything pending */
+}
+
+static void disable_cp7000_irq(unsigned int irq)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&rm7000_irq_lock, flags);
+	mask_irq(1 << irq);
+	spin_unlock_irqrestore(&rm7000_irq_lock, flags);
+}
+
+#define shutdown_cp7000_irq disable_cp7000_irq
+
+static void mask_and_ack_cp7000_irq(unsigned int irq)
+{
+	mask_irq(1 << irq);
+}
+
+static void end_cp7000_irq(unsigned int irq)
+{
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		unmask_irq(1 << irq);
+}
+
+static struct hw_interrupt_type cp7000_hpcdma_irq_type = {
+	"CP7000",
+	startup_cp7000_irq,
+	shutdown_cp7000_irq,
+	enable_cp7000_irq,
+	disable_cp7000_irq,
+	mask_and_ack_cp7000_irq,
+	end_cp7000_irq,
+	NULL
+};
+
+
+extern asmlinkage void ocelot_handle_int(void);
+extern void gt64120_irq_init(void);
+
+void __init init_IRQ(void)
+{
+	int i;
+
+	/*
+	 * Clear all of the interrupts while we change the able around a bit.
+	 * int-handler is not on bootstrap
+	 */
+	clear_cp0_status(ST0_IM | ST0_BEV);
+	__cli();
+
+	/* Sets the first-level interrupt dispatcher. */
+	set_except_vector(0, ocelot_handle_int);
+	init_generic_irq();
+
+	for (i = 0; i <= 15; i++) {
+		irq_desc[i].status	= IRQ_DISABLED;
+		irq_desc[i].action	= 0;
+		irq_desc[i].depth	= 1;
+		irq_desc[i].handler	= &cp7000_hpcdma_irq_type;
+	}
+
+	gt64120_irq_init();
+
+#ifdef CONFIG_REMOTE_DEBUG
+	printk("start kgdb ...\n");
+	set_debug_traps();
+	breakpoint();	/* you may move this line to whereever you want :-) */
+#endif
+#ifdef CONFIG_GDB_CONSOLE
+	register_gdb_console();
+#endif
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/gt64120/momenco_ocelot/ocelot_pld.h linux/arch/mips/gt64120/momenco_ocelot/ocelot_pld.h
--- v2.4.9/linux/arch/mips/gt64120/momenco_ocelot/ocelot_pld.h	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/gt64120/momenco_ocelot/ocelot_pld.h	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,34 @@
+/*
+ * $Id$
+ *
+ * Ocelot Board Register Definitions
+ *
+ * (C) 2001 Red Hat, Inc.
+ *
+ * GPL'd
+ *
+ */
+
+#ifndef __MOMENCO_OCELOT_PLD_H__
+#define __MOMENCO_OCELOT_PLD_H__
+
+#define OCELOT_CS0_ADDR (0xe0020000)
+
+#define OCELOT_REG_BOARDREV (0)
+#define OCELOT_REG_PLD1_ID (1)
+#define OCELOT_REG_PLD2_ID (2)
+#define OCELOT_REG_RESET_STATUS (3)
+#define OCELOT_REG_BOARD_STATUS (4)
+#define OCELOT_REG_CPCI_ID (5)
+#define OCELOT_REG_I2C_CTRL (8)
+#define OCELOT_REG_EEPROM_MODE (9)
+#define OCELOT_REG_INTMASK (10)
+#define OCELOT_REG_INTSTATUS (11)
+#define OCELOT_REG_INTSET (12)
+#define OCELOT_REG_INTCLR (13)
+
+#define OCELOT_PLD_WRITE(x, y) writeb(x, OCELOT_CS0_ADDR + OCELOT_REG_##y)
+#define OCELOT_PLD_READ(x) readb(OCELOT_CS0_ADDR + OCELOT_REG_##x)
+
+
+#endif /* __MOMENCO_OCELOT_PLD_H__ */
diff -u --recursive --new-file v2.4.9/linux/arch/mips/gt64120/momenco_ocelot/pci.c linux/arch/mips/gt64120/momenco_ocelot/pci.c
--- v2.4.9/linux/arch/mips/gt64120/momenco_ocelot/pci.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/gt64120/momenco_ocelot/pci.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
+ *
+ * arch/mips/gt64120/momenco_ocelot/pci.c
+ *     Board-specific PCI routines for gt64120 controller.
+ *
+ * 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 <linux/types.h>
+#include <linux/pci.h>
+#include <linux/kernel.h>
+#include <linux/version.h>
+#include <linux/init.h>
+#include <asm/pci.h>
+
+
+void __init gt64120_board_pcibios_fixup_bus(struct pci_bus *bus)
+{
+	struct pci_bus *current_bus = bus;
+	struct pci_dev *devices;
+	struct list_head *devices_link;
+	u16 cmd;
+
+	list_for_each(devices_link, &(current_bus->devices)) {
+
+		devices = pci_dev_b(devices_link);
+		if (devices == NULL)
+			continue;
+
+		if (PCI_SLOT(devices->devfn) == 1) {
+			/*
+			 * Slot 1 is primary ether port, i82559
+			 * we double-check against that assumption
+			 */
+			if ((devices->vendor != 0x8086) ||
+			    (devices->device != 0x1209) ) {
+				panic("gt64120_board_pcibios_fixup_bus: found "
+				      "unexpected PCI device in slot 1.");
+			}
+			devices->irq = 2;       /* irq_nr is 2 for INT0 */
+		} else if (PCI_SLOT(devices->devfn) == 2) {
+			/*
+			 * Slot 2 is secondary ether port, i21143 
+			 * we double-check against that assumption
+			 */
+			if ((devices->vendor != 0x1011) ||
+			    (devices->device != 0x19) ) {
+				panic("galileo_pcibios_fixup_bus: "
+				      "found unexpected PCI device in slot 2.");
+			}
+			devices->irq = 3;       /* irq_nr is 3 for INT1 */
+		} else if (PCI_SLOT(devices->devfn) == 4) {
+			/* PMC Slot 1 */
+			devices->irq = 8;       /* irq_nr is 8 for INT6 */
+		} else if (PCI_SLOT(devices->devfn) == 5) {
+			/* PMC Slot 1 */
+			devices->irq = 9;       /* irq_nr is 9 for INT7 */
+		} else {
+			/* We don't have assign interrupts for other devices. */
+			devices->irq = 0xff;
+		}
+
+		/* Assign an interrupt number for the device */
+		bus->ops->write_byte(devices, PCI_INTERRUPT_LINE, devices->irq);
+
+		/* enable master */
+		bus->ops->read_word(devices, PCI_COMMAND, &cmd);
+		cmd |= PCI_COMMAND_MASTER;
+		bus->ops->write_word(devices, PCI_COMMAND, cmd);
+	}
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/gt64120/momenco_ocelot/prom.c linux/arch/mips/gt64120/momenco_ocelot/prom.c
--- v2.4.9/linux/arch/mips/gt64120/momenco_ocelot/prom.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/gt64120/momenco_ocelot/prom.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: jsun@mvista.com or jsun@junsun.net
+ *
+ * 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 <linux/init.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <linux/bootmem.h>
+
+#include <asm/addrspace.h>
+#include <asm/bootinfo.h>
+
+#define PLD_BASE	0xbc000000
+
+#define REV             0x0     /* Board Assembly Revision */
+#define PLD1ID          0x1     /* PLD 1 ID */
+#define PLD2ID          0x2     /* PLD 2 ID */
+#define RESET_STAT      0x3     /* Reset Status Register */
+#define BOARD_STAT      0x4     /* Board Status Register */
+#define CPCI_ID         0x5     /* Compact PCI ID Register */
+#define CONTROL         0x8     /* Control Register */
+#define CPU_EEPROM      0x9     /* CPU Configuration EEPROM Register */
+#define INTMASK         0xA     /* Interrupt Mask Register */
+#define INTSTAT         0xB     /* Interrupt Status Register */
+#define INTSET          0xC     /* Interrupt Set Register */
+#define INTCLR          0xD     /* Interrupt Clear Register */
+
+#define PLD_REG(x)	((uint8_t*)(PLD_BASE+(x)))
+
+char arcs_cmdline[COMMAND_LINE_SIZE];
+
+/* [jsun@junsun.net] PMON passes arguments in C main() style */
+void __init prom_init(int argc, const char **arg)
+{
+	int i;
+
+	/* arg[0] is "g", the rest is boot parameters */
+	arcs_cmdline[0] = '\0';
+	for (i = 1; i < argc; i++) {
+		if (strlen(arcs_cmdline) + strlen(arg[i] + 1)
+		    >= sizeof(arcs_cmdline))
+			break;
+		strcat(arcs_cmdline, arg[i]);
+		strcat(arcs_cmdline, " ");
+	}
+
+	mips_machgroup = MACH_GROUP_MOMENCO;
+	mips_machtype = MACH_MOMENCO_OCELOT;
+
+	/* turn off the Bit Error LED, which comes on automatically
+	 * at power-up reset */
+	*PLD_REG(INTCLR) = 0x80;
+
+	/* All the boards have at least 64MiB. If there's more, we
+	   detect and register it later */
+	add_memory_region(0, 64 << 20, BOOT_MEM_RAM);
+}
+
+void __init prom_free_prom_memory(void)
+{
+}
+
+void __init prom_fixup_mem_map(unsigned long start, unsigned long end)
+{
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/gt64120/momenco_ocelot/reset.c linux/arch/mips/gt64120/momenco_ocelot/reset.c
--- v2.4.9/linux/arch/mips/gt64120/momenco_ocelot/reset.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/gt64120/momenco_ocelot/reset.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ *
+ * Copyright (C) 1997, 2001 Ralf Baechle
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: jsun@mvista.com or jsun@junsun.net
+ */
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <asm/io.h>
+#include <asm/pgtable.h>
+#include <asm/processor.h>
+#include <asm/reboot.h>
+#include <asm/system.h>
+
+void momenco_ocelot_restart(char *command)
+{
+	*(volatile char *) 0xbc000000 = 0x0f;
+
+	/*
+	 * Ouch, we're still alive ... This time we take the silver bullet ...
+	 * ... and find that we leave the hardware in a state in which the
+	 * kernel in the flush locks up somewhen during of after the PCI
+	 * detection stuff.
+	 */
+	clear_cp0_status(ST0_BEV | ST0_ERL);
+	change_cp0_config(CONF_CM_CMASK, CONF_CM_UNCACHED);
+	flush_cache_all();
+	write_32bit_cp0_register(CP0_WIRED, 0);
+	__asm__ __volatile__("jr\t%0"::"r"(0xbfc00000));
+}
+
+void momenco_ocelot_halt(void)
+{
+	printk(KERN_NOTICE "\n** You can safely turn off the power\n");
+	while (1)
+		__asm__(".set\tmips3\n\t"
+	                "wait\n\t"
+			".set\tmips0");
+}
+
+void momenco_ocelot_power_off(void)
+{
+	momenco_ocelot_halt();
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/gt64120/momenco_ocelot/setup.c linux/arch/mips/gt64120/momenco_ocelot/setup.c
--- v2.4.9/linux/arch/mips/gt64120/momenco_ocelot/setup.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/gt64120/momenco_ocelot/setup.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,282 @@
+/*
+ * setup.c
+ *
+ * BRIEF MODULE DESCRIPTION
+ * Galileo Evaluation Boards - board dependent boot routines
+ *
+ * Copyright (C) 1996, 1997, 2001  Ralf Baechle
+ * Copyright (C) 2000 RidgeRun, Inc.
+ * Copyright (C) 2001 Red Hat, Inc.
+ *
+ * Author: RidgeRun, Inc.
+ *   glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
+ *
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: jsun@mvista.com or jsun@junsun.net
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/mc146818rtc.h>
+#include <linux/mm.h>
+#include <linux/swap.h>
+#include <linux/ioport.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/pci.h>
+#include <linux/timex.h>
+#include <linux/vmalloc.h>
+#include <asm/time.h>
+#include <asm/bootinfo.h>
+#include <asm/page.h>
+#include <asm/bootinfo.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/pci.h>
+#include <asm/processor.h>
+#include <asm/ptrace.h>
+#include <asm/reboot.h>
+#include <asm/mc146818rtc.h>
+#include <linux/version.h>
+#include <linux/bootmem.h>
+#include <linux/blk.h>
+#include <asm/gt64120/gt64120.h>
+#include "ocelot_pld.h"
+
+extern struct rtc_ops no_rtc_ops;
+
+unsigned long gt64120_base = KSEG1ADDR(GT_DEF_BASE);
+
+/* These functions are used for rebooting or halting the machine*/
+extern void momenco_ocelot_restart(char *command);
+extern void momenco_ocelot_halt(void);
+extern void momenco_ocelot_power_off(void);
+
+extern void gt64120_time_init(void);
+extern void momenco_ocelot_irq_setup(void);
+
+static char reset_reason;
+
+#define ENTRYLO(x) ((pte_val(mk_pte_phys((x), PAGE_KERNEL_UNCACHED)) >> 6)|1)
+
+static void __init setup_l3cache(unsigned long size);
+
+void __init momenco_ocelot_setup(void)
+{
+	void (*l3func)(unsigned long)=KSEG1ADDR(&setup_l3cache);
+	unsigned int tmpword;
+
+	board_time_init = gt64120_time_init;
+
+	_machine_restart = momenco_ocelot_restart;
+	_machine_halt = momenco_ocelot_halt;
+	_machine_power_off = momenco_ocelot_power_off;
+
+	/*
+	 * initrd_start = (ulong)ocelot_initrd_start;
+	 * initrd_end = (ulong)ocelot_initrd_start + (ulong)ocelot_initrd_size;
+	 * initrd_below_start_ok = 1;
+	 */
+	rtc_ops = &no_rtc_ops;
+
+
+	/* A wired TLB entry for the GT64120A and the serial port. The
+	   GT64120A is going to be hit on every IRQ anyway - there's
+	   absolutely no point in letting it be a random TLB entry, as
+	   it'll just cause needless churning of the TLB. And we use
+	   the other half for the serial port, which is just a PITA
+	   otherwise :)
+
+		Device			Physical	Virtual
+		GT64120 Internal Regs	0x24000000	0xe0000000
+		UARTs (CS2)		0x2d000000	0xe0001000
+	*/
+	add_wired_entry(ENTRYLO(0x24000000), ENTRYLO(0x2D000000), 0xe0000000, PM_4K);
+
+	/* Also a temporary entry to let us talk to the Ocelot PLD and NVRAM
+	   in the CS[012] region. We can't use ioremap() yet. The NVRAM
+	   appears to be one of the variants of ST M48T35 - see 
+	   http://www.st.com/stonline/bin/sftab.exe?table=172&filter0=M48T35
+
+		Ocelot PLD (CS0)	0x2c000000	0xe0020000
+		NVRAM			0x2c800000	0xe0030000
+	*/
+		
+	add_temporary_entry(ENTRYLO(0x2C000000), ENTRYLO(0x2d000000), 0xe0020000, PM_64K);
+
+
+	/* Relocate the CS3/BootCS region */
+  	GT_WRITE( GT_CS3BOOTLD_OFS, 0x2f000000 >> 21);
+
+	/* Relocate CS[012] */
+ 	GT_WRITE(GT_CS20LD_OFS, 0x2c000000 >> 21);
+
+	/* Relocate the GT64120A itself... */
+	GT_WRITE(GT_ISD_OFS, 0x24000000 >> 21);
+	mb();
+	gt64120_base = 0xe0000000;
+
+	/* ...and the PCI0 view of it. */
+	GT_WRITE(GT_PCI0_CFGADDR_OFS, 0x80000020);
+	GT_WRITE(GT_PCI0_CFGDATA_OFS, 0x24000000);
+	GT_WRITE(GT_PCI0_CFGADDR_OFS, 0x80000024);
+	GT_WRITE(GT_PCI0_CFGDATA_OFS, 0x24000001);
+
+	/* Relocate PCI0 I/O and Mem0 */
+	GT_WRITE(GT_PCI0IOLD_OFS, 0x20000000 >> 21);
+	GT_WRITE(GT_PCI0M0LD_OFS, 0x22000000 >> 21);
+
+	/* Relocate PCI0 Mem1 */
+	GT_WRITE(GT_PCI0M1LD_OFS, 0x36000000 >> 21);
+
+	/* Relocate all the PCI1 stuff, not that we use it */
+	GT_WRITE(GT_PCI1IOLD_OFS, 0x30000000 >> 21);
+	GT_WRITE(GT_PCI1M0LD_OFS, 0x32000000 >> 21);
+	GT_WRITE(GT_PCI1M1LD_OFS, 0x34000000 >> 21);
+
+	/* Relocate the CPU's view of the RAM... */
+	GT_WRITE(GT_SCS10LD_OFS, 0);
+	GT_WRITE(GT_SCS10HD_OFS, 0x0fe00000 >> 21);
+	GT_WRITE(GT_SCS32LD_OFS, 0x10000000 >> 21);
+	GT_WRITE(GT_SCS32HD_OFS, 0x0fe00000 >> 21);
+
+	GT_WRITE(GT_SCS1LD_OFS, 0xff);
+	GT_WRITE(GT_SCS1HD_OFS, 0x00);
+	GT_WRITE(GT_SCS0LD_OFS, 0);
+	GT_WRITE(GT_SCS0HD_OFS, 0xff);
+	GT_WRITE(GT_SCS3LD_OFS, 0xff);
+	GT_WRITE(GT_SCS3HD_OFS, 0x00);
+	GT_WRITE(GT_SCS2LD_OFS, 0);
+	GT_WRITE(GT_SCS2HD_OFS, 0xff);
+
+	/* ...and the PCI0 view of it. */
+	GT_WRITE(GT_PCI0_CFGADDR_OFS, 0x80000010);
+	GT_WRITE(GT_PCI0_CFGDATA_OFS, 0x00000000);
+	GT_WRITE(GT_PCI0_CFGADDR_OFS, 0x80000014);
+	GT_WRITE(GT_PCI0_CFGDATA_OFS, 0x10000000);
+	GT_WRITE(GT_PCI0_BS_SCS10_OFS, 0x0ffff000);
+	GT_WRITE(GT_PCI0_BS_SCS32_OFS, 0x0ffff000);
+
+	tmpword = OCELOT_PLD_READ(BOARDREV);
+	if (tmpword < 26)
+		printk("Momenco Ocelot: Board Assembly Rev. %c\n", 'A'+tmpword);
+	else
+		printk("Momenco Ocelot: Board Assembly Revision #0x%x\n", tmpword);
+
+	tmpword = OCELOT_PLD_READ(PLD1_ID);
+	printk("PLD 1 ID: %d.%d\n", tmpword>>4, tmpword&15);
+	tmpword = OCELOT_PLD_READ(PLD2_ID);
+	printk("PLD 2 ID: %d.%d\n", tmpword>>4, tmpword&15);
+	tmpword = OCELOT_PLD_READ(RESET_STATUS);
+	printk("Reset reason: 0x%x\n", tmpword);
+	reset_reason = tmpword;
+	OCELOT_PLD_WRITE(0xff, RESET_STATUS);
+
+	tmpword = OCELOT_PLD_READ(BOARD_STATUS);
+	printk("Board Status register: 0x%02x\n", tmpword);
+	printk("  - User jumper: %s\n", (tmpword & 0x80)?"installed":"absent");
+	printk("  - Boot flash write jumper: %s\n", (tmpword&0x40)?"installed":"absent");
+	printk("  - Tulip PHY %s connected\n", (tmpword&0x10)?"is":"not");
+	printk("  - L3 Cache size: %d MiB\n", (1<<((tmpword&12) >> 2))&~1);
+	printk("  - SDRAM size: %d MiB\n", 1<<(6+(tmpword&3)));
+
+	if (tmpword&12)
+		l3func((1<<(((tmpword&12) >> 2)+20)));
+
+	switch(tmpword &3) {
+	case 3:
+		/* 512MiB */
+		add_memory_region(256<<20, 256<<20, BOOT_MEM_RAM);
+	case 2:
+		/* 256MiB */
+		/* FIXME: Is it actually here, or at 0x10000000? */
+		add_memory_region(128<<20, 128<<20, BOOT_MEM_RAM);
+	case 1:
+		/* 128MiB */
+		add_memory_region(64<<20, 64<<20, BOOT_MEM_RAM);
+	case 0:
+		/* 64MiB */
+		;
+	}
+
+	/* Fix up the DiskOnChip mapping */
+	GT_WRITE(0x468, 0xfef73);
+}
+
+extern int rm7k_tcache_enabled;
+/*
+ * This runs in KSEG1. See the verbiage in rm7k.c::probe_scache()
+ */
+#define Page_Invalidate_T 0x16
+static void __init setup_l3cache(unsigned long size)
+{
+	int register i;
+	unsigned long tmp;
+	
+	printk("Enabling L3 cache...");
+
+	/* Enable the L3 cache in the GT64120A's CPU Configuration register */
+	GT_READ(0, &tmp);
+	GT_WRITE(0, tmp | (1<<14));
+
+	/* Enable the L3 cache in the CPU */
+	set_cp0_config(1<<12 /* CONF_TE */);
+
+	/* Clear the cache */
+	set_taglo(0);
+	set_taghi(0);
+
+	for (i=0; i < size; i+= 4096) {
+		__asm__ __volatile__ (
+			".set noreorder\n\t"
+			".set mips3\n\t"
+			"cache %1, (%0)\n\t"
+			".set mips0\n\t"
+			".set reorder"
+			:
+			: "r" (KSEG0ADDR(i)),
+			  "i" (Page_Invalidate_T));
+	}
+
+	/* Let the RM7000 MM code know that the tertiary cache is enabled */
+	rm7k_tcache_enabled = 1;
+
+	printk("Done\n");
+}
+
+
+/* This needs to be one of the first initcalls, because no I/O port access
+   can work before this */
+
+static int io_base_ioremap(void)
+{
+	void *io_remap_range = ioremap(GT_PCI_IO_BASE, GT_PCI_IO_SIZE);
+	if (!io_remap_range) {
+		panic("Could not ioremap I/O port range\n");
+	}
+	mips_io_port_base = io_remap_range - GT_PCI_IO_BASE;
+	return 0;
+}
+module_init(io_base_ioremap);
+
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ite-boards/generic/Makefile linux/arch/mips/ite-boards/generic/Makefile
--- v2.4.9/linux/arch/mips/ite-boards/generic/Makefile	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/ite-boards/generic/Makefile	Sun Sep  9 10:43:01 2001
@@ -1,7 +1,7 @@
 #
 #  Copyright 2000 MontaVista Software Inc.
 #  Author: MontaVista Software, Inc.
-#     	ppopov@mvista.com or support@mvista.com
+#     	ppopov@mvista.com or source@mvista.com
 #
 # Makefile for the ITE 8172 (qed-4n-s01b) board, generic files.
 #
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ite-boards/generic/dbg_io.c linux/arch/mips/ite-boards/generic/dbg_io.c
--- v2.4.9/linux/arch/mips/ite-boards/generic/dbg_io.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/ite-boards/generic/dbg_io.c	Sun Sep  9 10:43:01 2001
@@ -7,8 +7,8 @@
 
 /* we need uint32 uint8 */
 /* #include "types.h" */
-typedef         unsigned char uint8;
-typedef         unsigned int  uint32;
+typedef unsigned char uint8;
+typedef unsigned int uint32;
 
 /* --- END OF CONFIG --- */
 
@@ -39,7 +39,7 @@
 /* === CONFIG === */
 
 /* [stevel] we use the IT8712 serial port for kgdb */
-#define	DEBUG_BASE  0xB40003F8 /* 8712 serial port 1 base address */
+#define	DEBUG_BASE  0xB40003F8	/* 8712 serial port 1 base address */
 #define MAX_BAUD    115200
 
 /* === END OF CONFIG === */
@@ -69,59 +69,57 @@
 
 void debugInit(uint32 baud, uint8 data, uint8 parity, uint8 stop)
 {
-    /* disable interrupts */
-    UART16550_WRITE(OFS_INTR_ENABLE, 0);
+	/* disable interrupts */
+	UART16550_WRITE(OFS_INTR_ENABLE, 0);
 
-    /* set up buad rate */
-    { 
-        uint32 divisor;
-       
-        /* set DIAB bit */
-        UART16550_WRITE(OFS_LINE_CONTROL, 0x80);
-        
-        /* set divisor */
-        divisor = MAX_BAUD / baud;
-        UART16550_WRITE(OFS_DIVISOR_LSB, divisor & 0xff);
-        UART16550_WRITE(OFS_DIVISOR_MSB, (divisor & 0xff00)>>8);
-
-        /* clear DIAB bit */
-        UART16550_WRITE(OFS_LINE_CONTROL, 0x0);
-    }
+	/* set up buad rate */
+	{
+		uint32 divisor;
+
+		/* set DIAB bit */
+		UART16550_WRITE(OFS_LINE_CONTROL, 0x80);
+
+		/* set divisor */
+		divisor = MAX_BAUD / baud;
+		UART16550_WRITE(OFS_DIVISOR_LSB, divisor & 0xff);
+		UART16550_WRITE(OFS_DIVISOR_MSB, (divisor & 0xff00) >> 8);
+
+		/* clear DIAB bit */
+		UART16550_WRITE(OFS_LINE_CONTROL, 0x0);
+	}
 
-    /* set data format */
-    UART16550_WRITE(OFS_DATA_FORMAT, data | parity | stop);
+	/* set data format */
+	UART16550_WRITE(OFS_DATA_FORMAT, data | parity | stop);
 }
 
 static int remoteDebugInitialized = 0;
 
 uint8 getDebugChar(void)
 {
-    if (!remoteDebugInitialized) {
-	remoteDebugInitialized = 1;
-	debugInit(UART16550_BAUD_115200,
-		  UART16550_DATA_8BIT,
-		  UART16550_PARITY_NONE,
-		  UART16550_STOP_1BIT);
-    }
+	if (!remoteDebugInitialized) {
+		remoteDebugInitialized = 1;
+		debugInit(UART16550_BAUD_115200,
+			  UART16550_DATA_8BIT,
+			  UART16550_PARITY_NONE, UART16550_STOP_1BIT);
+	}
 
-    while((UART16550_READ(OFS_LINE_STATUS) & 0x1) == 0);
-    return UART16550_READ(OFS_RCV_BUFFER);
+	while ((UART16550_READ(OFS_LINE_STATUS) & 0x1) == 0);
+	return UART16550_READ(OFS_RCV_BUFFER);
 }
 
 
 int putDebugChar(uint8 byte)
 {
-    if (!remoteDebugInitialized) {
-	remoteDebugInitialized = 1;
-	debugInit(UART16550_BAUD_115200,
-		  UART16550_DATA_8BIT,
-		  UART16550_PARITY_NONE,
-		  UART16550_STOP_1BIT);
-    }
-
-    while ((UART16550_READ(OFS_LINE_STATUS) &0x20) == 0);
-    UART16550_WRITE(OFS_SEND_BUFFER, byte);
-    return 1;
+	if (!remoteDebugInitialized) {
+		remoteDebugInitialized = 1;
+		debugInit(UART16550_BAUD_115200,
+			  UART16550_DATA_8BIT,
+			  UART16550_PARITY_NONE, UART16550_STOP_1BIT);
+	}
+
+	while ((UART16550_READ(OFS_LINE_STATUS) & 0x20) == 0);
+	UART16550_WRITE(OFS_SEND_BUFFER, byte);
+	return 1;
 }
 
 #endif
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ite-boards/generic/irq.c linux/arch/mips/ite-boards/generic/irq.c
--- v2.4.9/linux/arch/mips/ite-boards/generic/irq.c	Mon Aug 27 12:41:39 2001
+++ linux/arch/mips/ite-boards/generic/irq.c	Sun Sep  9 10:43:01 2001
@@ -5,7 +5,7 @@
  *
  * Copyright 2000,2001 MontaVista Software Inc.
  * Author: MontaVista Software, Inc.
- *         	ppopov@mvista.com or support@mvista.com
+ *         	ppopov@mvista.com or source@mvista.com
  *
  * Part of this file was derived from Carsten Langgaard's 
  * arch/mips/mips-boards/atlas/atlas_int.c.
@@ -33,7 +33,6 @@
  *  with this program; if not, write  to the Free Software Foundation, Inc.,
  *  675 Mass Ave, Cambridge, MA 02139, USA.
  */
-#include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/kernel_stat.h>
@@ -76,12 +75,13 @@
 extern void set_debug_traps(void);
 extern void mips_timer_interrupt(int irq, struct pt_regs *regs);
 extern asmlinkage void it8172_IRQ(void);
-irq_cpustat_t irq_stat [NR_CPUS];
 unsigned int local_bh_count[NR_CPUS];
 unsigned int local_irq_count[NR_CPUS];
 unsigned long spurious_count = 0;
 irq_desc_t irq_desc[NR_IRQS];
 irq_desc_t *irq_desc_base=&irq_desc[0];
+void disable_it8172_irq(unsigned int irq_nr);
+void enable_it8172_irq(unsigned int irq_nr);
 
 struct it8172_intc_regs volatile *it8172_hw0_icregs
 	= (struct it8172_intc_regs volatile *)(KSEG1ADDR(IT8172_PCI_IO_BASE + IT_INTC_BASE));
@@ -110,7 +110,7 @@
         unsigned long flags;
 
         save_and_cli(flags);
-        mask_irq(irq_nr);
+	disable_it8172_irq(irq_nr);
         restore_flags(flags);
 }
 
@@ -119,15 +119,13 @@
 	unsigned long flags;
 
         save_and_cli(flags);
-        unmask_irq(irq_nr);
+	enable_it8172_irq(irq_nr);
         restore_flags(flags);
 }
 
 
 void disable_it8172_irq(unsigned int irq_nr)
 {
-	unsigned short mask;
-
 	DPRINTK("disable_it8172_irq %d\n", irq_nr);
 
 	if ( (irq_nr >= IT8172_LPC_IRQ_BASE) && (irq_nr <= IT8172_SERIRQ_15)) {
@@ -290,7 +288,6 @@
 		printk("Unhandled interrupt %d, cause %x, disabled\n", 
 				(unsigned)irq, (unsigned)regs->cp0_cause);
 		disable_it8172_irq(irq);
-		//disable_irq(1<<irq);
 	}
 	irq_exit(cpu, irq);
 }
@@ -325,7 +322,6 @@
                         cli();
                         *p = action->next;
 			disable_it8172_irq(irq);
-                        //disable_irq(1<<irq);
                         restore_flags(flags);
                         kfree(action);
                         return 0;
@@ -378,7 +374,11 @@
 
 void enable_cpu_timer(void)
 {
-	enable_irq(1<<EXT_IRQ5_TO_IP); /* timer interrupt */
+        unsigned long flags;
+
+        save_and_cli(flags);
+	unmask_irq(1<<EXT_IRQ5_TO_IP); /* timer interrupt */
+        restore_flags(flags);
 }
 
 unsigned long probe_irq_on (void)
@@ -395,6 +395,8 @@
 void __init init_IRQ(void)
 {
 	int i;
+        unsigned long flags;
+
 
         memset(irq_desc, 0, sizeof(irq_desc));
         set_except_vector(0, it8172_IRQ);
@@ -440,8 +442,9 @@
 	 * Enable external int line 2
 	 * All ITE interrupts are masked for now.
 	 */
-	enable_irq(1<<EXT_IRQ0_TO_IP);
-	//change_cp0_status(ST0_IM, IE_IRQ2);
+        save_and_cli(flags);
+	unmask_irq(1<<EXT_IRQ0_TO_IP);
+        restore_flags(flags);
 
 #ifdef CONFIG_REMOTE_DEBUG
 	/* If local serial I/O used for debug port, enter kgdb at once */
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ite-boards/generic/it8172_cir.c linux/arch/mips/ite-boards/generic/it8172_cir.c
--- v2.4.9/linux/arch/mips/ite-boards/generic/it8172_cir.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/ite-boards/generic/it8172_cir.c	Sun Sep  9 10:43:01 2001
@@ -5,7 +5,7 @@
  *
  * Copyright 2001 MontaVista Software Inc.
  * Author: MontaVista Software, Inc.
- *         	ppopov@mvista.com or support@mvista.com
+ *         	ppopov@mvista.com or source@mvista.com
  *
  *  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
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ite-boards/generic/it8172_pci.c linux/arch/mips/ite-boards/generic/it8172_pci.c
--- v2.4.9/linux/arch/mips/ite-boards/generic/it8172_pci.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/ite-boards/generic/it8172_pci.c	Sun Sep  9 10:43:01 2001
@@ -1,11 +1,10 @@
 /*
- *
  * BRIEF MODULE DESCRIPTION
  *	IT8172 system controller specific pci support.
  *
  * Copyright 2000 MontaVista Software Inc.
  * Author: MontaVista Software, Inc.
- *         	ppopov@mvista.com or support@mvista.com
+ *         	ppopov@mvista.com or source@mvista.com
  *
  *  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
@@ -271,6 +270,12 @@
 
 void __init pcibios_fixup_bus(struct pci_bus *b)
 {
-	printk("pcibios_fixup_bus\n");
+	//printk("pcibios_fixup_bus\n");
 }
+
+unsigned __init int pcibios_assign_all_busses(void)
+{
+	return 1;
+}
+
 #endif /* CONFIG_PCI */
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ite-boards/generic/it8172_rtc.c linux/arch/mips/ite-boards/generic/it8172_rtc.c
--- v2.4.9/linux/arch/mips/ite-boards/generic/it8172_rtc.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/ite-boards/generic/it8172_rtc.c	Sun Sep  9 10:43:01 2001
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000 MontaVista Software Inc.
  * Author: MontaVista Software, Inc.
- *         	ppopov@mvista.com or support@mvista.com
+ *         	ppopov@mvista.com or source@mvista.com
  *
  * Carsten Langgaard, carstenl@mips.com
  * Copyright (C) 1999,2000 MIPS Technologies, Inc.  All rights reserved.
@@ -26,7 +26,6 @@
  * RTC routines for ITE8172 MC146818-compatible rtc chip.
  *
  */
-#include <asm/spinlock.h>
 #include <linux/mc146818rtc.h>
 #include <asm/it8172/it8172.h>
 
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ite-boards/generic/it8172_setup.c linux/arch/mips/ite-boards/generic/it8172_setup.c
--- v2.4.9/linux/arch/mips/ite-boards/generic/it8172_setup.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/ite-boards/generic/it8172_setup.c	Sun Sep  9 10:43:01 2001
@@ -5,7 +5,7 @@
  *
  * Copyright 2000 MontaVista Software Inc.
  * Author: MontaVista Software, Inc.
- *         	ppopov@mvista.com or support@mvista.com
+ *         	ppopov@mvista.com or source@mvista.com
  *
  *  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
@@ -66,7 +66,7 @@
 extern int SearchIT8712(void);
 extern void InitLPCInterface(void);
 extern char * __init prom_getcmdline(void);
-extern void it8172_restart(void);
+extern void it8172_restart(char *command);
 extern void it8172_halt(void);
 extern void it8172_power_off(void);
 
@@ -114,19 +114,18 @@
 
 void __init it8172_setup(void)
 {
-#ifdef CONFIG_BLK_DEV_IT8172
 	unsigned short dsr;
-#endif
 	char *argptr;
 
 	argptr = prom_getcmdline();
 #ifdef CONFIG_SERIAL_CONSOLE
-	if ((argptr = strstr(argptr, "console=ttyS0")) == NULL) {
-		strcpy(serial_console, "ttyS0,115200");
-		console_setup(serial_console, NULL);
+	if ((argptr = strstr(argptr, "console=")) == NULL) {
+		argptr = prom_getcmdline();
+		strcat(argptr, " console=ttyS0,115200");
 	}
 #endif	  
 
+	clear_cp0_status(ST0_FR);
 	rtc_ops = &it8172_rtc_ops;
 
 	_machine_restart = it8172_restart;
@@ -153,19 +152,25 @@
 	ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);
 #endif
 
-#ifdef CONFIG_BLK_DEV_IT8172
 	/*
-	 * Pull IDE device out of standby mode.
+	 * Pull enabled devices out of standby
 	 */
 	IT_IO_READ16(IT_PM_DSR, dsr);
+#ifdef CONFIG_SOUND_IT8172
+	dsr &= ~IT_PM_DSR_ACSB;
+#else
+	dsr |= IT_PM_DSR_ACSB;
+#endif	
+#ifdef CONFIG_BLK_DEV_IT8172
 	dsr &= ~IT_PM_DSR_IDESB;
-	IT_IO_WRITE16(IT_PM_DSR, dsr);
-
 	ide_ops = &std_ide_ops;
+#else
+	dsr |= IT_PM_DSR_IDESB;
 #endif
+	IT_IO_WRITE16(IT_PM_DSR, dsr);
 
 #ifdef CONFIG_FB
-    conswitchp = &dummy_con;
+	conswitchp = &dummy_con;
 #endif
 
 	InitLPCInterface();
@@ -266,8 +271,6 @@
 	unsigned int data_port = 0x14000060;
 	unsigned char data;
 	int i;
-
-	printk("8712 keyboard init");
 
 	outb(0xaa, cmd_port); /* send self-test cmd */
 	i = 0;
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ite-boards/generic/lpc.c linux/arch/mips/ite-boards/generic/lpc.c
--- v2.4.9/linux/arch/mips/ite-boards/generic/lpc.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/ite-boards/generic/lpc.c	Sun Sep  9 10:43:01 2001
@@ -5,7 +5,7 @@
  *
  * Copyright 2001 MontaVista Software Inc.
  * Author: MontaVista Software, Inc.
- *         	ppopov@mvista.com or support@mvista.com
+ *         	ppopov@mvista.com or source@mvista.com
  *
  *  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
@@ -41,7 +41,7 @@
 #define FALSE 0
 #endif
 
-void LPCEnterMBPnP()
+void LPCEnterMBPnP(void)
 {
 	int i;
 	unsigned char key[4] = {0x87, 0x01, 0x55, 0x55};
@@ -51,7 +51,7 @@
 
 }
 
-void LPCExitMBPnP()
+void LPCExitMBPnP(void)
 {
 	outb(0x02, LPC_KEY_ADDR);
 	outb(0x02, LPC_DATA_ADDR);
@@ -80,7 +80,7 @@
 	return rtn;
 }
 
-int SearchIT8712()
+int SearchIT8712(void)
 {
 	unsigned char Id1, Id2;
 	unsigned short Id;
@@ -98,7 +98,7 @@
 		return FALSE;
 }
 
-void InitLPCInterface()
+void InitLPCInterface(void)
 {
 	unsigned char bus, dev_fn;
 	unsigned long data;
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ite-boards/generic/pmon_prom.c linux/arch/mips/ite-boards/generic/pmon_prom.c
--- v2.4.9/linux/arch/mips/ite-boards/generic/pmon_prom.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/ite-boards/generic/pmon_prom.c	Sun Sep  9 10:43:01 2001
@@ -6,7 +6,7 @@
  *
  * Copyright 2000 MontaVista Software Inc.
  * Author: MontaVista Software, Inc.
- *         	ppopov@mvista.com or support@mvista.com
+ *         	ppopov@mvista.com or source@mvista.com
  *
  * This file was derived from Carsten Langgaard's 
  * arch/mips/mips-boards/xx files.
@@ -35,6 +35,7 @@
  *  675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/string.h>
@@ -44,8 +45,8 @@
 /* #define DEBUG_CMDLINE */
 
 char arcs_cmdline[COMMAND_LINE_SIZE];
-int prom_argc;
-char **prom_argv, **prom_envp;
+extern int prom_argc;
+extern char **prom_argv, **prom_envp;
 
 typedef struct
 {
@@ -126,12 +127,16 @@
 
 	memsize_str = prom_getenv("memsize");
 	if (!memsize_str) {
-		printk("memsize unknown: setting to 32MB\n");
+#ifdef CONFIG_MIPS_ITE8172
 		memsize = 32; 
-	} else {
-#ifdef DEBUG
-		printk("prom_memsize: %s\n", memsize_str);
+#elif defined(CONFIG_MIPS_IVR)
+		memsize = 64; 
+#else
+		memsize = 8; 
 #endif
+		printk("memsize unknown: setting to %dMB\n", memsize);
+	} else {
+		printk("memsize: %s\n", memsize_str);
 		memsize = simple_strtol(memsize_str, NULL, 0);
 	}
 	return memsize;
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ite-boards/generic/puts.c linux/arch/mips/ite-boards/generic/puts.c
--- v2.4.9/linux/arch/mips/ite-boards/generic/puts.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/ite-boards/generic/puts.c	Sun Sep  9 10:43:01 2001
@@ -5,7 +5,7 @@
  *
  * Copyright 2000,2001 MontaVista Software Inc.
  * Author: MontaVista Software, Inc.
- *         	ppopov@mvista.com or support@mvista.com
+ *         	ppopov@mvista.com or source@mvista.com
  *
  *  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
@@ -30,7 +30,7 @@
 
 #include <linux/types.h>
 
-#define SERIAL_BASE   0xB4011800 /* it8172 */
+#define SERIAL_BASE   0xB4011800	/* it8172 */
 #define SER_CMD       5
 #define SER_DATA      0x00
 #define TX_BUSY       0x20
@@ -39,106 +39,101 @@
 #undef SLOW_DOWN
 
 static const char digits[16] = "0123456789abcdef";
-static volatile unsigned char * const com1 = (unsigned char *)SERIAL_BASE;
+static volatile unsigned char *const com1 = (unsigned char *) SERIAL_BASE;
 
 
 #ifdef SLOW_DOWN
 static inline void slow_down()
 {
-    int k;
-    for (k=0; k<10000; k++);
+	int k;
+	for (k = 0; k < 10000; k++);
 }
 #else
 #define slow_down()
 #endif
 
-void
-putch(const unsigned char c)
+void putch(const unsigned char c)
 {
-    unsigned char ch;
-    int i = 0;
+	unsigned char ch;
+	int i = 0;
 
-    do {
-        ch = com1[SER_CMD];
-        slow_down();
-        i++;
-        if (i>TIMEOUT) {
-            break;
-        }
-    } while (0 == (ch & TX_BUSY));
-    com1[SER_DATA] = c;
+	do {
+		ch = com1[SER_CMD];
+		slow_down();
+		i++;
+		if (i > TIMEOUT) {
+			break;
+		}
+	} while (0 == (ch & TX_BUSY));
+	com1[SER_DATA] = c;
 }
 
-void
-puts(unsigned char *cp)
+void puts(unsigned char *cp)
 {
-    unsigned char ch;
-    int i = 0;
+	unsigned char ch;
+	int i = 0;
 
-    while (*cp) {
-        do {
-             ch = com1[SER_CMD];
-            slow_down();
-            i++;
-            if (i>TIMEOUT) {
-                break;
-            }
-        } while (0 == (ch & TX_BUSY));
-        com1[SER_DATA] = *cp++;
-    }
-    putch('\r');
-    putch('\n');
+	while (*cp) {
+		do {
+			ch = com1[SER_CMD];
+			slow_down();
+			i++;
+			if (i > TIMEOUT) {
+				break;
+			}
+		} while (0 == (ch & TX_BUSY));
+		com1[SER_DATA] = *cp++;
+	}
+	putch('\r');
+	putch('\n');
 }
 
-void
-fputs(unsigned char *cp)
+void fputs(unsigned char *cp)
 {
-    unsigned char ch;
-    int i = 0;
+	unsigned char ch;
+	int i = 0;
 
-    while (*cp) {
+	while (*cp) {
 
-        do {
-             ch = com1[SER_CMD];
-             slow_down();
-            i++;
-            if (i>TIMEOUT) {
-                break;
-            }
-        } while (0 == (ch & TX_BUSY));
-        com1[SER_DATA] = *cp++;
-    }
+		do {
+			ch = com1[SER_CMD];
+			slow_down();
+			i++;
+			if (i > TIMEOUT) {
+				break;
+			}
+		} while (0 == (ch & TX_BUSY));
+		com1[SER_DATA] = *cp++;
+	}
 }
 
 
-void
-put64(uint64_t ul)
+void put64(uint64_t ul)
 {
-    int cnt;
-    unsigned ch;
+	int cnt;
+	unsigned ch;
 
-    cnt = 16;            /* 16 nibbles in a 64 bit long */
-    putch('0');
-    putch('x');
-    do {
-        cnt--;
-        ch = (unsigned char)(ul >> cnt * 4) & 0x0F;
-                putch(digits[ch]);
-    } while (cnt > 0);
+	cnt = 16;		/* 16 nibbles in a 64 bit long */
+	putch('0');
+	putch('x');
+	do {
+		cnt--;
+		ch = (unsigned char) (ul >> cnt * 4) & 0x0F;
+		putch(digits[ch]);
+	} while (cnt > 0);
 }
 
-void
-put32(unsigned u)
+void put32(unsigned u)
 {
-    int cnt;
-    unsigned ch;
+	int cnt;
+	unsigned ch;
 
-    cnt = 8;            /* 8 nibbles in a 32 bit long */
-    putch('0');
-    putch('x');
-    do {
-        cnt--;
-        ch = (unsigned char)(u >> cnt * 4) & 0x0F;
-                putch(digits[ch]);
-    } while (cnt > 0);
+	cnt = 8;		/* 8 nibbles in a 32 bit long */
+	putch('0');
+	putch('x');
+	do {
+		cnt--;
+		ch = (unsigned char) (u >> cnt * 4) & 0x0F;
+		putch(digits[ch]);
+	} while (cnt > 0);
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ite-boards/generic/reset.c linux/arch/mips/ite-boards/generic/reset.c
--- v2.4.9/linux/arch/mips/ite-boards/generic/reset.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/ite-boards/generic/reset.c	Sun Sep  9 10:43:01 2001
@@ -3,10 +3,9 @@
  * BRIEF MODULE DESCRIPTION
  *	ITE 8172 reset routines.
  *
- * Copyright (C) 1997, 2001 Ralf Baechle
  * Copyright 2001 MontaVista Software Inc.
  * Author: MontaVista Software, Inc.
- *         	ppopov@mvista.com or support@mvista.com
+ *         	ppopov@mvista.com or source@mvista.com
  *
  *  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
@@ -37,7 +36,7 @@
 #include <asm/reboot.h>
 #include <asm/system.h>
 
-void it8172_restart(char *command)
+void it8172_restart()
 {
 	set_cp0_status(ST0_BEV | ST0_ERL);
 	change_cp0_config(CONF_CM_CMASK, CONF_CM_UNCACHED);
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ite-boards/generic/time.c linux/arch/mips/ite-boards/generic/time.c
--- v2.4.9/linux/arch/mips/ite-boards/generic/time.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/ite-boards/generic/time.c	Sun Sep  9 10:43:01 2001
@@ -23,6 +23,7 @@
  *
  */
 
+#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/kernel_stat.h>
 #include <linux/sched.h>
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ite-boards/ivr/Makefile linux/arch/mips/ite-boards/ivr/Makefile
--- v2.4.9/linux/arch/mips/ite-boards/ivr/Makefile	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ite-boards/ivr/Makefile	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,28 @@
+#
+#  Copyright 2000 MontaVista Software Inc.
+#  Author: MontaVista Software, Inc.
+#     	ppopov@mvista.com or source@mvista.com
+#
+# Makefile for the Globespan IVR board,
+# board-specific files.
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+
+.S.s:
+	$(CPP) $(CFLAGS) $< -o $*.s
+.S.o:
+	$(CC) $(CFLAGS) -c $< -o $*.o
+
+all: ivr.o
+
+O_TARGET := ivr.o
+
+obj-y := init.o 
+
+obj-CONFIG_PCI += pci_fixup.o
+obj-CONFIG_BLK_DEV_INITRD += le_ramdisk.o
+
+include $(TOPDIR)/Rules.make
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ite-boards/ivr/README linux/arch/mips/ite-boards/ivr/README
--- v2.4.9/linux/arch/mips/ite-boards/ivr/README	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ite-boards/ivr/README	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,3 @@
+This is not really a board made by ITE Semi, but it's very 
+similar to the ITE QED-4N-S01B board.  The IVR board is made
+by Globespan and it's a reference board for the PVR chip.
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ite-boards/ivr/init.c linux/arch/mips/ite-boards/ivr/init.c
--- v2.4.9/linux/arch/mips/ite-boards/ivr/init.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ite-boards/ivr/init.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,87 @@
+/*
+ *
+ * BRIEF MODULE DESCRIPTION
+ *	IVR board setup.
+ *
+ * Copyright 2000 MontaVista Software Inc.
+ * Author: MontaVista Software, Inc.
+ *         	ppopov@mvista.com or source@mvista.com
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <linux/bootmem.h>
+#include <asm/addrspace.h>
+#include <asm/bootinfo.h>
+#include <linux/config.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <asm/it8172/it8172.h>
+#include <asm/it8172/it8172_dbg.h>
+
+int prom_argc;
+char **prom_argv, **prom_envp;
+
+extern char _end;
+extern void  __init prom_init_cmdline(void);
+extern unsigned long __init prom_get_memsize(void);
+extern void __init it8172_init_ram_resource(unsigned long memsize);
+
+#define PFN_UP(x)	(((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
+#define PFN_ALIGN(x)	(((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
+
+
+int __init prom_init(int argc, char **argv, char **envp, int *prom_vec)
+{
+	unsigned long mem_size;
+	unsigned long pcicr;
+
+	prom_argc = argc;
+	prom_argv = argv;
+	prom_envp = envp;
+
+	puts("IVR board running...");
+
+	mips_machgroup = MACH_GROUP_GLOBESPAN;
+	mips_machtype = MACH_IVR;  /* Globespan's iTVC15 reference board */
+
+	prom_init_cmdline();
+
+	/* pmon does not set memsize */
+	mem_size = prom_get_memsize();
+	mem_size = mem_size << 20;
+
+	/*
+	 * make the entire physical memory visible to pci bus masters
+	 */
+	IT_READ(IT_MC_PCICR, pcicr);
+	pcicr &= ~0x1f; 
+	pcicr |= (mem_size - 1) >> 22;
+	IT_WRITE(IT_MC_PCICR, pcicr);
+
+	it8172_init_ram_resource(mem_size);
+	add_memory_region(0, mem_size, BOOT_MEM_RAM);
+	return 0;
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ite-boards/ivr/pci_fixup.c linux/arch/mips/ite-boards/ivr/pci_fixup.c
--- v2.4.9/linux/arch/mips/ite-boards/ivr/pci_fixup.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/ite-boards/ivr/pci_fixup.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,139 @@
+/*
+ *
+ * BRIEF MODULE DESCRIPTION
+ *	Globespan IVR board-specific pci fixups.
+ *
+ * Copyright 2000 MontaVista Software Inc.
+ * Author: MontaVista Software, Inc.
+ *         	ppopov@mvista.com or source@mvista.com
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include <linux/config.h>
+
+#ifdef CONFIG_PCI
+
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+
+#include <asm/it8172/it8172.h>
+#include <asm/it8172/it8172_pci.h>
+#include <asm/it8172/it8172_int.h>
+
+void __init board_int_line_fixup(struct pci_dev *dev)     
+{
+	unsigned int slot, func;
+	unsigned char pin;
+        const int internal_func_irqs[7] = {
+            IT8172_AC97_IRQ,
+            IT8172_DMA_IRQ,
+            IT8172_CDMA_IRQ,
+            IT8172_USB_IRQ,
+            IT8172_BRIDGE_MASTER_IRQ,
+            IT8172_IDE_IRQ,
+            IT8172_MC68K_IRQ
+        };
+
+#ifdef DEBUG
+	printk("board_int_line_fixup bus %d\n", dev->bus->number);
+#endif
+	if (dev->bus->number != 0)
+		return;
+
+	pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
+
+#ifdef DEBUG
+	pci_read_config_dword(dev, PCI_SUBSYSTEM_VENDOR_ID, &vendor);
+#endif
+
+	slot = PCI_SLOT(dev->devfn);
+        func = PCI_FUNC(dev->devfn);
+
+	switch (slot) {
+                case 0x01:
+                    /*
+                     * Internal device 1 is actually 7 different internal
+                     * devices on the IT8172G (a multi-function device).
+                     */
+                    if (func < 7)
+                        dev->irq = internal_func_irqs[func];
+                    break;
+		case 0x11:
+			switch (pin) {
+				case 0: /* pin A, hardware bug */
+				case 1: /* pin A */
+					dev->irq = IT8172_PCI_INTC_IRQ;
+					break;
+				case 2: /* pin B */
+					dev->irq = IT8172_PCI_INTD_IRQ;
+					break;
+				case 3: /* pin C */
+					dev->irq = IT8172_PCI_INTA_IRQ;
+					break;
+				case 4: /* pin D */
+					dev->irq = IT8172_PCI_INTB_IRQ;
+					break;
+				default:
+					dev->irq = 0xff; 
+					break;
+
+			}
+			break;
+		case 0x13:
+			switch (pin) {
+				case 0: /* pin A, hardware bug */
+				case 1: /* pin A */
+					dev->irq = IT8172_PCI_INTA_IRQ;
+					break;
+				case 2: /* pin B */
+					dev->irq = IT8172_PCI_INTB_IRQ;
+					break;
+				case 3: /* pin C */
+					dev->irq = IT8172_PCI_INTC_IRQ;
+					break;
+				case 4: /* pin D */
+					dev->irq = IT8172_PCI_INTD_IRQ;
+					break;
+				default:
+					dev->irq = 0xff; 
+					break;
+
+			}
+			break;
+		default:
+			return;
+	}
+
+#ifdef DEBUG
+	printk("irq fixup: slot %d, vendor %x, int line %d, int number %d\n",
+			slot, vendor, pin, dev->irq);
+#endif
+	pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
+
+}
+
+struct pci_fixup pcibios_fixups[] = {
+	{ PCI_FIXUP_HEADER, PCI_ANY_ID, PCI_ANY_ID, board_int_line_fixup },
+	{ 0 }
+};
+#endif
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ite-boards/qed-4n-s01b/Makefile linux/arch/mips/ite-boards/qed-4n-s01b/Makefile
--- v2.4.9/linux/arch/mips/ite-boards/qed-4n-s01b/Makefile	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/ite-boards/qed-4n-s01b/Makefile	Sun Sep  9 10:43:01 2001
@@ -1,7 +1,7 @@
 #
 #  Copyright 2000 MontaVista Software Inc.
 #  Author: MontaVista Software, Inc.
-#     	ppopov@mvista.com or support@mvista.com
+#     	ppopov@mvista.com or source@mvista.com
 #
 # Makefile for the ITE 8172 (qed-4n-s01b) board, board
 # specific files.
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ite-boards/qed-4n-s01b/init.c linux/arch/mips/ite-boards/qed-4n-s01b/init.c
--- v2.4.9/linux/arch/mips/ite-boards/qed-4n-s01b/init.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/ite-boards/qed-4n-s01b/init.c	Sun Sep  9 10:43:01 2001
@@ -5,7 +5,7 @@
  *
  * Copyright 2000 MontaVista Software Inc.
  * Author: MontaVista Software, Inc.
- *         	ppopov@mvista.com or support@mvista.com
+ *         	ppopov@mvista.com or source@mvista.com
  *
  *  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
@@ -34,8 +34,10 @@
 #include <linux/bootmem.h>
 #include <asm/addrspace.h>
 #include <asm/bootinfo.h>
+#include <linux/config.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
+#include <linux/sched.h>
 #include <asm/it8172/it8172.h>
 #include <asm/it8172/it8172_dbg.h>
 
@@ -53,7 +55,7 @@
 
 int __init prom_init(int argc, char **argv, char **envp, int *prom_vec)
 {
-	unsigned long mem_size, free_start, free_end, bootmap_size;
+	unsigned long mem_size;
 	unsigned long pcicr;
 
 	prom_argc = argc;
@@ -81,7 +83,7 @@
 	IT_WRITE(IT_MC_PCICR, pcicr);
 
 	it8172_init_ram_resource(mem_size);
-	add_memory_region(0, 20 << 20, BOOT_MEM_RAM);
+	add_memory_region(0, mem_size, BOOT_MEM_RAM);
 
 	return 0;
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips/ite-boards/qed-4n-s01b/pci_fixup.c linux/arch/mips/ite-boards/qed-4n-s01b/pci_fixup.c
--- v2.4.9/linux/arch/mips/ite-boards/qed-4n-s01b/pci_fixup.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/ite-boards/qed-4n-s01b/pci_fixup.c	Sun Sep  9 10:43:01 2001
@@ -5,7 +5,7 @@
  *
  * Copyright 2000 MontaVista Software Inc.
  * Author: MontaVista Software, Inc.
- *         	ppopov@mvista.com or support@mvista.com
+ *         	ppopov@mvista.com or source@mvista.com
  *
  *  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
diff -u --recursive --new-file v2.4.9/linux/arch/mips/jazz/irq.c linux/arch/mips/jazz/irq.c
--- v2.4.9/linux/arch/mips/jazz/irq.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/jazz/irq.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,45 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 1992 Linus Torvalds
+ * Copyright (C) 1994 - 2001 Ralf Baechle
+ */
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/spinlock.h>
+
+#include <asm/io.h>
+#include <asm/jazz.h>
+
+extern asmlinkage void jazz_handle_int(void);
+
+/*
+ * On systems with i8259-style interrupt controllers we assume for
+ * driver compatibility reasons interrupts 0 - 15 to be the i8295
+ * interrupts even if the hardware uses a different interrupt numbering.
+ */
+void __init init_IRQ (void)
+{
+	int i;
+
+	set_except_vector(0, jazz_handle_int);
+
+	init_generic_irq();
+	init_i8259_irqs();			/* Integrated i8259  */
+#if 0
+	init_jazz_irq();
+
+	/* Actually we've got more interrupts to handle ...  */
+	for (i = PCIMT_IRQ_INT2; i <= PCIMT_IRQ_ETHERNET; i++) {
+		irq_desc[i].status     = IRQ_DISABLED;
+		irq_desc[i].action     = 0;
+		irq_desc[i].depth      = 1;
+		irq_desc[i].handler    = &pciasic_irq_type;
+	}
+#endif
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/jazz/jazzdma.c linux/arch/mips/jazz/jazzdma.c
--- v2.4.9/linux/arch/mips/jazz/jazzdma.c	Thu Feb 24 22:52:30 2000
+++ linux/arch/mips/jazz/jazzdma.c	Sun Sep  9 10:43:01 2001
@@ -1,6 +1,4 @@
 /*
- * arch/mips/jazz/jazzdma.c
- *
  * Mips Jazz DMA controller support
  * Copyright (C) 1995, 1996 by Andreas Busse
  *
@@ -27,7 +25,7 @@
  */
 #define CONF_DEBUG_VDMA 0
 
-static unsigned long vdma_pagetable_start = 0;
+static unsigned long vdma_pagetable_start;
 
 /*
  * Debug stuff
@@ -44,16 +42,16 @@
  */
 static inline void vdma_pgtbl_init(void)
 {
-    int i;
-    unsigned long paddr = 0;
-    VDMA_PGTBL_ENTRY *pgtbl = (VDMA_PGTBL_ENTRY *)vdma_pagetable_start;
-  
-    for (i=0; i<VDMA_PGTBL_ENTRIES; i++)
-    {
-        pgtbl[i].frame = paddr;
-        pgtbl[i].owner = VDMA_PAGE_EMPTY;
-        paddr += VDMA_PAGESIZE;
-    }
+	int i;
+	unsigned long paddr = 0;
+	VDMA_PGTBL_ENTRY *pgtbl =
+	    (VDMA_PGTBL_ENTRY *) vdma_pagetable_start;
+
+	for (i = 0; i < VDMA_PGTBL_ENTRIES; i++) {
+		pgtbl[i].frame = paddr;
+		pgtbl[i].owner = VDMA_PAGE_EMPTY;
+		paddr += VDMA_PAGESIZE;
+	}
 }
 
 /*
@@ -77,13 +75,12 @@
 	 */
 	vdma_pgtbl_init();
 
-	r4030_write_reg32(JAZZ_R4030_TRSTBL_BASE,PHYSADDR(vdma_pagetable_start));
+	r4030_write_reg32(JAZZ_R4030_TRSTBL_BASE,
+			  PHYSADDR(vdma_pagetable_start));
 	r4030_write_reg32(JAZZ_R4030_TRSTBL_LIM, VDMA_PGTBL_SIZE);
 	r4030_write_reg32(JAZZ_R4030_TRSTBL_INV, 0);
 
 	printk("VDMA: R4030 DMA pagetables initialized.\n");
-
-	return KSEG0ADDR(vdma_pagetable_end);
 }
 
 /*
@@ -91,92 +88,90 @@
  */
 unsigned long vdma_alloc(unsigned long paddr, unsigned long size)
 {
-    VDMA_PGTBL_ENTRY *entry = (VDMA_PGTBL_ENTRY *)vdma_pagetable_start;
-    int first;
-    int last;
-    int pages;
-    unsigned int frame;
-    unsigned long laddr;
-    int i;
-    unsigned long flags;
-
-    /* check arguments */
-  
-    if (paddr > 0x1fffffff)
-    {
-        if (vdma_debug)
-            printk("vdma_alloc: Invalid physical address: %08lx\n",paddr);
-        return VDMA_ERROR;	/* invalid physical address */
-    }
-    if (size > 0x400000 || size == 0)
-    {
-        if (vdma_debug)
-            printk("vdma_alloc: Invalid size: %08lx\n",size);
-        return VDMA_ERROR;	/* invalid physical address */
-    }
-  
-    save_and_cli (flags);
-    /*
-     * Find free chunk
-     */
-    pages = (size + 4095) >> 12; /* no. of pages to allocate */
-    first = 0;
-    while (1)
-    {
-        while (entry[first].owner != VDMA_PAGE_EMPTY &&
-               first < VDMA_PGTBL_ENTRIES)
-            first++;
-        if (first+pages > VDMA_PGTBL_ENTRIES) { /* nothing free */
-	    restore_flags (flags);
-            return VDMA_ERROR;
-	}
-
-        last = first+1;
-        while (entry[last].owner == VDMA_PAGE_EMPTY && last-first < pages)
-            last++;
-    
-        if (last-first == pages)
-            break;			/* found */
-    }
-  
-    /*
-     * Mark pages as allocated
-     */
-    laddr = (first << 12) + (paddr & (VDMA_PAGESIZE-1));
-    frame = paddr & ~(VDMA_PAGESIZE-1);
-  
-    for (i=first; i<last; i++)
-    {
-        entry[i].frame = frame;
-        entry[i].owner = laddr;
-        frame += VDMA_PAGESIZE;
-    }
-
-    /*
-     * Update translation table and return logical start address
-     */
-    r4030_write_reg32(JAZZ_R4030_TRSTBL_INV,0);
-
-    if (vdma_debug > 1)
-        printk("vdma_alloc: Allocated %d pages starting from %08lx\n",
-               pages,laddr);
-
-    if (vdma_debug > 2)
-    {
-        printk("LADDR: ");
-        for (i=first; i<last; i++)
-            printk("%08x ",i<<12);
-        printk("\nPADDR: ");
-        for (i=first; i<last; i++)
-            printk("%08x ",entry[i].frame);
-        printk("\nOWNER: ");
-        for (i=first; i<last; i++)
-            printk("%08x ",entry[i].owner);
-        printk("\n");
-    }
-  
-    restore_flags(flags);
-    return laddr;
+	VDMA_PGTBL_ENTRY *entry =
+	    (VDMA_PGTBL_ENTRY *) vdma_pagetable_start;
+	int first;
+	int last;
+	int pages;
+	unsigned int frame;
+	unsigned long laddr;
+	int i;
+	unsigned long flags;
+
+	/* check arguments */
+
+	if (paddr > 0x1fffffff) {
+		if (vdma_debug)
+			printk("vdma_alloc: Invalid physical address: %08lx\n",
+			       paddr);
+		return VDMA_ERROR;	/* invalid physical address */
+	}
+	if (size > 0x400000 || size == 0) {
+		if (vdma_debug)
+			printk("vdma_alloc: Invalid size: %08lx\n", size);
+		return VDMA_ERROR;	/* invalid physical address */
+	}
+
+	save_and_cli(flags);
+	/*
+	 * Find free chunk
+	 */
+	pages = (size + 4095) >> 12;	/* no. of pages to allocate */
+	first = 0;
+	while (1) {
+		while (entry[first].owner != VDMA_PAGE_EMPTY &&
+		       first < VDMA_PGTBL_ENTRIES) first++;
+		if (first + pages > VDMA_PGTBL_ENTRIES) {	/* nothing free */
+			restore_flags(flags);
+			return VDMA_ERROR;
+		}
+
+		last = first + 1;
+		while (entry[last].owner == VDMA_PAGE_EMPTY
+		       && last - first < pages)
+			last++;
+
+		if (last - first == pages)
+			break;	/* found */
+	}
+
+	/*
+	 * Mark pages as allocated
+	 */
+	laddr = (first << 12) + (paddr & (VDMA_PAGESIZE - 1));
+	frame = paddr & ~(VDMA_PAGESIZE - 1);
+
+	for (i = first; i < last; i++) {
+		entry[i].frame = frame;
+		entry[i].owner = laddr;
+		frame += VDMA_PAGESIZE;
+	}
+
+	/*
+	 * Update translation table and return logical start address
+	 */
+	r4030_write_reg32(JAZZ_R4030_TRSTBL_INV, 0);
+
+	if (vdma_debug > 1)
+		printk
+		    ("vdma_alloc: Allocated %d pages starting from %08lx\n",
+		     pages, laddr);
+
+	if (vdma_debug > 2) {
+		printk("LADDR: ");
+		for (i = first; i < last; i++)
+			printk("%08x ", i << 12);
+		printk("\nPADDR: ");
+		for (i = first; i < last; i++)
+			printk("%08x ", entry[i].frame);
+		printk("\nOWNER: ");
+		for (i = first; i < last; i++)
+			printk("%08x ", entry[i].owner);
+		printk("\n");
+	}
+
+	restore_flags(flags);
+	return laddr;
 }
 
 /*
@@ -186,102 +181,103 @@
  */
 int vdma_free(unsigned long laddr)
 {
-    VDMA_PGTBL_ENTRY *pgtbl = (VDMA_PGTBL_ENTRY *)vdma_pagetable_start;
-    int i;
+	VDMA_PGTBL_ENTRY *pgtbl =
+	    (VDMA_PGTBL_ENTRY *) vdma_pagetable_start;
+	int i;
+
+	i = laddr >> 12;
+
+	if (pgtbl[i].owner != laddr) {
+		printk
+		    ("vdma_free: trying to free other's dma pages, laddr=%8lx\n",
+		     laddr);
+		return -1;
+	}
+
+	while (pgtbl[i].owner == laddr && i < VDMA_PGTBL_ENTRIES) {
+		pgtbl[i].owner = VDMA_PAGE_EMPTY;
+		i++;
+	}
 
-    i = laddr >> 12;
+	if (vdma_debug > 1)
+		printk("vdma_free: freed %ld pages starting from %08lx\n",
+		       i - (laddr >> 12), laddr);
 
-    if (pgtbl[i].owner != laddr)
-    {
-        printk("vdma_free: trying to free other's dma pages, laddr=%8lx\n",
-               laddr);
-        return -1;
-    }
-  
-    while (pgtbl[i].owner == laddr && i < VDMA_PGTBL_ENTRIES)
-    {
-        pgtbl[i].owner = VDMA_PAGE_EMPTY;
-        i++;
-    }
-  
-    if (vdma_debug > 1)
-        printk("vdma_free: freed %ld pages starting from %08lx\n",
-               i-(laddr>>12),laddr);
-  
-    return 0;
+	return 0;
 }
 
 /*
  * Map certain page(s) to another physical address.
  * Caller must have allocated the page(s) before.
  */
-int vdma_remap(unsigned long laddr, unsigned long paddr, unsigned long size)
+int vdma_remap(unsigned long laddr, unsigned long paddr,
+	       unsigned long size)
 {
-    VDMA_PGTBL_ENTRY *pgtbl = (VDMA_PGTBL_ENTRY *)vdma_pagetable_start;
-    int first, pages, npages;
+	VDMA_PGTBL_ENTRY *pgtbl =
+	    (VDMA_PGTBL_ENTRY *) vdma_pagetable_start;
+	int first, pages, npages;
+
+	if (laddr > 0xffffff) {
+		if (vdma_debug)
+			printk
+			    ("vdma_map: Invalid logical address: %08lx\n",
+			     laddr);
+		return -EINVAL;	/* invalid logical address */
+	}
+	if (paddr > 0x1fffffff) {
+		if (vdma_debug)
+			printk
+			    ("vdma_map: Invalid physical address: %08lx\n",
+			     paddr);
+		return -EINVAL;	/* invalid physical address */
+	}
+
+	npages = pages =
+	    (((paddr & (VDMA_PAGESIZE - 1)) + size) >> 12) + 1;
+	first = laddr >> 12;
+	if (vdma_debug)
+		printk("vdma_remap: first=%x, pages=%x\n", first, pages);
+	if (first + pages > VDMA_PGTBL_ENTRIES) {
+		if (vdma_debug)
+			printk("vdma_alloc: Invalid size: %08lx\n", size);
+		return -EINVAL;
+	}
+
+	paddr &= ~(VDMA_PAGESIZE - 1);
+	while (pages > 0 && first < VDMA_PGTBL_ENTRIES) {
+		if (pgtbl[first].owner != laddr) {
+			if (vdma_debug)
+				printk("Trying to remap other's pages.\n");
+			return -EPERM;	/* not owner */
+		}
+		pgtbl[first].frame = paddr;
+		paddr += VDMA_PAGESIZE;
+		first++;
+		pages--;
+	}
+
+	/*
+	 * Update translation table
+	 */
+	r4030_write_reg32(JAZZ_R4030_TRSTBL_INV, 0);
+
+	if (vdma_debug > 2) {
+		int i;
+		pages = (((paddr & (VDMA_PAGESIZE - 1)) + size) >> 12) + 1;
+		first = laddr >> 12;
+		printk("LADDR: ");
+		for (i = first; i < first + pages; i++)
+			printk("%08x ", i << 12);
+		printk("\nPADDR: ");
+		for (i = first; i < first + pages; i++)
+			printk("%08x ", pgtbl[i].frame);
+		printk("\nOWNER: ");
+		for (i = first; i < first + pages; i++)
+			printk("%08x ", pgtbl[i].owner);
+		printk("\n");
+	}
 
-    if (laddr > 0xffffff)
-    {
-        if (vdma_debug)
-            printk("vdma_map: Invalid logical address: %08lx\n",laddr);
-        return -EINVAL;		/* invalid logical address */
-    }
-    if (paddr > 0x1fffffff)
-    {
-        if (vdma_debug)
-            printk("vdma_map: Invalid physical address: %08lx\n",paddr);
-        return -EINVAL;		/* invalid physical address */
-    }
-  
-    npages = pages = (((paddr & (VDMA_PAGESIZE-1)) + size) >> 12) + 1;
-    first = laddr >> 12;
-    if (vdma_debug)
-        printk("vdma_remap: first=%x, pages=%x\n",first,pages);
-    if (first+pages > VDMA_PGTBL_ENTRIES)
-    {
-        if (vdma_debug)
-            printk("vdma_alloc: Invalid size: %08lx\n",size);
-        return -EINVAL;
-    }
-
-    paddr &= ~(VDMA_PAGESIZE-1);
-    while (pages > 0 && first < VDMA_PGTBL_ENTRIES)
-    {
-        if (pgtbl[first].owner != laddr)
-        {
-            if (vdma_debug)
-                printk("Trying to remap other's pages.\n");
-            return -EPERM;		/* not owner */
-        }
-        pgtbl[first].frame = paddr;
-        paddr += VDMA_PAGESIZE;
-        first++;
-        pages--;
-    }
-
-    /*
-     * Update translation table
-     */
-    r4030_write_reg32(JAZZ_R4030_TRSTBL_INV,0);
-  
-    if (vdma_debug > 2)
-    {
-        int i;
-        pages = (((paddr & (VDMA_PAGESIZE-1)) + size) >> 12) + 1;
-        first = laddr >> 12;
-        printk("LADDR: ");
-        for (i=first; i<first+pages; i++)
-            printk("%08x ",i<<12);
-        printk("\nPADDR: ");
-        for (i=first; i<first+pages; i++)
-            printk("%08x ",pgtbl[i].frame);
-        printk("\nOWNER: ");
-        for (i=first; i<first+pages; i++)
-            printk("%08x ",pgtbl[i].owner);
-        printk("\n");
-    }
-      
-    return 0;
+	return 0;
 }
 
 /*
@@ -291,22 +287,22 @@
  */
 unsigned long vdma_phys2log(unsigned long paddr)
 {
-    int i;
-    int frame;
-    VDMA_PGTBL_ENTRY *pgtbl = (VDMA_PGTBL_ENTRY *)vdma_pagetable_start;
-
-    frame = paddr & ~(VDMA_PAGESIZE-1);
-
-    for (i=0; i<VDMA_PGTBL_ENTRIES; i++)
-    {
-        if (pgtbl[i].frame == frame)
-            break;
-    }
+	int i;
+	int frame;
+	VDMA_PGTBL_ENTRY *pgtbl =
+	    (VDMA_PGTBL_ENTRY *) vdma_pagetable_start;
+
+	frame = paddr & ~(VDMA_PAGESIZE - 1);
+
+	for (i = 0; i < VDMA_PGTBL_ENTRIES; i++) {
+		if (pgtbl[i].frame == frame)
+			break;
+	}
 
-    if (i == VDMA_PGTBL_ENTRIES)
-        return ~0UL;
+	if (i == VDMA_PGTBL_ENTRIES)
+		return ~0UL;
 
-    return (i<<12) + (paddr & (VDMA_PAGESIZE-1));
+	return (i << 12) + (paddr & (VDMA_PAGESIZE - 1));
 }
 
 /*
@@ -314,44 +310,47 @@
  */
 unsigned long vdma_log2phys(unsigned long laddr)
 {
-    VDMA_PGTBL_ENTRY *pgtbl = (VDMA_PGTBL_ENTRY *)vdma_pagetable_start;
+	VDMA_PGTBL_ENTRY *pgtbl =
+	    (VDMA_PGTBL_ENTRY *) vdma_pagetable_start;
 
-    return pgtbl[laddr >> 12].frame + (laddr & (VDMA_PAGESIZE-1));
+	return pgtbl[laddr >> 12].frame + (laddr & (VDMA_PAGESIZE - 1));
 }
-  
+
 /*
  * Print DMA statistics
  */
 void vdma_stats(void)
 {
-    int i;
-  
-    printk("vdma_stats: CONFIG: %08x\n",
-           r4030_read_reg32(JAZZ_R4030_CONFIG));
-    printk("R4030 translation table base: %08x\n",
-           r4030_read_reg32(JAZZ_R4030_TRSTBL_BASE));
-    printk("R4030 translation table limit: %08x\n",
-           r4030_read_reg32(JAZZ_R4030_TRSTBL_LIM));
-    printk("vdma_stats: INV_ADDR: %08x\n",
-           r4030_read_reg32(JAZZ_R4030_INV_ADDR));
-    printk("vdma_stats: R_FAIL_ADDR: %08x\n",
-           r4030_read_reg32(JAZZ_R4030_R_FAIL_ADDR));
-    printk("vdma_stats: M_FAIL_ADDR: %08x\n",
-           r4030_read_reg32(JAZZ_R4030_M_FAIL_ADDR));
-    printk("vdma_stats: IRQ_SOURCE: %08x\n",
-           r4030_read_reg32(JAZZ_R4030_IRQ_SOURCE));
-    printk("vdma_stats: I386_ERROR: %08x\n",
-           r4030_read_reg32(JAZZ_R4030_I386_ERROR));
-    printk("vdma_chnl_modes:   ");
-    for (i=0; i<8; i++)
-        printk("%04x ",
-               (unsigned)r4030_read_reg32(JAZZ_R4030_CHNL_MODE+(i<<5)));
-    printk("\n");
-    printk("vdma_chnl_enables: ");
-    for (i=0; i<8; i++)
-        printk("%04x ",
-               (unsigned)r4030_read_reg32(JAZZ_R4030_CHNL_ENABLE+(i<<5)));
-    printk("\n");
+	int i;
+
+	printk("vdma_stats: CONFIG: %08x\n",
+	       r4030_read_reg32(JAZZ_R4030_CONFIG));
+	printk("R4030 translation table base: %08x\n",
+	       r4030_read_reg32(JAZZ_R4030_TRSTBL_BASE));
+	printk("R4030 translation table limit: %08x\n",
+	       r4030_read_reg32(JAZZ_R4030_TRSTBL_LIM));
+	printk("vdma_stats: INV_ADDR: %08x\n",
+	       r4030_read_reg32(JAZZ_R4030_INV_ADDR));
+	printk("vdma_stats: R_FAIL_ADDR: %08x\n",
+	       r4030_read_reg32(JAZZ_R4030_R_FAIL_ADDR));
+	printk("vdma_stats: M_FAIL_ADDR: %08x\n",
+	       r4030_read_reg32(JAZZ_R4030_M_FAIL_ADDR));
+	printk("vdma_stats: IRQ_SOURCE: %08x\n",
+	       r4030_read_reg32(JAZZ_R4030_IRQ_SOURCE));
+	printk("vdma_stats: I386_ERROR: %08x\n",
+	       r4030_read_reg32(JAZZ_R4030_I386_ERROR));
+	printk("vdma_chnl_modes:   ");
+	for (i = 0; i < 8; i++)
+		printk("%04x ",
+		       (unsigned) r4030_read_reg32(JAZZ_R4030_CHNL_MODE +
+						   (i << 5)));
+	printk("\n");
+	printk("vdma_chnl_enables: ");
+	for (i = 0; i < 8; i++)
+		printk("%04x ",
+		       (unsigned) r4030_read_reg32(JAZZ_R4030_CHNL_ENABLE +
+						   (i << 5)));
+	printk("\n");
 }
 
 /*
@@ -363,33 +362,35 @@
  */
 void vdma_enable(int channel)
 {
-    int status;
-  
-    if (vdma_debug)
-        printk("vdma_enable: channel %d\n",channel);
-  
-    /*
-     * Check error conditions first
-     */
-    status = r4030_read_reg32(JAZZ_R4030_CHNL_ENABLE+(channel<<5));
-    if (status & 0x400)
-        printk("VDMA: Channel %d: Address error!\n",channel);
-    if (status & 0x200)
-        printk("VDMA: Channel %d: Memory error!\n",channel);
-
-    /*
-     * Clear all interrupt flags
-     */
-    r4030_write_reg32(JAZZ_R4030_CHNL_ENABLE+(channel<<5),
-		      r4030_read_reg32(JAZZ_R4030_CHNL_ENABLE+(channel<<5)) |
-                      R4030_TC_INTR | R4030_MEM_INTR | R4030_ADDR_INTR);
-
-    /*
-     * Enable the desired channel
-     */
-    r4030_write_reg32(JAZZ_R4030_CHNL_ENABLE+(channel<<5),
-                      r4030_read_reg32(JAZZ_R4030_CHNL_ENABLE+(channel<<5)) |
-                      R4030_CHNL_ENABLE);
+	int status;
+
+	if (vdma_debug)
+		printk("vdma_enable: channel %d\n", channel);
+
+	/*
+	 * Check error conditions first
+	 */
+	status = r4030_read_reg32(JAZZ_R4030_CHNL_ENABLE + (channel << 5));
+	if (status & 0x400)
+		printk("VDMA: Channel %d: Address error!\n", channel);
+	if (status & 0x200)
+		printk("VDMA: Channel %d: Memory error!\n", channel);
+
+	/*
+	 * Clear all interrupt flags
+	 */
+	r4030_write_reg32(JAZZ_R4030_CHNL_ENABLE + (channel << 5),
+			  r4030_read_reg32(JAZZ_R4030_CHNL_ENABLE +
+					   (channel << 5)) | R4030_TC_INTR
+			  | R4030_MEM_INTR | R4030_ADDR_INTR);
+
+	/*
+	 * Enable the desired channel
+	 */
+	r4030_write_reg32(JAZZ_R4030_CHNL_ENABLE + (channel << 5),
+			  r4030_read_reg32(JAZZ_R4030_CHNL_ENABLE +
+					   (channel << 5)) |
+			  R4030_CHNL_ENABLE);
 }
 
 /*
@@ -397,28 +398,34 @@
  */
 void vdma_disable(int channel)
 {
-    if (vdma_debug)
-    {
-        int status = r4030_read_reg32(JAZZ_R4030_CHNL_ENABLE+(channel<<5));
-
-        printk("vdma_disable: channel %d\n",channel);
-        printk("VDMA: channel %d status: %04x (%s) mode: "
-               "%02x addr: %06x count: %06x\n",
-               channel,status,((status & 0x600) ? "ERROR" : "OK"),
-               (unsigned)r4030_read_reg32(JAZZ_R4030_CHNL_MODE+(channel<<5)),
-               (unsigned)r4030_read_reg32(JAZZ_R4030_CHNL_ADDR+(channel<<5)),
-               (unsigned)r4030_read_reg32(JAZZ_R4030_CHNL_COUNT+(channel<<5)));
-    }
-  
-    r4030_write_reg32(JAZZ_R4030_CHNL_ENABLE+(channel<<5),
-                      r4030_read_reg32(JAZZ_R4030_CHNL_ENABLE+(channel<<5)) &
-                      ~R4030_CHNL_ENABLE);
-
-    /*
-     * After disabling a DMA channel a remote bus register should be
-     * read to ensure that the current DMA acknowledge cycle is completed.
-     */
-    *((volatile unsigned int *)JAZZ_DUMMY_DEVICE);
+	if (vdma_debug) {
+		int status =
+		    r4030_read_reg32(JAZZ_R4030_CHNL_ENABLE +
+				     (channel << 5));
+
+		printk("vdma_disable: channel %d\n", channel);
+		printk("VDMA: channel %d status: %04x (%s) mode: "
+		       "%02x addr: %06x count: %06x\n",
+		       channel, status,
+		       ((status & 0x600) ? "ERROR" : "OK"),
+		       (unsigned) r4030_read_reg32(JAZZ_R4030_CHNL_MODE +
+						   (channel << 5)),
+		       (unsigned) r4030_read_reg32(JAZZ_R4030_CHNL_ADDR +
+						   (channel << 5)),
+		       (unsigned) r4030_read_reg32(JAZZ_R4030_CHNL_COUNT +
+						   (channel << 5)));
+	}
+
+	r4030_write_reg32(JAZZ_R4030_CHNL_ENABLE + (channel << 5),
+			  r4030_read_reg32(JAZZ_R4030_CHNL_ENABLE +
+					   (channel << 5)) &
+			  ~R4030_CHNL_ENABLE);
+
+	/*
+	 * After disabling a DMA channel a remote bus register should be
+	 * read to ensure that the current DMA acknowledge cycle is completed.
+	 */
+	*((volatile unsigned int *) JAZZ_DUMMY_DEVICE);
 }
 
 /*
@@ -432,56 +439,60 @@
  */
 void vdma_set_mode(int channel, int mode)
 {
-    if (vdma_debug)
-        printk("vdma_set_mode: channel %d, mode 0x%x\n", channel, mode);
-
-    switch(channel)
-    {
-    case JAZZ_SCSI_DMA:			/* scsi */
-        r4030_write_reg32(JAZZ_R4030_CHNL_MODE+(channel<<5),
+	if (vdma_debug)
+		printk("vdma_set_mode: channel %d, mode 0x%x\n", channel,
+		       mode);
+
+	switch (channel) {
+	case JAZZ_SCSI_DMA:	/* scsi */
+		r4030_write_reg32(JAZZ_R4030_CHNL_MODE + (channel << 5),
 /*			  R4030_MODE_FAST | */
 /*			  R4030_MODE_BURST | */
-                          R4030_MODE_INTR_EN |
-                          R4030_MODE_WIDTH_16 |
-                          R4030_MODE_ATIME_80);
-        break;
-      
-    case JAZZ_FLOPPY_DMA:	/* floppy */
-        r4030_write_reg32(JAZZ_R4030_CHNL_MODE+(channel<<5),
+				  R4030_MODE_INTR_EN |
+				  R4030_MODE_WIDTH_16 |
+				  R4030_MODE_ATIME_80);
+		break;
+
+	case JAZZ_FLOPPY_DMA:	/* floppy */
+		r4030_write_reg32(JAZZ_R4030_CHNL_MODE + (channel << 5),
 /*			  R4030_MODE_FAST | */
 /*			  R4030_MODE_BURST | */
-                          R4030_MODE_INTR_EN |
-                          R4030_MODE_WIDTH_8 |
-                          R4030_MODE_ATIME_120);
-        break;
-
-    case JAZZ_AUDIOL_DMA:
-    case JAZZ_AUDIOR_DMA:
-        printk("VDMA: Audio DMA not supported yet.\n");
-        break;
-      
-    default:
-        printk("VDMA: vdma_set_mode() called with unsupported channel %d!\n",
-               channel);
-    }
-  
-    switch(mode)
-    {
-    case DMA_MODE_READ:
-        r4030_write_reg32(JAZZ_R4030_CHNL_ENABLE+(channel<<5),
-                          r4030_read_reg32(JAZZ_R4030_CHNL_ENABLE+(channel<<5)) &
-                          ~R4030_CHNL_WRITE);
-        break;
-      
-    case DMA_MODE_WRITE:
-        r4030_write_reg32(JAZZ_R4030_CHNL_ENABLE+(channel<<5),
-                          r4030_read_reg32(JAZZ_R4030_CHNL_ENABLE+(channel<<5)) |
-                          R4030_CHNL_WRITE);
-      break;
-      
-    default:
-        printk("VDMA: vdma_set_mode() called with unknown dma mode 0x%x\n",mode);
-    }
+				  R4030_MODE_INTR_EN |
+				  R4030_MODE_WIDTH_8 |
+				  R4030_MODE_ATIME_120);
+		break;
+
+	case JAZZ_AUDIOL_DMA:
+	case JAZZ_AUDIOR_DMA:
+		printk("VDMA: Audio DMA not supported yet.\n");
+		break;
+
+	default:
+		printk
+		    ("VDMA: vdma_set_mode() called with unsupported channel %d!\n",
+		     channel);
+	}
+
+	switch (mode) {
+	case DMA_MODE_READ:
+		r4030_write_reg32(JAZZ_R4030_CHNL_ENABLE + (channel << 5),
+				  r4030_read_reg32(JAZZ_R4030_CHNL_ENABLE +
+						   (channel << 5)) &
+				  ~R4030_CHNL_WRITE);
+		break;
+
+	case DMA_MODE_WRITE:
+		r4030_write_reg32(JAZZ_R4030_CHNL_ENABLE + (channel << 5),
+				  r4030_read_reg32(JAZZ_R4030_CHNL_ENABLE +
+						   (channel << 5)) |
+				  R4030_CHNL_WRITE);
+		break;
+
+	default:
+		printk
+		    ("VDMA: vdma_set_mode() called with unknown dma mode 0x%x\n",
+		     mode);
+	}
 }
 
 /*
@@ -489,10 +500,11 @@
  */
 void vdma_set_addr(int channel, long addr)
 {
-    if (vdma_debug)
-        printk("vdma_set_addr: channel %d, addr %lx\n",channel,addr);
+	if (vdma_debug)
+		printk("vdma_set_addr: channel %d, addr %lx\n", channel,
+		       addr);
 
-    r4030_write_reg32(JAZZ_R4030_CHNL_ADDR+(channel<<5),addr);
+	r4030_write_reg32(JAZZ_R4030_CHNL_ADDR + (channel << 5), addr);
 }
 
 /*
@@ -500,25 +512,28 @@
  */
 void vdma_set_count(int channel, int count)
 {
-    if (vdma_debug)
-        printk("vdma_set_count: channel %d, count %08x\n",channel,(unsigned)count);
-  
-    r4030_write_reg32(JAZZ_R4030_CHNL_COUNT+(channel<<5),count);
+	if (vdma_debug)
+		printk("vdma_set_count: channel %d, count %08x\n", channel,
+		       (unsigned) count);
+
+	r4030_write_reg32(JAZZ_R4030_CHNL_COUNT + (channel << 5), count);
 }
-     
+
 /*
  * Get Residual
  */
 int vdma_get_residue(int channel)
 {
-    int residual;
-  
-    residual = r4030_read_reg32(JAZZ_R4030_CHNL_COUNT+(channel<<5));
-
-    if (vdma_debug)
-        printk("vdma_get_residual: channel %d: residual=%d\n",channel,residual);
-  
-    return residual;
+	int residual;
+
+	residual =
+	    r4030_read_reg32(JAZZ_R4030_CHNL_COUNT + (channel << 5));
+
+	if (vdma_debug)
+		printk("vdma_get_residual: channel %d: residual=%d\n",
+		       channel, residual);
+
+	return residual;
 }
 
 /*
@@ -526,12 +541,13 @@
  */
 int vdma_get_enable(int channel)
 {
-    int enable;
-    
-    enable = r4030_read_reg32(JAZZ_R4030_CHNL_ENABLE+(channel<<5));
-    
-    if (vdma_debug)
-	printk("vdma_get_enable: channel %d: enable=%d\n",channel,enable);
-    
-    return enable;
+	int enable;
+
+	enable = r4030_read_reg32(JAZZ_R4030_CHNL_ENABLE + (channel << 5));
+
+	if (vdma_debug)
+		printk("vdma_get_enable: channel %d: enable=%d\n", channel,
+		       enable);
+
+	return enable;
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips/jazz/rtc-jazz.c linux/arch/mips/jazz/rtc-jazz.c
--- v2.4.9/linux/arch/mips/jazz/rtc-jazz.c	Sat May 13 08:29:14 2000
+++ linux/arch/mips/jazz/rtc-jazz.c	Sun Sep  9 10:43:01 2001
@@ -1,12 +1,11 @@
-/* $Id: rtc-jazz.c,v 1.2 1998/06/25 20:19:14 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * RTC routines for Jazz style attached Dallas chip.
  *
- * Copyright (C) 1998 by Ralf Baechle
+ * Copyright (C) 1998, 2001 by Ralf Baechle
  */
 #include <linux/mc146818rtc.h>
 #include <asm/io.h>
diff -u --recursive --new-file v2.4.9/linux/arch/mips/jazz/setup.c linux/arch/mips/jazz/setup.c
--- v2.4.9/linux/arch/mips/jazz/setup.c	Sat May 13 08:29:14 2000
+++ linux/arch/mips/jazz/setup.c	Sun Sep  9 10:43:01 2001
@@ -1,12 +1,12 @@
-/* $Id: setup.c,v 1.24 1999/10/09 00:00:58 ralf Exp $
- *
+/*
  * Setup pointers to hardware-dependent routines.
  *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1996, 1997, 1998 by Ralf Baechle
+ * Copyright (C) 1996, 1997, 1998, 2001 by Ralf Baechle
+ * Copyright (C) 2001 MIPS Technologies, Inc.
  */
 #include <linux/config.h>
 #include <linux/hdreg.h>
@@ -72,7 +72,7 @@
 			  JAZZ_IE_FLOPPY);
 	r4030_read_reg16(JAZZ_IO_IRQ_SOURCE); /* clear pending IRQs */
 	r4030_read_reg32(JAZZ_R4030_INVAL_ADDR); /* clear error bits */
-	set_cp0_status(ST0_IM, IE_IRQ4 | IE_IRQ3 | IE_IRQ2 | IE_IRQ1);
+	change_cp0_status(ST0_IM, IE_IRQ4 | IE_IRQ3 | IE_IRQ2 | IE_IRQ1);
 	/* set the clock to 100 Hz */
 	r4030_write_reg32(JAZZ_TIMER_INTERVAL, 9);
 	request_region(0x20, 0x20, "pic1");
@@ -80,11 +80,6 @@
 	i8259_setup_irq(2, &irq2);
 }
 
-int __init page_is_ram(unsigned long pagenr)
-{
-	return 1;
-}
-
 void __init jazz_setup(void)
 {
 	add_wired_entry (0x02000017, 0x03c00017, 0xe0000000, PM_64K);
@@ -93,6 +88,8 @@
 
 	irq_setup = jazz_irq_setup;
 	mips_io_port_base = JAZZ_PORT_BASE;
+	if (mips_machtype == MACH_MIPS_MAGNUM_4000)
+		EISA_bus = 1;
 	isa_slot_offset = 0xe3000000;
 	request_region(0x00,0x20,"dma1");
 	request_region(0x40,0x20,"timer");
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/Makefile linux/arch/mips/kernel/Makefile
--- v2.4.9/linux/arch/mips/kernel/Makefile	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/kernel/Makefile	Sun Sep  9 10:43:01 2001
@@ -35,15 +35,12 @@
 endif
 
 obj-$(CONFIG_SMP)		+= smp.o
-obj-$(CONFIG_MIPS_FPE_MODULE)	+= fpe.o
-ifndef CONFIG_MIPS_FPU_EMULATOR
-  obj-y				+= softfp.o
-endif
 
 # Old style irq support, going to die in 2.5.
 export-objs			+= old-irq.o
 obj-$(CONFIG_NEW_IRQ)		+= irq.o
 obj-$(CONFIG_ROTTEN_IRQ)	+= old-irq.o
+obj-$(CONFIG_I8259)		+= i8259.o
 
 # transition from old time.c to new time.c
 # some boards uses old-time.c, some use time.c, and some use their own ones
@@ -56,6 +53,11 @@
 obj-$(CONFIG_REMOTE_DEBUG)	+= gdb-low.o gdb-stub.o 
 obj-$(CONFIG_PCI)		+= pci-dma.o
 obj-$(CONFIG_PROC_FS)		+= proc.o
+
+ifdef CONFIG_PCI
+obj-$(CONFIG_NEW_PCI)          += pci.o
+obj-$(CONFIG_PCI_AUTO)         += pci_auto.o
+endif
 
 entry.o: entry.S
 head.o: head.S
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/branch.c linux/arch/mips/kernel/branch.c
--- v2.4.9/linux/arch/mips/kernel/branch.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/kernel/branch.c	Sun Sep  9 10:43:01 2001
@@ -5,9 +5,9 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1996, 97, 2000 by Ralf Baechle
+ * Copyright (C) 1996, 97, 2000, 2001 by Ralf Baechle
+ * Copyright (C) 2001 MIPS Technologies, Inc.
  */
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/signal.h>
@@ -29,11 +29,8 @@
 	union mips_instruction insn;
 
 	epc = regs->cp0_epc;
-	if (epc & 3) {
-		printk("%s: unaligned epc - sending SIGBUS.\n", current->comm);
-		force_sig(SIGBUS, current);
-		return -EFAULT;
-	}
+	if (epc & 3)
+		goto unaligned;
 
 	/*
 	 * Read the instruction
@@ -167,12 +164,10 @@
 	 * And now the FPA/cp1 branch instructions.
 	 */
 	case cop1_op:
-#ifdef CONFIG_MIPS_FPU_EMULATOR
 		if(!(mips_cpu.options & MIPS_CPU_FPU))
 			fcr31 = current->thread.fpu.soft.sr;
 		else
-#endif
-		asm ("cfc1\t%0,$31":"=r" (fcr31));
+			asm ("cfc1\t%0,$31":"=r" (fcr31));
 		bit = (insn.i_format.rt >> 2);
 		bit += (bit != 0);
 		bit += 23;
@@ -199,4 +194,9 @@
 	}
 
 	return 0;
+
+unaligned:
+	printk("%s: unaligned epc - sending SIGBUS.\n", current->comm);
+	force_sig(SIGBUS, current);
+	return -EFAULT;
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/entry.S linux/arch/mips/kernel/entry.S
--- v2.4.9/linux/arch/mips/kernel/entry.S	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/kernel/entry.S	Sun Sep  9 10:43:01 2001
@@ -1,13 +1,12 @@
-/* $Id: entry.S,v 1.19 1999/12/08 22:05:10 harald Exp $
- *
- * Low level exception handling
- *
+/*
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1994 - 2000 by Ralf Baechle
+ * Copyright (C) 1994 - 2000, 2001 by Ralf Baechle
  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
+ * Copyright (C) 2001 MIPS Technologies, Inc.
  */
 #include <linux/config.h>
 #include <linux/sys.h>
@@ -26,50 +25,64 @@
 #include <asm/unistd.h>
 #include <asm/isadep.h>
 
+/* This duplicates the definition from <linux/sched.h> */
+#define PT_TRACESYS	0x00000002		/* tracing system calls */
+
+
 		.text
 		.align 4
 		.set	push
 		.set	reorder
 EXPORT(ret_from_fork)
-		 move	a0, v0			# prev
+		move	a0, v0			# prev
 		jal	schedule_tail
+		lw	t0, TASK_PTRACE($28)	# syscall tracing enabled?
+		andi	t0, PT_TRACESYS
+		bnez	t0, tracesys_exit
 		j	ret_from_sys_call
 
-EXPORT(handle_softirq)
-		jal	do_softirq
-		b	9f
+tracesys_exit:	jal	syscall_trace
+		b	ret_from_sys_call
+
+EXPORT(ret_from_irq)
+EXPORT(ret_from_exception)
+		lw	t0, PT_STATUS(sp)	# returning to kernel mode?
+		andi	t0, t0, KU_USER
+		bnez	t0, ret_from_sys_call
+		j	restore_all
 
 reschedule:	jal	schedule 
 
 EXPORT(ret_from_sys_call)
-EXPORT(ret_from_irq)
 		.type	ret_from_irq,@function
-		la	t1, irq_stat		# softirq_active
-#ifdef CONFIG_SMP
-		lw	t0, TASK_PROCESSOR($28)
-		sll	t0, t0, 5
-		addu	t1, t0
-#endif
-		lw	t0, 0(t1)		# softirq_active
-		lw	t1, 4(t1)		# softirq_mask.  unused delay slot
-		and	t0, t1
-		bnez	t0, handle_softirq
-
-9:		lw	t0,PT_STATUS(sp)	# returning to kernel mode?
-		lw	t2, TASK_NEED_RESCHED($28)
-		andi	t1, t0, KU_USER
-		beqz	t1, return		# -> yes
-		bnez	t2, reschedule
-		lw	v0, TASK_SIGPENDING($28)
-		 move	a0, zero
-		beqz	v0, return
-		 move	a1, sp
-		jal	do_signal
 
-EXPORT(return)	.set	noat
+		mfc0	t0, CP0_STATUS	# need_resched and signals atomic test
+		ori	t0, t0, 1
+		xori	t0, t0, 1
+		mtc0	t0, CP0_STATUS
+		nop; nop; nop
+
+		lw	v0, TASK_NEED_RESCHED($28)
+		lw	v1, TASK_SIGPENDING($28)
+		bnez	v0, reschedule
+		bnez	v1, signal_return
+restore_all:	.set	noat
 		RESTORE_ALL_AND_RET
 		.set	at
 
+/* Put this behind restore_all for the sake of the branch prediction.  */
+signal_return:
+		.type	signal_return, @function
+
+		mfc0	t0, CP0_STATUS
+		ori	t0, t0, 1
+		mtc0	t0, CP0_STATUS
+
+		move	a0, zero
+		move	a1, sp
+		jal	do_signal
+		b	restore_all
+
 /*
  * Common spurious interrupt handler.
  */
@@ -85,8 +98,8 @@
 		lw      t0,%lo(spurious_count)(t1)
 		.set	noreorder
 		addiu   t0,1
+		sw      t0,%lo(spurious_count)(t1)
 		j	ret_from_irq
-		 sw      t0,%lo(spurious_count)(t1)
 		END(spurious_interrupt)
 
 /*
@@ -106,7 +119,7 @@
 		ctc1	a2,fcr31;                                       \
 		STI
 #define __BUILD_clear_ade(exception)                                    \
-		.set	reorder;						\
+		.set	reorder;					\
 		MFC0	t0,CP0_BADVADDR;                                \
 		.set	noreorder;					\
 		REG_S	t0,PT_BVADDR(sp);                               \
@@ -139,8 +152,8 @@
 		.set	at;                                             \
 		__BUILD_##verbose(exception);                           \
 		jal	do_##handler;                                   \
-		 move	a0,sp;                                          \
-		j	ret_from_sys_call;                              \
+		 move	a0, sp;                                         \
+		j	ret_from_exception;                             \
 		 nop;                                                   \
 		END(handle_##exception)
 
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/fpe.c linux/arch/mips/kernel/fpe.c
--- v2.4.9/linux/arch/mips/kernel/fpe.c	Sun Jul  9 22:18:15 2000
+++ linux/arch/mips/kernel/fpe.c	Wed Dec 31 16:00:00 1969
@@ -1,51 +0,0 @@
-/*
- * The real floating point exception handler.  While it doesn't really
- * make sense to have this in a module, it makes debugging of this code
- * in the kernel space a lot easier.  So far this handler in the released
- * kernel source is just a dummy.
- *
- * Copyright (C) 1997, 2000 Ralf Baechle
- */
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
-#include <linux/smp.h>
-#include <linux/smp_lock.h>
-
-#include <asm/branch.h>
-#include <asm/ptrace.h>
-
-MODULE_AUTHOR("Ralf Baechle <ralf@gnu.org>");
-MODULE_DESCRIPTION("Experimental floating point exception handler");
-MODULE_SUPPORTED_DEVICE("MIPS FPU");
-
-static void do_fpe(struct pt_regs *regs, unsigned int fcr31)
-{
-#ifdef CONF_DEBUG_EXCEPTIONS
-	show_regs(regs);
-#endif
-	printk("Caught floating exception at epc == %08lx, fcr31 == %08x\n",
-	       regs->cp0_epc, fcr31);
-	if (compute_return_epc(regs))
-		goto out;
-	force_sig(SIGFPE, current);
-out:
-}
-
-/*
- * For easier experimentation we never increment/decrement
- * the module usable counter.
- */
-int register_fpe(void (*handler)(struct pt_regs *regs, unsigned int fcr31));
-int unregister_fpe(void (*handler)(struct pt_regs *regs, unsigned int fcr31));
-
-int init_module(void)
-{
-	return register_fpe(do_fpe);
-}
-
-void cleanup_module(void)
-{
-	unregister_fpe(do_fpe);
-}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/gdb-low.S linux/arch/mips/kernel/gdb-low.S
--- v2.4.9/linux/arch/mips/kernel/gdb-low.S	Sat May 13 08:29:14 2000
+++ linux/arch/mips/kernel/gdb-low.S	Sun Sep  9 10:43:01 2001
@@ -1,16 +1,13 @@
 /*
- * arch/mips/kernel/gdb-low.S
- *
  * gdb-low.S contains the low-level trap handler for the GDB stub.
  *
  * Copyright (C) 1995 Andreas Busse
- *
- * $Id: gdb-low.S,v 1.4 1997/12/01 17:57:26 ralf Exp $
  */
-
+#include <linux/config.h>
 #include <linux/sys.h>
 
 #include <asm/asm.h>
+#include <asm/errno.h>
 #include <asm/mipsregs.h>
 #include <asm/regdef.h>
 #include <asm/stackframe.h>
@@ -30,10 +27,15 @@
 		move	k1,sp
 
 		/*
-		 * Called from user mode, new stack
+		 * Called from user mode, go somewhere else.
 		 */
-		lui	k1,%hi(kernelsp)
-		lw	k1,%lo(kernelsp)(k1)
+		lui	k1,%hi(saved_vectors)
+		mfc0	k0,CP0_CAUSE
+		andi	k0,k0,0x7c
+		add	k1,k1,k0
+		lw	k0,%lo(saved_vectors)(k1)
+		jr	k0
+		nop
 1:
 		move	k0,sp
 		subu	sp,k1,GDB_FR_SIZE
@@ -302,11 +304,51 @@
 		lw	v1,GDB_FR_REG3(sp)
 		lw	v0,GDB_FR_REG2(sp)
 		lw	$1,GDB_FR_REG1(sp)
-		lw	sp,GDB_FR_REG29(sp)		/* Deallocate stack */
+#ifdef CONFIG_CPU_R3000
+		lw	k0, GDB_FR_EPC(sp)
+		lw	sp, GDB_FR_REG29(sp)		/* Deallocate stack */
+		jr	k0
+		rfe
+#else
+		lw	sp, GDB_FR_REG29(sp)		/* Deallocate stack */
 
 		.set	mips3
 		eret
 		.set	mips0
+#endif
 		.set	at
 		.set	reorder
 		END(trap_low)
+
+LEAF(kgdb_read_byte)
+		.set push
+		.set noreorder
+		.set nomacro
+4:		lb	t0, (a0)
+		.set pop
+		sb	t0, (a1)
+		li	v0, 0
+		jr	ra
+		.section __ex_table,"a"
+		PTR	4b, kgdbfault
+		.previous
+		END(kgdb_read_byte)
+
+LEAF(kgdb_write_byte)
+		.set push
+		.set noreorder
+		.set nomacro
+5:		sb	a0, (a1)
+		.set pop
+		li	v0, 0
+		jr	ra
+		.section __ex_table,"a"
+		PTR	5b, kgdbfault
+		.previous
+		END(kgdb_write_byte)
+
+		.type	kgdbfault@function
+		.ent	kgdbfault
+kgdbfault:	li	v0, -EFAULT
+		jr	ra
+		.end	kgdbfault
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/gdb-stub.c linux/arch/mips/kernel/gdb-stub.c
--- v2.4.9/linux/arch/mips/kernel/gdb-stub.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/kernel/gdb-stub.c	Sun Sep  9 10:43:01 2001
@@ -142,7 +142,6 @@
 
 extern int putDebugChar(char c);    /* write a single character      */
 extern char getDebugChar(void);     /* read and return a single char */
-extern void fltr_set_mem_err(void);
 extern void trap_low(void);
 
 /*
@@ -175,6 +174,10 @@
 static int initialized;	/* !0 means we've been initialized */
 static const char hexchars[]="0123456789abcdef";
 
+/* Used to prevent crashes in memory access.  Note that they'll crash anyway if
+   we haven't set up fault handlers yet... */
+int kgdb_read_byte(unsigned *address, unsigned *dest);
+int kgdb_write_byte(unsigned val, unsigned *dest);
 
 /*
  * Convert ch from a hex digit to an int
@@ -294,42 +297,18 @@
 
 
 /*
- * Indicate to caller of mem2hex or hex2mem that there
- * has been an error.
- */
-static volatile int mem_err = 0;
-
-
-#if 0
-static void set_mem_fault_trap(int enable)
-{
-  mem_err = 0;
-
-#if 0
-  if (enable)
-    exceptionHandler(9, fltr_set_mem_err);
-  else
-    exceptionHandler(9, trap_low);
-#endif  
-}
-#endif /* dead code */
-
-/*
  * Convert the memory pointed to by mem into hex, placing result in buf.
  * Return a pointer to the last char put in buf (null), in case of mem fault,
  * return 0.
- * If MAY_FAULT is non-zero, then we will handle memory faults by returning
- * a 0, else treat a fault like any other fault in the stub.
+ * may_fault is non-zero if we are reading from arbitrary memory, but is currently
+ * not used.
  */
 static unsigned char *mem2hex(char *mem, char *buf, int count, int may_fault)
 {
 	unsigned char ch;
 
-/*	set_mem_fault_trap(may_fault); */
-
 	while (count-- > 0) {
-		ch = *(mem++);
-		if (mem_err)
+		if (kgdb_read_byte(mem++, &ch) != 0)
 			return 0;
 		*buf++ = hexchars[ch >> 4];
 		*buf++ = hexchars[ch & 0xf];
@@ -337,33 +316,28 @@
 
 	*buf = 0;
 
-/*	set_mem_fault_trap(0); */
-
 	return buf;
 }
 
 /*
  * convert the hex array pointed to by buf into binary to be placed in mem
  * return a pointer to the character AFTER the last byte written
+ * may_fault is non-zero if we are reading from arbitrary memory, but is currently
+ * not used.
  */
 static char *hex2mem(char *buf, char *mem, int count, int may_fault)
 {
 	int i;
 	unsigned char ch;
 
-/*	set_mem_fault_trap(may_fault); */
-
 	for (i=0; i<count; i++)
 	{
 		ch = hex(*buf++) << 4;
 		ch |= hex(*buf++);
-		*(mem++) = ch;
-		if (mem_err)
+		if (kgdb_write_byte(ch, mem++) != 0)
 			return 0;
 	}
 
-/*	set_mem_fault_trap(0); */
-
 	return mem;
 }
 
@@ -390,6 +364,8 @@
 	{ 0, 0}				/* Must be last */
 };
 
+/* Save the normal trap handlers for user-mode traps. */
+void *saved_vectors[32];
 
 /*
  * Set up exception handlers for tracing and breakpoints
@@ -402,7 +378,7 @@
 
 	save_and_cli(flags);
 	for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
-		set_except_vector(ht->tt, trap_low);
+		saved_vectors[ht->tt] = set_except_vector(ht->tt, trap_low);
   
 	putDebugChar('+'); /* 'hello world' */
 	/*
@@ -417,18 +393,6 @@
 
 	initialized = 1;
 	restore_flags(flags);
-}
-
-
-/*
- * Trap handler for memory errors.  This just sets mem_err to be non-zero.  It
- * assumes that %l1 is non-zero.  This should be safe, as it is doubtful that
- * 0 would ever contain code that could mem fault.  This routine will skip
- * past the faulting instruction after setting mem_err.
- */
-extern void fltr_set_mem_err(void)
-{
-	/* FIXME: Needs to be written... */
 }
 
 /*
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/head.S linux/arch/mips/kernel/head.S
--- v2.4.9/linux/arch/mips/kernel/head.S	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/kernel/head.S	Sun Sep  9 10:43:01 2001
@@ -76,7 +76,11 @@
 	addu	k1, k1, k0			# add in pgd offset
 	mfc0	k0, CP0_CONTEXT			# get context reg
 	lw	k1, (k1)
+#if defined(CONFIG_CPU_VR41XX)
+	srl	k0, k0, 3			# get pte offset
+#else
 	srl	k0, k0, 1			# get pte offset
+#endif
 	and	k0, k0, 0xff8
 	addu	k1, k1, k0			# add in offset
 	lw	k0, 0(k1)			# get even pte
@@ -275,7 +279,7 @@
 	END(except_vec0_r4k_MP250MHZhwbug)
 #endif
 
-	/* TLB refill, EXL == 0, R[23]00 version */
+	/* TLB refill, R[23]00 version */
 	LEAF(except_vec0_r2300)
 	.set	noat
 	.set	mips1
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/i8259.c linux/arch/mips/kernel/i8259.c
--- v2.4.9/linux/arch/mips/kernel/i8259.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/kernel/i8259.c	Sun Sep  9 10:43:01 2001
@@ -295,7 +295,6 @@
 
 	request_resource(&ioport_resource, &pic1_io_resource);
 	request_resource(&ioport_resource, &pic2_io_resource);
-	setup_irq(2, &irq2);
 
 	init_8259A(0);
 
@@ -305,4 +304,6 @@
 		irq_desc[i].depth = 1;
 		irq_desc[i].handler = &i8259A_irq_type;
 	}
+
+	setup_irq(2, &irq2);
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/irq.c linux/arch/mips/kernel/irq.c
--- v2.4.9/linux/arch/mips/kernel/irq.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/kernel/irq.c	Sun Sep  9 10:43:01 2001
@@ -303,7 +303,7 @@
 	desc->handler->end(irq);
 	spin_unlock(&desc->lock);
 
-	if (softirq_active(cpu) & softirq_mask(cpu))
+	if (softirq_pending(cpu))
 		do_softirq();
 	return 1;
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/mips_ksyms.c linux/arch/mips/kernel/mips_ksyms.c
--- v2.4.9/linux/arch/mips/kernel/mips_ksyms.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/kernel/mips_ksyms.c	Sun Sep  9 10:43:01 2001
@@ -17,6 +17,7 @@
 #include <linux/pci.h>
 #include <linux/ide.h>
 
+#include <asm/bootinfo.h>
 #include <asm/checksum.h>
 #include <asm/dma.h>
 #include <asm/io.h>
@@ -40,6 +41,7 @@
 extern long __strnlen_user_nocheck_asm(const char *s);
 extern long __strnlen_user_asm(const char *s);
 
+EXPORT_SYMBOL(mips_machtype);
 EXPORT_SYMBOL(EISA_bus);
 
 /*
@@ -125,12 +127,6 @@
 
 int register_fpe(void (*handler)(struct pt_regs *regs, unsigned int fcr31));
 int unregister_fpe(void (*handler)(struct pt_regs *regs, unsigned int fcr31));
-
-#ifdef CONFIG_MIPS_FPE_MODULE
-EXPORT_SYMBOL(__compute_return_epc);
-EXPORT_SYMBOL(register_fpe);
-EXPORT_SYMBOL(unregister_fpe);
-#endif
 
 #ifdef CONFIG_VT
 EXPORT_SYMBOL(screen_info);
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/old-irq.c linux/arch/mips/kernel/old-irq.c
--- v2.4.9/linux/arch/mips/kernel/old-irq.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/kernel/old-irq.c	Sun Sep  9 10:43:01 2001
@@ -232,7 +232,7 @@
 	}
 	irq_exit(cpu, irq);
 
-	if (softirq_active(cpu)&softirq_mask(cpu))
+	if (softirq_pending(cpu))
 		do_softirq();
 
 	/* unmasking and bottom half handling is done magically for us. */
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/old-time.c linux/arch/mips/kernel/old-time.c
--- v2.4.9/linux/arch/mips/kernel/old-time.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/kernel/old-time.c	Sun Sep  9 10:43:01 2001
@@ -1,18 +1,11 @@
 /*
  * Copyright (C) 1991, 1992, 1995  Linus Torvalds
  * Copyright (C) 1996 - 2000  Ralf Baechle
+ * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
  *
- * This file contains the time handling details for PC-style clocks as
- * found in some MIPS systems.
+ * Don't use.  Deprecated.  Dead meat.
  */
-/**************************************************************************
- *  9 Nov, 2000.
- *  Changed init_cycle_counter() routine, use the mips_cpu structure.
- *
- *  Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips
- *  Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
- *************************************************************************/
-
 #include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/init.h>
@@ -450,7 +443,12 @@
 void indy_r4k_timer_interrupt (struct pt_regs *regs)
 {
 	static const int INDY_R4K_TIMER_IRQ = 7;
+	int cpu = smp_processor_id();
+
 	r4k_timer_interrupt (INDY_R4K_TIMER_IRQ, NULL, regs);
+
+	if (softirq_pending(cpu))
+		do_softirq();
 }
 
 struct irqaction irq0  = { timer_interrupt, SA_INTERRUPT, 0,
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/pci-dma.c linux/arch/mips/kernel/pci-dma.c
--- v2.4.9/linux/arch/mips/kernel/pci-dma.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/kernel/pci-dma.c	Sun Sep  9 10:43:01 2001
@@ -4,9 +4,10 @@
  * for more details.
  *
  * Copyright (C) 2000  Ani Joshi <ajoshi@unixbox.com>
- * Copyright (C) 2000  Ralf Baechle <ralf@gnu.org>
+ * Copyright (C) 2000, 2001  Ralf Baechle <ralf@gnu.org>
  * swiped from i386, and cloned for MIPS by Geert, polished by Ralf.
  */
+#include <linux/config.h>
 #include <linux/types.h>
 #include <linux/mm.h>
 #include <linux/string.h>
@@ -26,9 +27,11 @@
 
 	if (ret != NULL) {
 		memset(ret, 0, size);
+#ifndef CONFIG_COHERENT_IO
 		dma_cache_wback_inv((unsigned long) ret, size);
-		*dma_handle = virt_to_bus(ret);
 		ret = KSEG1ADDR(ret);
+#endif
+		*dma_handle = virt_to_bus(ret);
 	}
 
 	return ret;
@@ -37,5 +40,10 @@
 void pci_free_consistent(struct pci_dev *hwdev, size_t size,
 			 void *vaddr, dma_addr_t dma_handle)
 {
-	free_pages((unsigned long) KSEG0ADDR(vaddr), get_order(size));
+	unsigned long addr = (unsigned long) vaddr;
+
+#ifndef CONFIG_COHERENT_IO
+	addr = KSEG0ADDR(addr);
+#endif
+	free_pages(addr, get_order(size));
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/pci.c linux/arch/mips/kernel/pci.c
--- v2.4.9/linux/arch/mips/kernel/pci.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/kernel/pci.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,174 @@
+/*
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
+ *
+ * Modified to be mips generic, ppopov@mvista.com
+ * arch/mips/kernl/pci.c
+ *     Common MIPS PCI routines.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+/*
+ * This file contains common PCI routines meant to be shared for
+ * all MIPS machines.
+ *
+ * Strategies:
+ *
+ * . We rely on pci_auto.c file to assign PCI resources (MEM and IO)
+ *   TODO: this shold be optional for some machines where they do have
+ *   a real "pcibios" that does resource assignment.
+ *
+ * . We then use pci_scan_bus() to "discover" all the resources for
+ *   later use by Linux.
+ *
+ * . We finally reply on a board supplied function, pcibios_fixup_irq(), to
+ *   to assign the interrupts.  We may use setup-irq.c under drivers/pci
+ *   later.
+ *
+ * . Specifically, we will *NOT* use pci_assign_unassigned_resources(),
+ *   because we assume all PCI devices should have the resources correctly
+ *   assigned and recorded.
+ *
+ * Limitations:
+ *
+ * . We "collapse" all IO and MEM spaces in sub-buses under a top-level bus
+ *   into a contiguous range.
+ *
+ * . In the case of Memory space, the rnage is 1:1 mapping with CPU physical
+ *   address space.
+ *
+ * . In the case of IO space, it starts from 0, and the beginning address
+ *   is mapped to KSEG0ADDR(mips_io_port) in the CPU physical address.
+ *
+ * . These are the current MIPS limitations (by ioremap, etc).  In the
+ *   future, we may remove them.
+ *
+ * Credits:
+ *	Most of the code are derived from the pci routines from PPC and Alpha,
+ *	which were mostly writtne by
+ *		Cort Dougan, cort@fsmlabs.com
+ *		Matt Porter, mporter@mvista.com
+ *		Dave Rusling david.rusling@reo.mts.dec.com
+ *		David Mosberger davidm@cs.arizona.edu
+ */
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+
+#include <asm/pci_channel.h>
+
+extern void pcibios_fixup(void);
+extern void pcibios_fixup_irqs(void);
+
+struct pci_fixup pcibios_fixups[] = {
+	{ PCI_FIXUP_HEADER, PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_resources },
+	{ 0 }
+};
+
+extern int pciauto_assign_resources(int busno, struct pci_channel * hose);
+
+void __init pcibios_init(void)
+{
+	struct pci_channel *p;
+	struct pci_bus *bus;
+	int busno;
+
+#ifdef CONFIG_PCI_AUTO
+	/* assign resources */
+	busno=0;
+	for (p= mips_pci_channels; p->pci_ops != NULL; p++) {
+		busno = pciauto_assign_resources(busno, p) + 1;
+	}
+#endif
+
+	/* scan the buses */
+	busno = 0;
+	for (p= mips_pci_channels; p->pci_ops != NULL; p++) {
+		bus = pci_scan_bus(busno, p->pci_ops, p);
+		busno = bus->subordinate+1;
+	}
+
+	/* machine dependent fixups */
+	pcibios_fixup();
+	/* fixup irqs (board specific routines) */
+	pcibios_fixup_irqs();
+}
+
+int pcibios_enable_device(struct pci_dev *dev)
+{
+	/* pciauto_assign_resources() will enable all devices found */
+	return 0;
+}
+
+unsigned long __init pci_bridge_check_io(struct pci_dev *bridge)
+{
+	u16 io;
+
+	pci_read_config_word(bridge, PCI_IO_BASE, &io);
+	if (!io) {
+		pci_write_config_word(bridge, PCI_IO_BASE, 0xf0f0);
+		pci_read_config_word(bridge, PCI_IO_BASE, &io);
+		pci_write_config_word(bridge, PCI_IO_BASE, 0x0);
+	}
+	if (io)
+		return IORESOURCE_IO;
+	printk(KERN_WARNING "PCI: bridge %s does not support I/O forwarding!\n",
+				bridge->name);
+	return 0;
+}
+
+void __init pcibios_fixup_bus(struct pci_bus *bus)
+{
+	/* Propogate hose info into the subordinate devices.  */
+
+	struct pci_channel *hose = bus->sysdata;
+	struct pci_dev *dev = bus->self;
+
+	if (!dev) {
+		/* Root bus */
+		bus->resource[0] = hose->io_resource;
+		bus->resource[1] = hose->mem_resource;
+	} else {
+		/* This is a bridge. Do not care how it's initialized,
+		   just link its resources to the bus ones */
+		int i;
+
+		for(i=0; i<3; i++) {
+			bus->resource[i] =
+				&dev->resource[PCI_BRIDGE_RESOURCES+i];
+			bus->resource[i]->name = bus->name;
+		}
+		bus->resource[0]->flags |= pci_bridge_check_io(dev);
+		bus->resource[1]->flags |= IORESOURCE_MEM;
+		/* For now, propogate hose limits to the bus;
+		   we'll adjust them later. */
+		bus->resource[0]->end = hose->io_resource->end;
+		bus->resource[1]->end = hose->mem_resource->end;
+		/* Turn off downstream PF memory address range by default */
+		bus->resource[2]->start = 1024*1024;
+		bus->resource[2]->end = bus->resource[2]->start - 1;
+	}
+}
+
+char *pcibios_setup(char *str)
+{
+	return str;
+}
+
+void
+pcibios_align_resource(void *data, struct resource *res, unsigned long size)
+{
+	/* this should not be called */
+}
+
+void
+pcibios_update_resource(struct pci_dev *dev, struct resource *root,
+			struct resource *res, int resource)
+{
+	/* this should not be called */
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/pci_auto.c linux/arch/mips/kernel/pci_auto.c
--- v2.4.9/linux/arch/mips/kernel/pci_auto.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/kernel/pci_auto.c	Sun Sep  9 10:43:01 2001
@@ -0,0 +1,323 @@
+/*
+ * PCI autoconfiguration library
+ *
+ * Author: Matt Porter <mporter@mvista.com>
+ *
+ * Copyright 2000, 2001 MontaVista Software Inc.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+/*
+ * Modified for MIPS by Jun Sun, jsun@mvista.com
+ *
+ * . Simplify the interface between pci_auto and the rest: a single function.
+ * . Assign resources from low address to upper address.
+ * . change most int to u32.
+ *
+ * Further modified to include it as mips generic code, ppopov@mvista.com.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+
+#include <asm/pci_channel.h>
+
+#define	DEBUG
+#ifdef 	DEBUG
+#define	DBG(x...)	printk(x)
+#else
+#define	DBG(x...)	
+#endif
+
+/* These are used for config access before all the PCI probing has been done. */
+int early_read_config_byte(struct pci_channel *hose, int bus, int dev_fn, int where, u8 *val);
+int early_read_config_word(struct pci_channel *hose, int bus, int dev_fn, int where, u16 *val);
+int early_read_config_dword(struct pci_channel *hose, int bus, int dev_fn, int where, u32 *val);
+int early_write_config_byte(struct pci_channel *hose, int bus, int dev_fn, int where, u8 val);
+int early_write_config_word(struct pci_channel *hose, int bus, int dev_fn, int where, u16 val);
+int early_write_config_dword(struct pci_channel *hose, int bus, int dev_fn, int where, u32 val);
+
+static u32 pciauto_lower_iospc;
+static u32 pciauto_upper_iospc;
+
+static u32 pciauto_lower_memspc;
+static u32 pciauto_upper_memspc;
+
+void __init 
+pciauto_setup_bars(struct pci_channel *hose,
+		   int current_bus,
+		   int pci_devfn)
+{
+	u32 bar_response, bar_size, bar_value;
+	u32 bar, addr_mask, bar_nr = 0;
+	u32 * upper_limit;
+	u32 * lower_limit;
+	int found_mem64 = 0;
+
+	DBG("PCI Autoconfig: Found Bus %d, Device %d, Function %d\n",
+	    current_bus, PCI_SLOT(pci_devfn), PCI_FUNC(pci_devfn) );
+
+	for (bar = PCI_BASE_ADDRESS_0; bar <= PCI_BASE_ADDRESS_5; bar+=4) {
+		/* Tickle the BAR and get the response */
+		early_write_config_dword(hose,
+					 current_bus,
+					 pci_devfn,
+					 bar,
+					 0xffffffff);
+		early_read_config_dword(hose,
+					current_bus,
+					pci_devfn,
+					bar,
+					&bar_response);
+
+		/* If BAR is not implemented go to the next BAR */
+		if (!bar_response)
+			continue;
+
+		/* Check the BAR type and set our address mask */
+		if (bar_response & PCI_BASE_ADDRESS_SPACE) {
+			addr_mask = PCI_BASE_ADDRESS_IO_MASK;
+			upper_limit = &pciauto_upper_iospc;
+			lower_limit = &pciauto_lower_iospc;
+			DBG("PCI Autoconfig: BAR %d, I/O, ", bar_nr);
+		} else {
+			if ((bar_response & PCI_BASE_ADDRESS_MEM_TYPE_MASK) ==
+			    PCI_BASE_ADDRESS_MEM_TYPE_64)
+				found_mem64 = 1;
+
+			addr_mask = PCI_BASE_ADDRESS_MEM_MASK;		
+			upper_limit = &pciauto_upper_memspc;
+			lower_limit = &pciauto_lower_memspc;
+			DBG("PCI Autoconfig: BAR %d, Mem, ", bar_nr);
+		}
+
+		/* Calculate requested size */
+		bar_size = ~(bar_response & addr_mask) + 1;
+
+		/* Allocate a base address */
+		bar_value = ((*lower_limit - 1) & ~(bar_size - 1)) + bar_size;
+
+		/* Write it out and update our limit */
+		early_write_config_dword(hose, current_bus, pci_devfn,
+					 bar, bar_value);
+
+		*lower_limit = bar_value + bar_size;
+
+		/*
+		 * If we are a 64-bit decoder then increment to the
+		 * upper 32 bits of the bar and force it to locate
+		 * in the lower 4GB of memory.
+		 */ 
+		if (found_mem64) {
+			bar += 4;
+			early_write_config_dword(hose,
+						 current_bus,
+						 pci_devfn,
+						 bar,
+						 0x00000000);
+		}
+
+		bar_nr++;
+
+		DBG("size=0x%x, address=0x%x\n",
+		    bar_size, bar_value);
+	}
+
+}
+
+void __init
+pciauto_prescan_setup_bridge(struct pci_channel *hose,
+			     int current_bus,
+			     int pci_devfn,
+			     int sub_bus)
+{
+	int cmdstat;
+
+	/* Configure bus number registers */
+	early_write_config_byte(hose, current_bus, pci_devfn,
+	                        PCI_PRIMARY_BUS, current_bus);
+	early_write_config_byte(hose, current_bus, pci_devfn,
+				PCI_SECONDARY_BUS, sub_bus + 1);
+	early_write_config_byte(hose, current_bus, pci_devfn,
+				PCI_SUBORDINATE_BUS, 0xff);
+
+	/* Round memory allocator to 1MB boundary */
+	pciauto_upper_memspc &= ~(0x100000 - 1);
+
+	/* Round I/O allocator to 4KB boundary */
+	pciauto_upper_iospc &= ~(0x1000 - 1);
+
+	/* Set up memory and I/O filter limits, assume 32-bit I/O space */
+	early_write_config_word(hose, current_bus, pci_devfn, PCI_MEMORY_LIMIT,
+				((pciauto_upper_memspc - 1) & 0xfff00000) >> 16);
+	early_write_config_byte(hose, current_bus, pci_devfn, PCI_IO_LIMIT,
+				((pciauto_upper_iospc - 1) & 0x0000f000) >> 8);
+	early_write_config_word(hose, current_bus, pci_devfn,
+				PCI_IO_LIMIT_UPPER16,
+				((pciauto_upper_iospc - 1) & 0xffff0000) >> 16);
+			
+	/* We don't support prefetchable memory for now, so disable */
+	early_write_config_word(hose, current_bus, pci_devfn,
+				PCI_PREF_MEMORY_BASE, 0x1000);
+	early_write_config_word(hose, current_bus, pci_devfn,
+				PCI_PREF_MEMORY_LIMIT, 0x1000);
+
+	/* Enable memory and I/O accesses, enable bus master */
+	early_read_config_dword(hose, current_bus, pci_devfn, PCI_COMMAND,
+				&cmdstat);
+	early_write_config_dword(hose, current_bus, pci_devfn, PCI_COMMAND,
+				 cmdstat | PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
+				 PCI_COMMAND_MASTER);
+}
+
+void __init
+pciauto_postscan_setup_bridge(struct pci_channel *hose,
+			      int current_bus,
+			      int pci_devfn,
+			      int sub_bus)
+{
+	/* Configure bus number registers */
+	early_write_config_byte(hose, current_bus, pci_devfn,
+				PCI_SUBORDINATE_BUS, sub_bus);
+
+	/* Round memory allocator to 1MB boundary */
+	pciauto_upper_memspc &= ~(0x100000 - 1);
+	early_write_config_word(hose, current_bus, pci_devfn, PCI_MEMORY_BASE,
+				pciauto_upper_memspc >> 16);
+
+	/* Round I/O allocator to 4KB boundary */
+	pciauto_upper_iospc &= ~(0x1000 - 1);
+	early_write_config_byte(hose, current_bus, pci_devfn, PCI_IO_BASE,
+				(pciauto_upper_iospc & 0x0000f000) >> 8);
+	early_write_config_word(hose, current_bus, pci_devfn,
+				PCI_IO_BASE_UPPER16, pciauto_upper_iospc >> 16);
+}
+
+#define      PCIAUTO_IDE_MODE_MASK           0x05
+
+int __init
+pciauto_bus_scan(struct pci_channel *hose, int current_bus)
+{
+	int sub_bus;
+	u32 pci_devfn, pci_class, cmdstat, found_multi=0;
+	unsigned short vid;
+	unsigned char header_type;
+	int devfn_start = 0;
+	int devfn_stop = 0xff;
+
+	sub_bus = current_bus;
+	
+	if (hose->first_devfn)
+		devfn_start = hose->first_devfn;
+	if (hose->last_devfn)
+		devfn_stop = hose->last_devfn;
+	
+	for (pci_devfn=devfn_start; pci_devfn<devfn_stop; pci_devfn++) {
+
+		if (PCI_FUNC(pci_devfn) && !found_multi)
+			continue;
+
+		early_read_config_byte(hose, current_bus, pci_devfn,
+				       PCI_HEADER_TYPE, &header_type);
+
+		if (!PCI_FUNC(pci_devfn))
+			found_multi = header_type & 0x80;
+
+		early_read_config_word(hose, current_bus, pci_devfn,
+				       PCI_VENDOR_ID, &vid);
+
+		if (vid == 0xffff) continue;
+
+		early_read_config_dword(hose, current_bus, pci_devfn,
+					PCI_CLASS_REVISION, &pci_class);
+		if ((pci_class >> 16) == PCI_CLASS_BRIDGE_PCI) {
+			DBG("PCI Autoconfig: Found P2P bridge, device %d\n", PCI_SLOT(pci_devfn));
+			pciauto_prescan_setup_bridge(hose, current_bus,
+						     pci_devfn, sub_bus);
+			sub_bus = pciauto_bus_scan(hose, sub_bus+1);
+			pciauto_postscan_setup_bridge(hose, current_bus,
+						      pci_devfn, sub_bus);
+
+		} else if ((pci_class >> 16) == PCI_CLASS_STORAGE_IDE) {
+
+			unsigned char prg_iface;
+
+			early_read_config_byte(hose, current_bus, pci_devfn,
+					       PCI_CLASS_PROG, &prg_iface);
+			if (!(prg_iface & PCIAUTO_IDE_MODE_MASK)) {
+				DBG("PCI Autoconfig: Skipping legacy mode IDE controller\n");
+				continue;
+			}
+		}
+
+		/*
+		 * Found a peripheral, enable some standard
+		 * settings
+		 */
+		early_read_config_dword(hose, current_bus, pci_devfn,
+					PCI_COMMAND, &cmdstat);
+		early_write_config_dword(hose, current_bus, pci_devfn,
+					 PCI_COMMAND, cmdstat | PCI_COMMAND_IO |
+					 PCI_COMMAND_MEMORY |
+					 PCI_COMMAND_MASTER);
+		early_write_config_byte(hose, current_bus, pci_devfn,
+					PCI_LATENCY_TIMER, 0x80);
+
+		/* Allocate PCI I/O and/or memory space */
+		pciauto_setup_bars(hose, current_bus, pci_devfn);
+	}
+	return sub_bus;
+}
+
+int __init
+pciauto_assign_resources(int busno, struct pci_channel *hose)
+{
+	/* setup resource limits */
+	pciauto_lower_iospc = hose->io_resource->start;
+	pciauto_upper_iospc = hose->io_resource->end + 1;
+	pciauto_lower_memspc = hose->mem_resource->start;
+	pciauto_upper_memspc = hose->mem_resource->end + 1;
+
+	return pciauto_bus_scan(hose, busno);
+}
+
+
+/*
+ * These functions are used early on before PCI scanning is done
+ * and all of the pci_dev and pci_bus structures have been created.
+ */
+static struct pci_dev *fake_pci_dev(struct pci_channel *hose, int busnr,
+                                    int devfn)
+{
+	static struct pci_dev dev;
+	static struct pci_bus bus;
+
+	dev.bus = &bus;
+	dev.sysdata = hose;
+	dev.devfn = devfn;
+	bus.number = busnr;
+	bus.ops = hose->pci_ops;
+
+	return &dev;
+}
+
+#define EARLY_PCI_OP(rw, size, type)					\
+int early_##rw##_config_##size(struct pci_channel *hose, int bus,	\
+                               int devfn, int offset, type value)	\
+{									\
+	return pci_##rw##_config_##size(fake_pci_dev(hose, bus, devfn),	\
+	                                offset, value);			\
+}
+
+EARLY_PCI_OP(read, byte, u8 *)
+EARLY_PCI_OP(read, word, u16 *)
+EARLY_PCI_OP(read, dword, u32 *)
+EARLY_PCI_OP(write, byte, u8)
+EARLY_PCI_OP(write, word, u16)
+EARLY_PCI_OP(write, dword, u32)
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/proc.c linux/arch/mips/kernel/proc.c
--- v2.4.9/linux/arch/mips/kernel/proc.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/kernel/proc.c	Sun Sep  9 10:43:01 2001
@@ -1,8 +1,10 @@
 /*
  *  linux/arch/mips/kernel/proc.c
  *
- *  Copyright (C) 1995, 1996  Ralf Baechle
+ *  Copyright (C) 1995, 1996, 2001  Ralf Baechle
+ *  Copyright (C) 2001  MIPS Technologies, Inc.
  */
+#include <linux/config.h>
 #include <linux/delay.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -12,9 +14,9 @@
 #include <asm/processor.h>
 #include <asm/watch.h>
 
-unsigned long unaligned_instructions;
+extern unsigned long unaligned_instructions;
 unsigned int vced_count, vcei_count;
-#if !defined(CONFIG_CPU_HAS_LLSC)
+#ifndef CONFIG_CPU_HAS_LLSC
 unsigned long ll_ops, sc_ops;
 #endif
 
@@ -83,7 +85,7 @@
 	len += sprintf(buffer + len, "microsecond timers\t: %s\n",
 	               (mips_cpu.options & MIPS_CPU_COUNTER) ? "yes" : "no");
 	len += sprintf(buffer + len, "extra interrupt vector\t: %s\n",
-	               dedicated_iv_available ? "yes" : "no");
+	               (mips_cpu.options & MIPS_CPU_DIVEC) ? "yes" : "no");
 	len += sprintf(buffer + len, "hardware watchpoint\t: %s\n",
 	               watch_available ? "yes" : "no");
 
@@ -92,7 +94,7 @@
 	len += sprintf(buffer + len, fmt, 'D', vced_count);
 	len += sprintf(buffer + len, fmt, 'I', vcei_count);
 
-#if !defined(CONFIG_CPU_HAS_LLSC)
+#ifndef CONFIG_CPU_HAS_LLSC
 	len += sprintf(buffer + len, "ll emulations\t\t: %lu\n",
 		       ll_ops);
 	len += sprintf(buffer + len, "sc emulations\t\t: %lu\n",
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/process.c linux/arch/mips/kernel/process.c
--- v2.4.9/linux/arch/mips/kernel/process.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/kernel/process.c	Sun Sep  9 10:43:01 2001
@@ -83,13 +83,10 @@
 	childksp = (unsigned long)p + KERNEL_STACK_SIZE - 32;
 
 	if (last_task_used_math == current)
-#ifdef CONFIG_MIPS_FPU_EMULATOR
-		if (mips_cpu.options & MIPS_CPU_FPU)
-#endif
-	{
+		if (mips_cpu.options & MIPS_CPU_FPU) {
 			set_cp0_status(ST0_CU1);
 			save_fp(p);
-	}
+		}
 	/* set up new TSS. */
 	childregs = (struct pt_regs *) childksp - 1;
 	*childregs = *regs;
@@ -120,8 +117,8 @@
 	 * switching for most programs since they don't use the fpu.
 	 */
 	p->thread.cp0_status = read_32bit_cp0_register(CP0_STATUS) &
-                            ~(ST0_CU3|ST0_CU2|ST0_CU1|KU_MASK);
-	childregs->cp0_status &= ~(ST0_CU3|ST0_CU2|ST0_CU1);
+                            ~(ST0_CU2|ST0_CU1|KU_MASK);
+	childregs->cp0_status &= ~(ST0_CU2|ST0_CU1);
 
 	return 0;
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/ptrace.c linux/arch/mips/kernel/ptrace.c
--- v2.4.9/linux/arch/mips/kernel/ptrace.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips/kernel/ptrace.c	Sun Sep  9 10:43:01 2001
@@ -33,7 +33,7 @@
 {
 	struct task_struct *child;
 	int res;
-	extern void save_fp(void*);
+	extern void save_fp(struct task_struct *);
 
 	lock_kernel();
 #if 0
@@ -111,19 +111,31 @@
 			        unsigned long long *fregs
 					= (unsigned long long *)
 					    &child->thread.fpu.hard.fp_regs[0];
-#ifdef CONFIG_MIPS_FPU_EMULATOR
-			    if(!(mips_cpu.options & MIPS_CPU_FPU)) {
-				    fregs = (unsigned long long *)
-					&child->thread.fpu.soft.regs[0];
-			    } else 
+			 	if(!(mips_cpu.options & MIPS_CPU_FPU)) {
+					fregs = (unsigned long long *)
+						child->thread.fpu.soft.regs;
+				} else 
+					if (last_task_used_math == child) {
+						enable_cp1();
+						save_fp(child);
+						disable_cp1();
+						last_task_used_math = NULL;
+						regs->cp0_status &= ~ST0_CU1;
+					}
+				/*
+				 * The odd registers are actually the high
+				 * order bits of the values stored in the even
+				 * registers - unless we're using r2k_switch.S.
+				 */
+#ifdef CONFIG_CPU_R3000
+				if (mips_cpu.options & MIPS_CPU_FPU)
+					tmp = *(unsigned long *)(fregs + addr);
+				else
 #endif
-				if (last_task_used_math == child) {
-					enable_cp1();
-					save_fp(child);
-					disable_cp1();
-					last_task_used_math = NULL;
-				}
-				tmp = (unsigned long) fregs[(addr - 32)];
+				if (addr & 1)
+					tmp = (unsigned long) (fregs[((addr & ~1) - 32)] >> 32);
+				else
+					tmp = (unsigned long) (fregs[(addr - 32)] & 0xffffffff);
 			} else {
 				tmp = -1;	/* FP not yet used  */
 			}
@@ -144,12 +156,10 @@
 			tmp = regs->lo;
 			break;
 		case FPC_CSR:
-#ifdef CONFIG_MIPS_FPU_EMULATOR
-			if(!(mips_cpu.options & MIPS_CPU_FPU))
+			if (!(mips_cpu.options & MIPS_CPU_FPU))
 				tmp = child->thread.fpu.soft.sr;
 			else
-#endif
-			tmp = child->thread.fpu.hard.control;
+				tmp = child->thread.fpu.hard.control;
 			break;
 		case FPC_EIR: {	/* implementation / version register */
 			unsigned int flags;
@@ -192,19 +202,17 @@
 			unsigned long long *fregs;
 			fregs = (unsigned long long *)&child->thread.fpu.hard.fp_regs[0];
 			if (child->used_math) {
-				if (last_task_used_math == child)
-#ifdef CONFIG_MIPS_FPU_EMULATOR
-				    if(!(mips_cpu.options & MIPS_CPU_FPU)) {
-					fregs = (unsigned long long *)
-					    &child->thread.fpu.soft.regs[0];
-				    } else
-#endif
-				{
-					enable_cp1();
-					save_fp(child);
-					disable_cp1();
-					last_task_used_math = NULL;
-					regs->cp0_status &= ~ST0_CU1;
+				if (last_task_used_math == child) {
+					if(!(mips_cpu.options & MIPS_CPU_FPU)) {
+						fregs = (unsigned long long *)
+						child->thread.fpu.soft.regs;
+					} else {
+						enable_cp1();
+						save_fp(child);
+						disable_cp1();
+						last_task_used_math = NULL;
+						regs->cp0_status &= ~ST0_CU1;
+					}
 				}
 			} else {
 				/* FP not yet used  */
@@ -212,7 +220,23 @@
 				       sizeof(child->thread.fpu.hard));
 				child->thread.fpu.hard.control = 0;
 			}
-			fregs[addr - FPR_BASE] = data;
+			/*
+			 * The odd registers are actually the high order bits
+			 * of the values stored in the even registers - unless
+			 * we're using r2k_switch.S.
+			 */
+#ifdef CONFIG_CPU_R3000
+			if (mips_cpu.options & MIPS_CPU_FPU)
+				*(unsigned long *)(fregs + addr) = data;
+			else
+#endif
+			if (addr & 1) {
+				fregs[(addr & ~1) - FPR_BASE] &= 0xffffffff;
+				fregs[(addr & ~1) - FPR_BASE] |= ((unsigned long long) data) << 32;
+			} else {
+				fregs[addr - FPR_BASE] &= ~0xffffffffLL;
+				fregs[addr - FPR_BASE] |= data;
+			}
 			break;
 		}
 		case PC:
@@ -225,12 +249,10 @@
 			regs->lo = data;
 			break;
 		case FPC_CSR:
-#ifdef CONFIG_MIPS_FPU_EMULATOR
-			if(!(mips_cpu.options & MIPS_CPU_FPU)) 
+			if (!(mips_cpu.options & MIPS_CPU_FPU)) 
 				child->thread.fpu.soft.sr = data;
 			else
-#endif
-			child->thread.fpu.hard.control = data;
+				child->thread.fpu.hard.control = data;
 			break;
 		default:
 			/* The rest are not allowed. */
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/r2300_switch.S linux/arch/mips/kernel/r2300_switch.S
--- v2.4.9/linux/arch/mips/kernel/r2300_switch.S	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/kernel/r2300_switch.S	Sun Sep  9 10:43:01 2001
@@ -1,5 +1,4 @@
-/* $Id: r2300_switch.S,v 1.8 1999/08/18 23:37:44 ralf Exp $
- *
+/*
  * r2300_switch.S: R2300 specific task switching code.
  *
  * Copyright (C) 1994, 1995, 1996, 1999 by Ralf Baechle
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/r4k_switch.S linux/arch/mips/kernel/r4k_switch.S
--- v2.4.9/linux/arch/mips/kernel/r4k_switch.S	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/kernel/r4k_switch.S	Sun Sep  9 10:43:01 2001
@@ -7,15 +7,10 @@
  * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
  * Copyright (C) 1994, 1995, 1996, by Andreas Busse
  * Copyright (C) 1999 Silicon Graphics, Inc.
+ * Copyright (C) 2000 MIPS Technologies, Inc.
+ *    written by Carsten Langgaard, carstenl@mips.com
  */
-/**************************************************************************
- *  13 Nov, 2000.
- *  Made support for MIPS32 CPUs and restoring of fp registers.
- *
- *  Carsten Langgaard, carstenl@mips.com
- *  Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
- *************************************************************************/
-	
+#include <linux/config.h>
 #include <asm/asm.h>
 #include <asm/bootinfo.h>
 #include <asm/cachectl.h>
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/reset.c linux/arch/mips/kernel/reset.c
--- v2.4.9/linux/arch/mips/kernel/reset.c	Thu Jun 26 12:33:37 1997
+++ linux/arch/mips/kernel/reset.c	Sun Sep  9 10:43:01 2001
@@ -1,7 +1,10 @@
 /*
- *  linux/arch/mips/sni/process.c
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
  *
- *  Reset the machine.
+ * Copyright (C) 2001 by Ralf Baechle
+ * Copyright (C) 2001 MIPS Technologies, Inc.
  */
 #include <linux/kernel.h>
 #include <linux/types.h>
@@ -13,6 +16,9 @@
  * So handle all using function pointers to machine specific
  * functions.
  */
+void (*_machine_restart)(char *command);
+void (*_machine_halt)(void);
+void (*_machine_power_off)(void);
 
 void machine_restart(char *command)
 {
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/scall_o32.S linux/arch/mips/kernel/scall_o32.S
--- v2.4.9/linux/arch/mips/kernel/scall_o32.S	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/kernel/scall_o32.S	Sun Sep  9 10:43:01 2001
@@ -65,36 +65,32 @@
 1:	sw	v0, PT_R2(sp)		# result
 
 EXPORT(o32_ret_from_sys_call)
-	la	t1, irq_stat		# softirq_active
-#ifdef CONFIG_SMP
-	lw	t0, TASK_PROCESSOR($28)
-        sll	t0, t0, 5
-	addu	t1, t0
-#endif
-	lw	t0, 0(t1)		# softirq_active
-	lw	t1, 4(t1)		# softirq_mask.  unused delay slot
-	and	t0, t1
-	bnez	t0, o32_handle_softirq
+	mfc0	t0, CP0_STATUS		# need_resched and signals atomic test
+	ori	t0, t0, 1
+	xori	t0, t0, 1
+	mtc0	t0, CP0_STATUS
 
-9:	lw	t0,PT_STATUS(sp)	# returning to kernel mode?
-	andi	t1, t0, KU_USER
 	lw	t2, TASK_NEED_RESCHED($28)
-	beqz	t1, o32_return		# -> yes
 	bnez	t2, o32_reschedule
 	lw	v0, TASK_SIGPENDING($28)
+	bnez	v0, signal_return
+restore_all:
+	RESTORE_SOME
+	RESTORE_SP_AND_RET
+
+/* Put this behind restore_all for the sake of the branch prediction.  */
+signal_return:
+	.type	signal_return, @function
+
+	mfc0	t0, CP0_STATUS
+	ori	t0, t0, 1
+	mtc0	t0, CP0_STATUS
+
 	move	a0, zero
-	beqz	v0, o32_return
 	move	a1, sp
-	SAVE_STATIC
 	jal	do_signal
+	b	restore_all
 
-o32_return:
-	RESTORE_SOME
-	RESTORE_SP_AND_RET
-
-o32_handle_softirq:
-	jal	do_softirq
-	b	9b
 o32_reschedule:
 	SAVE_STATIC
 	jal	schedule
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/setup.c linux/arch/mips/kernel/setup.c
--- v2.4.9/linux/arch/mips/kernel/setup.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/kernel/setup.c	Sun Sep  9 10:43:01 2001
@@ -191,6 +191,12 @@
 				           MIPS_CPU_WATCH | MIPS_CPU_VCE;
 			mips_cpu.tlbsize = 48;
 			break;
+                case PRID_IMP_VR41XX:
+                        mips_cpu.cputype = CPU_VR41XX;
+                        mips_cpu.isa_level = MIPS_CPU_ISA_III;
+                        mips_cpu.options = R4K_OPTS;
+                        mips_cpu.tlbsize = 32;
+                        break;
 		case PRID_IMP_R4600:
 			mips_cpu.cputype = CPU_R4600;
 			mips_cpu.isa_level = MIPS_CPU_ISA_III;
@@ -282,7 +288,7 @@
 			break;
 		case PRID_IMP_R10000:
 			mips_cpu.cputype = CPU_R10000;
-			mips_cpu.cputype = MIPS_CPU_ISA_IV;
+			mips_cpu.isa_level = MIPS_CPU_ISA_IV;
 			mips_cpu.options = MIPS_CPU_TLB | MIPS_CPU_4KEX | 
 				           MIPS_CPU_FPU | MIPS_CPU_32FPR | 
 				           MIPS_CPU_COUNTER | MIPS_CPU_WATCH;
@@ -719,8 +725,10 @@
 #ifdef CONFIG_BLK_DEV_INITRD
 	/* Board specific code should have set up initrd_start and initrd_end */
 	ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);
-	initrd_start = (unsigned long)&__rd_start;
-	initrd_end = (unsigned long)&__rd_end;
+	if( __rd_start != __rd_end ) {
+		initrd_start = (unsigned long)&__rd_start;
+		initrd_end = (unsigned long)&__rd_end;
+	}
 	initrd_below_start_ok = 1;
 	if (initrd_start) {
 		unsigned long initrd_size = ((unsigned char *)initrd_end) - ((unsigned char *)initrd_start); 
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/signal.c linux/arch/mips/kernel/signal.c
--- v2.4.9/linux/arch/mips/kernel/signal.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/kernel/signal.c	Sun Sep  9 10:43:01 2001
@@ -464,10 +464,10 @@
 		/*
 		 * Set up the return code ...
 		 *
-		 *         li      v0, __NR_sigreturn
+		 *         li      v0, __NR_rt_sigreturn
 		 *         syscall
 		 */
-		err |= __put_user(0x24020000 + __NR_sigreturn,
+		err |= __put_user(0x24020000 + __NR_rt_sigreturn,
 		                  frame->rs_code + 0);
 		err |= __put_user(0x0000000c                 ,
 		                  frame->rs_code + 1);
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/softfp.S linux/arch/mips/kernel/softfp.S
--- v2.4.9/linux/arch/mips/kernel/softfp.S	Sun Jul  9 22:18:15 2000
+++ linux/arch/mips/kernel/softfp.S	Wed Dec 31 16:00:00 1969
@@ -1,666 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1998, 2000 by Ralf Baechle
- *
- * For now it's just a crude hack good enough to run certain fp programs like
- * Mozilla.
- * XXX: Handle MIPS II/III/IV/V enhancements, exceptions, ...
- */
-#include <asm/regdef.h>
-#include <asm/asm.h>
-
-#ifndef __KERNEL__
-#define printk printf
-#endif
-
-#define LOCK_KERNEL
-#define UNLOCK_KERNEL
-
-/*
- * This duplicates definitions from <linux/kernel.h>.
- */
-#define KERN_EMERG      "<0>"   /* system is unusable                   */
-#define KERN_ALERT      "<1>"   /* action must be taken immediately     */
-#define KERN_CRIT       "<2>"   /* critical conditions                  */
-#define KERN_ERR        "<3>"   /* error conditions                     */
-#define KERN_WARNING    "<4>"   /* warning conditions                   */
-#define KERN_NOTICE     "<5>"   /* normal but significant condition     */
-#define KERN_INFO       "<6>"   /* informational                        */
-#define KERN_DEBUG      "<7>"   /* debug-level messages                 */
-
-/*
- * This duplicates definitions from <asm/signal.h>
- */
-#define SIGILL           4      /* Illegal instruction (ANSI).  */
-
-/*
- * Definitions about the instruction format
- */
-#define fd_shift	6
-#define fr_shift	21
-#define fs_shift	11
-#define ft_shift	16
-
-/*
- * NaNs as use by the MIPS architecture
- */
-#define S_QNaN		0x7fbfffff
-#define D_QNaN		0x7ff7ffffffffffff
-#define W_QNaN		0x7fffffff
-#define L_QNaN		0x7fffffffffffffff
-
-/*
- * Checking for NaNs
- */
-#define S_is_QNaN(reg,res)						\
-	sll	res, reg, S_F_size - S_F_bits
-#define D_is_QNaN(reg1,reg2,res)					\
-	sll	res, reg1, (D_F_size - 32) - (D_F_bits - 32);		\
-	or	res, reg2
-
-/*
- * Checking for Denorms
- */
-#define S_is_Denorm(reg,res)						\
-	li	res, 1 << (S_F_bits - 1);				\
-	and	reg, res
-
-/*
- * Some constants that define the properties of single precission numbers.
- */
-#define S_M_prec	24
-#define S_E_max		127
-#define S_E_min		-126
-#define S_E_bias	127
-#define S_E_bits	8
-#define S_F_bits	23
-#define S_F_size	32
-
-/* Set temp0, if exponent of reg is S_E_max + 1.  */
-#define S_is_E_max(reg,temp0,temp1)					\
-	li	temp0, (S_E_max + 1 + S_E_bias) << S_F_bits;		\
-	and	temp1, temp0, reg;					\
-	seq	temp0, temp1			/* temp0 != 0 if NaN */
-
-/* Clear temp0, if exponent of reg is S_E_min - 1.  */
-#define S_is_E_min(reg,temp0)						\
-	li	temp0, (S_E_min - 1 + S_E_bias) << S_F_bits;		\
-	and	temp0, reg	/* temp0 == 0 if denorm or zero */
-
-/* Set temp0 if reg is a NaN assuming S_is_E_max is true  */
-#define S_get_F(reg,temp0)						\
-	li	temp0, (1 << S_F_bits) - 1;				\
-	and	temp0, reg			/* temp0 != 0 if NaN */
-
-/* Set res if fraction of reg is != 0.  */
-#define S_is_Inf(reg,res)						\
-	li	res, (1 << S_F_bits) - 1;				\
-	and	res, reg			/* temp0 == 0 if Inf */
-
-
-/*
- * Some constants that define the properties of double precission numbers.
- */
-#define D_M_prec	53
-#define D_E_max		1023
-#define D_E_min		-1022
-#define D_E_bias	1023
-#define D_E_bits	8
-#define D_F_bits	52
-#define D_F_size	64
-
-/* Set temp0, if exponent of reg1/reg2 is D_E_max.  */
-#define D_is_E_max(reg1,reg2,temp0,temp1)				\
-	li	temp0, (D_E_max + 1 + D_E_bias) << (D_F_bits - 32);	\
-	and	temp1, temp0, reg1;					\
-	seq	temp0, temp1			/* temp0 != 0 if NaN */
-
-/* Clear temp0, if exponent of reg is D_E_min.  */
-#define D_is_E_min(reg1,reg2,res)					\
-	li	res, (D_E_min + 1 + D_E_bias) << (D_F_bits - 32);	\
-	and	res, reg1	/* temp0 == 0 if NaN or zero */
-
-/* Set res if reg is a NaN assuming S_is_E_max is true  */
-#define D_get_F(reg1,reg2,res)						\
-	li	res, (1 << (D_F_bits - 32)) - 1;			\
-	and	res, reg1			/* temp0 != 0 if NaN */
-
-/* Set temp0 if reg1/reg2 is a NaN  */
-#define D_is_NAN(reg1,reg2,temp0,temp1)					\
-	li	temp0, (1 << (D_F_bits - 32) - 1;			\
-	and	temp0, reg1;						\
-	or	temp0, reg2;						\
-	sne	temp0, zero, temp0		/* temp0 != 0 if NaN */
-
-/* Set res if fraction of reg1/reg2 is != 0.  */
-#define D_is_Inf(reg1,reg2,res)						\
-	li	res, (1 << (D_F_bits - 32)) - 1;			\
-	and	res, reg1;						\
-	or	res, reg2			/* temp0 == 0 if Inf */
-
-/* Complain about yet unhandled instruction.  */
-#define BITCH(insn)							\
-insn:	LOCK_KERNEL;							\
-	la	a1, 8f;							\
-	TEXT(#insn);							\
-	la	a0, nosim;						\
-	UNLOCK_KERNEL;							\
-	j	done
-
-	.data
-nosim: .asciz	KERN_DEBUG "Don't know how to simulate %s instruction\n"
-	.previous
-
-/*
- * When we come here, we've saved some of the integer registers and
- * reenabled interrupts.
- */
-LEAF(simfp)
-	.set	noreorder
-	.cpload	$25
-	.set	reorder
-
-	subu	sp, 16
-	.cprestore 20
-	sw	ra, 16(sp)
-
-	/* For now we assume that we get the opcode to simulate passed in as
-	   an argument.  */
-	move	t0, a0
-
-	/*
-	 * First table lookup using insn[5:0]
-	 */
-	la	t1, lowtab
-	andi	t2, t0, 0x3f
-	sll	t2, t2, 2
-	addu	t1, t2
-	lw	t1, (t1)
-	jr	t1
-	END(simfp)
-
-/*
- * We only decode the lower 3 of the 5 bit in the fmt field.  That way we
- * can keep the jump table significantly shorter.
- */
-#define FMT_switch(insn,opc,temp0,temp1)				\
-insn:	srl	temp0, opc, 19;						\
-	andi	temp0, 0x1c;						\
-	la	temp1, insn##.tab;					\
-	addu	temp0, temp1;						\
-	lw	temp0, (temp0);						\
-	jr	temp0;							\
-									\
-	.data;								\
-insn##.tab:								\
-	.word	insn##.s, insn##.d, unimp, unimp;			\
-	.word	insn##.w, insn##.l, unimp, unimp;			\
-	.previous
-
-	BITCH(add)
-	BITCH(sub)
-	BITCH(mul)
-	BITCH(div)
-	BITCH(sqrt)
-	BITCH(abs)
-	BITCH(mov)
-	BITCH(neg)
-	BITCH(round.l)
-	BITCH(trunc.l)
-	BITCH(ceil.l)
-	BITCH(floor.l)
-	BITCH(round.w)
-	BITCH(trunc.w)
-	BITCH(ceil.w)
-	BITCH(floor.w)
-	BITCH(cvt.s)
-	BITCH(cvt.d)
-
-/* ------------------------------------------------------------------------ */
-
-FMT_switch(cvt.w,t0,t1,t2)
-
-/* Convert a single fp to a fixed point integer.  */
-cvt.w.s:
-	srl	t1, t0, fs_shift	# Get source register
-	andi	t1, 31
-	jal	s_get_fpreg
-
-	S_is_E_max(t1,t2,t3)
-	beqz	t2, 3f
-	/* Might be a NaN or Inf.  */
-	S_get_F(t1,t2)
-	beqz	t2, 2f
-
-	/* It's a NaN.  IEEE says undefined.  */
-	/* Is it a QNaN?  Then the result is a QNaN as well.  */
-	S_is_QNaN(t1,t2)
-	bltz	t2, 1f
-
-	/* XXX Ok, it's a SNaN.  Signal invalid exception, if enabled.
-	   For now we don't signal and supply a QNaN for result.  */
-
-1:	li	t2, W_QNaN
-	srl	t1, t0, fd_shift	# Put result register
-	andi	t1, 31
-	jal	s_put_fpreg
-	j	done
-2:
-
-	S_is_Inf(t1,t2)
-	bnez	t2, 2f
-
-	/* It's +/- Inf.  Set register to +/- max. integer.  */
-	/* XXX Send invalid operation exception instead, if enabled.  */
-	srl	t1, t1, 31		# Extract sign bit
-	li	t2, 0x7fffffff
-	addu	t2, t1
-
-	srl	t1, t0, fd_shift	# Put result register
-	andi	t1, 31
-	jal	s_put_fpreg
-	j	done
-2:
-3:	
-
-	/* But then it might be a denorm or zero?  */
-	S_is_E_min(t1,t2)
-	bnez	t2, 2f
-
-	/* Ok, it's a denorm or zero.  */
-	S_get_F(t1,t2)
-	beqz	t2, 1f
-
-	/* It's a denorm.  */
-	/* XXX Should be signaling inexact exception, if enabled.  */
-	/* Fall through.  */
-1:
-	/* Yes, it is a denorm or zero.  Supply a zero as result.  */
-	move	t2, zero
-	srl	t1, t0, fd_shift	# Put result register
-	andi	t1, 31
-	jal	s_put_fpreg
-	j	done
-2:
-
-	/* XXX Ok, it's a normal number.  We don't handle that case yet.
-	   If we have fp hardware this case is unreached.  Add this for
-	   full fp simulation.  */
-
-	/* Done, return.  */
-	lw	ra, 16(sp)
-	addu	sp, 16
-	jr	ra
-
-/* Convert a double fp to a fixed point integer.  */
-cvt.w.d:
-	srl	t1, t0, fs_shift	# Get source register
-	andi	t1, 31
-	jal	d_get_fpreg
-
-	D_is_E_max(t1,t2,t3,t4)
-	beqz	t3, 3f
-
-	/* Might be a NaN or Inf.  */
-	D_get_F(t1,t2,t3)
-	or	t3, t2
-	beqz	t3, 2f
-
-	/* It's a NaN.  IEEE says undefined.  */
-	/* Is it a QNaN?  Then the result is a QNaN as well.  */
-	D_is_QNaN(t1,t2,t3)
-	bltz	t3, 1f
-
-	/* XXX Ok, it's a SNaN.  Signal invalid exception, if enabled.
-	   For now we don't signal and supply a QNaN for result.  */
-
-1:	li	t2, W_QNaN
-	srl	t1, t0, fd_shift	# Put result register
-	andi	t1, 31
-	jal	s_put_fpreg
-	j	done
-2:
-
-	D_is_Inf(t1,t2,t3)
-	bnez	t3, 2f
-
-	/* It's +/- Inf.  Set register to +/- max. integer.  */
-	/* XXX Send invalid operation exception instead, if enabled.  */
-	srl	t1, t1, 31		# Extract sign bit
-	li	t2, 0x7fffffff
-	addu	t2, t1
-
-	srl	t1, t0, fd_shift	# Put result register
-	andi	t1, 31
-	jal	s_put_fpreg
-	j	done
-2:
-3:	
-
-	/* But then it might be a denorm or zero?  */
-	D_is_E_min(t1,t2,t3)
-	bnez	t3, 2f
-
-	/* Ok, it's a denorm or zero.  */
-	D_get_F(t1,t2,t3)
-	or	t3, t2
-	beqz	t3, 1f
-
-	/* It's a denorm.  */
-	/* XXX Should be signaling inexact exception, if enabled.  */
-	/* Fall through.  */
-1:
-	/* Yes, it is a denorm or zero.  Supply a zero as result.  */
-	move	t2, zero
-	srl	t1, t0, fd_shift	# Put result register
-	andi	t1, 31
-	jal	s_put_fpreg
-	j	done
-2:
-
-	/* XXX Ok, it's a normal number.  We don't handle that case yet.
-	   If we have fp hardware this case is only reached if the value
-	   of the source register exceeds the range which is representable
-	   in a single precission register.  For now we kludge by returning
-	   +/- maxint and don't signal overflow. */
-
-	srl	t1, t1, 31		# Extract sign bit
-	li	t2, 0x7fffffff
-	addu	t2, t1
-
-	srl	t1, t0, fd_shift	# Put result register
-	andi	t1, 31
-	jal	s_put_fpreg
-
-	/* Done, return.  */
-	lw	ra, 16(sp)
-	addu	sp, 16
-	jr	ra
-
-cvt.w.w = unimp				# undefined result
-cvt.w.l = unimp				# undefined result
-
-/* MIPS III extension, no need to handle for 32bit OS.  */
-cvt.l = unimp
-
-/* ------------------------------------------------------------------------ */
-
-	BITCH(c.f)
-	BITCH(c.un)
-	BITCH(c.eq)
-	BITCH(c.ueq)
-	BITCH(c.olt)
-	BITCH(c.ult)
-	BITCH(c.ole)
-	BITCH(c.ule)
-	BITCH(c.sf)
-	BITCH(c.ngle)
-	BITCH(c.seq)
-	BITCH(c.ngl)
-	BITCH(c.lt)
-	BITCH(c.nge)
-	BITCH(c.le)
-	BITCH(c.ngt)
-
-/* Get the single precission register which's number is in t1.  */
-s_get_fpreg:
-	.set	noat
-	sll	AT, t1, 2
-	sll	t1, 3
-	addu	t1, AT
-	la	AT, 1f
-	addu	AT, t1
-	jr	AT
-	.set	at
-
-1:	mfc1	t1, $0
-	jr	ra
-	mfc1	t1, $1
-	jr	ra
-	mfc1	t1, $2
-	jr	ra
-	mfc1	t1, $3
-	jr	ra
-	mfc1	t1, $4
-	jr	ra
-	mfc1	t1, $5
-	jr	ra
-	mfc1	t1, $6
-	jr	ra
-	mfc1	t1, $7
-	jr	ra
-	mfc1	t1, $8
-	jr	ra
-	mfc1	t1, $9
-	jr	ra
-	mfc1	t1, $10
-	jr	ra
-	mfc1	t1, $11
-	jr	ra
-	mfc1	t1, $12
-	jr	ra
-	mfc1	t1, $13
-	jr	ra
-	mfc1	t1, $14
-	jr	ra
-	mfc1	t1, $15
-	jr	ra
-	mfc1	t1, $16
-	jr	ra
-	mfc1	t1, $17
-	jr	ra
-	mfc1	t1, $18
-	jr	ra
-	mfc1	t1, $19
-	jr	ra
-	mfc1	t1, $20
-	jr	ra
-	mfc1	t1, $21
-	jr	ra
-	mfc1	t1, $22
-	jr	ra
-	mfc1	t1, $23
-	jr	ra
-	mfc1	t1, $24
-	jr	ra
-	mfc1	t1, $25
-	jr	ra
-	mfc1	t1, $26
-	jr	ra
-	mfc1	t1, $27
-	jr	ra
-	mfc1	t1, $28
-	jr	ra
-	mfc1	t1, $29
-	jr	ra
-	mfc1	t1, $30
-	jr	ra
-	mfc1	t1, $31
-	jr	ra
-
-/*
- * Put the value in t2 into the single precission register which's number
- * is in t1.
- */
-s_put_fpreg:
-	.set	noat
-	sll	AT, t1, 2
-	sll	t1, 3
-	addu	t1, AT
-	la	AT, 1f
-	addu	AT, t1
-	jr	AT
-	.set	at
-	
-1:	mtc1	t2, $0
-	jr	ra
-	mtc1	t2, $1
-	jr	ra
-	mtc1	t2, $2
-	jr	ra
-	mtc1	t2, $3
-	jr	ra
-	mtc1	t2, $4
-	jr	ra
-	mtc1	t2, $5
-	jr	ra
-	mtc1	t2, $6
-	jr	ra
-	mtc1	t2, $7
-	jr	ra
-	mtc1	t2, $8
-	jr	ra
-	mtc1	t2, $9
-	jr	ra
-	mtc1	t2, $10
-	jr	ra
-	mtc1	t2, $11
-	jr	ra
-	mtc1	t2, $12
-	jr	ra
-	mtc1	t2, $13
-	jr	ra
-	mtc1	t2, $14
-	jr	ra
-	mtc1	t2, $15
-	jr	ra
-	mtc1	t2, $16
-	jr	ra
-	mtc1	t2, $17
-	jr	ra
-	mtc1	t2, $18
-	jr	ra
-	mtc1	t2, $19
-	jr	ra
-	mtc1	t2, $20
-	jr	ra
-	mtc1	t2, $21
-	jr	ra
-	mtc1	t2, $22
-	jr	ra
-	mtc1	t2, $23
-	jr	ra
-	mtc1	t2, $24
-	jr	ra
-	mtc1	t2, $25
-	jr	ra
-	mtc1	t2, $26
-	jr	ra
-	mtc1	t2, $27
-	jr	ra
-	mtc1	t2, $28
-	jr	ra
-	mtc1	t2, $29
-	jr	ra
-	mtc1	t2, $30
-	jr	ra
-	mtc1	t2, $31
-	jr	ra
-
-/* Get the double precission register which's number is in t1 into t1/t2.  */
-d_get_fpreg:
-	.set	noat
-	sll	t1, 3
-	la	AT, 1f
-	addu	AT, t1
-	jr	AT
-	.set	at
-
-1:	mfc1	t1, $0
-	mfc1	t2, $1
-	jr	ra
-	mfc1	t1, $2
-	mfc1	t2, $3
-	jr	ra
-	mfc1	t1, $4
-	mfc1	t2, $5
-	jr	ra
-	mfc1	t1, $6
-	mfc1	t2, $7
-	jr	ra
-	mfc1	t1, $8
-	mfc1	t2, $9
-	jr	ra
-	mfc1	t1, $10
-	mfc1	t2, $11
-	jr	ra
-	mfc1	t1, $12
-	mfc1	t2, $13
-	jr	ra
-	mfc1	t1, $14
-	mfc1	t2, $15
-	jr	ra
-	mfc1	t1, $16
-	mfc1	t2, $17
-	jr	ra
-	mfc1	t1, $18
-	mfc1	t2, $19
-	jr	ra
-	mfc1	t1, $20
-	mfc1	t2, $21
-	jr	ra
-	mfc1	t1, $22
-	mfc1	t2, $23
-	jr	ra
-	mfc1	t1, $24
-	mfc1	t2, $25
-	jr	ra
-	mfc1	t1, $26
-	mfc1	t2, $27
-	jr	ra
-	mfc1	t1, $28
-	mfc1	t2, $29
-	jr	ra
-	mfc1	t1, $30
-	mfc1	t2, $31
-	jr	ra
-
-/*
- * Send an invalid operation exception.
- */
-invalid:
-	lw	ra, 16(sp)
-	addu	sp, 16
-	jr	ra
-
-/*
- * Done, just skip over the current instruction
- */
-done:
-	lw	ra, 16(sp)
-	addu	sp, 16
-	jr	ra
-
-unimp:
-	/* We've run into an yet unknown instruction.  This happens either
-	   on new, yet unsupported CPU types or when the faulting instruction
-	   is being executed for cache but has been overwritten in memory.  */
-	LOCK_KERNEL
-	move	a0, t0
-	PRINT(KERN_DEBUG "FP support: unknown fp op %08lx, ")
-	PRINT("please mail to ralf@gnu.org.\n")
-
-	li	a0, SIGILL			# Die, sucker ...
-	move	a1, $28
-	jal	force_sig
-	UNLOCK_KERNEL
-
-	lw	ra, 16(sp)
-	addu	sp, 16
-	jr	ra
-
-/*
- * Jump table for the lowest 6 bits of a cp1 instruction.
- */
-	.data
-lowtab:	.word	add,   sub,   mul,   div,   sqrt,  abs,   mov,   neg
-	.word	round.l,trunc.l,ceil.l,floor.l,round.w,trunc.w,ceil.w,floor.w
-	.word	unimp, unimp, unimp, unimp, unimp, unimp, unimp, unimp
-	.word	unimp, unimp, unimp, unimp, unimp, unimp, unimp, unimp
-	.word	cvt.s, cvt.d, unimp, unimp, cvt.w, cvt.l, unimp, unimp
-	.word	unimp, unimp, unimp, unimp, unimp, unimp, unimp, unimp
-	.word	c.f,   c.un,  c.eq,  c.ueq, c.olt, c.ult, c.ole, c.ule
-	.word	c.sf,  c.ngle,c.seq, c.ngl, c.lt,  c.nge, c.le, c.ngt
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/time.c linux/arch/mips/kernel/time.c
--- v2.4.9/linux/arch/mips/kernel/time.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/kernel/time.c	Sun Sep  9 10:43:01 2001
@@ -1,18 +1,15 @@
-/***********************************************************************
+/*
  * Copyright 2001 MontaVista Software Inc.
  * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
  *
- * arch/mips/kernel/time.c
- *     Common time service routines for MIPS machines.  See 
- *     Documents/MIPS/time.txt. 
+ * Common time service routines for MIPS machines. See 
+ * Documents/MIPS/README.txt. 
  *
  * 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 <linux/config.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
@@ -29,22 +26,11 @@
 #include <asm/cpu.h>
 #include <asm/time.h>
 #include <asm/hardirq.h>
-
-/* 
- * macro for catching spurious errors.  Eable to LL_DEBUG in kernel hacking
- * config menu.
- */
-#ifdef CONFIG_LL_DEBUG
-#define	MIPS_ASSERT(x)	if (!(x)) { panic("MIPS_ASSERT failed at %s:%d\n", __FILE__, __LINE__); }
-#define MIPS_DEBUG(x)  do { x; } while (0)
-#else
-#define MIPS_ASSERT(x)
-#define MIPS_DEBUG(x)
-#endif
+#include <asm/div64.h>
 
 /* This is for machines which generate the exact clock. */
 #define USECS_PER_JIFFY (1000000/HZ)
-#define USECS_PER_JIFFY_FRAC (0x100000000*1000000/HZ&0xffffffff)
+#define USECS_PER_JIFFY_FRAC ((1000000ULL << 32) / HZ & 0xffffffff)
 
 /*
  * forward reference
@@ -74,50 +60,50 @@
  */
 void do_gettimeofday(struct timeval *tv)
 {
-        unsigned long flags;
+	unsigned long flags;
+
+	read_lock_irqsave (&xtime_lock, flags);
+	*tv = xtime;
+	tv->tv_usec += do_gettimeoffset();
+
+	/*
+	 * xtime is atomically updated in timer_bh. jiffies - wall_jiffies
+	 * is nonzero if the timer bottom half hasnt executed yet.
+	 */
+	if (jiffies - wall_jiffies)
+		tv->tv_usec += USECS_PER_JIFFY;
 
-        read_lock_irqsave (&xtime_lock, flags);
-        *tv = xtime;
-        tv->tv_usec += do_gettimeoffset();
-
-        /*
-         * xtime is atomically updated in timer_bh. jiffies - wall_jiffies
-         * is nonzero if the timer bottom half hasnt executed yet.
-         */
-        if (jiffies - wall_jiffies)
-                tv->tv_usec += USECS_PER_JIFFY;
-
-        read_unlock_irqrestore (&xtime_lock, flags);
-
-        if (tv->tv_usec >= 1000000) {
-                tv->tv_usec -= 1000000;
-                tv->tv_sec++;
-        }
+	read_unlock_irqrestore (&xtime_lock, flags);
+
+	if (tv->tv_usec >= 1000000) {
+		tv->tv_usec -= 1000000;
+		tv->tv_sec++;
+	}
 }
 
 void do_settimeofday(struct timeval *tv)
 {
-        write_lock_irq (&xtime_lock);
+	write_lock_irq (&xtime_lock);
 
-        /* This is revolting. We need to set the xtime.tv_usec
-         * correctly. However, the value in this location is
-         * is value at the last tick.
-         * Discover what correction gettimeofday
-         * would have done, and then undo it!
-         */
-        tv->tv_usec -= do_gettimeoffset();
-
-        if (tv->tv_usec < 0) {
-                tv->tv_usec += 1000000;
-                tv->tv_sec--;
-        }
-        xtime = *tv;
-        time_adjust = 0;                /* stop active adjtime() */
-        time_status |= STA_UNSYNC;
-        time_maxerror = NTP_PHASE_LIMIT;
-        time_esterror = NTP_PHASE_LIMIT;
+	/* This is revolting. We need to set the xtime.tv_usec
+	 * correctly. However, the value in this location is
+	 * is value at the last tick.
+	 * Discover what correction gettimeofday
+	 * would have done, and then undo it!
+	 */
+	tv->tv_usec -= do_gettimeoffset();
 
-        write_unlock_irq (&xtime_lock);
+	if (tv->tv_usec < 0) {
+		tv->tv_usec += 1000000;
+		tv->tv_sec--;
+	}
+	xtime = *tv;
+	time_adjust = 0;			/* stop active adjtime() */
+	time_status |= STA_UNSYNC;
+	time_maxerror = NTP_PHASE_LIMIT;
+	time_esterror = NTP_PHASE_LIMIT;
+
+	write_unlock_irq (&xtime_lock);
 }
 
 
@@ -162,30 +148,26 @@
 	u32 count;
 	unsigned long res;
 
-	MIPS_ASSERT(mips_cpu.options & MIPS_CPU_COUNTER);
-	MIPS_ASSERT(mips_counter_frequency != 0);
-	MIPS_ASSERT(sll32_usecs_per_cycle != 0);
-
 	/* Get last timer tick in absolute kernel time */
-        count = read_32bit_cp0_register(CP0_COUNT);
+	count = read_32bit_cp0_register(CP0_COUNT);
 
-        /* .. relative to previous jiffy (32 bits is enough) */
-        count -= timerlo;
+	/* .. relative to previous jiffy (32 bits is enough) */
+	count -= timerlo;
 
-        __asm__("multu\t%1,%2\n\t"
-                "mfhi\t%0"
-                :"=r" (res)
-                :"r" (count),
-                 "r" (sll32_usecs_per_cycle));
-
-        /*
-         * Due to possible jiffies inconsistencies, we need to check
-         * the result so that we'll get a timer that is monotonic.
-         */
-        if (res >= USECS_PER_JIFFY)
-                res = USECS_PER_JIFFY-1;
+	__asm__("multu\t%1,%2\n\t"
+	        "mfhi\t%0"
+	        :"=r" (res)
+	        :"r" (count),
+	         "r" (sll32_usecs_per_cycle));
 
-        return res;
+	/*
+	 * Due to possible jiffies inconsistencies, we need to check
+	 * the result so that we'll get a timer that is monotonic.
+	 */
+	if (res >= USECS_PER_JIFFY)
+		res = USECS_PER_JIFFY-1;
+
+	return res;
 }
 
 /*
@@ -197,156 +179,107 @@
 /* Last jiffy when calibrate_divXX_gettimeoffset() was called. */
 static unsigned long last_jiffies = 0;
 
-/* 
- * copied from include/asm/div64.  
- * We do the copy instead of include the header file because we don't
- * want to reply on _MIPS_ISA value.
- */
-#define do_div64_32(res, high, low, base) ({ \
-        unsigned long __quot, __mod; \
-        unsigned long __cf, __tmp, __i; \
-        \
-        __asm__(".set   push\n\t" \
-                ".set   noat\n\t" \
-                ".set   noreorder\n\t" \
-                "b      1f\n\t" \
-                " li    %4,0x21\n" \
-                "0:\n\t" \
-                "sll    $1,%0,0x1\n\t" \
-                "srl    %3,%0,0x1f\n\t" \
-                "or     %0,$1,$2\n\t" \
-                "sll    %1,%1,0x1\n\t" \
-                "sll    %2,%2,0x1\n" \
-                "1:\n\t" \
-                "bnez   %3,2f\n\t" \
-                "sltu   $2,%0,%z5\n\t" \
-                "bnez   $2,3f\n\t" \
-                "2:\n\t" \
-                " addiu %4,%4,-1\n\t" \
-                "subu   %0,%0,%z5\n\t" \
-                "addiu  %2,%2,1\n" \
-                "3:\n\t" \
-                "bnez   %4,0b\n\t" \
-                " srl   $2,%1,0x1f\n\t" \
-                ".set   pop" \
-                : "=&r" (__mod), "=&r" (__tmp), "=&r" (__quot), "=&r" (__cf), \
-                  "=&r" (__i) \
-                : "Jr" (base), "0" (high), "1" (low), "2" (0), "3" (0) \
-                /* Aarrgh!  Ran out of gcc's limit on constraints... */ \
-                : "$1", "$2"); \
-        \
-        (res) = __quot; \
-        __mod; })
 
 /*
  * This is copied from dec/time.c:do_ioasic_gettimeoffset() by Mercij.
  */
 unsigned long calibrate_div32_gettimeoffset(void)
 {
-        u32 count;
-        unsigned long res, tmp;
-        unsigned long quotient;
-
-	MIPS_ASSERT(mips_cpu.options & MIPS_CPU_COUNTER);
-
-        tmp = jiffies;
-
-        quotient = cached_quotient;
-
-        if (last_jiffies != tmp) {
-                last_jiffies = tmp;
-                if (last_jiffies != 0) {
-                        unsigned long r0;
-                        do_div64_32(r0, timerhi, timerlo, tmp);
-                        do_div64_32(quotient, USECS_PER_JIFFY,
-                                    USECS_PER_JIFFY_FRAC, r0);
-                        cached_quotient = quotient;
-                }
-        }
-
-        /* Get last timer tick in absolute kernel time */
-        count = read_32bit_cp0_register(CP0_COUNT);
-
-        /* .. relative to previous jiffy (32 bits is enough) */
-        count -= timerlo;
-
-        __asm__("multu  %2,%3"
-                : "=l" (tmp), "=h" (res)
-                : "r" (count), "r" (quotient));
-
-        /*
-         * Due to possible jiffies inconsistencies, we need to check
-         * the result so that we'll get a timer that is monotonic.
-         */
-        if (res >= USECS_PER_JIFFY)
-                res = USECS_PER_JIFFY - 1;
+	u32 count;
+	unsigned long res, tmp;
+	unsigned long quotient;
+
+	tmp = jiffies;
+
+	quotient = cached_quotient;
+
+	if (last_jiffies != tmp) {
+		last_jiffies = tmp;
+		if (last_jiffies != 0) {
+			unsigned long r0;
+			do_div64_32(r0, timerhi, timerlo, tmp);
+			do_div64_32(quotient, USECS_PER_JIFFY,
+			            USECS_PER_JIFFY_FRAC, r0);
+			cached_quotient = quotient;
+		}
+	}
+
+	/* Get last timer tick in absolute kernel time */
+	count = read_32bit_cp0_register(CP0_COUNT);
+
+	/* .. relative to previous jiffy (32 bits is enough) */
+	count -= timerlo;
+
+	__asm__("multu  %2,%3"
+	        : "=l" (tmp), "=h" (res)
+	        : "r" (count), "r" (quotient));
+
+	/*
+	 * Due to possible jiffies inconsistencies, we need to check
+	 * the result so that we'll get a timer that is monotonic.
+	 */
+	if (res >= USECS_PER_JIFFY)
+		res = USECS_PER_JIFFY - 1;
 
-        return res;
+	return res;
 }
 
 unsigned long calibrate_div64_gettimeoffset(void)
 {
-        u32 count;
-        unsigned long res, tmp;
-        unsigned long quotient;
-
-
-	MIPS_ASSERT(mips_cpu.options & MIPS_CPU_COUNTER);
-	MIPS_ASSERT((mips_cpu.isa_level != MIPS_CPU_ISA_I) &&
-		    (mips_cpu.isa_level != MIPS_CPU_ISA_II) &&
-		    (mips_cpu.isa_level != MIPS_CPU_ISA_M32));
-
-
-        tmp = jiffies;
-
-        quotient = cached_quotient;
-
-        if (tmp && last_jiffies != tmp) {
-                last_jiffies = tmp;
-                __asm__(".set\tnoreorder\n\t"
-                        ".set\tnoat\n\t"
-                        ".set\tmips3\n\t"
-                        "lwu\t%0,%2\n\t"
-                        "dsll32\t$1,%1,0\n\t"
-                        "or\t$1,$1,%0\n\t"
-                        "ddivu\t$0,$1,%3\n\t"
-                        "mflo\t$1\n\t"
-                        "dsll32\t%0,%4,0\n\t"
-                        "nop\n\t"
-                        "ddivu\t$0,%0,$1\n\t"
-                        "mflo\t%0\n\t"
-                        ".set\tmips0\n\t"
-                        ".set\tat\n\t"
-                        ".set\treorder"
-                        :"=&r" (quotient)
-                        :"r" (timerhi),
-                         "m" (timerlo),
-                         "r" (tmp),
-                         "r" (USECS_PER_JIFFY)
-                        :"$1");
-                cached_quotient = quotient;
-        }
-
-        /* Get last timer tick in absolute kernel time */
-        count = read_32bit_cp0_register(CP0_COUNT);
-
-        /* .. relative to previous jiffy (32 bits is enough) */
-        count -= timerlo;
-
-        __asm__("multu\t%1,%2\n\t"
-                "mfhi\t%0"
-                :"=r" (res)
-                :"r" (count),
-                 "r" (quotient));
-
-        /*
-         * Due to possible jiffies inconsistencies, we need to check
-         * the result so that we'll get a timer that is monotonic.
-         */
-        if (res >= USECS_PER_JIFFY)
-                res = USECS_PER_JIFFY-1;
+	u32 count;
+	unsigned long res, tmp;
+	unsigned long quotient;
+
+	tmp = jiffies;
 
-        return res;
+	quotient = cached_quotient;
+
+	if (tmp && last_jiffies != tmp) {
+		last_jiffies = tmp;
+		__asm__(".set\tnoreorder\n\t"
+	        ".set\tnoat\n\t"
+	        ".set\tmips3\n\t"
+	        "lwu\t%0,%2\n\t"
+	        "dsll32\t$1,%1,0\n\t"
+	        "or\t$1,$1,%0\n\t"
+	        "ddivu\t$0,$1,%3\n\t"
+	        "mflo\t$1\n\t"
+	        "dsll32\t%0,%4,0\n\t"
+	        "nop\n\t"
+	        "ddivu\t$0,%0,$1\n\t"
+	        "mflo\t%0\n\t"
+	        ".set\tmips0\n\t"
+	        ".set\tat\n\t"
+	        ".set\treorder"
+	        :"=&r" (quotient)
+	        :"r" (timerhi),
+	         "m" (timerlo),
+	         "r" (tmp),
+	         "r" (USECS_PER_JIFFY)
+	        :"$1");
+	        cached_quotient = quotient;
+	}
+
+	/* Get last timer tick in absolute kernel time */
+	count = read_32bit_cp0_register(CP0_COUNT);
+
+	/* .. relative to previous jiffy (32 bits is enough) */
+	count -= timerlo;
+
+	__asm__("multu\t%1,%2\n\t"
+	        "mfhi\t%0"
+	        :"=r" (res)
+	        :"r" (count),
+	         "r" (quotient));
+
+	/*
+	 * Due to possible jiffies inconsistencies, we need to check
+	 * the result so that we'll get a timer that is monotonic.
+	 */
+	if (res >= USECS_PER_JIFFY)
+		res = USECS_PER_JIFFY-1;
+
+	return res;
 }
 
 
@@ -377,57 +310,56 @@
 
 	}
 
-        if(!user_mode(regs)) {
+	if(!user_mode(regs)) {
 		if (prof_buffer && current->pid) {
-                        extern int _stext;
-                        unsigned long pc = regs->cp0_epc;
+			extern int _stext;
+			unsigned long pc = regs->cp0_epc;
 
-                        pc -= (unsigned long) &_stext;
-                        pc >>= prof_shift;
-                        /*
-                         * Dont ignore out-of-bounds pc values silently,
-                         * put them into the last histogram slot, so if
-                         * present, they will show up as a sharp peak.
-                         */
-                        if (pc > prof_len-1)
-                                pc = prof_len-1;
-                        atomic_inc((atomic_t *)&prof_buffer[pc]);
-                }
-        }
+			pc -= (unsigned long) &_stext;
+			pc >>= prof_shift;
+			/*
+			 * Dont ignore out-of-bounds pc values silently,
+			 * put them into the last histogram slot, so if
+			 * present, they will show up as a sharp peak.
+			 */
+			if (pc > prof_len-1)
+			pc = prof_len-1;
+			atomic_inc((atomic_t *)&prof_buffer[pc]);
+		}
+	}
 
 	/*
 	 * call the generic timer interrupt handling
 	 */
-        do_timer(regs);
-
-        /*
-         * If we have an externally synchronized Linux clock, then update
-         * CMOS clock accordingly every ~11 minutes. rtc_set_time() has to be
-         * called as close as possible to 500 ms before the new second starts.
-         */
-        read_lock (&xtime_lock);
-        if ((time_status & STA_UNSYNC) == 0 &&
-            xtime.tv_sec > last_rtc_update + 660 &&
-            xtime.tv_usec >= 500000 - ((unsigned) tick) / 2 &&
-            xtime.tv_usec <= 500000 + ((unsigned) tick) / 2) {
+	do_timer(regs);
 
+	/*
+	 * If we have an externally synchronized Linux clock, then update
+	 * CMOS clock accordingly every ~11 minutes. rtc_set_time() has to be
+	 * called as close as possible to 500 ms before the new second starts.
+	 */
+	read_lock (&xtime_lock);
+	if ((time_status & STA_UNSYNC) == 0 &&
+	    xtime.tv_sec > last_rtc_update + 660 &&
+	    xtime.tv_usec >= 500000 - ((unsigned) tick) / 2 &&
+	    xtime.tv_usec <= 500000 + ((unsigned) tick) / 2) {
 		if (rtc_set_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 */
 		}
-        }
-        read_unlock (&xtime_lock);
+	}
+	read_unlock (&xtime_lock);
 
 	/*
 	 * If jiffies has overflowed in this timer_interrupt we must
 	 * update the timer[hi]/[lo] to make fast gettimeoffset funcs
 	 * quotient calc still valid. -arca
 	 */
-        if (!jiffies) {
-                timerhi = timerlo = 0;
-        }
+	if (!jiffies) {
+		timerhi = timerlo = 0;
+	}
 }
 
 asmlinkage void ll_timer_interrupt(int irq, struct pt_regs *regs)
@@ -442,9 +374,8 @@
 	
 	irq_exit(cpu, irq);
 
-	/* check for bottom half */
-        if (softirq_active(cpu)&softirq_mask(cpu))
-                do_softirq();
+	if (softirq_pending(cpu))
+		do_softirq();
 }
 
 
@@ -480,19 +411,14 @@
 
 void __init time_init(void)
 {
-	printk("New MIPS time_init() invoked.\n");
-
 	if (board_time_init)
 		board_time_init();
 
-	/* setup xtime */
-	write_lock_irq(&xtime_lock);
 	xtime.tv_sec = rtc_get_time();
 	xtime.tv_usec = 0;
-	write_unlock_irq(&xtime_lock);
 
 	/* choose appropriate gettimeoffset routine */
-	if ( ! (mips_cpu.options & MIPS_CPU_COUNTER) ) {
+	if (!(mips_cpu.options & MIPS_CPU_COUNTER)) {
 		/* no cpu counter - sorry */
 		do_gettimeoffset = null_gettimeoffset;
 	} else if (mips_counter_frequency != 0) {
@@ -519,11 +445,6 @@
 		sll32_usecs_per_cycle = mips_counter_frequency / 100000;
 		sll32_usecs_per_cycle = 0xffffffff / sll32_usecs_per_cycle;
 		sll32_usecs_per_cycle *= 10;
-
-		MIPS_DEBUG(printk("cycles_per_jiffy = %d\n", 
-				  cycles_per_jiffy));
-		MIPS_DEBUG(printk("sll32_usecs_per_cycle = %d \n",
-				  sll32_usecs_per_cycle));
 	}
 
 	/* 
@@ -537,6 +458,52 @@
 	 * to be NULL function so that we are sure the high-level code
 	 * is not invoked accidentally.
 	 */
-	MIPS_ASSERT(board_timer_setup != NULL);
 	board_timer_setup(&timer_irqaction);
+}
+
+#define FEBRUARY		2
+#define STARTOFTIME		1970
+#define SECDAY			86400L
+#define SECYR			(SECDAY * 365)
+#define leapyear(year)		((year) % 4 == 0)
+#define days_in_year(a)		(leapyear(a) ? 366 : 365)
+#define days_in_month(a)	(month_days[(a) - 1])
+
+static int month_days[12] = {
+	31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
+};
+
+void to_tm(unsigned long tim, struct rtc_time * tm)
+{
+	long hms, day;
+	int i;
+
+	day = tim / SECDAY;
+	hms = tim % SECDAY;
+
+	/* Hours, minutes, seconds are easy */
+	tm->tm_hour = hms / 3600;
+	tm->tm_min = (hms % 3600) / 60;
+	tm->tm_sec = (hms % 3600) % 60;
+
+	/* Number of years in days */
+	for (i = STARTOFTIME; day >= days_in_year(i); i++)
+	day -= days_in_year(i);
+	tm->tm_year = i;
+
+	/* Number of months in days left */
+	if (leapyear(tm->tm_year))
+	days_in_month(FEBRUARY) = 29;
+	for (i = 1; day >= days_in_month(i); i++)
+	day -= days_in_month(i);
+	days_in_month(FEBRUARY) = 28;
+	tm->tm_mon = i;
+
+	/* Days are what is left over (+1) from all that. */
+	tm->tm_mday = day + 1;
+
+	/*
+	 * Determine the day of week
+	 */
+	tm->tm_wday = (day + 3) % 7;
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/traps.c linux/arch/mips/kernel/traps.c
--- v2.4.9/linux/arch/mips/kernel/traps.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/kernel/traps.c	Sun Sep  9 10:43:01 2001
@@ -3,17 +3,18 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1994 - 1999 by Ralf Baechle
+ * Copyright (C) 1994 - 1999, 2000, 01 Ralf Baechle
  * Modified for R3000 by Paul M. Antoine, 1995, 1996
  * Complete output from die() by Ulf Carlsson, 1998
  * Copyright (C) 1999 Silicon Graphics, Inc.
  *
  * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
- * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ * Copyright (C) 2000, 01 MIPS Technologies, Inc.
  */
 #include <linux/config.h>
 #include <linux/init.h>
 #include <linux/mm.h>
+#include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
@@ -25,6 +26,7 @@
 #include <asm/cachectl.h>
 #include <asm/inst.h>
 #include <asm/jazz.h>
+#include <asm/module.h>
 #include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/siginfo.h>
@@ -32,9 +34,6 @@
 #include <asm/system.h>
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
-#ifndef CONFIG_MIPS_FPU_EMULATOR 
-#include <asm/inst.h>
-#endif
 
 /*
  * Machine specific interrupt handlers
@@ -63,12 +62,9 @@
 extern asmlinkage void handle_mcheck(void);
 extern asmlinkage void handle_reserved(void);
 
-extern int fpu_emulator_cop1Handler(int, struct pt_regs *);
-
-static char *cpu_names[] = CPU_NAMES;
+extern int fpu_emulator_cop1Handler(struct pt_regs *);
 
 char watch_available = 0;
-char dedicated_iv_available = 0;
 
 void (*ibe_board_handler)(struct pt_regs *regs);
 void (*dbe_board_handler)(struct pt_regs *regs);
@@ -81,7 +77,7 @@
  */
 #define MODULE_RANGE (8*1024*1024)
 
-#if !defined(CONFIG_CPU_HAS_LLSC)
+#ifndef CONFIG_CPU_HAS_LLSC
 /*
  * This stuff is needed for the userland ll-sc emulation for R2300
  */
@@ -94,8 +90,6 @@
 #define OFFSET 0x0000ffff
 #define LL     0xc0000000
 #define SC     0xe0000000
-
-#undef DEBUG_LLSC
 #endif
 
 /*
@@ -212,7 +206,6 @@
 	show_trace((unsigned int *) regs->regs[29]);
 	show_code((unsigned int *) regs->cp0_epc);
 	printk("\n");
-while(1);
 	spin_unlock_irq(&die_lock);
 	do_exit(SIGSEGV);
 }
@@ -254,89 +247,101 @@
 	return (first == last && first->insn == value) ? first->nextinsn : 0;
 }
 
-#define search_dbe_table(addr)	\
-	search_one_table(__start___dbe_table, __stop___dbe_table - 1, (addr))
+extern spinlock_t modlist_lock;
+
+static inline unsigned long
+search_dbe_table(unsigned long addr)
+{
+	unsigned long ret = 0;
+
+#ifndef CONFIG_MODULES
+	/* There is only the kernel to search.  */
+	ret = search_one_table(__start___dbe_table, __stop___dbe_table-1, addr);
+	return ret;
+#else
+	unsigned long flags;
+
+	/* The kernel is the last "module" -- no need to treat it special.  */
+	struct module *mp;
+	struct archdata *ap;
+
+	spin_lock_irqsave(&modlist_lock, flags);
+	for (mp = module_list; mp != NULL; mp = mp->next) {
+		if (!mod_member_present(mp, archdata_end) ||
+        	    !mod_archdata_member_present(mp, struct archdata,
+						 dbe_table_end))
+			continue;
+		ap = (struct archdata *)(mp->archdata_start);
+
+		if (ap->dbe_table_start == NULL ||
+		    !(mp->flags & (MOD_RUNNING | MOD_INITIALIZING)))
+			continue;
+		ret = search_one_table(ap->dbe_table_start,
+				       ap->dbe_table_end - 1, addr);
+		if (ret)
+			break;
+	}
+	spin_unlock_irqrestore(&modlist_lock, flags);
+	return ret;
+#endif
+}
 
 static void default_be_board_handler(struct pt_regs *regs)
 {
 	unsigned long new_epc;
-	unsigned long fixup = search_dbe_table(regs->cp0_epc);
+	unsigned long fixup;
+	int data = regs->cp0_cause & 4;
 
-	if (fixup) {
-		new_epc = fixup_exception(dpf_reg, fixup, regs->cp0_epc);
-		regs->cp0_epc = new_epc;
-		return;
+	if (data && !user_mode(regs)) {
+		fixup = search_dbe_table(regs->cp0_epc);
+		if (fixup) {
+			new_epc = fixup_exception(dpf_reg, fixup,
+						  regs->cp0_epc);
+			regs->cp0_epc = new_epc;
+			return;
+		}
 	}
 
 	/*
 	 * Assume it would be too dangerous to continue ...
 	 */
+	printk(KERN_ALERT "%s bus error, epc == %08lx, ra == %08lx\n",
+	       data ? "Data" : "Instruction",
+	       regs->cp0_epc, regs->regs[31]);
+	die_if_kernel("Oops", regs);
 	force_sig(SIGBUS, current);
 }
 
-void do_ibe(struct pt_regs *regs)
+asmlinkage void do_ibe(struct pt_regs *regs)
 {
 	ibe_board_handler(regs);
 }
 
-void do_dbe(struct pt_regs *regs)
+asmlinkage void do_dbe(struct pt_regs *regs)
 {
 	dbe_board_handler(regs);
 }
 
-void do_ov(struct pt_regs *regs)
+asmlinkage void do_ov(struct pt_regs *regs)
 {
 	if (compute_return_epc(regs))
 		return;
-	force_sig(SIGFPE, current);
-}
-
-#ifdef CONFIG_MIPS_FPE_MODULE
-static void (*fpe_handler)(struct pt_regs *regs, unsigned int fcr31);
 
-/*
- * Register_fpe/unregister_fpe are for debugging purposes only.  To make
- * this hack work a bit better there is no error checking.
- */
-int register_fpe(void (*handler)(struct pt_regs *regs, unsigned int fcr31))
-{
-	fpe_handler = handler;
-	return 0;
-}
-
-int unregister_fpe(void (*handler)(struct pt_regs *regs, unsigned int fcr31))
-{
-	fpe_handler = NULL;
-	return 0;
+	force_sig(SIGFPE, current);
 }
-#endif
 
 /*
  * XXX Delayed fp exceptions when doing a lazy ctx switch XXX
  */
-void do_fpe(struct pt_regs *regs, unsigned long fcr31)
+asmlinkage void do_fpe(struct pt_regs *regs, unsigned long fcr31)
 {
-
-#ifdef CONFIG_MIPS_FPU_EMULATOR
-	if(!(mips_cpu.options & MIPS_CPU_FPU))
-		panic("Floating Point Exception with No FPU");
-#endif
-
-#ifdef CONFIG_MIPS_FPE_MODULE
-	if (fpe_handler != NULL) {
-		fpe_handler(regs, fcr31);
-		return;
-	}
-#endif
-
 	if (fcr31 & FPU_CSR_UNI_X) {
-#ifdef CONFIG_MIPS_FPU_EMULATOR
 		extern void save_fp(struct task_struct *);
 		extern void restore_fp(struct task_struct *);
 		int sig;
 		/*
 	 	 * Unimplemented operation exception.  If we've got the
-	 	 * Full software emulator on-board, let's use it...
+	 	 * full software emulator on-board, let's use it...
 		 *
 		 * Force FPU to dump state into task/thread context.
 		 * We're moving a lot of data here for what is probably
@@ -348,11 +353,11 @@
 		save_fp(current);
 	
 		/* Run the emulator */
-		sig = fpu_emulator_cop1Handler(0, regs);
+		sig = fpu_emulator_cop1Handler(regs);
 
 		/* 
 		 * We can't allow the emulated instruction to leave the
-		 * Unimplemented Operation bit set in the FCR31 fp-register.
+		 * Unimplemented Operation bit set in $fcr31.
 		 */
 		current->thread.fpu.soft.sr &= ~FPU_CSR_UNI_X;
 
@@ -362,37 +367,6 @@
 		/* If something went wrong, signal */
 		if (sig)
 			force_sig(sig, current);
-#else
-		/* Else use mini-emulator */
-
-		extern void simfp(int);
-		unsigned long pc;
-		unsigned int insn;
-
-		/* Retry instruction with flush to zero ...  */
-		if (!(fcr31 & (1<<24))) {
-			printk("Setting flush to zero for %s.\n",
-			       current->comm);
-			fcr31 &= ~FPU_CSR_UNI_X;
-			fcr31 |= (1<<24);
-			__asm__ __volatile__(
-				"ctc1\t%0,$31"
-				: /* No outputs */
-				: "r" (fcr31));
-			return;
-		}
-		pc = regs->cp0_epc + ((regs->cp0_cause & CAUSEF_BD) ? 4 : 0);
-		if(pc & 0x80000000) insn = *(unsigned int *)pc;
-		else if (get_user(insn, (unsigned int *)pc)) {
-			/* XXX Can this happen?  */
-			force_sig(SIGSEGV, current);
-		}
-
-		printk(KERN_DEBUG "Unimplemented exception for insn %08x at 0x%08lx in %s.\n",
-		       insn, regs->cp0_epc, current->comm);
-		simfp(MIPSInst(insn));
-		compute_return_epc(regs);
-#endif /* CONFIG_MIPS_FPU_EMULATOR */
 
 		return;
 	}
@@ -408,31 +382,31 @@
 {
 	unsigned int *epc;
 
-	epc = (unsigned int *) (unsigned long) regs->cp0_epc;
-	if (regs->cp0_cause & CAUSEF_BD)
-		epc++;
-
-	if (verify_area(VERIFY_READ, epc, 4)) {
-		force_sig(SIGSEGV, current);
-		return 1;
-	}
-	*opcode = *epc;
+	epc = (unsigned int *) regs->cp0_epc +
+	      ((regs->cp0_cause & CAUSEF_BD) != 0);
+	if (!get_user(*opcode, epc))
+		return 0;
 
-	return 0;
+	force_sig(SIGSEGV, current);
+	return 1;
 }
 
-void do_bp(struct pt_regs *regs)
+asmlinkage void do_bp(struct pt_regs *regs)
 {
 	siginfo_t info;
 	unsigned int opcode, bcode;
+	unsigned int *epc;
+
+	epc = (unsigned int *) regs->cp0_epc +
+	      ((regs->cp0_cause & CAUSEF_BD) != 0);
+	if (get_user(opcode, epc))
+		goto sigsegv;
 
 	/*
 	 * There is the ancient bug in the MIPS assemblers that the break
 	 * code starts left to bit 16 instead to bit 6 in the opcode.
 	 * Gas is bug-compatible ...
 	 */
-	if (get_insn_opcode(regs, &opcode))
-		return;
 	bcode = ((opcode >> 16) & ((1 << 20) - 1));
 
 	/*
@@ -456,15 +430,23 @@
 	default:
 		force_sig(SIGTRAP, current);
 	}
+	return;
+
+sigsegv:
+	force_sig(SIGSEGV, current);
 }
 
-void do_tr(struct pt_regs *regs)
+asmlinkage void do_tr(struct pt_regs *regs)
 {
 	siginfo_t info;
 	unsigned int opcode, bcode;
+	unsigned *epc;
+
+	epc = (unsigned int *) regs->cp0_epc +
+	      ((regs->cp0_cause & CAUSEF_BD) != 0);
+	if (get_user(opcode, epc))
+		goto sigsegv;
 
-	if (get_insn_opcode(regs, &opcode))
-		return;
 	bcode = ((opcode >> 6) & ((1 << 20) - 1));
 
 	/*
@@ -488,9 +470,13 @@
 	default:
 		force_sig(SIGTRAP, current);
 	}
+	return;
+
+sigsegv:
+	force_sig(SIGSEGV, current);
 }
 
-#if !defined(CONFIG_CPU_HAS_LLSC)
+#ifndef CONFIG_CPU_HAS_LLSC
 
 #ifdef CONFIG_SMP
 #error "ll/sc emulation is not SMP safe"
@@ -503,7 +489,7 @@
  * this implementation can handle only sychronization between 2 or more
  * user contexts and is not SMP safe.
  */
-void do_ri(struct pt_regs *regs)
+asmlinkage void do_ri(struct pt_regs *regs)
 {
 	unsigned int opcode;
 
@@ -520,9 +506,7 @@
 			return;
 		}
 	}
-	printk("[%s:%d] Illegal instruction %08lx at %08lx, ra=%08lx, CP0_STATUS=%08lx\n",
-	       current->comm, current->pid, *((unsigned long*)regs->cp0_epc), regs->cp0_epc,
-		regs->regs[31], regs->cp0_status);
+
 	if (compute_return_epc(regs))
 		return;
 	force_sig(SIGILL, current);
@@ -558,10 +542,6 @@
 
 	vaddr = (unsigned long *)((long)(regp->regs[(opcode & BASE) >> 21]) + offset);
 
-#ifdef DEBUG_LLSC
-	printk("ll: vaddr = 0x%08x, reg = %d\n", (unsigned int)vaddr, (opcode & RT) >> 16);
-#endif
-
 #ifdef CONFIG_PROC_FS
 	ll_ops++;
 #endif
@@ -604,10 +584,6 @@
 	vaddr = (unsigned long *)((long)(regp->regs[(opcode & BASE) >> 21]) + offset);
 	reg = (opcode & RT) >> 16;
 
-#ifdef DEBUG_LLSC
-	printk("sc: vaddr = 0x%08x, reg = %d\n", (unsigned int)vaddr, (unsigned int)reg);
-#endif
-
 #ifdef CONFIG_PROC_FS
 	sc_ops++;
 #endif
@@ -628,52 +604,33 @@
 
 #else /* MIPS 2 or higher */
 
-void do_ri(struct pt_regs *regs)
+asmlinkage void do_ri(struct pt_regs *regs)
 {
 	unsigned int opcode;
 
-        get_insn_opcode(regs, &opcode);
-	printk("[%s:%ld] Illegal instruction %08x at %08lx ra=%08lx\n",
-	       current->comm, (unsigned long)current->pid, opcode,
-	       regs->cp0_epc, regs->regs[31]);
+	get_insn_opcode(regs, &opcode);
 	if (compute_return_epc(regs))
 		return;
+
 	force_sig(SIGILL, current);
 }
 
 #endif
 
-void do_cpu(struct pt_regs *regs)
+asmlinkage void do_cpu(struct pt_regs *regs)
 {
 	unsigned int cpid;
-	extern void lazy_fpu_switch(void*);
+	extern void lazy_fpu_switch(void *);
 	extern void init_fpu(void);
-#ifdef CONFIG_MIPS_FPU_EMULATOR
 	void fpu_emulator_init_fpu(void);
 	int sig;
-#endif
+
 	cpid = (regs->cp0_cause >> CAUSEB_CE) & 3;
 	if (cpid != 1)
 		goto bad_cid;
 
-#ifdef CONFIG_MIPS_FPU_EMULATOR
-	if(!(mips_cpu.options & MIPS_CPU_FPU)) {
-	    if (last_task_used_math != current) {
-		if(!current->used_math) {
-		    fpu_emulator_init_fpu();
-		    current->used_math = 1;
-		}
-	    }
-	    sig = fpu_emulator_cop1Handler(0, regs);
-	    last_task_used_math = current;
-	    if(sig) {
-		force_sig(sig, current);
-	    }
-	    return;
-	}
-#else
-	if(!(mips_cpu.options & MIPS_CPU_FPU)) goto bad_cid;
-#endif
+	if (!(mips_cpu.options & MIPS_CPU_FPU))
+		goto fp_emul;
 
 	regs->cp0_status |= ST0_CU1;
 	if (last_task_used_math == current)
@@ -682,18 +639,30 @@
 	if (current->used_math) {		/* Using the FPU again.  */
 		lazy_fpu_switch(last_task_used_math);
 	} else {				/* First time FPU user.  */
-
 		init_fpu();
 		current->used_math = 1;
 	}
 	last_task_used_math = current;
 	return;
 
+fp_emul:
+	if (last_task_used_math != current) {
+		if (!current->used_math) {
+			fpu_emulator_init_fpu();
+			current->used_math = 1;
+		}
+	}
+	sig = fpu_emulator_cop1Handler(regs);
+	last_task_used_math = current;
+	if (sig)
+		force_sig(sig, current);
+	return;
+
 bad_cid:
 	force_sig(SIGILL, current);
 }
 
-void do_watch(struct pt_regs *regs)
+asmlinkage void do_watch(struct pt_regs *regs)
 {
 	/*
 	 * We use the watch exception where available to detect stack
@@ -703,14 +672,14 @@
 	panic("Caught WATCH exception - probably caused by stack overflow.");
 }
 
-void do_mcheck(struct pt_regs *regs)
+asmlinkage void do_mcheck(struct pt_regs *regs)
 {
 	show_regs(regs);
 	panic("Caught Machine Check exception - probably caused by multiple "
 	      "matching entries in the TLB.");
 }
 
-void do_reserved(struct pt_regs *regs)
+asmlinkage void do_reserved(struct pt_regs *regs)
 {
 	/*
 	 * Game over - no way to handle this if it ever occurs.  Most probably
@@ -723,34 +692,19 @@
 
 static inline void watch_init(void)
 {
-        if(mips_cpu.options & MIPS_CPU_WATCH ) {
-		(void)set_except_vector(23, handle_watch);
+	if (mips_cpu.options & MIPS_CPU_WATCH ) {
+		set_except_vector(23, handle_watch);
  		watch_available = 1;
  	}
 }
 
 /*
- * Some MIPS CPUs have a dedicated interrupt vector which reduces the
- * interrupt processing overhead.  Use it where available.
- */
-static inline void setup_dedicated_int(void)
-{
-	extern void except_vec4(void);
-
-	if(mips_cpu.options & MIPS_CPU_DIVEC) {
-		memcpy((void *)(KSEG0 + 0x200), except_vec4, 8);
-		set_cp0_cause(CAUSEF_IV);
-		dedicated_iv_available = 1;
-	}
-}
-
-/*
- * Some MIPS CPUs can enable/disable for cache parity detection, but does
+ * Some MIPS CPUs can enable/disable for cache parity detection, but do
  * it different ways.
  */
 static inline void parity_protection_init(void)
 {
-	switch(mips_cpu.cputype) {
+	switch (mips_cpu.cputype) {
 	case CPU_5KC:
 		/* Set the PE bit (bit 31) in the CP0_ECC register. */
 		printk(KERN_INFO "Enable the cache parity protection for "
@@ -764,38 +718,39 @@
 	}
 }
 
-void cache_parity_error(void)
+asmlinkage void cache_parity_error(void)
 {
-        unsigned int reg_val;
+	unsigned int reg_val;
 
-        /* For the moment, report the problem and hang. */
-        reg_val = read_32bit_cp0_register(CP0_ERROREPC);
+	/* For the moment, report the problem and hang. */
+	reg_val = read_32bit_cp0_register(CP0_ERROREPC);
 	printk("Cache error exception:\n");
 	printk("cp0_errorepc == %08x\n", reg_val);
 	reg_val = read_32bit_cp0_register(CP0_CACHEERR);
 	printk("cp0_cacheerr == %08x\n", reg_val);
 
 	printk("Decoded CP0_CACHEERR: %s cache fault in %s reference.\n",
-	       reg_val&(1<<30)?"secondary":"primary",
-	       reg_val&(1<<31)?"data":"insn");
+	       reg_val & (1<<30) ? "secondary" : "primary",
+	       reg_val & (1<<31) ? "data" : "insn");
 	printk("Error bits: %s%s%s%s%s%s%s\n",
-	       reg_val&(1<<29)?"ED ":"",
-	       reg_val&(1<<28)?"ET ":"",
-	       reg_val&(1<<26)?"EE ":"",
-	       reg_val&(1<<25)?"EB ":"",
-	       reg_val&(1<<24)?"EI ":"",
-	       reg_val&(1<<23)?"E1 ":"",
-	       reg_val&(1<<22)?"E0 ":"");
-	printk("IDX: 0x%08x\n", reg_val&((1<<22)-1));
+	       reg_val & (1<<29) ? "ED " : "",
+	       reg_val & (1<<28) ? "ET " : "",
+	       reg_val & (1<<26) ? "EE " : "",
+	       reg_val & (1<<25) ? "EB " : "",
+	       reg_val & (1<<24) ? "EI " : "",
+	       reg_val & (1<<23) ? "E1 " : "",
+	       reg_val & (1<<22) ? "E0 " : "");
+	printk("IDX: 0x%08x\n", reg_val & ((1<<22)-1));
 
 	if (reg_val&(1<<22))
-		printk("DErrAddr0: 0x%08x\n", read_32bit_cp0_set1_register(CP0_S1_DERRADDR0));
+		printk("DErrAddr0: 0x%08x\n",
+		       read_32bit_cp0_set1_register(CP0_S1_DERRADDR0));
 
 	if (reg_val&(1<<23))
-		printk("DErrAddr1: 0x%08x\n", read_32bit_cp0_set1_register(CP0_S1_DERRADDR1));
+		printk("DErrAddr1: 0x%08x\n",
+		       read_32bit_cp0_set1_register(CP0_S1_DERRADDR1));
 
-
-	panic("Can't handle the cache error - panic!");
+	panic("Can't handle the cache error!");
 }
 
 unsigned long exception_handlers[32];
@@ -810,7 +765,8 @@
 	unsigned handler = (unsigned long) addr;
 	unsigned old_handler = exception_handlers[n];
 	exception_handlers[n] = handler;
-	if (n == 0 && dedicated_iv_available) {
+
+	if (n == 0 && mips_cpu.options & MIPS_CPU_DIVEC) {
 		*(volatile u32 *)(KSEG0+0x200) = 0x08000000 |
 		                                 (0x03ffffff & (handler >> 2));
 		flush_icache_range(KSEG0+0x200, KSEG0 + 0x204);
@@ -823,10 +779,8 @@
 extern asmlinkage int _save_fp_context(struct sigcontext *sc);
 extern asmlinkage int _restore_fp_context(struct sigcontext *sc);
 
-#ifdef CONFIG_MIPS_FPU_EMULATOR
 extern asmlinkage int fpu_emulator_save_context(struct sigcontext *sc);
 extern asmlinkage int fpu_emulator_restore_context(struct sigcontext *sc);
-#endif
 
 void __init trap_init(void)
 {
@@ -834,13 +788,10 @@
 	extern char except_vec0_r4600, except_vec0_r2300;
 	extern char except_vec1_generic, except_vec2_generic;
 	extern char except_vec3_generic, except_vec3_r4000;
+	extern char except_vec4;
 	extern char except_vec_ejtag_debug;
 	unsigned long i;
 
-	if(mips_machtype == MACH_MIPS_MAGNUM_4000 ||
-	   mips_machtype == MACH_SNI_RM200_PCI)
-		EISA_bus = 1;
-
 	/* Some firmware leaves the BEV flag set, clear it.  */
 	clear_cp0_status(ST0_BEV);
 
@@ -852,8 +803,8 @@
 	/*
 	 * Setup default vectors
 	 */
-	for(i = 0; i <= 31; i++)
-		(void)set_except_vector(i, handle_reserved);
+	for (i = 0; i <= 31; i++)
+		set_except_vector(i, handle_reserved);
 
 	/* 
 	 * Copy the EJTAG debug exception vector handler code to it's final 
@@ -866,7 +817,15 @@
 	 * interrupt vector.
 	 */
 	watch_init();
-	setup_dedicated_int();
+
+	/*
+	 * Some MIPS CPUs have a dedicated interrupt vector which reduces the
+	 * interrupt processing overhead.  Use it where available.
+	 */
+	if (mips_cpu.options & MIPS_CPU_DIVEC) {
+		memcpy((void *)(KSEG0 + 0x200), &except_vec4, 8);
+		set_cp0_cause(CAUSEF_IV);
+	}
 
 	/*
 	 * Some CPUs can enable/disable for cache parity detection, but does
@@ -874,35 +833,38 @@
 	 */
 	parity_protection_init();
 
-	(void)set_except_vector(1, handle_mod);
-	(void)set_except_vector(2, handle_tlbl);
-	(void)set_except_vector(3, handle_tlbs);
-	(void)set_except_vector(4, handle_adel);
-	(void)set_except_vector(5, handle_ades);
+	set_except_vector(1, handle_mod);
+	set_except_vector(2, handle_tlbl);
+	set_except_vector(3, handle_tlbs);
+	set_except_vector(4, handle_adel);
+	set_except_vector(5, handle_ades);
+
 	/*
 	 * The Data Bus Error/ Instruction Bus Errors are signaled
 	 * by external hardware.  Therefore these two expection have
 	 * board specific handlers.
 	 */
-	(void)set_except_vector(6, handle_ibe);
-	(void)set_except_vector(7, handle_dbe);
+	set_except_vector(6, handle_ibe);
+	set_except_vector(7, handle_dbe);
 	ibe_board_handler = default_be_board_handler;
 	dbe_board_handler = default_be_board_handler;
 
-	(void)set_except_vector(8, handle_sys);
-	(void)set_except_vector(9, handle_bp);
-	(void)set_except_vector(10, handle_ri);
-	(void)set_except_vector(11, handle_cpu);
-	(void)set_except_vector(12, handle_ov);
-	(void)set_except_vector(13, handle_tr);
-	(void)set_except_vector(15, handle_fpe);
-	
+	set_except_vector(8, handle_sys);
+	set_except_vector(9, handle_bp);
+	set_except_vector(10, handle_ri);
+	set_except_vector(11, handle_cpu);
+	set_except_vector(12, handle_ov);
+	set_except_vector(13, handle_tr);
+
+	if (mips_cpu.options & MIPS_CPU_FPU)
+		set_except_vector(15, handle_fpe);
+
 	/*
 	 * Handling the following exceptions depends mostly of the cpu type
 	 */
 	if ((mips_cpu.options & MIPS_CPU_4KEX)
 	    && (mips_cpu.options & MIPS_CPU_4KTLB)) {
-		if(mips_cpu.cputype == CPU_NEVADA) {
+		if (mips_cpu.cputype == CPU_NEVADA) {
 			memcpy((void *)KSEG0, &except_vec0_nevada, 0x80);
 		} else if (mips_cpu.cputype == CPU_R4600)
 			memcpy((void *)KSEG0, &except_vec0_r4600, 0x80);
@@ -919,36 +881,25 @@
 			       0x80);
 		}
 
-		if(mips_cpu.options & MIPS_CPU_FPU) {
+		if (mips_cpu.options & MIPS_CPU_FPU) {
 		        save_fp_context = _save_fp_context;
 			restore_fp_context = _restore_fp_context;
-#ifdef CONFIG_MIPS_FPU_EMULATOR
 		} else {
 		        save_fp_context = fpu_emulator_save_context;
 			restore_fp_context = fpu_emulator_restore_context;
-#endif
 		}
-	} else switch(mips_cpu.cputype) {
-	case CPU_R10000:
-		/*
-		 * The R10000 is in most aspects similar to the R4400.  It
-		 * should get some special optimizations.
-		 */
-		write_32bit_cp0_register(CP0_FRAMEMASK, 0);
-		set_cp0_status(ST0_XX);
+	} else switch (mips_cpu.cputype) {
+	case CPU_SB1:
 		/*
-		 * The R10k might even work for Linux/MIPS - but we're paranoid
-		 * and refuse to run until this is tested on real silicon
+		 * XXX - This should be folded in to the "cleaner" handling,
+		 * above
 		 */
-		panic("CPU too expensive - making holiday in the ANDES!");
-		break;
-	case CPU_SB1:
-		/* XXX - This should be folded in to the "cleaner" handling, above */
 		memcpy((void *)KSEG0, &except_vec0_r4000, 0x80);
 		memcpy((void *)(KSEG0 + 0x180), &except_vec3_r4000, 0x80);
 		save_fp_context = _save_fp_context;
 		restore_fp_context = _restore_fp_context;
-		/* Enable timer interrupt and scd mapped interrupt in status register */
+
+		/* Enable timer interrupt and scd mapped interrupt */
 		clear_cp0_status(0xf000);
 		set_cp0_status(0xc00);
 		break;
@@ -983,17 +934,15 @@
 		memcpy((void *)KSEG0, &except_vec0_r2300, 0x80);
 		memcpy((void *)(KSEG0 + 0x80), &except_vec3_generic, 0x80);
 		break;
-	case CPU_R8000:
-		printk("Detected unsupported CPU type %s.\n",
-			cpu_names[mips_cpu.cputype]);
-		panic("Can't handle CPU");
-		break;
 
 	case CPU_UNKNOWN:
 	default:
 		panic("Unknown CPU type");
 	}
 	flush_icache_range(KSEG0, KSEG0 + 0x200);
+
+	if (mips_cpu.isa_level == MIPS_CPU_ISA_IV)
+		set_cp0_status(ST0_XX);
 
 	atomic_inc(&init_mm.mm_count);	/* XXX  UP?  */
 	current->active_mm = &init_mm;
diff -u --recursive --new-file v2.4.9/linux/arch/mips/kernel/unaligned.c linux/arch/mips/kernel/unaligned.c
--- v2.4.9/linux/arch/mips/kernel/unaligned.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/kernel/unaligned.c	Sun Sep  9 10:43:01 2001
@@ -72,6 +72,7 @@
  *       A store crossing a page boundary might be executed only partially.
  *       Undo the partial store in this case.
  */
+#include <linux/config.h>
 #include <linux/mm.h>
 #include <linux/signal.h>
 #include <linux/smp.h>
@@ -378,26 +379,26 @@
 	return;
 }
 
+#ifdef CONFIG_PROC_FS
 unsigned long unaligned_instructions;
+#endif
 
 asmlinkage void do_ade(struct pt_regs *regs)
 {
 	unsigned long pc;
-#ifdef CONFIG_MIPS_FPU_EMULATOR
-        extern int do_dsemulret(struct pt_regs *);
+	extern int do_dsemulret(struct pt_regs *);
+
+	/* 
+	 * Address errors may be deliberately induced
+	 * by the FPU emulator to take retake control
+	 * of the CPU after executing the instruction
+	 * in the delay slot of an emulated branch.
+	 */
 
-        /* 
-         * Address errors may be deliberately induced
-         * by the FPU emulator to take retake control
-         * of the CPU after executing the instruction
-         * in the delay slot of an emulated branch.
-         */
-
-        if((unsigned long)regs->cp0_epc == current->thread.dsemul_aerpc) {
-                (void)do_dsemulret(regs);
-                return;
-        }
-#endif /* CONFIG_MIPS_FPU_EMULATOR */
+	if ((unsigned long)regs->cp0_epc == current->thread.dsemul_aerpc) {
+		do_dsemulret(regs);
+		return;
+	}
 
 	/*
 	 * Did we catch a fault trying to load an instruction?
@@ -414,7 +415,9 @@
 		goto sigbus;
 
 	emulate_load_store_insn(regs, regs->cp0_badvaddr, pc);
+#ifdef CONFIG_PROC_FS
 	unaligned_instructions++;
+#endif
 
 	return;
 
diff -u --recursive --new-file v2.4.9/linux/arch/mips/lib/ide-std.c linux/arch/mips/lib/ide-std.c
--- v2.4.9/linux/arch/mips/lib/ide-std.c	Sat May 13 08:29:14 2000
+++ linux/arch/mips/lib/ide-std.c	Sun Sep  9 10:43:01 2001
@@ -1,12 +1,11 @@
-/* $Id: ide-std.c,v 1.4 1999/06/11 14:29:45 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * IDE routines for typical pc-like standard configurations.
  *
- * Copyright (C) 1998, 1999 by Ralf Baechle
+ * Copyright (C) 1998, 1999, 2001 by Ralf Baechle
  */
 #include <linux/sched.h>
 #include <linux/ide.h>
@@ -60,6 +59,7 @@
 	}
 	if (irq != NULL)
 		*irq = 0;
+	hw->io_ports[IDE_IRQ_OFFSET] = 0;
 }
 
 static int std_ide_request_irq(unsigned int irq,
diff -u --recursive --new-file v2.4.9/linux/arch/mips/lib/memcpy.S linux/arch/mips/lib/memcpy.S
--- v2.4.9/linux/arch/mips/lib/memcpy.S	Tue Dec  5 23:15:12 2000
+++ linux/arch/mips/lib/memcpy.S	Sun Sep  9 10:43:01 2001
@@ -402,16 +402,20 @@
 
 	.align	5
 LEAF(memmove)
-	sltu	t0, a0, a1			# dst < src -> memcpy
-	bnez	t0, memcpy
-	 addu	v0, a0, a2
-	sltu	t0, v0, a1			# dst + len < src -> non-
-	bnez	t0, __memcpy			# overlapping, can use memcpy
+	addu	t0, a0, a2
+	sltu	t0, a1, t0			# dst + len <= src -> memcpy
+	addu	t1, a1, a2
+	sltu	t1, a0, t1			# dst >= src + len -> memcpy
+	and	t0, t1
+	beqz	t0, __memcpy
 	 move	v0, a0				/* return value */
 	beqz	a2, r_out
 	END(memmove)
 
 LEAF(__rmemcpy)					/* a0=dst a1=src a2=len */
+	sltu	t0, a1, a0
+	beqz	t0, r_end_bytes_up		# src >= dst
+	 nop
 	addu	a0, a2				# dst = dst + len
 	addu	a1, a2				# src = src + len
 
@@ -563,6 +567,17 @@
 	 subu	a0, a0, 0x1
 
 r_out:
+	jr	ra
+	 move	a2, zero
+
+r_end_bytes_up:
+	lb	t0, (a1)
+	subu	a2, a2, 0x1
+	sb	t0, (a0)
+	addu	a1, a1, 0x1
+	bnez	a2, r_end_bytes_up
+	 addu	a0, a0, 0x1
+
 	jr	ra
 	 move	a2, zero
 
diff -u --recursive --new-file v2.4.9/linux/arch/mips/math-emu/cp1emu.c linux/arch/mips/math-emu/cp1emu.c
--- v2.4.9/linux/arch/mips/math-emu/cp1emu.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/math-emu/cp1emu.c	Sun Sep  9 10:43:01 2001
@@ -5,7 +5,8 @@
  * Copyright (C) 1994-2000 Algorithmics Ltd.  All rights reserved.
  * http://www.algor.co.uk
  *
- * ########################################################################
+ * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000  MIPS Technologies, Inc.
  *
  *  This program is free software; you can distribute it and/or modify it
  *  under the terms of the GNU General Public License (Version 2) as
@@ -20,8 +21,6 @@
  *  with this program; if not, write to the Free Software Foundation, Inc.,
  *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
  *
- * ########################################################################
- *
  * A complete emulator for MIPS coprocessor 1 instructions.  This is
  * required for #float(switch) or #float(trap), where it catches all
  * COP1 instructions via the "CoProcessor Unusable" exception.  
@@ -32,24 +31,9 @@
  * quite nasty because emulation of some non-COP1 instructions is
  * required, e.g. in branch delay slots.
  * 
- * Notes: 
- *  1) the IEEE754 library (-le) performs the actual arithmetic;
- *  2) if you know that you won't have an fpu, then you'll get much 
- *     better performance by compiling with -msoft-float!  */
-
-/**************************************************************************
- *  Nov 7, 2000
- *  Massive changes to integrate with Linux kernel.
- *
- *  Replace use of kernel data area with use of user stack 
- *  for execution of instructions in branch delay slots.
- *
- *  Replace use of static kernel variables with thread_struct elements.
- *
- *  Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
- *  Copyright (C) 2000  MIPS Technologies, Inc.  All rights reserved.
- *************************************************************************/
-#include <linux/config.h>
+ * Note if you know that you won't have an fpu, then you'll get much 
+ * better performance by compiling with -msoft-float!
+ */
 #include <linux/mm.h>
 #include <linux/signal.h>
 #include <linux/smp.h>
@@ -57,7 +41,9 @@
 
 #include <asm/asm.h>
 #include <asm/branch.h>
+#include <asm/bootinfo.h>
 #include <asm/byteorder.h>
+#include <asm/cpu.h>
 #include <asm/inst.h>
 #include <asm/uaccess.h>
 #include <asm/processor.h>
@@ -181,19 +167,17 @@
 #define REG_TO_VA (vaddr_t)
 #define VA_TO_REG (unsigned long)
 
-static unsigned long
-mips_get_word(struct pt_regs *xcp, void *va, int *perr)
+static unsigned long mips_get_word(struct pt_regs *xcp, void *va, int *perr)
 {
 	unsigned long temp;
 
 	if (!user_mode(xcp)) {
 		*perr = 0;
 		return (*(unsigned long *) va);
-	} else {
-		/* Use kernel get_user() macro */
-		*perr = (int) get_user(temp, (unsigned long *) va);
-		return temp;
 	}
+
+	*perr = (int) get_user(temp, (unsigned long *) va);
+	return temp;
 }
 
 static unsigned long long
@@ -204,11 +188,10 @@
 	if (!user_mode(xcp)) {
 		*perr = 0;
 		return (*(unsigned long long *) va);
-	} else {
-		/* Use kernel get_user() macro */
-		*perr = (int) get_user(temp, (unsigned long long *) va);
-		return temp;
 	}
+
+	*perr = (int) get_user(temp, (unsigned long long *) va);
+	return temp;
 }
 
 static int mips_put_word(struct pt_regs *xcp, void *va, unsigned long val)
@@ -216,10 +199,9 @@
 	if (!user_mode(xcp)) {
 		*(unsigned long *) va = val;
 		return 0;
-	} else {
-		/* Use kernel get_user() macro */
-		return (int) put_user(val, (unsigned long *) va);
 	}
+
+	return put_user(val, (unsigned long *) va);
 }
 
 static int mips_put_dword(struct pt_regs *xcp, void *va, long long val)
@@ -227,10 +209,9 @@
 	if (!user_mode(xcp)) {
 		*(unsigned long long *) va = val;
 		return 0;
-	} else {
-		/* Use kernel get_user() macro */
-		return (int) put_user(val, (unsigned long long *) va);
 	}
+
+	return put_user(val, (unsigned long long *) va);
 }
 
 
@@ -249,9 +230,7 @@
  * Two instructions if the instruction is in a branch delay slot.
  */
 
-static int
-cop1Emulate(int xcptno, struct pt_regs *xcp,
-	    struct mips_fpu_soft_struct *ctx)
+static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_soft_struct *ctx)
 {
 	mips_instruction ir;
 	vaddr_t emulpc;
@@ -259,7 +238,6 @@
 	unsigned int cond;
 	int err = 0;
 
-
 	ir = mips_get_word(xcp, REG_TO_VA xcp->cp0_epc, &err);
 	if (err) {
 		fpuemuprivate.stats.errors++;
@@ -303,7 +281,7 @@
 		contpc = REG_TO_VA xcp->cp0_epc + 4;
 	}
 
-      emul:
+emul:
 	fpuemuprivate.stats.emulated++;
 	switch (MIPSInst_OPCODE(ir)) {
 #ifdef CP0_STATUS_FR_SUPPORT
@@ -491,9 +469,8 @@
 			}
 			break;
 
-		case dmtc_op:
+		case dmtc_op: {
 			/* copregister fs <- rt */
-			{
 				fpureg_t value;
 				int fs = MIPSInst_RD(ir);
 				if (!(xcp->cp0_status & ST0_FR))
@@ -502,8 +479,8 @@
 				    (MIPSInst_RT(ir) ==
 				     0) ? 0 : xcp->regs[MIPSInst_RT(ir)];
 				ctx->regs[fs] = value;
-			}
 			break;
+		}
 #endif
 
 		case mfc_op:
@@ -638,95 +615,92 @@
 			}
 			break;
 
-		case bc_op:
-			if (xcp->cp0_cause & CAUSEF_BD) {
+		case bc_op: {
+			int likely = 0;
+
+			if (xcp->cp0_cause & CAUSEF_BD)
 				return SIGILL;
-			}
-			{
-				int likely = 0;
 
 #if __mips >= 4
-				cond =
-				    ctx->
-				    sr & fpucondbit[MIPSInst_RT(ir) >> 2];
+			cond = ctx-> sr & fpucondbit[MIPSInst_RT(ir) >> 2];
 #else
-				cond = ctx->sr & FPU_CSR_COND;
+			cond = ctx->sr & FPU_CSR_COND;
 #endif
-				switch (MIPSInst_RT(ir) & 3) {
-				case bcfl_op:
-					likely = 1;
-				case bcf_op:
-					cond = !cond;
-					break;
-				case bctl_op:
-					likely = 1;
-				case bct_op:
-					break;
-				default:
-					/* thats an illegal instruction */
-					return SIGILL;
-				}
+			switch (MIPSInst_RT(ir) & 3) {
+			case bcfl_op:
+				likely = 1;
+			case bcf_op:
+				cond = !cond;
+				break;
+			case bctl_op:
+				likely = 1;
+			case bct_op:
+				break;
+			default:
+				/* thats an illegal instruction */
+				return SIGILL;
+			}
 
-				xcp->cp0_cause |= CAUSEF_BD;
-				if (cond) {
-					/* branch taken: emulate dslot instruction */
-					xcp->cp0_epc += 4;
-					contpc =
-					    REG_TO_VA xcp->cp0_epc +
-					    (MIPSInst_SIMM(ir) << 2);
-
-					ir =
-					    mips_get_word(xcp,
-							  REG_TO_VA(xcp->
-								    cp0_epc),
-							  &err);
-					if (err) {
-						fpuemuprivate.stats.
-						    errors++;
-						return SIGBUS;
-					}
+			xcp->cp0_cause |= CAUSEF_BD;
+			if (cond) {
+				/* branch taken: emulate dslot instruction */
+				xcp->cp0_epc += 4;
+				contpc = REG_TO_VA xcp->cp0_epc +
+				         (MIPSInst_SIMM(ir) << 2);
+
+				ir = mips_get_word(xcp, REG_TO_VA(xcp->cp0_epc),
+				      &err);
+				if (err) {
+					fpuemuprivate.stats.errors++;
+					return SIGBUS;
+				}
 
-					switch (MIPSInst_OPCODE(ir)) {
-					case lwc1_op:
-					case swc1_op:
+				switch (MIPSInst_OPCODE(ir)) {
+				case lwc1_op:
+				case swc1_op:
 #if (__mips >= 2 || __mips64) && !defined(SINGLE_ONLY_FPU)
-					case ldc1_op:
-					case sdc1_op:
+				case ldc1_op:
+				case sdc1_op:
 #endif
-					case cop1_op:
+				case cop1_op:
 #if __mips >= 4 && __mips != 32
-					case cop1x_op:
+				case cop1x_op:
 #endif
-						/* its one of ours */
-						goto emul;
+					/* its one of ours */
+					goto emul;
 #if __mips >= 4
-					case spec_op:
-						if (MIPSInst_FUNC(ir) ==
-						    movc_op) goto emul;
-						break;
+				case spec_op:
+					if (MIPSInst_FUNC(ir) == movc_op)
+						goto emul;
+					break;
 #endif
-					}
+				}
 
-					/* single step the non-cp1 instruction in the dslot */
-					return mips_dsemul(xcp, ir,
-							   contpc);
-				} else {
-					/* branch not taken */
-					if (likely)
-						/* branch likely nullifies dslot if not taken */
-						xcp->cp0_epc += 4;
+				/*
+				 * Single step the non-cp1 instruction in the
+				 * dslot
+				 */
+				return mips_dsemul(xcp, ir, contpc);
+			} else {
+				/* branch not taken */
+				if (likely)
+					/*
+					 * branch likely nullifies dslot if not
+					 * taken
+					 */
+					xcp->cp0_epc += 4;
 					/* else continue & execute dslot as normal insn */
-				}
 			}
 			break;
+		}
 
-		default:
-			if (!(MIPSInst_RS(ir) & 0x10)) {
+		default: {
+			int sig;
+
+			if (!(MIPSInst_RS(ir) & 0x10))
 				return SIGILL;
-			}
+
 			/* a real fpu computation instruction */
-			{
-				int sig;
 				if ((sig = fpu_emu(xcp, ctx, ir)))
 					return sig;
 			}
@@ -822,14 +796,15 @@
 	 */
 	dsemul_insns = (mips_instruction *) (xcp->regs[29] & ~3);
 	dsemul_insns -= 3;	/* Two instructions, plus one for luck ;-) */
+
 	/* Verify that the stack pointer is not competely insane */
-	if (verify_area
-	    (VERIFY_WRITE, dsemul_insns, sizeof(mips_instruction) * 2))
+	if (verify_area(VERIFY_WRITE, dsemul_insns,
+	                sizeof(mips_instruction) * 2))
 		return SIGBUS;
 
 	if (mips_put_word(xcp, &dsemul_insns[0], ir)) {
 		fpuemuprivate.stats.errors++;
-		return (SIGBUS);
+		return SIGBUS;
 	}
 
 	/* 
@@ -856,11 +831,8 @@
 	current->thread.dsemul_epc = (unsigned long) cpc;
 	current->thread.dsemul_aerpc = (unsigned long) &dsemul_insns[1];
 	xcp->cp0_epc = VA_TO_REG & dsemul_insns[0];
+	flush_cache_sigtramp((unsigned long) dsemul_insns);
 
-	/* What we'd really like to do is just flush the line(s) of the */
-	/* icache containing the dsemulret instructions, but there's no */
-	/* mechanism to do this yet...  */
-	flush_cache_all();
 	return SIGILL;		/* force out of emulation loop */
 }
 
@@ -971,9 +943,8 @@
 	return ieee754sp_neg(ieee754sp_sub(ieee754sp_mul(s, t), r));
 }
 
-static int
-fpux_emu(struct pt_regs *xcp, struct mips_fpu_soft_struct *ctx,
-	 mips_instruction ir)
+static int fpux_emu(struct pt_regs *xcp, struct mips_fpu_soft_struct *ctx,
+                    mips_instruction ir)
 {
 	unsigned rcsr = 0;	/* resulting csr */
 
@@ -1226,9 +1197,8 @@
 /*
  * Emulate a single COP1 arithmetic instruction.
  */
-static int
-fpu_emu(struct pt_regs *xcp, struct mips_fpu_soft_struct *ctx,
-	mips_instruction ir)
+static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_soft_struct *ctx,
+                   mips_instruction ir)
 {
 	int rfmt;		/* resulting format */
 	unsigned rcsr = 0;	/* resulting csr */
@@ -1244,8 +1214,7 @@
 
 	fpuemuprivate.stats.cp1ops++;
 	switch (rfmt = (MIPSInst_FFMT(ir) & 0xf)) {
-
-	case s_fmt:{		/* 0 */
+	case s_fmt: {		/* 0 */
 		ieee754sp(*handler) ();
 
 		switch (MIPSInst_FUNC(ir)) {
@@ -1342,73 +1311,68 @@
 				/* unary conv ops */
 		case fcvts_op:
 			return SIGILL;	/* not defined */
-		case fcvtd_op:
-#if defined(SINGLE_ONLY_FPU)
+		case fcvtd_op: {
+#ifdef SINGLE_ONLY_FPU
 			return SIGILL;	/* not defined */
 #else
-			{
-				ieee754sp fs;
+			ieee754sp fs;
 
-				SPFROMREG(fs, MIPSInst_FS(ir));
-				rv.d = ieee754dp_fsp(fs);
-				rfmt = d_fmt;
-				goto copcsr;
-			}
+			SPFROMREG(fs, MIPSInst_FS(ir));
+			rv.d = ieee754dp_fsp(fs);
+			rfmt = d_fmt;
+			goto copcsr;
+		}
 #endif
-		case fcvtw_op:
-			{
-				ieee754sp fs;
+		case fcvtw_op: {
+			ieee754sp fs;
 
-				SPFROMREG(fs, MIPSInst_FS(ir));
-				rv.w = ieee754sp_tint(fs);
-				rfmt = w_fmt;
-				goto copcsr;
-			}
+			SPFROMREG(fs, MIPSInst_FS(ir));
+			rv.w = ieee754sp_tint(fs);
+			rfmt = w_fmt;
+			goto copcsr;
+		}
 
 #if __mips >= 2 || __mips64
 		case fround_op:
 		case ftrunc_op:
 		case fceil_op:
-		case ffloor_op:
-			{
-				unsigned int oldrm = ieee754_csr.rm;
-				ieee754sp fs;
-
-				SPFROMREG(fs, MIPSInst_FS(ir));
-				ieee754_csr.rm = ieee_rm[MIPSInst_FUNC(ir) & 0x3];
-				rv.w = ieee754sp_tint(fs);
-				ieee754_csr.rm = oldrm;
-				rfmt = w_fmt;
-				goto copcsr;
-			}
-#endif			/* __mips >= 2 */
+		case ffloor_op: {
+			unsigned int oldrm = ieee754_csr.rm;
+			ieee754sp fs;
+
+			SPFROMREG(fs, MIPSInst_FS(ir));
+			ieee754_csr.rm = ieee_rm[MIPSInst_FUNC(ir) & 0x3];
+			rv.w = ieee754sp_tint(fs);
+			ieee754_csr.rm = oldrm;
+			rfmt = w_fmt;
+			goto copcsr;
+		}
+#endif /* __mips >= 2 */
 
 #if __mips64 && !defined(SINGLE_ONLY_FPU)
-		case fcvtl_op:
-			{
-				ieee754sp fs;
+		case fcvtl_op: {
+			ieee754sp fs;
 
-				SPFROMREG(fs, MIPSInst_FS(ir));
-				rv.l = ieee754sp_tlong(fs);
-				rfmt = l_fmt;
-				goto copcsr;
-			}
+			SPFROMREG(fs, MIPSInst_FS(ir));
+			rv.l = ieee754sp_tlong(fs);
+			rfmt = l_fmt;
+			goto copcsr;
+		}
 
 		case froundl_op:
 		case ftruncl_op:
 		case fceill_op:
-		case ffloorl_op:
-			{
-				unsigned int oldrm = ieee754_csr.rm;
-				ieee754sp fs;
-
-				SPFROMREG(fs, MIPSInst_FS(ir));
-				ieee754_csr.rm = ieee_rm[MIPSInst_FUNC(ir) & 0x3];
-				rv.l = ieee754sp_tlong(fs);
-				ieee754_csr.rm = oldrm;
-				rfmt = l_fmt;
-				goto copcsr;
-			}
+		case ffloorl_op: {
+			unsigned int oldrm = ieee754_csr.rm;
+			ieee754sp fs;
+
+			SPFROMREG(fs, MIPSInst_FS(ir));
+			ieee754_csr.rm = ieee_rm[MIPSInst_FUNC(ir) & 0x3];
+			rv.l = ieee754sp_tlong(fs);
+			ieee754_csr.rm = oldrm;
+			rfmt = l_fmt;
+			goto copcsr;
+		}
 #endif /* __mips64 && !fpu(single) */
 
 		default:
@@ -1484,9 +1448,11 @@
 		case fabs_op:
 			handler = ieee754dp_abs;
 			goto dcopuop;
+
 		case fneg_op:
 			handler = ieee754dp_neg;
 			goto dcopuop;
+
 		case fmov_op:
 			/* an easy one */
 			DPFROMREG(rv.d, MIPSInst_FS(ir));
@@ -1513,71 +1479,67 @@
 			}
 
 		/* unary conv ops */
-		case fcvts_op:
-			{
-				ieee754dp fs;
+		case fcvts_op: {
+			ieee754dp fs;
 
-				DPFROMREG(fs, MIPSInst_FS(ir));
-				rv.s = ieee754sp_fdp(fs);
-				rfmt = s_fmt;
-				goto copcsr;
-			}
+			DPFROMREG(fs, MIPSInst_FS(ir));
+			rv.s = ieee754sp_fdp(fs);
+			rfmt = s_fmt;
+			goto copcsr;
+		}
 		case fcvtd_op:
 			return SIGILL;	/* not defined */
-		case fcvtw_op:
-			{
-				ieee754dp fs;
 
-				DPFROMREG(fs, MIPSInst_FS(ir));
-				rv.w = ieee754dp_tint(fs);	/* wrong */
-				rfmt = w_fmt;
-				goto copcsr;
-			}
+		case fcvtw_op: {
+			ieee754dp fs;
+
+			DPFROMREG(fs, MIPSInst_FS(ir));
+			rv.w = ieee754dp_tint(fs);	/* wrong */
+			rfmt = w_fmt;
+			goto copcsr;
+		}
 
 #if __mips >= 2 || __mips64
 		case fround_op:
 		case ftrunc_op:
 		case fceil_op:
-		case ffloor_op:
-			{
-				unsigned int oldrm = ieee754_csr.rm;
-				ieee754dp fs;
-
-				DPFROMREG(fs, MIPSInst_FS(ir));
-				ieee754_csr.rm = ieee_rm[MIPSInst_FUNC(ir) & 0x3];
-				rv.w = ieee754dp_tint(fs);
-				ieee754_csr.rm = oldrm;
-				rfmt = w_fmt;
-				goto copcsr;
-			}
+		case ffloor_op: {
+			unsigned int oldrm = ieee754_csr.rm;
+			ieee754dp fs;
+
+			DPFROMREG(fs, MIPSInst_FS(ir));
+			ieee754_csr.rm = ieee_rm[MIPSInst_FUNC(ir) & 0x3];
+			rv.w = ieee754dp_tint(fs);
+			ieee754_csr.rm = oldrm;
+			rfmt = w_fmt;
+			goto copcsr;
+		}
 #endif
 
 #if __mips64 && !defined(SINGLE_ONLY_FPU)
-		case fcvtl_op:
-			{
-				ieee754dp fs;
+		case fcvtl_op: {
+			ieee754dp fs;
 
-				DPFROMREG(fs, MIPSInst_FS(ir));
-				rv.l = ieee754dp_tlong(fs);
-				rfmt = l_fmt;
-				goto copcsr;
-			}
+			DPFROMREG(fs, MIPSInst_FS(ir));
+			rv.l = ieee754dp_tlong(fs);
+			rfmt = l_fmt;
+			goto copcsr;
+		}
 
 		case froundl_op:
 		case ftruncl_op:
 		case fceill_op:
-		case ffloorl_op:
-			{
-				unsigned int oldrm = ieee754_csr.rm;
-				ieee754dp fs;
-
-				DPFROMREG(fs, MIPSInst_FS(ir));
-				ieee754_csr.rm = ieee_rm[MIPSInst_FUNC(ir) & 0x3];
-				rv.l = ieee754dp_tlong(fs);
-				ieee754_csr.rm = oldrm;
-				rfmt = l_fmt;
-				goto copcsr;
-			}
+		case ffloorl_op: {
+			unsigned int oldrm = ieee754_csr.rm;
+			ieee754dp fs;
+
+			DPFROMREG(fs, MIPSInst_FS(ir));
+			ieee754_csr.rm = ieee_rm[MIPSInst_FUNC(ir) & 0x3];
+			rv.l = ieee754dp_tlong(fs);
+			ieee754_csr.rm = oldrm;
+			rfmt = l_fmt;
+			goto copcsr;
+		}
 #endif /* __mips >= 3 && !fpu(single) */
 
 		default:
@@ -1598,7 +1560,7 @@
 		}
 		break;
 	}
-#endif				/* !defined(SINGLE_ONLY_FPU) */
+#endif /* !defined(SINGLE_ONLY_FPU) */
 
 	case w_fmt: {
 		switch (MIPSInst_FUNC(ir)) {
@@ -1698,12 +1660,11 @@
 
 
 /*
- * Emulate the floating point instruction at EPC, and continue
- * to run until we hit a non-fp instruction, or a backward
- * branch.  This cuts down dramatically on the per instruction 
- * exception overhead.
+ * Emulate the floating point instruction at EPC, and continue to run until we
+ * hit a non-fp instruction, or a backward branch.  This cuts down dramatically
+ * on the per instruction exception overhead.
  */
-int fpu_emulator_cop1Handler(int xcptno, struct pt_regs *xcp)
+int fpu_emulator_cop1Handler(struct pt_regs *xcp)
 {
 	struct mips_fpu_soft_struct *ctx = &current->thread.fpu.soft;
 	unsigned long oldepc, prevepc;
@@ -1713,6 +1674,9 @@
 
 	oldepc = xcp->cp0_epc;
 	do {
+		if (current->need_resched)
+			schedule();
+
 		prevepc = xcp->cp0_epc;
 		insn = mips_get_word(xcp, REG_TO_VA(xcp->cp0_epc), &err);
 		if (err) {
@@ -1720,9 +1684,12 @@
 			return SIGBUS;
 		}
 		if (insn != 0)
-			sig = cop1Emulate(xcptno, xcp, ctx);
+			sig = cop1Emulate(xcp, ctx);
 		else
 			xcp->cp0_epc += 4;	/* skip nops */
+
+		if (mips_cpu.options & MIPS_CPU_FPU)
+			break;
 	} while (xcp->cp0_epc > prevepc && sig == 0);
 
 	/* SIGILL indicates a non-fpu instruction */
@@ -1753,7 +1720,7 @@
 
 	/* get current rounding mode for IEEE library, and emulate insn */
 	ieee754_csr.rm = ieee_rm[ctx->sr & 0x3];
-	sig = cop1Emulate(xcptno, xcp, ctx);
+	sig = cop1Emulate(xcp, ctx);
 
 	/* don't return with f.p. exceptions pending */
 	ctx->sr &= ~FPU_CSR_ALL_X;
@@ -1809,4 +1776,3 @@
 	}
 }
 #endif
-
diff -u --recursive --new-file v2.4.9/linux/arch/mips/mips-boards/atlas/atlas_int.c linux/arch/mips/mips-boards/atlas/atlas_int.c
--- v2.4.9/linux/arch/mips/mips-boards/atlas/atlas_int.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/mips-boards/atlas/atlas_int.c	Sun Sep  9 10:43:02 2001
@@ -51,6 +51,11 @@
 #define DEBUG_INT(x...)
 #endif
 
+void inline disable_irq_nosync(unsigned int irq_nr)
+{
+	disable_atlas_irq(irq_nr);
+}
+
 void disable_atlas_irq(unsigned int irq_nr)
 {
 	atlas_hw0_icregs->intrsten = (1 << irq_nr);
diff -u --recursive --new-file v2.4.9/linux/arch/mips/mips-boards/atlas/atlas_rtc.c linux/arch/mips/mips-boards/atlas/atlas_rtc.c
--- v2.4.9/linux/arch/mips/mips-boards/atlas/atlas_rtc.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/mips-boards/atlas/atlas_rtc.c	Sun Sep  9 10:43:02 2001
@@ -22,7 +22,6 @@
  * RTC routines for Atlas style attached Dallas chip.
  *
  */
-#include <linux/spinlock.h>
 #include <linux/mc146818rtc.h>
 #include <asm/mips-boards/atlas.h>
 
diff -u --recursive --new-file v2.4.9/linux/arch/mips/mips-boards/atlas/atlas_setup.c linux/arch/mips/mips-boards/atlas/atlas_setup.c
--- v2.4.9/linux/arch/mips/mips-boards/atlas/atlas_setup.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/mips-boards/atlas/atlas_setup.c	Sun Sep  9 10:43:02 2001
@@ -54,8 +54,8 @@
 	char rs_getDebugChar(void);
 	int saa9730_putDebugChar(char);
 	char saa9730_getDebugChar(void);
-	extern int (*putDebugChar)(char);
-	extern char (*getDebugChar)(void);
+	extern int (*generic_putDebugChar)(char);
+	extern char (*generic_getDebugChar)(void);
 #endif
 	char *argptr;
 
@@ -89,12 +89,12 @@
 
 		if(line == 0) {
 			rs_kgdb_hook(line);
-			putDebugChar = rs_putDebugChar;
-			getDebugChar = rs_getDebugChar;
+			generic_putDebugChar = rs_putDebugChar;
+			generic_getDebugChar = rs_getDebugChar;
 		} else {
 			saa9730_kgdb_hook();
-			putDebugChar = saa9730_putDebugChar;
-			getDebugChar = saa9730_getDebugChar;
+			generic_putDebugChar = saa9730_putDebugChar;
+			generic_getDebugChar = saa9730_getDebugChar;
 		}
 
 		prom_printf("KGDB: Using serial line /dev/ttyS%d for session, "
diff -u --recursive --new-file v2.4.9/linux/arch/mips/mips-boards/generic/cmdline.c linux/arch/mips/mips-boards/generic/cmdline.c
--- v2.4.9/linux/arch/mips/mips-boards/generic/cmdline.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/mips-boards/generic/cmdline.c	Sun Sep  9 10:43:02 2001
@@ -17,6 +17,7 @@
  *
  * Kernel command line creation using the prom monitor (YAMON) argc/argv.
  */
+#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/string.h>
 
diff -u --recursive --new-file v2.4.9/linux/arch/mips/mips-boards/generic/gdb_hook.c linux/arch/mips/mips-boards/generic/gdb_hook.c
--- v2.4.9/linux/arch/mips/mips-boards/generic/gdb_hook.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/mips-boards/generic/gdb_hook.c	Sun Sep  9 10:43:02 2001
@@ -23,7 +23,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/serialP.h>
 #include <linux/serial_reg.h>
 
@@ -36,8 +35,8 @@
 
 static struct async_struct kdb_port_info = {0};
 
-int (*putDebugChar)(char);
-char (*getDebugChar)(void);
+int (*generic_putDebugChar)(char);
+char (*generic_getDebugChar)(void);
 
 static __inline__ unsigned int serial_in(struct async_struct *info, int offset)
 {
@@ -96,6 +95,16 @@
 	serial_out(&kdb_port_info, UART_DLM, t >> 8);  /* MS of divisor */
 	/* reset DLAB */
 	serial_out(&kdb_port_info, UART_LCR, UART_LCR_WLEN8);
+}
+
+int putDebugChar(char c)
+{
+	return generic_putDebugChar(c);
+}
+
+char getDebugChar(void) 
+{
+	return generic_getDebugChar();
 }
 
 int rs_putDebugChar(char c)
diff -u --recursive --new-file v2.4.9/linux/arch/mips/mips-boards/generic/memory.c linux/arch/mips/mips-boards/generic/memory.c
--- v2.4.9/linux/arch/mips/mips-boards/generic/memory.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/mips-boards/generic/memory.c	Sun Sep  9 10:43:02 2001
@@ -50,6 +50,11 @@
 };
 #endif
 
+/* References to section boundaries */
+extern char _end;
+
+#define PFN_ALIGN(x)    (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
+
 
 struct prom_pmemblock * __init prom_getmdesc(void)
 {
@@ -94,9 +99,13 @@
 	mdesc[2].size = 0x00010000;
 #endif
 
-	mdesc[3].type = yamon_free;
+	mdesc[3].type = yamon_dontuse;
 	mdesc[3].base = 0x00100000;
-	mdesc[3].size = memsize - mdesc[3].base;
+	mdesc[3].size = PHYSADDR(PFN_ALIGN(&_end)) - mdesc[3].base;
+
+	mdesc[4].type = yamon_free;
+	mdesc[4].base = PHYSADDR(PFN_ALIGN(&_end));
+	mdesc[4].size = memsize - mdesc[4].base;
 
 	return &mdesc[0];
 }
@@ -118,11 +127,10 @@
 	struct prom_pmemblock *p;
 
 #ifdef DEBUG
-	int i = 0;
-
 	prom_printf("YAMON MEMORY DESCRIPTOR dump:\n");
 	p = prom_getmdesc();
 	while (p->size) {
+		int i = 0;
 		prom_printf("[%d,%p]: base<%08lx> size<%08lx> type<%s>\n",
 			    i, p, p->base, p->size, mtypes[p->type]);
 		p++;
@@ -130,24 +138,24 @@
 	}
 #endif
 	p = prom_getmdesc();
+
 	while (p->size) {
-		unsigned long base, size;
 		long type;
+		unsigned long base, size;
 
 		type = prom_memtype_classify (p->type);
 		base = p->base;
 		size = p->size;
 
 		add_memory_region(base, size, type);
-
-		p++;
+                p++; 
 	}
 }
 
-void prom_free_prom_memory (void)
+void __init
+prom_free_prom_memory (void)
 {
 	int i;
-	struct prom_pmemblock *p;
 	unsigned long freed = 0;
 	unsigned long addr;
 
@@ -158,9 +166,9 @@
 		addr = boot_mem_map.map[i].addr;
 		while (addr < boot_mem_map.map[i].addr
 			      + boot_mem_map.map[i].size) {
-		        ClearPageReserved(virt_to_page(phys_to_virt(addr)));
-			set_page_count(virt_to_page(phys_to_virt(addr)), 1);
-			free_page(phys_to_virt(addr));
+			ClearPageReserved(virt_to_page(__va(addr)));
+			set_page_count(virt_to_page(__va(addr)), 1);
+			free_page(__va(addr));
 			addr += PAGE_SIZE;
 			freed += PAGE_SIZE;
 		}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/mips-boards/generic/pci.c linux/arch/mips/mips-boards/generic/pci.c
--- v2.4.9/linux/arch/mips/mips-boards/generic/pci.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/mips-boards/generic/pci.c	Sun Sep  9 10:43:02 2001
@@ -325,4 +325,9 @@
 	pci_read_bridge_bases(b);
 }
 
+unsigned __init int pcibios_assign_all_busses(void)
+{
+	return 1;
+}
+
 #endif /* CONFIG_PCI */
diff -u --recursive --new-file v2.4.9/linux/arch/mips/mips-boards/generic/time.c linux/arch/mips/mips-boards/generic/time.c
--- v2.4.9/linux/arch/mips/mips-boards/generic/time.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/mips-boards/generic/time.c	Sun Sep  9 10:43:02 2001
@@ -275,7 +275,7 @@
 
 /* This is for machines which generate the exact clock. */
 #define USECS_PER_JIFFY (1000000/HZ)
-#define USECS_PER_JIFFY_FRAC (0x100000000*1000000/HZ&0xffffffff)
+#define USECS_PER_JIFFY_FRAC ((1000000 << 32) / HZ & 0xffffffff)
 
 /* Cycle counter value at the previous timer interrupt.. */
 
diff -u --recursive --new-file v2.4.9/linux/arch/mips/mips-boards/malta/malta_int.c linux/arch/mips/mips-boards/malta/malta_int.c
--- v2.4.9/linux/arch/mips/mips-boards/malta/malta_int.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/mips-boards/malta/malta_int.c	Sun Sep  9 10:43:02 2001
@@ -1,6 +1,7 @@
 /*
  * Carsten Langgaard, carstenl@mips.com
- * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ * Copyright (C) 2000, 2001 MIPS Technologies, Inc.
+ * Copyright (C) 2001 Ralf Baechle
  *
  *  This program is free software; you can distribute it and/or modify it
  *  under the terms of the GNU General Public License (Version 2) as
@@ -20,6 +21,7 @@
  * The interrupt controller is located in the South Bridge a PIIX4 device 
  * with two internal 82C95 interrupt controllers.
  */
+#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
@@ -37,342 +39,42 @@
 
 extern asmlinkage void mipsIRQ(void);
 
-unsigned int local_bh_count[NR_CPUS];
-unsigned int local_irq_count[NR_CPUS];
-unsigned long spurious_count = 0;
-
-static struct irqaction *hw0_irq_action[MALTAINT_END] = {
-	NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL
-};
-
-static struct irqaction r4ktimer_action = {
-	NULL, 0, 0, "R4000 timer/counter", NULL, NULL,
-};
-
-static struct irqaction *irq_action[8] = {
-	NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, &r4ktimer_action
-};
-
-#if 0
-#define DEBUG_INT(x...) printk(x)
-#else
-#define DEBUG_INT(x...)
-#endif
-
-/*
- * This contains the interrupt mask for both 82C59 interrupt controllers.
- */
-static unsigned int cached_int_mask = 0xffff;
-
-
-void disable_irq(unsigned int irq_nr)
-{
-        unsigned long flags;
-
-	if(irq_nr >= MALTAINT_END) {
-		printk("whee, invalid irq_nr %d\n", irq_nr);
-		panic("IRQ, you lose...");
-	}
-
-	save_and_cli(flags);
-	cached_int_mask |= (1 << irq_nr);
-	if (irq_nr & 8) {
-	        outb((cached_int_mask >> 8) & 0xff, PIIX4_ICTLR2_OCW1);
-	} else {
-		outb(cached_int_mask & 0xff, PIIX4_ICTLR1_OCW1);
-	}
-	restore_flags(flags);
-}
-
-
-void enable_irq(unsigned int irq_nr)
-{
-        unsigned long flags;
-
-	if(irq_nr >= MALTAINT_END) {
-		printk("whee, invalid irq_nr %d\n", irq_nr);
-		panic("IRQ, you lose...");
-	}
-
-	save_and_cli(flags);
-	cached_int_mask &= ~(1 << irq_nr);
-	if (irq_nr & 8) {
-		outb((cached_int_mask >> 8) & 0xff, PIIX4_ICTLR2_OCW1);
-
-		/* Enable irq 2 (cascade interrupt). */
-	        cached_int_mask &= ~(1 << 2); 
-		outb(cached_int_mask & 0xff, PIIX4_ICTLR1_OCW1);
-	} else {
-		outb(cached_int_mask & 0xff, PIIX4_ICTLR1_OCW1);
-	}	
-	restore_flags(flags);
-}
-
-
-int get_irq_list(char *buf)
-{
-	int i, len = 0;
-	int num = 0;
-	struct irqaction *action;
-
-	for (i = 0; i < 8; i++, num++) {
-		action = irq_action[i];
-		if (!action) 
-			continue;
-		len += sprintf(buf+len, "%2d: %8d %c %s",
-			num, kstat.irqs[0][num],
-			(action->flags & SA_INTERRUPT) ? '+' : ' ',
-			action->name);
-		for (action=action->next; action; action = action->next) {
-			len += sprintf(buf+len, ",%s %s",
-				(action->flags & SA_INTERRUPT) ? " +" : "",
-				action->name);
-		}
-		len += sprintf(buf+len, " [on-chip]\n");
-	}
-	for (i = 0; i < MALTAINT_END; i++, num++) {
-		action = hw0_irq_action[i];
-		if (!action) 
-			continue;
-		len += sprintf(buf+len, "%2d: %8d %c %s",
-			num, kstat.irqs[0][num],
-			(action->flags & SA_INTERRUPT) ? '+' : ' ',
-			action->name);
-		for (action=action->next; action; action = action->next) {
-			len += sprintf(buf+len, ",%s %s",
-				(action->flags & SA_INTERRUPT) ? " +" : "",
-				action->name);
-		}
-		len += sprintf(buf+len, " [hw0]\n");
-	}
-	return len;
-}
-
-
-static int setup_irq(unsigned int irq, struct irqaction * new)
-{
-	int shared = 0;
-	struct irqaction *old, **p;
-
-	p = &hw0_irq_action[irq];
-	if ((old = *p) != NULL) {
-		/* Can't share interrupts unless both agree to */
-		if (!(old->flags & new->flags & SA_SHIRQ))
-			return -EBUSY;
-
-		/* Can't share interrupts unless both are same type */
-		if ((old->flags ^ new->flags) & SA_INTERRUPT)
-			return -EBUSY;
-
-		/* add new interrupt at end of irq queue */
-		do {
-			p = &old->next;
-			old = *p;
-		} while (old);
-		shared = 1;
-	}
-
-	if (new->flags & SA_SAMPLE_RANDOM)
-		rand_initialize_irq(irq);
-
-	*p = new;
-	if (!shared)
-		enable_irq(irq);
-
-	return 0;
-}
-
-int request_irq(unsigned int irq, 
-		void (*handler)(int, void *, struct pt_regs *),
-		unsigned long irqflags, 
-		const char * devname,
-		void *dev_id)
-{  
-        struct irqaction *action;
-	int retval;
-
-	DEBUG_INT("request_irq: irq=%d, devname = %s\n", irq, devname);
-
-        if (irq >= MALTAINT_END)
-	        return -EINVAL;
-	if (!handler)
-	        return -EINVAL;
-
-	action = (struct irqaction *)kmalloc(sizeof(struct irqaction), GFP_KERNEL);
-	if(!action)
-	        return -ENOMEM;
-
-	action->handler = handler;
-	action->flags = irqflags;
-	action->mask = 0;
-	action->name = devname;
-	action->dev_id = dev_id;
-	action->next = 0;
-
-	retval = setup_irq(irq, action);
-	if (retval)
-		kfree(action);
-
-	return retval;	
-}
-
-
-void free_irq(unsigned int irq, void *dev_id)
-{
-	struct irqaction *action, **p;
-
-	if (irq >= MALTAINT_END) {
-		printk("Trying to free IRQ%d\n",irq);
-		return;
-	}
-	
-	for (p = &hw0_irq_action[irq]; (action = *p) != NULL; 
-	     p = &action->next) 
-	{
-		if (action->dev_id != dev_id)
-			continue;
-
-		/* Found it - now free it */
-		*p = action->next;
-		kfree(action);
-		if (!hw0_irq_action[irq])
-			disable_irq(irq);
-		return;
-	}
-	printk("Trying to free IRQ%d\n",irq);
-}
-
-void __init init_IRQ(void)
+void malta_hw0_irqdispatch(struct pt_regs *regs)
 {
-	irq_setup();
-}
+	int irq;
 
-static inline int get_int(int *irq)
-{
 	/*  
-	 * Determine highest priority pending interrupt by performing
-         * a PCI Interrupt Acknowledge cycle.
+	 * Determine highest priority pending interrupt by performing a PCI
+	 * Interrupt Acknowledge cycle.
 	 */
-	GT_READ(GT_PCI0_IACK_OFS, *irq);
-	*irq &= 0xFF;
+	GT_READ(GT_PCI0_IACK_OFS, irq);
+	irq &= 0xFF;
 
 	/*  
-	 * IRQ7 is used to detect spurious interrupts.
-	 * The interrupt acknowledge cycle returns IRQ7, if no 
-	 * interrupts is requested.
-	 * We can differentiate between this situation and a
-	 * "Normal" IRQ7 by reading the ISR.
+	 * IRQ7 is used to detect spurious interrupts.  The interrupt
+	 * acknowledge cycle returns IRQ7, if no interrupts is requested.  We
+	 * can differentiate between this situation and a "normal" IRQ7 by
+	 * reading the ISR.
 	 */
-	if (*irq == 7) 
-	{
+	if (irq == 7) {
 		outb(PIIX4_OCW3_SEL | PIIX4_OCW3_ISR, PIIX4_ICTLR1_OCW3);
 		if (!(inb(PIIX4_ICTLR1_OCW3) & (1 << 7)))
-		        return -1;    /* Spurious interrupt. */
-	}
-
-	return 0;
-}
-
-static inline void ack_int(int irq)
-{
-	if (irq & 8) {
-	        /* Specific EOI to cascade */
-		outb(PIIX4_OCW2_SEL | PIIX4_OCW2_NSEOI | PIIX4_OCW2_ILS_2, 
-		     PIIX4_ICTLR1_OCW2);
-
-	        /* Non specific EOI to cascade */
-		outb(PIIX4_OCW2_SEL | PIIX4_OCW2_NSEOI, PIIX4_ICTLR2_OCW2);
-	} else {
-	        /* Non specific EOI to cascade */
-		outb(PIIX4_OCW2_SEL | PIIX4_OCW2_NSEOI, PIIX4_ICTLR1_OCW2);
+		        return;    /* Spurious interrupt. */
 	}
-}
-
-void malta_hw0_irqdispatch(struct pt_regs *regs)
-{
-        struct irqaction *action;
-	int irq=0, cpu = smp_processor_id();
-
-	DEBUG_INT("malta_hw0_irqdispatch\n");
-	
-	if (get_int(&irq))
-	        return;  /* interrupt has already been cleared */
 
-	disable_irq(irq);
-	ack_int(irq);
-
-	DEBUG_INT("malta_hw0_irqdispatch: irq=%d\n", irq);
-	action = hw0_irq_action[irq];
-
-	/* 
-	 * if action == NULL, then we don't have a handler 
-	 * for the irq 
-	 */
-	if ( action == NULL )
-		return;
-
-	irq_enter(cpu, irq);
-	kstat.irqs[0][irq + 8]++;
-	do {
-	        action->handler(irq, action->dev_id, regs);
-		action = action->next;
-	} while (action);
-
-	enable_irq(irq);
-	irq_exit(cpu, irq);
+	do_IRQ(irq, regs);
 }
 
-
-unsigned long probe_irq_on (void)
+void __init init_IRQ(void)
 {
-	unsigned int i, irqs = 0;
-	unsigned long delay;
+	set_except_vector(0, mipsIRQ);
+	init_generic_irq();
+	init_i8259_irqs();
 
-	/* first, enable any unassigned irqs */
-	for (i = MALTAINT_END-1; i > 0; i--) {
-		if (!hw0_irq_action[i]) {
-			enable_irq(i);
-			irqs |= (1 << i);
-		}
+#ifdef CONFIG_REMOTE_DEBUG
+	if (remote_debug) {
+		set_debug_traps();
+		breakpoint();
 	}
-
-	/* wait for spurious interrupts to mask themselves out again */
-	for (delay = jiffies + HZ/10; time_before(jiffies, delay); )
-		/* about 100ms delay */;
-
-	/* now filter out any obviously spurious interrupts */
-	return irqs & ~cached_int_mask;
-}
-
-
-int probe_irq_off (unsigned long irqs)
-{
-	unsigned int i;
-
-	irqs &= cached_int_mask;
-	if (!irqs)
-		return 0;
-	i = ffz(~irqs);
-	if (irqs != (irqs & (1 << i)))
-		i = -i;
-
-	return i;
-}
-
-
-void __init maltaint_init(void)
-{
-        /* 
-	 * Mask out all interrupt by writing "1" to all bit position in 
-	 * the IMR register. 
-	 */
-	outb(cached_int_mask & 0xff, PIIX4_ICTLR1_OCW1);
-	outb((cached_int_mask >> 8) & 0xff, PIIX4_ICTLR2_OCW1);
-
-	/* Now safe to set the exception vector. */
-	set_except_vector(0, mipsIRQ);
+#endif
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips/mips-boards/malta/malta_rtc.c linux/arch/mips/mips-boards/malta/malta_rtc.c
--- v2.4.9/linux/arch/mips/mips-boards/malta/malta_rtc.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/mips-boards/malta/malta_rtc.c	Sun Sep  9 10:43:02 2001
@@ -23,7 +23,6 @@
  * Motorola MC146818A-compatible Real Time Clock.
  *
  */
-#include <linux/spinlock.h>
 #include <linux/mc146818rtc.h>
 #include <asm/mips-boards/malta.h>
 
diff -u --recursive --new-file v2.4.9/linux/arch/mips/mips-boards/malta/malta_setup.c linux/arch/mips/mips-boards/malta/malta_setup.c
--- v2.4.9/linux/arch/mips/mips-boards/malta/malta_setup.c	Fri Apr 13 20:26:07 2001
+++ linux/arch/mips/mips-boards/malta/malta_setup.c	Sun Sep  9 10:43:02 2001
@@ -2,8 +2,6 @@
  * Carsten Langgaard, carstenl@mips.com
  * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
  *
- * ########################################################################
- *
  *  This program is free software; you can distribute it and/or modify it
  *  under the terms of the GNU General Public License (Version 2) as
  *  published by the Free Software Foundation.
@@ -16,11 +14,6 @@
  *  You should have received a copy of the GNU General Public License along
  *  with this program; if not, write to the Free Software Foundation, Inc.,
  *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * ########################################################################
- *
- * Malta specific setup, including init of the feature struct.
- *
  */
 #include <linux/config.h>
 #include <linux/init.h>
@@ -56,53 +49,33 @@
 static int remote_debug = 0;
 #endif
 
-#ifdef CONFIG_BLK_DEV_IDE
 extern struct ide_ops std_ide_ops;
-#endif
-#ifdef CONFIG_BLK_DEV_FD
 extern struct fd_ops std_fd_ops;
-#endif
 extern struct rtc_ops malta_rtc_ops;
+extern struct kbd_ops std_kbd_ops;
 
 extern void mips_reboot_setup(void);
 
 struct resource standard_io_resources[] = {
 	{ "dma1", 0x00, 0x1f, IORESOURCE_BUSY },
-	{ "pic1", 0x20, 0x3f, IORESOURCE_BUSY },
 	{ "timer", 0x40, 0x5f, IORESOURCE_BUSY },
 	{ "dma page reg", 0x80, 0x8f, IORESOURCE_BUSY },
-	{ "pic2", 0xa0, 0xbf, IORESOURCE_BUSY },
 	{ "dma2", 0xc0, 0xdf, IORESOURCE_BUSY },
 };
 
 #define STANDARD_IO_RESOURCES (sizeof(standard_io_resources)/sizeof(struct resource))
 
-static void __init malta_irq_setup(void)
-{
-  	maltaint_init();
-
-#ifdef CONFIG_REMOTE_DEBUG
-	if (remote_debug) {
-		set_debug_traps();
-		breakpoint(); 
-	}
-#endif
-}
-
-
 void __init malta_setup(void)
 {
 #ifdef CONFIG_REMOTE_DEBUG
 	int rs_putDebugChar(char);
 	char rs_getDebugChar(void);
-	extern int (*putDebugChar)(char);
-	extern char (*getDebugChar)(void);
+	extern int (*generic_putDebugChar)(char);
+	extern char (*generic_getDebugChar)(void);
 #endif
 	char *argptr;
 	int i;
 
-	irq_setup = malta_irq_setup;
-
 	/* Request I/O space for devices used on the Malta board. */
 	for (i = 0; i < STANDARD_IO_RESOURCES; i++)
 		request_resource(&ioport_resource, standard_io_resources+i);
@@ -133,14 +106,14 @@
 		       line ? 1 : 0);
 
 		rs_kgdb_hook(line);
-		putDebugChar = rs_putDebugChar;
-		getDebugChar = rs_getDebugChar;
+		generic_putDebugChar = rs_putDebugChar;
+		generic_getDebugChar = rs_getDebugChar;
 
 		prom_printf("KGDB: Using serial line /dev/ttyS%d for session, "
 			    "please connect your debugger\n", line ? 1 : 0);
 
 		remote_debug = 1;
-		/* Breakpoints and stuff are in malta_irq_setup() */
+		/* Breakpoints are in init_IRQ() */
 	}
 #endif
 
@@ -154,6 +127,9 @@
 #endif
 #ifdef CONFIG_BLK_DEV_FD
         fd_ops = &std_fd_ops;
+#endif
+#ifdef CONFIG_PC_KEYB
+	kbd_ops = &std_kbd_ops;
 #endif
 	mips_reboot_setup();
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips/mm/Makefile linux/arch/mips/mm/Makefile
--- v2.4.9/linux/arch/mips/mm/Makefile	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips/mm/Makefile	Sun Sep  9 10:43:02 2001
@@ -15,11 +15,13 @@
 obj-$(CONFIG_CPU_R3000)		+= r2300.o
 obj-$(CONFIG_CPU_R4300)		+= r4xx0.o
 obj-$(CONFIG_CPU_R4X00)		+= r4xx0.o
+obj-$(CONFIG_CPU_VR41XX)	+= r4xx0.o
 obj-$(CONFIG_CPU_R5000)		+= r4xx0.o
 obj-$(CONFIG_CPU_NEVADA)	+= r4xx0.o
 obj-$(CONFIG_CPU_R5432)		+= r5432.o
 obj-$(CONFIG_CPU_RM7000)	+= rm7k.o
 obj-$(CONFIG_CPU_MIPS32)	+= mips32.o
+obj-$(CONFIG_CPU_MIPS64)	+= mips32.o
 obj-$(CONFIG_SGI_IP22)		+= umap.o
 obj-$(CONFIG_BAGET_MIPS)	+= umap.o
 
diff -u --recursive --new-file v2.4.9/linux/arch/mips/mm/andes.c linux/arch/mips/mm/andes.c
--- v2.4.9/linux/arch/mips/mm/andes.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips/mm/andes.c	Sun Sep  9 10:43:02 2001
@@ -132,7 +132,8 @@
 
 static void andes_flush_cache_sigtramp(unsigned long page)
 {
-	/* XXX */
+	protected_writeback_dcache_line(addr & ~(dc_lsize - 1));
+	protected_flush_icache_line(addr & ~(ic_lsize - 1));
 }
 
 /* TLB operations. XXX Write these dave... */
@@ -182,6 +183,14 @@
 	_flush_icache_page = andes_flush_icache_page;
 	_flush_icache_range = andes_flush_icache_range;
 
+	write_32bit_cp0_register(CP0_FRAMEMASK, 0);
+
 	flush_cache_all();
 	flush_tlb_all();
+
+	/*
+	 * The R10k might even work for Linux/MIPS - but we're paranoid
+	 * and refuse to run until this is tested on real silicon
+	 */
+	panic("CPU too expensive - making holiday in the ANDES!");
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips/mm/loadmmu.c linux/arch/mips/mm/loadmmu.c
--- v2.4.9/linux/arch/mips/mm/loadmmu.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips/mm/loadmmu.c	Sun Sep  9 10:43:02 2001
@@ -52,8 +52,9 @@
 {
 
 	if (mips_cpu.options & MIPS_CPU_4KTLB) {
-#if defined(CONFIG_CPU_R4X00) || defined(CONFIG_CPU_R4300) || \
-    defined(CONFIG_CPU_R5000) || defined(CONFIG_CPU_NEVADA)
+#if defined(CONFIG_CPU_R4X00) || defined(CONFIG_CPU_VR41XX) || \
+    defined(CONFIG_CPU_R4300) || defined(CONFIG_CPU_R5000) || \
+    defined(CONFIG_CPU_NEVADA)
 		printk("Loading R4000 MMU routines.\n");
 		ld_mmu_r4xx0();
 #endif
@@ -66,7 +67,7 @@
 		ld_mmu_r5432();
 #endif
 
-#if defined(CONFIG_CPU_MIPS32)
+#if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64)
 		printk("Loading MIPS32 MMU routines.\n");
 		ld_mmu_mips32();
 #endif
diff -u --recursive --new-file v2.4.9/linux/arch/mips/mm/mips32.c linux/arch/mips/mm/mips32.c
--- v2.4.9/linux/arch/mips/mm/mips32.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips/mm/mips32.c	Sun Sep  9 10:43:02 2001
@@ -69,10 +69,8 @@
 {
 	unsigned long i;
 
-        if (mips_cpu.options & MIPS_CPU_CACHE_CDEX)
-	{
-	        for (i=page; i<page+PAGE_SIZE; i+=dc_lsize)
-		{
+        if (mips_cpu.options & MIPS_CPU_CACHE_CDEX) {
+	        for (i=page; i<page+PAGE_SIZE; i+=dc_lsize) {
 		        __asm__ __volatile__(
 			        ".set\tnoreorder\n\t"
 				".set\tnoat\n\t"
@@ -94,10 +92,8 @@
 {
 	unsigned long i;
 
-        if (mips_cpu.options & MIPS_CPU_CACHE_CDEX)
-	{
-	        for (i=page; i<page+PAGE_SIZE; i+=sc_lsize)
-		{
+        if (mips_cpu.options & MIPS_CPU_CACHE_CDEX) {
+	        for (i=page; i<page+PAGE_SIZE; i+=sc_lsize) {
 		        __asm__ __volatile__(
 				".set\tnoreorder\n\t"
 				".set\tnoat\n\t"
@@ -119,10 +115,8 @@
 {
 	unsigned long i;
 
-        if (mips_cpu.options & MIPS_CPU_CACHE_CDEX)
-	{
-	        for (i=to; i<to+PAGE_SIZE; i+=dc_lsize)
-		{
+        if (mips_cpu.options & MIPS_CPU_CACHE_CDEX) {
+	        for (i=to; i<to+PAGE_SIZE; i+=dc_lsize) {
 		        __asm__ __volatile__(
 			        ".set\tnoreorder\n\t"
 				".set\tnoat\n\t"
@@ -144,10 +138,8 @@
 {
 	unsigned long i;
 
-        if (mips_cpu.options & MIPS_CPU_CACHE_CDEX)
-	{
-	        for (i=to; i<to+PAGE_SIZE; i+=sc_lsize)
-		{
+        if (mips_cpu.options & MIPS_CPU_CACHE_CDEX) {
+	        for (i=to; i<to+PAGE_SIZE; i+=sc_lsize) {
 		        __asm__ __volatile__(
 				".set\tnoreorder\n\t"
 				".set\tnoat\n\t"
@@ -514,14 +506,8 @@
  */
 static void mips32_flush_cache_sigtramp(unsigned long addr)
 {
-	unsigned long daddr, iaddr;
-
-	daddr = addr & ~(dc_lsize - 1);
-	protected_writeback_dcache_line(daddr);
-	protected_writeback_dcache_line(daddr + dc_lsize);
-	iaddr = addr & ~(ic_lsize - 1);
-	protected_flush_icache_line(iaddr);
-	protected_flush_icache_line(iaddr + ic_lsize);
+	protected_writeback_dcache_line(addr & ~(dc_lsize - 1));
+	protected_flush_icache_line(addr & ~(ic_lsize - 1));
 }
 
 #undef DEBUG_TLB
diff -u --recursive --new-file v2.4.9/linux/arch/mips/mm/r2300.c linux/arch/mips/mm/r2300.c
--- v2.4.9/linux/arch/mips/mm/r2300.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips/mm/r2300.c	Sun Sep  9 10:43:02 2001
@@ -33,7 +33,7 @@
 /* For R3000 cores with R4000 style caches */
 static unsigned long icache_size, dcache_size;		/* Size in bytes */
 static unsigned long icache_lsize, dcache_lsize;	/* Size in bytes */
-static unsigned long scache_size = 0;
+static unsigned long scache_size;
 
 #include <asm/cacheops.h>
 #include <asm/r4kcache.h>
@@ -134,31 +134,64 @@
 	dummy = *p;
 	status = read_32bit_cp0_register(CP0_STATUS);
 
-	if (dummy != 0xa5a55a5a || (status & (1<<19))) {
+	if (dummy != 0xa5a55a5a || (status & ST0_CM)) {
 		size = 0;
 	} else {
-		for (size = 512; size <= 0x40000; size <<= 1)
+		for (size = 128; size <= 0x40000; size <<= 1)
 			*(p + size) = 0;
 		*p = -1;
-		for (size = 512; 
+		for (size = 128; 
 		     (size <= 0x40000) && (*(p + size) == 0); 
 		     size <<= 1)
 			;
 		if (size > 0x40000)
 			size = 0;
 	}
+
 	write_32bit_cp0_register(CP0_STATUS, flags);
 
 	return size * sizeof(*p);
 }
 
+unsigned long __init r3k_cache_lsize(unsigned long ca_flags)
+{
+	unsigned long flags, status, lsize, i, j;
+	volatile unsigned long *p;
+
+	p = (volatile unsigned long *) KSEG0;
+
+	flags = read_32bit_cp0_register(CP0_STATUS);
+
+	/* isolate cache space */
+	write_32bit_cp0_register(CP0_STATUS, (ca_flags|flags)&~ST0_IEC);
+
+	for (i = 0; i < 128; i++)
+		*(p + i) = 0;
+	*(volatile unsigned char *)p = 0;
+	for (lsize = 1; lsize < 128; lsize <<= 1) {
+		*(p + lsize);
+		status = read_32bit_cp0_register(CP0_STATUS);
+		if (!(status & ST0_CM))
+			break;
+	}
+	for (i = 0; i < 128; i += lsize)
+		*(volatile unsigned char *)(p + i) = 0;
+
+	write_32bit_cp0_register(CP0_STATUS, flags);
+
+	return lsize * sizeof(*p);
+}
+
 static void __init r3k_probe_cache(void)
 {
 	dcache_size = r3k_cache_size(ST0_ISC);
-	dcache_lsize = 4;
+	if (dcache_size)
+		dcache_lsize = r3k_cache_lsize(ST0_ISC);
+	
 
 	icache_size = r3k_cache_size(ST0_ISC|ST0_SWC);
-	icache_lsize = 4;
+	if (icache_size)
+		icache_lsize = r3k_cache_lsize(ST0_ISC|ST0_SWC);
 }
 
 static void r3k_flush_icache_range(unsigned long start, unsigned long end)
@@ -391,11 +424,17 @@
 
 	flags = read_32bit_cp0_register(CP0_STATUS);
 
+	write_32bit_cp0_register(CP0_STATUS, flags&~ST0_IEC);
+
+	/* Fill the TLB to avoid an exception with caches isolated. */
+	asm ( 	"lw\t$0,0x000(%0)\n\t"
+		"lw\t$0,0x004(%0)\n\t"
+		: : "r" (addr) );
+
 	write_32bit_cp0_register(CP0_STATUS, (ST0_ISC|ST0_SWC|flags)&~ST0_IEC);
 
 	asm ( 	"sb\t$0,0x000(%0)\n\t"
 		"sb\t$0,0x004(%0)\n\t"
-		"sb\t$0,0x008(%0)\n\t"
 		: : "r" (addr) );
 
 	write_32bit_cp0_register(CP0_STATUS, flags);
diff -u --recursive --new-file v2.4.9/linux/arch/mips/mm/r4xx0.c linux/arch/mips/mm/r4xx0.c
--- v2.4.9/linux/arch/mips/mm/r4xx0.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips/mm/r4xx0.c	Sun Sep  9 10:43:02 2001
@@ -2088,43 +2088,29 @@
  */
 static void r4k_flush_cache_sigtramp(unsigned long addr)
 {
-	unsigned long daddr, iaddr;
-
-	daddr = addr & ~(dc_lsize - 1);
 	__asm__ __volatile__("nop;nop;nop;nop");	/* R4600 V1.7 */
-	protected_writeback_dcache_line(daddr);
-	protected_writeback_dcache_line(daddr + dc_lsize);
-	iaddr = addr & ~(ic_lsize - 1);
-	protected_flush_icache_line(iaddr);
-	protected_flush_icache_line(iaddr + ic_lsize);
+	protected_writeback_dcache_line(addr & ~(dc_lsize - 1));
+	protected_flush_icache_line(addr & ~(ic_lsize - 1));
 }
 
 static void r4600v20k_flush_cache_sigtramp(unsigned long addr)
 {
-	unsigned long daddr, iaddr;
 	unsigned int flags;
 
-	daddr = addr & ~(dc_lsize - 1);
 	__save_and_cli(flags);
 
 	/* Clear internal cache refill buffer */
 	*(volatile unsigned int *)KSEG1;
 
-	protected_writeback_dcache_line(daddr);
-	protected_writeback_dcache_line(daddr + dc_lsize);
-	iaddr = addr & ~(ic_lsize - 1);
-	protected_flush_icache_line(iaddr);
-	protected_flush_icache_line(iaddr + ic_lsize);
+	protected_writeback_dcache_line(addr & ~(dc_lsize - 1));
+	protected_flush_icache_line(addr & ~(ic_lsize - 1));
+
 	__restore_flags(flags);
 }
 
 #undef DEBUG_TLB
 #undef DEBUG_TLBUPDATE
 
-#define NTLB_ENTRIES       48  /* Fixed on all R4XX0 variants... */
-
-#define NTLB_ENTRIES_HALF  24  /* Fixed on all R4XX0 variants... */
-
 void flush_tlb_all(void)
 {
 	unsigned long flags;
@@ -2146,7 +2132,7 @@
 	entry = get_wired();
 
 	/* Blast 'em all away. */
-	while(entry < NTLB_ENTRIES) {
+	while(entry < mips_cpu.tlbsize) {
 		set_index(entry);
 		BARRIER;
 		tlb_write_indexed();
@@ -2188,7 +2174,7 @@
 		__save_and_cli(flags);
 		size = (end - start + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
 		size = (size + 1) >> 1;
-		if(size <= NTLB_ENTRIES_HALF) {
+		if(size <= mips_cpu.tlbsize/2) {
 			int oldpid = (get_entryhi() & 0xff);
 			int newpid = (mm->context & 0xff);
 
@@ -2416,7 +2402,14 @@
 /* Detect and size the various r4k caches. */
 static void __init probe_icache(unsigned long config)
 {
-	icache_size = 1 << (12 + ((config >> 9) & 7));
+        switch (mips_cpu.cputype) {
+        case CPU_VR41XX:
+                icache_size = 1 << (10 + ((config >> 9) & 7));
+                break;
+        default:
+                icache_size = 1 << (12 + ((config >> 9) & 7));
+                break;
+        }
 	ic_lsize = 16 << ((config >> 5) & 1);
 
 	printk("Primary instruction cache %dkb, linesize %d bytes.\n",
@@ -2425,7 +2418,14 @@
 
 static void __init probe_dcache(unsigned long config)
 {
-	dcache_size = 1 << (12 + ((config >> 6) & 7));
+        switch (mips_cpu.cputype) {
+        case CPU_VR41XX:
+                dcache_size = 1 << (10 + ((config >> 6) & 7));
+                break;
+        default:
+                dcache_size = 1 << (12 + ((config >> 6) & 7));
+                break;
+        }
 	dc_lsize = 16 << ((config >> 4) & 1);
 
 	printk("Primary data cache %dkb, linesize %d bytes.\n",
@@ -2708,6 +2708,6 @@
 	 *   - The entire mm handling assumes the c0_pagemask register to
 	 *     be set for 4kb pages.
 	 */
-	write_32bit_cp0_register(CP0_PAGEMASK, PM_4K);
+	set_pagemask(PM_4K);
 	flush_tlb_all();
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips/mm/r5432.c linux/arch/mips/mm/r5432.c
--- v2.4.9/linux/arch/mips/mm/r5432.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips/mm/r5432.c	Sun Sep  9 10:43:02 2001
@@ -531,14 +531,8 @@
  */
 static void r5432_flush_cache_sigtramp(unsigned long addr)
 {
-	unsigned long daddr, iaddr;
-
-	daddr = addr & ~(dc_lsize - 1);
-	protected_writeback_dcache_line(daddr);
-	protected_writeback_dcache_line(daddr + dc_lsize);
-	iaddr = addr & ~(ic_lsize - 1);
-	protected_flush_icache_line(iaddr);
-	protected_flush_icache_line(iaddr + ic_lsize);
+	protected_writeback_dcache_line(addr & ~(dc_lsize - 1));
+	protected_flush_icache_line(addr & ~(ic_lsize - 1));
 }
 
 #undef DEBUG_TLB
diff -u --recursive --new-file v2.4.9/linux/arch/mips/philips/nino/Makefile linux/arch/mips/philips/nino/Makefile
--- v2.4.9/linux/arch/mips/philips/nino/Makefile	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/philips/nino/Makefile	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,33 @@
+#
+# Makefile for the Philips Nino specific parts of the kernel
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+
+.S.s:
+	$(CPP) $(AFLAGS) $< -o $@
+.S.o:
+	$(CC) $(AFLAGS) -c $< -o $@
+
+O_TARGET := nino.o
+
+all: nino.o
+
+obj-y	 := int-handler.o setup.o irq.o time.o reset.o rtc.o prom.o power.o
+
+int-handler.o: int-handler.S
+
+obj-$(CONFIG_REMOTE_DEBUG)	+= kgdb.o
+
+obj-$(CONFIG_BLK_DEV_INITRD)	+= ramdisk.o
+
+ramdisk.o:
+		$(MAKE) -C ramdisk
+		mv ramdisk/ramdisk.o ramdisk.o
+
+clean:
+		rm -f *.o
+
+include $(TOPDIR)/Rules.make
diff -u --recursive --new-file v2.4.9/linux/arch/mips/philips/nino/int-handler.S linux/arch/mips/philips/nino/int-handler.S
--- v2.4.9/linux/arch/mips/philips/nino/int-handler.S	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/philips/nino/int-handler.S	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,137 @@
+/*
+ *  linux/arch/mips/philips/nino/int-handler.S
+ *
+ *  Copyright (C) 1999 Harald Koerfgen
+ *  Copyright (C) 2000 Jim Pick (jim@jimpick.com)
+ *  Copyright (C) 2001 Steven J. Hill (sjhill@realitydiluted.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  Interrupt handler for Philips Nino.
+ */
+#include <asm/asm.h>
+#include <asm/regdef.h>
+#include <asm/mipsregs.h>
+#include <asm/stackframe.h>
+#include <asm/tx3912.h>
+
+		.data
+	        .globl  HighPriVect
+
+HighPriVect:	.word   spurious        # Reserved
+	        .word   io_posnegint0   # IOPOSINT(0) or IONEGINT(0)
+	        .word   spurious        # CHIDMACNTINT
+	        .word   spurious        # TELDMACNTINT
+	        .word   spurious        # SNDDMACNTINT
+	        .word   spurious        # Reserved
+	        .word   io_negint56     # IONEGINT(6) or IONEGINT(5)
+	        .word   spurious        # Reserved
+	        .word   io_posint56     # IOPOSINT(6) or IOPOSINT(5)
+	        .word   spurious        # Reserved
+	        .word   spurious        # UARTBRXINT
+	        .word   uarta_rx        # UARTARXINT
+	        .word   spurious        # Reserved
+	        .word   periodic_timer  # PERINT
+	        .word   spurious        # ALARMINT
+	        .word   spurious        # POSPWROKINT or NEGPWROKINT
+
+/*
+ *  Here is the entry point to handle all interrupts.
+ */
+		.text
+		.set	noreorder
+		.align	5
+		NESTED(nino_handle_int, PT_SIZE, ra)
+		.set	noat
+		SAVE_ALL
+		CLI
+		.set	at
+	
+		/*
+		 * Get pending Interrupts
+		 */
+		mfc0	t0, CP0_CAUSE		# Get pending interrupts
+		andi	t2, t0, IE_IRQ4		# IRQ4 (high priority)
+		bne	t2, IE_IRQ4, low_priority
+		nop
+
+/*
+ *  Ok, we've got a high priority interrupt (a.k.a. an external interrupt).
+ *  Read Interrupt Status Register 6 to get vector.
+ */
+high_priority:
+		lui	t0, %hi(IntStatus6)
+		lw	t1, %lo(IntStatus6)(t0)
+		andi	t1, INT6_INTVECT
+		la	t2, HighPriVect
+		addu	t1, t1, t2
+		lw	t2, 0(t1)
+		jr	t2
+		nop
+
+/*
+ * Ok, we've got one of over a hundred other interupts.
+ */
+low_priority:
+		lui	t0, %hi(IntStatus1)
+		lw	t1, %lo(IntStatus1)(t0)
+		j	handle_it
+		li	a0, 20
+
+/*
+ * We don't currently handle spurious interrupts.
+ */
+spurious:	
+		j	spurious_interrupt
+		nop
+
+/*
+ * We have the IRQ number, dispatch to the real handler.
+ */
+handle_it:	jal	do_IRQ
+		move	a1,sp
+		j	ret_from_irq
+		nop
+
+/************************************
+ * High priority interrupt mappings *
+ ************************************/
+		
+/* 
+ *  Periodic timer - IRQ 0
+ */
+periodic_timer:
+		j	handle_it
+		li	a0, 0
+
+/* 
+ *  UARTA RX - IRQ 3
+ */
+uarta_rx:
+		j	handle_it
+		li	a0, 3
+
+/* 
+ *  GPIO Pin 0 transition - IRQ 10
+ */
+io_posnegint0:
+		j	handle_it
+		li	a0, 10
+
+/* 
+ *  GPIO Pin 5 or 6 transition (0-to-1) - IRQ 11
+ */
+io_posint56:
+		j	handle_it
+		li	a0, 11
+
+/*
+ *  GPIO Pin 5 or 6 transition (1-to-0) - IRQ 12
+ */
+io_negint56:
+		j	handle_it
+		li	a0, 12
+
+		END(nino_handle_int)
diff -u --recursive --new-file v2.4.9/linux/arch/mips/philips/nino/irq.c linux/arch/mips/philips/nino/irq.c
--- v2.4.9/linux/arch/mips/philips/nino/irq.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/philips/nino/irq.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,314 @@
+/*
+ *  linux/arch/mips/philips/nino/irq.c
+ *
+ *  Copyright (C) 1992 Linus Torvalds
+ *  Copyright (C) 1999 Harald Koerfgen
+ *  Copyright (C) 2000 Pavel Machek (pavel@suse.cz)
+ *  Copyright (C) 2001 Steven J. Hill (sjhill@realitydiluted.com)
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *  
+ *  Generic interrupt handler for Philips Nino.
+ */
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kernel_stat.h>
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/ioport.h>
+#include <linux/timex.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+
+#include <asm/bitops.h>
+#include <asm/bootinfo.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/mipsregs.h>
+#include <asm/system.h>
+#include <asm/tx3912.h>
+
+unsigned long spurious_count = 0;
+
+irq_cpustat_t irq_stat [NR_CPUS];
+
+static inline void mask_irq(unsigned int irq_nr)
+{
+	switch (irq_nr) {
+	case 0:  /* Periodic Timer Interrupt */ 
+		IntClear5 = INT5_PERIODICINT;
+		IntClear6 = INT6_PERIODICINT;
+		IntEnable6 &= ~INT6_PERIODICINT;
+		break;
+
+	case 3:
+		/* Serial port receive interrupt */
+		break;
+
+	case 2:
+		/* Serial port transmit interrupt */
+		break;
+
+	default:
+		printk( "Attempt to mask unknown IRQ %d?\n", irq_nr );
+	}
+}
+
+static inline void unmask_irq(unsigned int irq_nr)
+{
+	switch (irq_nr) {
+	case 0:
+		IntEnable6 |= INT6_PERIODICINT;
+		break;
+
+	case 3:
+		/* Serial port receive interrupt */
+		break;
+
+	case 2:
+		/* Serial port transmit interrupt */
+		break;
+
+	default:
+		printk( "Attempt to unmask unknown IRQ %d?\n", irq_nr );
+	}
+}
+
+void disable_irq(unsigned int irq_nr)
+{
+    unsigned long flags;
+
+    save_and_cli(flags);
+    mask_irq(irq_nr);
+    restore_flags(flags);
+}
+
+void enable_irq(unsigned int irq_nr)
+{
+    unsigned long flags;
+
+    save_and_cli(flags);
+    unmask_irq(irq_nr);
+    restore_flags(flags);
+}
+
+/*
+ * Pointers to the low-level handlers: first the general ones, then the
+ * fast ones, then the bad ones.
+ */
+extern void interrupt(void);
+
+static struct irqaction *irq_action[NR_IRQS] =
+{
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+};
+
+int get_irq_list(char *buf)
+{
+    int i, len = 0;
+    struct irqaction *action;
+
+    for (i = 0; i < NR_IRQS; i++) {
+	action = irq_action[i];
+	if (!action)
+	    continue;
+	len += sprintf(buf + len, "%2d: %8d %c %s",
+		       i, kstat.irqs[0][i],
+		       (action->flags & SA_INTERRUPT) ? '+' : ' ',
+		       action->name);
+	for (action = action->next; action; action = action->next) {
+	    len += sprintf(buf + len, ",%s %s",
+			   (action->flags & SA_INTERRUPT) ? " +" : "",
+			   action->name);
+	}
+	len += sprintf(buf + len, "\n");
+    }
+    return len;
+}
+
+atomic_t __mips_bh_counter;
+
+/*
+ * do_IRQ handles IRQ's that have been installed without the
+ * SA_INTERRUPT flag: it uses the full signal-handling return
+ * and runs with other interrupts enabled. All relatively slow
+ * IRQ's should use this format: notably the keyboard/timer
+ * routines.
+ */
+asmlinkage void do_IRQ(int irq, struct pt_regs *regs)
+{
+    struct irqaction *action;
+    int do_random, cpu;
+
+    if (irq == 20) {
+        if (IntStatus2 & 0xfffff00) {
+		if (IntStatus2 & 0x0f000000)
+		return do_IRQ(2, regs);
+	}
+    }
+
+    cpu = smp_processor_id();
+    irq_enter(cpu, irq);
+    kstat.irqs[cpu][irq]++;
+
+    if (irq == 20) {
+            printk("20 %08lx %08lx\n   %08lx %08lx\n   %08lx\n",
+                   IntStatus1, IntStatus2, IntStatus3,
+                   IntStatus4, IntStatus5 );
+            printk("20 %08lx %08lx\n   %08lx %08lx\n   %08lx\n",
+                   IntEnable1, IntEnable2, IntEnable3,
+                   IntEnable4, IntEnable5 );
+
+    }
+
+    mask_irq(irq);
+    action = *(irq + irq_action);
+    if (action) {
+	if (!(action->flags & SA_INTERRUPT))
+	    __sti();
+	do_random = 0;
+	do {
+	    do_random |= action->flags;
+	    action->handler(irq, action->dev_id, regs);
+	    action = action->next;
+	} while (action);
+	if (do_random & SA_SAMPLE_RANDOM)
+	    add_interrupt_randomness(irq);
+	unmask_irq(irq);
+	__cli();
+    } else {
+            IntClear1 = ~0;
+            IntClear3 = ~0;
+	    IntClear4 = ~0;
+	    IntClear5 = ~0;
+	    unmask_irq(irq);
+    }
+    irq_exit(cpu, irq);
+
+    /* unmasking and bottom half handling is done magically for us. */
+}
+
+/*
+ * Idea is to put all interrupts
+ * in a single table and differenciate them just by number.
+ */
+int setup_nino_irq(int irq, struct irqaction *new)
+{
+    int shared = 0;
+    struct irqaction *old, **p;
+    unsigned long flags;
+
+    p = irq_action + irq;
+    if ((old = *p) != NULL) {
+	/* Can't share interrupts unless both agree to */
+	if (!(old->flags & new->flags & SA_SHIRQ))
+	    return -EBUSY;
+
+	/* Can't share interrupts unless both are same type */
+	if ((old->flags ^ new->flags) & SA_INTERRUPT)
+	    return -EBUSY;
+
+	/* add new interrupt at end of irq queue */
+	do {
+	    p = &old->next;
+	    old = *p;
+	} while (old);
+	shared = 1;
+    }
+    if (new->flags & SA_SAMPLE_RANDOM)
+	rand_initialize_irq(irq);
+
+    save_and_cli(flags);
+    *p = new;
+
+    if (!shared) {
+	unmask_irq(irq);
+    }
+    restore_flags(flags);
+    return 0;
+}
+
+int request_irq(unsigned int irq,
+		void (*handler) (int, void *, struct pt_regs *),
+		unsigned long irqflags,
+		const char *devname,
+		void *dev_id)
+{
+    int retval;
+    struct irqaction *action;
+
+    if (irq >= NR_IRQS)
+	return -EINVAL;
+    if (!handler)
+	return -EINVAL;
+
+    action = (struct irqaction *) kmalloc(sizeof(struct irqaction), GFP_KERNEL);
+    if (!action)
+	return -ENOMEM;
+
+    action->handler = handler;
+    action->flags = irqflags;
+    action->mask = 0;
+    action->name = devname;
+    action->next = NULL;
+    action->dev_id = dev_id;
+
+    retval = setup_nino_irq(irq, action);
+
+    if (retval)
+	kfree(action);
+    return retval;
+}
+
+void free_irq(unsigned int irq, void *dev_id)
+{
+    struct irqaction *action, **p;
+    unsigned long flags;
+
+    if (irq >= NR_IRQS) {
+	printk(KERN_CRIT __FUNCTION__ ": trying to free IRQ%d\n", irq);
+	return;
+    }
+    for (p = irq + irq_action; (action = *p) != NULL; p = &action->next) {
+	if (action->dev_id != dev_id)
+	    continue;
+
+	/* Found it - now free it */
+	save_and_cli(flags);
+	*p = action->next;
+	if (!irq[irq_action])
+	    mask_irq(irq);
+	restore_flags(flags);
+	kfree(action);
+	return;
+    }
+    printk(KERN_CRIT __FUNCTION__ ": trying to free free IRQ%d\n", irq);
+}
+
+unsigned long probe_irq_on(void)
+{
+    /* TODO */
+    return 0;
+}
+
+int probe_irq_off(unsigned long irqs)
+{
+    /* TODO */
+    return 0;
+}
+
+void __init init_IRQ(void)
+{
+    irq_setup();
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/philips/nino/kgdb.c linux/arch/mips/philips/nino/kgdb.c
--- v2.4.9/linux/arch/mips/philips/nino/kgdb.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/philips/nino/kgdb.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,83 @@
+/*
+ *  linux/arch/mips/philips/nino/kgdb.c
+ *
+ *  Copyright (C) 2001 Steven J. Hill (sjhill@realitydiluted.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  Kernel debugging on the Philips Nino.
+ */
+#include <asm/system.h>
+#include <asm/tx3912.h>
+
+static int remoteDebugInitialized = 0;
+
+void debugInit(void)
+{
+/*
+ * If low-level debugging (before GDB or console operational) is
+ * configured, then we do not need to re-initialize the UART.
+ */
+#ifndef CONFIG_DEBUG_LL
+	earlyInitUartPR31700();
+#endif
+}
+
+char getDebugChar(void)
+{
+	char buf;
+	unsigned long int2, flags;
+
+	if (!remoteDebugInitialized) {
+		debugInit();
+		remoteDebugInitialized = 1;
+	}
+
+	save_and_cli(flags);
+
+	int2 = IntEnable2;
+
+	IntEnable2 = 0;
+
+	while(!(UartA_Ctrl1 & UART_RX_HOLD_FULL));
+
+	buf = UartA_Data;
+
+	IntEnable2 = int2;
+
+	restore_flags(flags);
+
+	return buf;	
+}
+
+int putDebugChar(char c)
+{
+	int i;
+	unsigned long int2;
+
+	if (!remoteDebugInitialized) {
+		debugInit();
+		remoteDebugInitialized = 1;
+	}
+
+	int2 = IntEnable2;
+
+	IntEnable2 &=
+		~(INT2_UARTATXINT | INT2_UARTATXOVERRUN | INT2_UARTAEMPTY);
+
+	for (i = 0; !(IntStatus2 & INT2_UARTATXINT) && (i < 10000); i++);
+
+	IntClear2 = INT2_UARTATXINT | INT2_UARTATXOVERRUN | INT2_UARTAEMPTY;
+
+	UartA_Data = c;
+
+	for (i = 0; !(IntStatus2 & INT2_UARTATXINT) && (i < 10000); i++);
+
+	IntClear2 = INT2_UARTATXINT | INT2_UARTATXOVERRUN | INT2_UARTAEMPTY;
+
+	IntEnable2 = int2;
+
+	return 1;
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/philips/nino/power.c linux/arch/mips/philips/nino/power.c
--- v2.4.9/linux/arch/mips/philips/nino/power.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/philips/nino/power.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,36 @@
+/*
+ *  linux/arch/mips/philips/nino/power.c
+ *
+ *  Copyright (C) 2000 Jim Pick <jim@jimpick.com>
+ *  Copyright (C) 2001 Steven J. Hill (sjhill@realitydiluted.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  Power management routines on the Philips Nino.
+ */
+#include <asm/tx3912.h>
+
+void nino_wait(void)
+{
+	/* We stop the CPU to conserve power */
+	PowerControl |= PWR_STOPCPU;
+
+	/* 
+	 * We wait until an interrupt happens...
+	 */
+
+	/* We resume here */
+	PowerControl &= ~PWR_STOPCPU;
+
+	/* Give ourselves a little delay */
+	__asm__ __volatile__(
+		"nop\n\t"
+		"nop\n\t"
+		"nop\n\t"
+		"nop\n\t"
+		"nop\n\t"
+		"nop\n\t"
+		"nop\n\t");
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/philips/nino/prom.c linux/arch/mips/philips/nino/prom.c
--- v2.4.9/linux/arch/mips/philips/nino/prom.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/philips/nino/prom.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,80 @@
+/*
+ *  linux/arch/mips/philips/nino/prom.c
+ *
+ *  Copyright (C) 2001 Steven J. Hill (sjhill@realitydiluted.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *  
+ *  Early initialization code for the Philips Nino.
+ */
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <asm/bootinfo.h>
+#include <asm/addrspace.h>
+#include <asm/page.h>
+
+char arcs_cmdline[COMMAND_LINE_SIZE];
+
+#ifdef CONFIG_FB_TX3912
+extern u_long tx3912fb_paddr;
+extern u_long tx3912fb_vaddr;
+extern u_long tx3912fb_size;
+#endif
+
+/* Do basic initialization */
+void __init prom_init(int argc, char **argv,
+		unsigned long magic, int *prom_vec)
+{
+	u_long free_end, mem_size;
+	u_int i;
+
+	/*
+	 * collect args and prepare cmd_line
+	 */
+	for (i = 1; i < argc; i++) {
+		strcat(arcs_cmdline, argv[i]);
+		if (i < (argc - 1))
+			strcat(arcs_cmdline, " ");
+	}
+
+	mips_machgroup = MACH_GROUP_PHILIPS;
+	mips_machtype = MACH_PHILIPS_NINO;
+
+#ifdef CONFIG_NINO_4MB
+	mem_size = 4 << 20;
+#elif CONFIG_NINO_8MB
+	mem_size = 8 << 20;
+#elif CONFIG_NINO_16MB
+	mem_size = 16 << 20;
+#endif
+
+#ifdef CONFIG_FB_TX3912
+	/*
+	 * The LCD controller requires that the framebuffer
+	 * start address fall within a 1MB segment and is
+	 * aligned on a 16 byte boundary. The way to assure
+	 * this is to place the framebuffer at the end of
+	 * memory and mark it as reserved.
+	 */
+	free_end = (mem_size - tx3912fb_size) & PAGE_MASK;
+	add_memory_region(0, free_end, BOOT_MEM_RAM); 
+	add_memory_region(free_end, (mem_size - free_end), BOOT_MEM_RESERVED); 
+
+	/*
+	 * Calculate physical and virtual addresses for
+	 * the beginning of the framebuffer.
+	 */
+	tx3912fb_paddr = PHYSADDR(free_end);
+	tx3912fb_vaddr = KSEG1ADDR(free_end);
+#else
+	add_memory_region(0, mem_size, BOOT_MEM_RAM); 
+#endif
+}
+
+void __init prom_free_prom_memory (void)
+{
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/philips/nino/ramdisk/Makefile linux/arch/mips/philips/nino/ramdisk/Makefile
--- v2.4.9/linux/arch/mips/philips/nino/ramdisk/Makefile	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/philips/nino/ramdisk/Makefile	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,12 @@
+#
+# Makefile for the Philips Nino ramdisk
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+
+ramdisk.o: ramdisk.gz ld.script
+	$(LD) -T ld.script -b binary -o $@ ramdisk.gz
+
+include $(TOPDIR)/Rules.make
diff -u --recursive --new-file v2.4.9/linux/arch/mips/philips/nino/ramdisk/ld.script linux/arch/mips/philips/nino/ramdisk/ld.script
--- v2.4.9/linux/arch/mips/philips/nino/ramdisk/ld.script	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/philips/nino/ramdisk/ld.script	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,9 @@
+OUTPUT_FORMAT("ecoff-littlemips")
+OUTPUT_ARCH(mips)
+SECTIONS
+{
+  .initrd :
+  {
+        *(.data)
+  }
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/philips/nino/reset.c linux/arch/mips/philips/nino/reset.c
--- v2.4.9/linux/arch/mips/philips/nino/reset.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/philips/nino/reset.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,37 @@
+/*
+ *  linux/arch/mips/philips/nino/reset.c
+ *
+ *  Copyright (C) 2001 Steven J. Hill (sjhill@realitydiluted.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  Generic restart, halt and power off functions for Philips Nino.
+ */
+#include <linux/init.h>
+#include <asm/reboot.h>
+
+void (*reset_vector)(void) = (void (*)(void)) 0xBFC00000;
+
+void nino_machine_restart(char *command)
+{
+	reset_vector();
+}
+
+void nino_machine_halt(void)
+{
+	reset_vector();
+}
+
+void nino_machine_power_off(void)
+{
+	reset_vector();
+}
+
+void __init setup_nino_reset_vectors(void)
+{
+	_machine_restart = nino_machine_restart;
+	_machine_halt = nino_machine_halt;
+	_machine_power_off = nino_machine_power_off;
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/philips/nino/rtc.c linux/arch/mips/philips/nino/rtc.c
--- v2.4.9/linux/arch/mips/philips/nino/rtc.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/philips/nino/rtc.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,34 @@
+/*
+ *  linux/arch/mips/philips/nino/rtc.c
+ *
+ *  Copyright (C) 2001 Steven J. Hill (sjhill@realitydiluted.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  Functions to access RTC on the Philips Nino.
+ */
+#include <linux/spinlock.h>
+#include <linux/mc146818rtc.h>
+
+static unsigned char nino_rtc_read_data(unsigned long addr)
+{
+	return 0;
+}
+
+static void nino_rtc_write_data(unsigned char data, unsigned long addr)
+{
+}
+
+static int nino_rtc_bcd_mode(void)
+{
+	return 0;
+}
+
+struct rtc_ops nino_rtc_ops =
+{
+	&nino_rtc_read_data,
+	&nino_rtc_write_data,
+	&nino_rtc_bcd_mode
+};
diff -u --recursive --new-file v2.4.9/linux/arch/mips/philips/nino/setup.c linux/arch/mips/philips/nino/setup.c
--- v2.4.9/linux/arch/mips/philips/nino/setup.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/philips/nino/setup.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,120 @@
+/*
+ *  linux/arch/mips/philips/nino/setup.c
+ *
+ *  Copyright (C) 2001 Steven J. Hill (sjhill@realitydiluted.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  Interrupt and exception initialization for Philips Nino.
+ */
+#include <linux/console.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/mc146818rtc.h>
+#include <linux/sched.h>
+#include <asm/addrspace.h>
+#include <asm/gdb-stub.h>
+#include <asm/irq.h>
+#include <asm/wbflush.h>
+#include <asm/tx3912.h>
+
+extern struct rtc_ops nino_rtc_ops;
+
+extern void nino_wait(void);
+extern void setup_nino_reset_vectors(void);
+extern asmlinkage void nino_handle_int(void);
+extern int setup_nino_irq(int, struct irqaction *);
+void (*board_time_init) (struct irqaction * irq);
+
+#ifdef CONFIG_REMOTE_DEBUG
+extern void set_debug_traps(void);
+extern void breakpoint(void);
+static int remote_debug = 0;
+#endif
+
+static void __init nino_irq_setup(void)
+{
+	unsigned int tmp;
+
+	/* Turn all interrupts off */
+	IntEnable1 = 0;
+	IntEnable2 = 0;
+	IntEnable3 = 0;
+	IntEnable4 = 0;
+	IntEnable5 = 0;
+	IntEnable6 = 0;
+
+	/* Clear all interrupts */
+	IntClear1 = 0xffffffff;
+	IntClear2 = 0xffffffff;
+	IntClear3 = 0xffffffff;
+	IntClear4 = 0xffffffff;
+	IntClear5 = 0xffffffff;
+	IntClear6 = 0xffffffff;
+
+	/*
+	 * Enable only the interrupts for the UART and negative
+	 * edge (1-to-0) triggered multi-function I/O pins.
+	 */
+    	change_cp0_status(ST0_BEV, 0);
+	tmp = read_32bit_cp0_register(CP0_STATUS);
+    	change_cp0_status(ST0_IM, tmp | IE_IRQ2 | IE_IRQ4);
+
+	/* Register the global interrupt handler */
+	set_except_vector(0, nino_handle_int);
+
+#ifdef CONFIG_REMOTE_DEBUG
+	if (remote_debug) {
+		set_debug_traps();
+		breakpoint();
+	}
+#endif
+}
+
+static __init void nino_time_init(struct irqaction *irq)
+{
+	unsigned int scratch = 0;
+
+	/*
+	 * Enable periodic interrupts
+	 */
+	setup_nino_irq(0, irq);
+
+	RTCperiodTimer = PER_TIMER_COUNT;
+	RTCtimerControl = TIM_ENPERTIMER;
+	IntEnable5 |= INT5_PERIODICINT;
+
+	scratch = inl(TX3912_CLK_CTRL_BASE);
+	scratch |= TX3912_CLK_CTRL_ENTIMERCLK;
+	outl(scratch, TX3912_CLK_CTRL_BASE);
+
+	/* Enable all interrupts */
+	IntEnable6 |= INT6_GLOBALEN | INT6_PERIODICINT;
+}
+
+void __init nino_setup(void)
+{
+	irq_setup = nino_irq_setup;
+
+	board_time_init = nino_time_init;
+
+	/* Base address to use for PC type I/O accesses */
+	mips_io_port_base = KSEG1ADDR(0xB0C00000);
+
+	setup_nino_reset_vectors();
+
+	/* Function called during process idle (cpu_idle) */
+	cpu_wait = nino_wait;
+
+#ifdef CONFIG_FB
+	conswitchp = &dummy_con;
+#endif
+
+#ifdef CONFIG_REMOTE_DEBUG
+	remote_debug = 1;
+#endif
+
+	rtc_ops = &nino_rtc_ops;
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/philips/nino/time.c linux/arch/mips/philips/nino/time.c
--- v2.4.9/linux/arch/mips/philips/nino/time.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/philips/nino/time.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,216 @@
+/*
+ *  linux/arch/mips/philips/nino/time.c
+ *
+ *  Copyright (C) 1999 Harald Koerfgen
+ *  Copyright (C) 2000 Pavel Machek (pavel@suse.cz)
+ *  Copyright (C) 2001 Steven J. Hill (sjhill@realitydiluted.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  Time handling functinos for Philips Nino.
+ */
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/param.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/interrupt.h>
+#include <linux/timex.h>
+#include <linux/delay.h>
+#include <asm/tx3912.h>
+
+extern volatile unsigned long wall_jiffies;
+extern rwlock_t xtime_lock;
+
+static struct timeval xbase;
+
+#define USECS_PER_JIFFY (1000000/HZ)
+
+/*
+ * Poll the Interrupt Status Registers
+ */
+#undef POLL_STATUS
+
+static unsigned long do_gettimeoffset(void)
+{
+    /*
+     * This is a kludge
+     */
+    return 0;
+}
+
+static
+void inline readRTC(unsigned long *high, unsigned long *low)
+{
+	/* read twice, and keep reading till we find two
+	 * the same pairs. This is needed in case the RTC
+	 * was updating its registers and we read a old
+	 * High but a new Low. */
+	do {
+		*high = RTChigh & RTC_HIGHMASK;
+		*low = RTClow;
+	} while (*high != (RTChigh & RTC_HIGHMASK) || RTClow!=*low);
+}
+
+/*
+ * This version of gettimeofday has near millisecond resolution.
+ */
+void do_gettimeofday(struct timeval *tv)
+{
+    unsigned long flags;
+    unsigned long high, low;
+
+    read_lock_irqsave(&xtime_lock, flags);
+    // 40 bit RTC, driven by 32khz source:
+    // +-----------+-----------------------------------------+
+    // | HHHH.HHHH | LLLL.LLLL.LLLL.LLLL.LMMM.MMMM.MMMM.MMMM |
+    // +-----------+-----------------------------------------+
+    readRTC(&high,&low);
+    tv->tv_sec  = (high << 17) | (low >> 15);
+    tv->tv_usec = (low % 32768) * 1953 / 64;
+    tv->tv_sec += xbase.tv_sec;
+    tv->tv_usec += xbase.tv_usec;
+
+    tv->tv_usec += do_gettimeoffset();
+
+    /*
+     * xtime is atomically updated in timer_bh. lost_ticks is
+     * nonzero if the timer bottom half hasnt executed yet.
+     */
+    if (jiffies - wall_jiffies)
+	tv->tv_usec += USECS_PER_JIFFY;
+
+    read_unlock_irqrestore(&xtime_lock, flags);
+
+    if (tv->tv_usec >= 1000000) {
+	tv->tv_usec -= 1000000;
+	tv->tv_sec++;
+    }
+}
+
+void do_settimeofday(struct timeval *tv)
+{
+    write_lock_irq(&xtime_lock);
+    /* This is revolting. We need to set the xtime.tv_usec
+     * correctly. However, the value in this location is
+     * is value at the last tick.
+     * Discover what correction gettimeofday
+     * would have done, and then undo it!
+     */
+    tv->tv_usec -= do_gettimeoffset();
+
+    if (tv->tv_usec < 0) {
+	tv->tv_usec += 1000000;
+	tv->tv_sec--;
+    }
+
+    /* reset RTC to 0 (real time is xbase + RTC) */
+    xbase = *tv;
+    RTCtimerControl |=  TIM_RTCCLEAR;
+    RTCtimerControl &= ~TIM_RTCCLEAR;
+    RTCalarmHigh = RTCalarmLow = ~0UL;
+
+    xtime = *tv;
+    time_state = TIME_BAD;
+    time_maxerror = MAXPHASE;
+    time_esterror = MAXPHASE;
+    write_unlock_irq(&xtime_lock);
+}
+
+static int set_rtc_mmss(unsigned long nowtime)
+{
+    int retval = 0;
+
+    return retval;
+}
+
+/* last time the cmos clock got updated */
+static long last_rtc_update = 0;
+
+/*
+ * timer_interrupt() needs to keep up the real-time clock,
+ * as well as call the "do_timer()" routine every clocktick
+ */
+
+int do_write = 1;
+
+static void
+timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+#ifdef POLL_STATUS
+    static unsigned long old_IntStatus1 = 0;
+    static unsigned long old_IntStatus3 = 0;
+    static unsigned long old_IntStatus4 = 0;
+    static unsigned long old_IntStatus5 = 0;
+    static int counter = 0;
+    int i;
+
+    new_spircv = SPIData & 0xff;
+    if ((old_spircv != new_spircv) && (new_spircv != 0xff)) {
+	    printk( "SPIData changed: %x\n", new_spircv );
+    }
+    old_spircv = new_spircv;
+    if (do_write)
+	    SPIData = 0;
+#endif
+
+    if (!user_mode(regs)) {
+	if (prof_buffer && current->pid) {
+	    extern int _stext;
+	    unsigned long pc = regs->cp0_epc;
+
+	    pc -= (unsigned long) &_stext;
+	    pc >>= prof_shift;
+	    /*
+	     * Dont ignore out-of-bounds pc values silently,
+	     * put them into the last histogram slot, so if
+	     * present, they will show up as a sharp peak.
+	     */
+	    if (pc > prof_len - 1)
+		pc = prof_len - 1;
+		atomic_inc((atomic_t *) & prof_buffer[pc]);
+	    }
+    }
+
+    /*
+     * aaaand... action!
+     */
+    do_timer(regs);
+
+    /*
+     * If we have an externally syncronized Linux clock, then update
+     * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
+     * called as close as possible to 500 ms before the new second starts.
+     */
+    if (time_state != TIME_BAD && xtime.tv_sec > last_rtc_update + 660 &&
+	xtime.tv_usec > 500000 - (tick >> 1) &&
+	xtime.tv_usec < 500000 + (tick >> 1))
+    {
+	if (set_rtc_mmss(xtime.tv_sec) == 0)
+	    last_rtc_update = xtime.tv_sec;
+	else
+	    last_rtc_update = xtime.tv_sec - 600;  /* do it again in 60 s */
+    }
+}
+
+static struct irqaction irq0 = {timer_interrupt, SA_INTERRUPT, 0,
+ 			 "timer", NULL, NULL};
+
+void (*board_time_init) (struct irqaction * irq);
+
+int __init time_init(void)
+{
+    struct timeval starttime;
+
+    starttime.tv_sec = mktime(2000, 1, 1, 0, 0, 0);
+    starttime.tv_usec = 0;
+    do_settimeofday(&starttime);
+
+    board_time_init(&irq0);
+
+    return 0;
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/sgi/kernel/indy_hpc.c linux/arch/mips/sgi/kernel/indy_hpc.c
--- v2.4.9/linux/arch/mips/sgi/kernel/indy_hpc.c	Sat May 13 08:29:14 2000
+++ linux/arch/mips/sgi/kernel/indy_hpc.c	Sun Sep  9 10:43:02 2001
@@ -12,6 +12,7 @@
 #include <asm/sgi/sgihpc.h>
 #include <asm/sgi/sgint23.h>
 #include <asm/sgialib.h>
+#include <asm/bootinfo.h>
 
 /* #define DEBUG_SGIHPC */
 
@@ -50,10 +51,12 @@
 		prom_printf("GUINESS ");
 #endif
 		sgi_guiness = 1;
+		mips_machtype = MACH_SGI_INDY;
 	} else {
 #ifdef DEBUG_SGIHPC
 		prom_printf("FULLHOUSE ");
 #endif
+                mips_machtype = MACH_SGI_INDIGO2;
 		sgi_guiness = 0;
 	}
 	sgi_boardid = brev;
diff -u --recursive --new-file v2.4.9/linux/arch/mips/sgi/kernel/indy_int.c linux/arch/mips/sgi/kernel/indy_int.c
--- v2.4.9/linux/arch/mips/sgi/kernel/indy_int.c	Fri Feb  9 11:29:44 2001
+++ linux/arch/mips/sgi/kernel/indy_int.c	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: indy_int.c,v 1.18 2000/03/02 02:36:50 ralf Exp $
- *
+/*
  * indy_int.c: Routines for generic manipulation of the INT[23] ASIC
  *             found on INDY workstations..
  *
@@ -70,8 +69,6 @@
 
 extern asmlinkage void indyIRQ(void);
 
-unsigned long spurious_count = 0;
-
 /* Local IRQ's are layed out logically like this:
  *
  * 0  --> 7   ==   local 0 interrupts
@@ -79,433 +76,333 @@
  * 16 --> 23  ==   vectored level 2 interrupts
  * 24 --> 31  ==   vectored level 3 interrupts (not used)
  */
-void disable_local_irq(unsigned int irq_nr)
+static void enable_local0_irq(unsigned int irq)
 {
 	unsigned long flags;
 
 	save_and_cli(flags);
-	switch(irq_nr) {
-	case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
-		ioc_icontrol->imask0 &= ~(1 << irq_nr);
-		break;
-
-	case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15:
-		ioc_icontrol->imask1 &= ~(1 << (irq_nr - 8));
-		break;
-
-	case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23:
-		ioc_icontrol->cmeimask0 &= ~(1 << (irq_nr - 16));
-		break;
-
-	default:
-		/* This way we'll see if anyone would ever want vectored
-		 * level 3 interrupts.  Highly unlikely.
-		 */
-		printk("Yeeee, got passed irq_nr %d at disable_irq\n", irq_nr);
-		panic("INVALID IRQ level!");
-	};
+	ioc_icontrol->imask0 |= (1 << (irq - SGINT_LOCAL0));
 	restore_flags(flags);
 }
 
-void enable_local_irq(unsigned int irq_nr)
+static unsigned int startup_local0_irq(unsigned int irq)
+{
+	enable_local0_irq(irq);
+
+	return 0;		/* Never anything pending  */
+}
+
+static void disable_local0_irq(unsigned int irq)
 {
 	unsigned long flags;
+
 	save_and_cli(flags);
-	switch(irq_nr) {
-	case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
-		ioc_icontrol->imask0 |= (1 << irq_nr);
-		break;
-
-	case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15:
-		ioc_icontrol->imask1 |= (1 << (irq_nr - 8));
-		break;
-
-	case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23:
-		enable_local_irq(7);
-		ioc_icontrol->cmeimask0 |= (1 << (irq_nr - 16));
-		break;
-
-	default:
-		printk("Yeeee, got passed irq_nr %d at disable_irq\n", irq_nr);
-		panic("INVALID IRQ level!");
-	};
+	ioc_icontrol->imask0 &= ~(1 << (irq - SGINT_LOCAL0));
 	restore_flags(flags);
 }
 
-void disable_gio_irq(unsigned int irq_nr)
+#define shutdown_local0_irq	disable_local0_irq
+#define mask_and_ack_local0_irq	disable_local0_irq
+
+static void end_local0_irq (unsigned int irq)
 {
-	/* XXX TODO XXX */
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_local0_irq(irq);
 }
 
-void enable_gio_irq(unsigned int irq_nr)
+static struct hw_interrupt_type ip22_local0_irq_type = {
+	"IP22 local 0",
+	startup_local0_irq,
+	shutdown_local0_irq,
+	enable_local0_irq,
+	disable_local0_irq,
+	mask_and_ack_local0_irq,
+	end_local0_irq,
+	NULL
+};
+
+static void enable_local1_irq(unsigned int irq)
 {
-	/* XXX TODO XXX */
+	unsigned long flags;
+
+	save_and_cli(flags);
+	ioc_icontrol->imask1 |= (1 << (irq - SGINT_LOCAL1));
+	restore_flags(flags);
 }
 
-void disable_hpcdma_irq(unsigned int irq_nr)
+static unsigned int startup_local1_irq(unsigned int irq)
 {
-	/* XXX TODO XXX */
+	enable_local1_irq(irq);
+
+	return 0;		/* Never anything pending  */
 }
 
-void enable_hpcdma_irq(unsigned int irq_nr)
+void disable_local1_irq(unsigned int irq)
 {
-	/* XXX TODO XXX */
+	unsigned long flags;
+
+	save_and_cli(flags);
+	ioc_icontrol->imask1 &= ~(1 << (irq- SGINT_LOCAL1));
+	restore_flags(flags);
 }
 
-void disable_irq(unsigned int irq_nr)
+#define shutdown_local1_irq	disable_local1_irq
+#define mask_and_ack_local1_irq	disable_local1_irq
+
+static void end_local1_irq (unsigned int irq)
 {
-	unsigned int n = irq_nr;
-	if(n >= SGINT_END) {
-		printk("whee, invalid irq_nr %d\n", irq_nr);
-		panic("IRQ, you lose...");
-	}
-	if(n >= SGINT_LOCAL0 && n < SGINT_GIO) {
-		disable_local_irq(n - SGINT_LOCAL0);
-	} else if(n >= SGINT_GIO && n < SGINT_HPCDMA) {
-		disable_gio_irq(n - SGINT_GIO);
-	} else if(n >= SGINT_HPCDMA && n < SGINT_END) {
-		disable_hpcdma_irq(n - SGINT_HPCDMA);
-	} else {
-		panic("how did I get here?");
-	}
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_local1_irq(irq);
 }
 
-void enable_irq(unsigned int irq_nr)
+static struct hw_interrupt_type ip22_local1_irq_type = {
+	"IP22 local 1",
+	startup_local1_irq,
+	shutdown_local1_irq,
+	enable_local1_irq,
+	disable_local1_irq,
+	mask_and_ack_local1_irq,
+	end_local1_irq,
+	NULL
+};
+
+static void enable_local2_irq(unsigned int irq)
 {
-	unsigned int n = irq_nr;
-	if(n >= SGINT_END) {
-		printk("whee, invalid irq_nr %d\n", irq_nr);
-		panic("IRQ, you lose...");
-	}
-	if(n >= SGINT_LOCAL0 && n < SGINT_GIO) {
-		enable_local_irq(n - SGINT_LOCAL0);
-	} else if(n >= SGINT_GIO && n < SGINT_HPCDMA) {
-		enable_gio_irq(n - SGINT_GIO);
-	} else if(n >= SGINT_HPCDMA && n < SGINT_END) {
-		enable_hpcdma_irq(n - SGINT_HPCDMA);
-	} else {
-		panic("how did I get here?");
-	}
+	unsigned long flags;
+
+	save_and_cli(flags);
+	enable_local0_irq(7);
+	ioc_icontrol->cmeimask0 |= (1 << (irq - SGINT_LOCAL2));
+	restore_flags(flags);
 }
 
-#if 0
-/*
- * Currently unused.
- */
-static void local_unex(int irq, void *data, struct pt_regs *regs)
+static unsigned int startup_local2_irq(unsigned int irq)
 {
-	printk("Whee: unexpected local IRQ at %08lx\n",
-	       (unsigned long) regs->cp0_epc);
-	printk("DUMP: stat0<%x> stat1<%x> vmeistat<%x>\n",
-	       ioc_icontrol->istat0, ioc_icontrol->istat1,
-	       ioc_icontrol->vmeistat);
-}
-#endif
+	enable_local2_irq(irq);
 
-static struct irqaction *local_irq_action[24] = {
-	NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL
-};
+	return 0;		/* Never anything pending  */
+}
 
-int setup_indy_irq(int irq, struct irqaction * new)
+void disable_local2_irq(unsigned int irq)
 {
-	printk("setup_indy_irq: Yeee, don't know how to setup irq<%d> for %s  %p\n",
-	       irq, new->name, new->handler);
-	return 0;
+	unsigned long flags;
+
+	save_and_cli(flags);
+	ioc_icontrol->cmeimask0 &= ~(1 << (irq - SGINT_LOCAL2));
+	restore_flags(flags);
 }
 
-static struct irqaction r4ktimer_action = {
-	NULL, 0, 0, "R4000 timer/counter", NULL, NULL,
-};
+#define shutdown_local2_irq disable_local2_irq
+#define mask_and_ack_local2_irq	disable_local2_irq
 
-static struct irqaction indy_berr_action = {
-	NULL, 0, 0, "IP22 Bus Error", NULL, NULL,
-};
+static void end_local2_irq (unsigned int irq)
+{
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_local2_irq(irq);
+}
 
-static struct irqaction *irq_action[16] = {
-	NULL, NULL, NULL, NULL,
-	NULL, NULL, &indy_berr_action, &r4ktimer_action,
-	NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL
+static struct hw_interrupt_type ip22_local2_irq_type = {
+	"IP22 local 2",
+	startup_local2_irq,
+	shutdown_local2_irq,
+	enable_local2_irq,
+	disable_local2_irq,
+	mask_and_ack_local2_irq,
+	end_local2_irq,
+	NULL
 };
 
-int get_irq_list(char *buf)
+static void enable_local3_irq(unsigned int irq)
 {
-	int i, len = 0;
-	int num = 0;
-	struct irqaction * action;
-
-	for (i = 0 ; i < 16 ; i++, num++) {
-		action = irq_action[i];
-		if (!action) 
-			continue;
-		len += sprintf(buf+len, "%2d: %8d %c %s",
-			num, kstat.irqs[0][num],
-			(action->flags & SA_INTERRUPT) ? '+' : ' ',
-			action->name);
-		for (action=action->next; action; action = action->next) {
-			len += sprintf(buf+len, ",%s %s",
-				(action->flags & SA_INTERRUPT) ? " +" : "",
-				action->name);
-		}
-		len += sprintf(buf+len, " [on-chip]\n");
-	}
-	for (i = 0 ; i < 24 ; i++, num++) {
-		action = local_irq_action[i];
-		if (!action) 
-			continue;
-		len += sprintf(buf+len, "%2d: %8d %c %s",
-			num, kstat.irqs[0][num],
-			(action->flags & SA_INTERRUPT) ? '+' : ' ',
-			action->name);
-		for (action=action->next; action; action = action->next) {
-			len += sprintf(buf+len, ",%s %s",
-				(action->flags & SA_INTERRUPT) ? " +" : "",
-				action->name);
-		}
-		len += sprintf(buf+len, " [local]\n");
-	}
-	return len;
+	unsigned long flags;
+
+	save_and_cli(flags);
+	printk("Yeeee, got passed irq_nr %d at enable_local3_irq\n", irq);
+	panic("INVALID IRQ level!");
+	restore_flags(flags);
 }
 
-/*
- * do_IRQ handles IRQ's that have been installed without the
- * SA_INTERRUPT flag: it uses the full signal-handling return
- * and runs with other interrupts enabled. All relatively slow
- * IRQ's should use this format: notably the keyboard/timer
- * routines.
- */
-asmlinkage void do_IRQ(int irq, struct pt_regs * regs)
+static unsigned int startup_local3_irq(unsigned int irq)
 {
-	struct irqaction *action;
-	int do_random, cpu;
+	enable_local3_irq(irq);
 
-	cpu = smp_processor_id();
-	irq_enter(cpu);
-	kstat.irqs[0][irq]++;
+	return 0;		/* Never anything pending  */
+}
 
-	printk("Got irq %d, press a key.", irq);
-	prom_getchar();
-	romvec->imode();
+void disable_local3_irq(unsigned int irq)
+{
+	unsigned long flags;
 
+	save_and_cli(flags);
 	/*
-	 * mask and ack quickly, we don't want the irq controller
-	 * thinking we're snobs just because some other CPU has
-	 * disabled global interrupts (we have already done the
-	 * INT_ACK cycles, it's too late to try to pretend to the
-	 * controller that we aren't taking the interrupt).
-	 *
-	 * Commented out because we've already done this in the
-	 * machinespecific part of the handler.  It's reasonable to
-	 * do this here in a highlevel language though because that way
-	 * we could get rid of a good part of duplicated code ...
+	 * This way we'll see if anyone would ever want vectored level 3
+	 * interrupts.  Highly unlikely.
 	 */
-        /* mask_and_ack_irq(irq); */
+	printk("Yeeee, got passed irq_nr %d at disable_local3_irq\n", irq);
+	panic("INVALID IRQ level!");
+	restore_flags(flags);
+}
 
-	action = *(irq + irq_action);
-	if (action) {
-		if (!(action->flags & SA_INTERRUPT))
-			__sti();
-		action = *(irq + irq_action);
-		do_random = 0;
-		do {
-			do_random |= action->flags;
-			action->handler(irq, action->dev_id, regs);
-			action = action->next;
-		} while (action);
-		if (do_random & SA_SAMPLE_RANDOM)
-			add_interrupt_randomness(irq);
-		__cli();
-	}
-	irq_exit(cpu);
+#define shutdown_local3_irq disable_local3_irq
+#define mask_and_ack_local3_irq	disable_local3_irq
 
-	/* unmasking and bottom half handling is done magically for us. */
+static void end_local3_irq (unsigned int irq)
+{
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_local3_irq(irq);
 }
 
-int request_local_irq(unsigned int lirq, void (*func)(int, void *, struct pt_regs *),
-		      unsigned long iflags, const char *dname, void *devid)
+static struct hw_interrupt_type ip22_local3_irq_type = {
+	"IP22 local 3",
+	startup_local3_irq,
+	shutdown_local3_irq,
+	enable_local3_irq,
+	disable_local3_irq,
+	mask_and_ack_local3_irq,
+	end_local3_irq,
+	NULL
+};
+
+void enable_gio_irq(unsigned int irq)
 {
-	struct irqaction *action;
+	/* XXX TODO XXX */
+}
 
-	lirq -= SGINT_LOCAL0;
-	if(lirq >= 24 || !func)
-		return -EINVAL;
+static unsigned int startup_gio_irq(unsigned int irq)
+{
+	enable_gio_irq(irq);
 
-	action = (struct irqaction *)kmalloc(sizeof(struct irqaction), GFP_KERNEL);
-	if(!action)
-		return -ENOMEM;
+	return 0;		/* Never anything pending  */
+}
 
-	action->handler = func;
-	action->flags = iflags;
-	action->mask = 0;
-	action->name = dname;
-	action->dev_id = devid;
-	action->next = 0;
-	local_irq_action[lirq] = action;
-	enable_irq(lirq + SGINT_LOCAL0);
-	return 0;
+void disable_gio_irq(unsigned int irq)
+{
+	/* XXX TODO XXX */
 }
 
-void free_local_irq(unsigned int lirq, void *dev_id)
+#define shutdown_gio_irq	disable_gio_irq
+#define mask_and_ack_gio_irq	disable_gio_irq
+
+static void end_gio_irq (unsigned int irq)
 {
-	struct irqaction *action;
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_gio_irq(irq);
+}
 
-	lirq -= SGINT_LOCAL0;
-	if(lirq >= 24) {
-		printk("Aieee: trying to free bogus local irq %d\n",
-		       lirq + SGINT_LOCAL0);
-		return;
-	}
-	action = local_irq_action[lirq];
-	local_irq_action[lirq] = NULL;
-	disable_irq(lirq + SGINT_LOCAL0);
-	kfree(action);
-}
-
-int request_irq(unsigned int irq, 
-		void (*handler)(int, void *, struct pt_regs *),
-		unsigned long irqflags, 
-		const char * devname,
-		void *dev_id)
-{
-	int retval;
-	struct irqaction * action;
-
-	if (irq >= SGINT_END)
-		return -EINVAL;
-	if (!handler)
-		return -EINVAL;
-
-	if((irq >= SGINT_LOCAL0) && (irq < SGINT_GIO))
-		return request_local_irq(irq, handler, irqflags, devname, dev_id);
-
-	action = (struct irqaction *)kmalloc(sizeof(struct irqaction), GFP_KERNEL);
-	if (!action)
-		return -ENOMEM;
-
-	action->handler = handler;
-	action->flags = irqflags;
-	action->mask = 0;
-	action->name = devname;
-	action->next = NULL;
-	action->dev_id = dev_id;
-
-	retval = setup_indy_irq(irq, action);
-
-	if (retval)
-		kfree(action);
-	return retval;
+static struct hw_interrupt_type ip22_gio_irq_type = {
+	"IP22 GIO",
+	startup_gio_irq,
+	shutdown_gio_irq,
+	enable_gio_irq,
+	disable_gio_irq,
+	mask_and_ack_gio_irq,
+	end_gio_irq,
+	NULL
+};
+
+void enable_hpcdma_irq(unsigned int irq)
+{
+	/* XXX TODO XXX */
 }
-		
-void free_irq(unsigned int irq, void *dev_id)
+
+static unsigned int startup_hpcdma_irq(unsigned int irq)
 {
-	struct irqaction * action, **p;
-	unsigned long flags;
+	enable_hpcdma_irq(irq);
 
-	if (irq >= SGINT_END) {
-		printk("Trying to free IRQ%d\n",irq);
-		return;
-	}
-	if((irq >= SGINT_LOCAL0) && (irq < SGINT_GIO)) {
-		free_local_irq(irq, dev_id);
-		return;
-	}
-	for (p = irq + irq_action; (action = *p) != NULL; p = &action->next) {
-		if (action->dev_id != dev_id)
-			continue;
-
-		/* Found it - now free it */
-		save_and_cli(flags);
-		*p = action->next;
-		restore_flags(flags);
-		kfree(action);
-		return;
-	}
-	printk("Trying to free free IRQ%d\n",irq);
+	return 0;		/* Never anything pending  */
 }
 
-int (*irq_cannonicalize)(int irq);
-
-static int indy_irq_cannonicalize(int irq)
+void disable_hpcdma_irq(unsigned int irq)
 {
-	return irq;	/* Sane hardware, sane code ... */
+	/* XXX TODO XXX */
 }
 
-void __init init_IRQ(void)
+#define shutdown_hpcdma_irq	disable_hpcdma_irq
+#define mask_and_ack_hpcdma_irq	disable_hpcdma_irq
+
+static void end_hpcdma_irq (unsigned int irq)
 {
-	irq_cannonicalize = indy_irq_cannonicalize;
-	irq_setup();
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_hpcdma_irq(irq);
 }
 
+static struct hw_interrupt_type ip22_hpcdma_irq_type = {
+	"IP22 HPC DMA",
+	startup_hpcdma_irq,
+	shutdown_hpcdma_irq,
+	enable_hpcdma_irq,
+	disable_hpcdma_irq,
+	mask_and_ack_hpcdma_irq,
+	end_hpcdma_irq,
+	NULL
+};
+
+static struct irqaction r4ktimer_action = {
+	NULL, 0, 0, "R4000 timer/counter", NULL, NULL,
+};
+
+static struct irqaction indy_berr_action = {
+	NULL, 0, 0, "IP22 Bus Error", NULL, NULL,
+};
+
+static struct irqaction *irq_action[16] = {
+	NULL, NULL, NULL, NULL,
+	NULL, NULL, &indy_berr_action, &r4ktimer_action,
+	NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL
+};
+
 void indy_local0_irqdispatch(struct pt_regs *regs)
 {
-	struct irqaction *action;
 	unsigned char mask = ioc_icontrol->istat0;
 	unsigned char mask2 = 0;
-	int irq, cpu = smp_processor_id();;
+	int irq;
 
 	mask &= ioc_icontrol->imask0;
-	if(mask & ISTAT0_LIO2) {
+	if (mask & ISTAT0_LIO2) {
 		mask2 = ioc_icontrol->vmeistat;
 		mask2 &= ioc_icontrol->cmeimask0;
 		irq = lc2msk_to_irqnr[mask2];
-		action = local_irq_action[irq];
 	} else {
 		irq = lc0msk_to_irqnr[mask];
-		action = local_irq_action[irq];
 	}
 
 	/* if irq == 0, then the interrupt has already been cleared */
-	if ( irq == 0 ) { goto end; }
-	/* if action == NULL, then we do have a handler for the irq */
-	if ( action == NULL ) { goto no_handler; }
-	
-	irq_enter(cpu);
-	kstat.irqs[0][irq + 16]++;
-	action->handler(irq, action->dev_id, regs);
-	irq_exit(cpu);
+	if (irq == 0)
+		goto end;
+
+	do_IRQ(irq, regs);
 	goto end;
 
 no_handler:
 	printk("No handler for local0 irq: %i\n", irq);
 
 end:	
-	return;	
-	
+	return;
 }
 
 void indy_local1_irqdispatch(struct pt_regs *regs)
 {
-	struct irqaction *action;
 	unsigned char mask = ioc_icontrol->istat1;
 	unsigned char mask2 = 0;
-	int irq, cpu = smp_processor_id();;
+	int irq;
 
 	mask &= ioc_icontrol->imask1;
-	if(mask & ISTAT1_LIO3) {
+	if (mask & ISTAT1_LIO3) {
 		printk("WHee: Got an LIO3 irq, winging it...\n");
 		mask2 = ioc_icontrol->vmeistat;
 		mask2 &= ioc_icontrol->cmeimask1;
 		irq = lc3msk_to_irqnr[ioc_icontrol->vmeistat];
-		action = local_irq_action[irq];
 	} else {
 		irq = lc1msk_to_irqnr[mask];
-		action = local_irq_action[irq];
 	}
+
 	/* if irq == 0, then the interrupt has already been cleared */
 	/* not sure if it is needed here, but it is needed for local0 */
-	if ( irq == 0 ) { goto end; }
-	/* if action == NULL, then we do have a handler for the irq */
-	if ( action == NULL ) { goto no_handler; }
-	
-	irq_enter(cpu);
-	kstat.irqs[0][irq + 24]++;
-	action->handler(irq, action->dev_id, regs);
-	irq_exit(cpu);
+	if (irq == 0)
+		goto end;
+
+	do_IRQ(irq, regs);
 	goto end;
 	
 no_handler:
@@ -520,27 +417,16 @@
 	int cpu = smp_processor_id();
 	int irq = 6;
 
-	irq_enter(cpu);
+	irq_enter(cpu, irq);
 	kstat.irqs[0][irq]++;
 	printk("Got a bus error IRQ, shouldn't happen yet\n");
 	show_regs(regs);
 	printk("Spinning...\n");
 	while(1);
-	irq_exit(cpu);
-}
-
-/* Misc. crap just to keep the kernel linking... */
-unsigned long probe_irq_on (void)
-{
-	return 0;
+	irq_exit(cpu, irq);
 }
 
-int probe_irq_off (unsigned long irqs)
-{
-	return 0;
-}
-
-void __init sgint_init(void)
+void __init init_IRQ(void)
 {
 	int i;
 
@@ -548,43 +434,43 @@
 	sgi_i3regs = (struct sgi_int3_regs *) (KSEG1 + SGI_INT3_BASE);
 
 	/* Init local mask --> irq tables. */
-	for(i = 0; i < 256; i++) {
-		if(i & 0x80) {
+	for (i = 0; i < 256; i++) {
+		if (i & 0x80) {
 			lc0msk_to_irqnr[i] = 7;
 			lc1msk_to_irqnr[i] = 15;
 			lc2msk_to_irqnr[i] = 23;
 			lc3msk_to_irqnr[i] = 31;
-		} else if(i & 0x40) {
+		} else if (i & 0x40) {
 			lc0msk_to_irqnr[i] = 6;
 			lc1msk_to_irqnr[i] = 14;
 			lc2msk_to_irqnr[i] = 22;
 			lc3msk_to_irqnr[i] = 30;
-		} else if(i & 0x20) {
+		} else if (i & 0x20) {
 			lc0msk_to_irqnr[i] = 5;
 			lc1msk_to_irqnr[i] = 13;
 			lc2msk_to_irqnr[i] = 21;
 			lc3msk_to_irqnr[i] = 29;
-		} else if(i & 0x10) {
+		} else if (i & 0x10) {
 			lc0msk_to_irqnr[i] = 4;
 			lc1msk_to_irqnr[i] = 12;
 			lc2msk_to_irqnr[i] = 20;
 			lc3msk_to_irqnr[i] = 28;
-		} else if(i & 0x08) {
+		} else if (i & 0x08) {
 			lc0msk_to_irqnr[i] = 3;
 			lc1msk_to_irqnr[i] = 11;
 			lc2msk_to_irqnr[i] = 19;
 			lc3msk_to_irqnr[i] = 27;
-		} else if(i & 0x04) {
+		} else if (i & 0x04) {
 			lc0msk_to_irqnr[i] = 2;
 			lc1msk_to_irqnr[i] = 10;
 			lc2msk_to_irqnr[i] = 18;
 			lc3msk_to_irqnr[i] = 26;
-		} else if(i & 0x02) {
+		} else if (i & 0x02) {
 			lc0msk_to_irqnr[i] = 1;
 			lc1msk_to_irqnr[i] = 9;
 			lc2msk_to_irqnr[i] = 17;
 			lc3msk_to_irqnr[i] = 25;
-		} else if(i & 0x01) {
+		} else if (i & 0x01) {
 			lc0msk_to_irqnr[i] = 0;
 			lc1msk_to_irqnr[i] = 8;
 			lc2msk_to_irqnr[i] = 16;
@@ -614,6 +500,29 @@
 	ioc_icontrol->cmeimask0 = 0;
 	ioc_icontrol->cmeimask1 = 0;
 
-	/* Now safe to set the exception vector. */
 	set_except_vector(0, indyIRQ);
+
+	init_generic_irq();
+
+	for (i = SGINT_LOCAL0; i < SGINT_END; i++) {
+		hw_irq_controller *handler;
+
+		if (i < SGINT_LOCAL1)
+			handler		= &ip22_local0_irq_type;
+		else if (i < SGINT_LOCAL2)
+			handler		= &ip22_local1_irq_type;
+		else if (i < SGINT_LOCAL3)
+			handler		= &ip22_local2_irq_type;
+		else if (i < SGINT_GIO)
+			handler		= &ip22_local3_irq_type;
+		else if (i < SGINT_HPCDMA)
+			handler		= &ip22_gio_irq_type;
+		else if (i < SGINT_END)
+			handler		= &ip22_hpcdma_irq_type;
+
+		irq_desc[i].status	= IRQ_DISABLED;
+		irq_desc[i].action	= 0;
+		irq_desc[i].depth	= 1;
+		irq_desc[i].handler	= handler;
+	}
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips/sgi/kernel/indy_rtc.c linux/arch/mips/sgi/kernel/indy_rtc.c
--- v2.4.9/linux/arch/mips/sgi/kernel/indy_rtc.c	Sat May 13 08:29:14 2000
+++ linux/arch/mips/sgi/kernel/indy_rtc.c	Sun Sep  9 10:43:02 2001
@@ -1,12 +1,11 @@
-/* $Id: indy_rtc.c,v 1.1 1998/06/30 00:21:58 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * RTC routines for Indy style attached Dallas chip.
  *
- * Copyright (C) 1998 by Ralf Baechle
+ * Copyright (C) 1998, 2001 by Ralf Baechle
  */
 #include <linux/mc146818rtc.h>
 #include <asm/sgi/sgihpc.h>
diff -u --recursive --new-file v2.4.9/linux/arch/mips/sgi/kernel/indy_sc.c linux/arch/mips/sgi/kernel/indy_sc.c
--- v2.4.9/linux/arch/mips/sgi/kernel/indy_sc.c	Tue Mar  6 19:44:36 2001
+++ linux/arch/mips/sgi/kernel/indy_sc.c	Sun Sep  9 10:43:02 2001
@@ -1,8 +1,7 @@
-/* $Id: indy_sc.c,v 1.14 2000/03/25 22:35:07 ralf Exp $
- *
+/*
  * indy_sc.c: Indy cache management functions.
  *
- * Copyright (C) 1997 Ralf Baechle (ralf@gnu.org),
+ * Copyright (C) 1997, 2001 Ralf Baechle (ralf@gnu.org),
  * derived from r4xx0.c by David S. Miller (dm@engr.sgi.com).
  */
 #include <linux/init.h>
@@ -34,30 +33,30 @@
 {
 	unsigned long tmp;
 
-	__asm__ __volatile__("
-		.set	noreorder
-		.set	mips3
-		.set	noat
-		mfc0	%2, $12
-		li	$1, 0x80	# Go 64 bit
-		mtc0	$1, $12
-
-		dli	$1, 0x9000000080000000
-		or	%0, $1		# first line to flush
-		or	%1, $1		# last line to flush
-		.set	at
-
-1:		sw	$0, 0(%0)
-		bne	%0, %1, 1b
-		daddu	%0, 32
-
-		mtc0	%2, $12		# Back to 32 bit
-		nop; nop; nop; nop;
-		.set mips0
-		.set reorder"
-		: "=r" (first), "=r" (last), "=&r" (tmp)
-		: "0" (first), "1" (last)
-		: "$1");
+	__asm__ __volatile__(
+	".set\tnoreorder\t\t\t# indy_sc_wipe\n\t"
+	".set\tmips3\n\t"
+	".set\tnoat\n\t"
+	"mfc0\t%2, $12\n\t"
+	"li\t$1, 0x80\t\t\t# Go 64 bit\n\t"
+	"mtc0\t$1, $12\n\t"
+
+	"dli\t$1, 0x9000000080000000\n\t"
+	"or\t%0, $1\t\t\t# first line to flush\n\t"
+	"or\t%1, $1\t\t\t# last line to flush\n\t"
+	".set\tat\n\t"
+
+	"1:\tsw\t$0, 0(%0)\n\t"
+	"bne\t%0, %1, 1b\n\t"
+	"daddu\t%0, 32\n\t"
+
+	"mtc0\t%2, $12\t\t\t# Back to 32 bit\n\t"
+	"nop; nop; nop; nop;\n\t"
+	".set\tmips0\n\t"
+	".set\treorder"
+	: "=r" (first), "=r" (last), "=&r" (tmp)
+	: "0" (first), "1" (last)
+	: "$1");
 }
 
 static void indy_sc_wback_invalidate(unsigned long addr, unsigned long size)
@@ -96,27 +95,27 @@
 #ifdef DEBUG_CACHE
 	printk("Enabling R4600 SCACHE\n");
 #endif
-	__asm__ __volatile__("
-		.set	push
-		.set	noreorder
-		.set	mips3
-		mfc0	%2, $12
-		nop; nop; nop; nop;
-		li	%1, 0x80
-		mtc0	%1, $12
-		nop; nop; nop; nop;
-		li	%0, 0x1
-		dsll	%0, 31
-		lui	%1, 0x9000
-		dsll32	%1, 0
-		or	%0, %1, %0
-		sb	$0, 0(%0)
-		mtc0	$0, $12
-		nop; nop; nop; nop;
-		mtc0	%2, $12
-		nop; nop; nop; nop;
-		.set	pop"
-		: "=r" (tmp1), "=r" (tmp2), "=r" (addr));
+	__asm__ __volatile__(
+	".set\tpush\n\t"
+	".set\tnoreorder\n\t"
+	".set\tmips3\n\t"
+	"mfc0\t%2, $12\n\t"
+	"nop; nop; nop; nop;\n\t"
+	"li\t%1, 0x80\n\t"
+	"mtc0\t%1, $12\n\t"
+	"nop; nop; nop; nop;\n\t"
+	"li\t%0, 0x1\n\t"
+	"dsll\t%0, 31\n\t"
+	"lui\t%1, 0x9000\n\t"
+	"dsll32\t%1, 0\n\t"
+	"or\t%0, %1, %0\n\t"
+	"sb\t$0, 0(%0)\n\t"
+	"mtc0\t$0, $12\n\t"
+	"nop; nop; nop; nop;\n\t"
+	"mtc0\t%2, $12\n\t"
+	"nop; nop; nop; nop;\n\t"
+	".set\tpop"
+	: "=r" (tmp1), "=r" (tmp2), "=r" (addr));
 }
 
 static void indy_sc_disable(void)
@@ -126,27 +125,27 @@
 #ifdef DEBUG_CACHE
 	printk("Disabling R4600 SCACHE\n");
 #endif
-	__asm__ __volatile__("
-		.set	push
-		.set	noreorder
-		.set	mips3
-		li	%0, 0x1
-		dsll	%0, 31
-		lui	%1, 0x9000
-		dsll32	%1, 0
-		or	%0, %1, %0
-		mfc0	%2, $12
-		nop; nop; nop; nop;
-		li	%1, 0x80
-		mtc0	%1, $12
-		nop; nop; nop; nop;
-		sh	$0, 0(%0)
-		mtc0	$0, $12
-		nop; nop; nop; nop;
-		mtc0	%2, $12
-		nop; nop; nop; nop;
-		.set	pop"
-		: "=r" (tmp1), "=r" (tmp2), "=r" (tmp3));
+	__asm__ __volatile__(
+	".set\tpush\n\t"
+	".set\tnoreorder\n\t"
+	".set\tmips3\n\t"
+	"li\t%0, 0x1\n\t"
+	"dsll\t%0, 31\n\t"
+	"lui\t%1, 0x9000\n\t"
+	"dsll32\t%1, 0\n\t"
+	"or\t%0, %1, %0\n\t"
+	"mfc0\t%2, $12\n\t"
+	"nop; nop; nop; nop\n\t"
+	"li\t%1, 0x80\n\t"
+	"mtc0\t%1, $12\n\t"
+	"nop; nop; nop; nop\n\t"
+	"sh\t$0, 0(%0)\n\t"
+	"mtc0\t$0, $12\n\t"
+	"nop; nop; nop; nop\n\t"
+	"mtc0\t%2, $12\n\t"
+	"nop; nop; nop; nop\n\t"
+	".set\tpop"
+	: "=r" (tmp1), "=r" (tmp2), "=r" (tmp3));
 }
 
 static inline int __init indy_sc_probe(void)
diff -u --recursive --new-file v2.4.9/linux/arch/mips/sgi/kernel/indy_timer.c linux/arch/mips/sgi/kernel/indy_timer.c
--- v2.4.9/linux/arch/mips/sgi/kernel/indy_timer.c	Mon Oct 16 12:58:51 2000
+++ linux/arch/mips/sgi/kernel/indy_timer.c	Wed Dec 31 16:00:00 1969
@@ -1,266 +0,0 @@
-/* $Id: indy_timer.c,v 1.17 2000/01/21 22:34:03 ralf Exp $
- *
- * indy_timer.c: Setting up the clock on the INDY 8254 controller.
- *
- * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
- * Copytight (C) 1997, 1998 Ralf Baechle (ralf@gnu.org)
- */
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/param.h>
-#include <linux/string.h>
-#include <linux/mm.h>
-#include <linux/interrupt.h>
-#include <linux/timex.h>
-#include <linux/kernel_stat.h>
-
-#include <asm/bootinfo.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/ptrace.h>
-#include <asm/system.h>
-#include <asm/sgialib.h>
-#include <asm/sgi/sgi.h>
-#include <asm/sgi/sgihpc.h>
-#include <asm/sgi/sgint23.h>
-
-
-/* Because of a bug in the i8254 timer we need to use the onchip r4k
- * counter as our system wide timer interrupt running at 100HZ.
- */
-static unsigned long r4k_offset; /* Amount to increment compare reg each time */
-static unsigned long r4k_cur;    /* What counter should be at next timer irq */
-
-extern rwlock_t xtime_lock;
-
-static inline void ack_r4ktimer(unsigned long newval)
-{
-	write_32bit_cp0_register(CP0_COMPARE, newval);
-}
-
-static int set_rtc_mmss(unsigned long nowtime)
-{
-	struct indy_clock *clock = (struct indy_clock *)INDY_CLOCK_REGS;
-	int retval = 0;
-	int real_seconds, real_minutes, clock_minutes;
-
-#define FROB_FROM_CLOCK(x) (((x) & 0xf) | ((((x) & 0xf0) >> 4) * 10));
-#define FROB_TO_CLOCK(x)  ((((((x) & 0xff) / 10)<<4) | (((x) & 0xff) % 10)) & 0xff)
-
-	clock->cmd &= ~(0x80);
-	clock_minutes = clock->min;
-	clock->cmd |= (0x80);
-
-	clock_minutes = FROB_FROM_CLOCK(clock_minutes);
-	real_seconds = nowtime % 60;
-	real_minutes = nowtime / 60;
-
-	if(((abs(real_minutes - clock_minutes) + 15)/30) & 1)
-		real_minutes += 30; /* correct for half hour time zone */
-
-	real_minutes %= 60;
-	if(abs(real_minutes - clock_minutes) < 30) {
-		/* Force clock oscillator to be on. */
-		clock->month &= ~(0x80);
-
-		/* Write real_seconds and real_minutes into the Dallas. */
-		clock->cmd &= ~(0x80);
-		clock->sec = real_seconds;
-		clock->min = real_minutes;
-		clock->cmd |= (0x80);
-	} else
-		return -1;
-
-#undef FROB_FROM_CLOCK
-#undef FROB_TO_CLOCK
-
-	return retval;
-}
-
-static long last_rtc_update;
-unsigned long missed_heart_beats;
-
-void indy_timer_interrupt(struct pt_regs *regs)
-{
-	unsigned long count;
-	int irq = 7;
-
-	write_lock(&xtime_lock);
-	/* Ack timer and compute new compare. */
-	count = read_32bit_cp0_register(CP0_COUNT);
-	/* This has races.  */
-	if ((count - r4k_cur) >= r4k_offset) {
-		/* If this happens to often we'll need to compensate.  */
-		missed_heart_beats++;
-		r4k_cur = count + r4k_offset;
-	}
-        else
-            r4k_cur += r4k_offset;
-	ack_r4ktimer(r4k_cur);
-	kstat.irqs[0][irq]++;
-	do_timer(regs);
-
-	/* We update the Dallas time of day approx. every 11 minutes,
-	 * because of how the numbers work out we need to make
-	 * absolutely sure we do this update within 500ms before the
-	 * next second starts, thus the following code.
-	 */
-	if ((time_status & STA_UNSYNC) == 0 &&
-	    xtime.tv_sec > last_rtc_update + 660 &&
-	    xtime.tv_usec >= 500000 - (tick >> 1) &&
-	    xtime.tv_usec <= 500000 + (tick >> 1)) {
-		if (set_rtc_mmss(xtime.tv_sec) == 0)
-			last_rtc_update = xtime.tv_sec;
-		else
-			/* do it again in 60 s */
-			last_rtc_update = xtime.tv_sec - 600;
-	}
-	write_unlock(&xtime_lock);
-}
-
-static unsigned long dosample(volatile unsigned char *tcwp,
-                              volatile unsigned char *tc2p)
-{
-	unsigned long ct0, ct1;
-	unsigned char msb, lsb;
-
-	/* Start the counter. */
-	*tcwp = (SGINT_TCWORD_CNT2 | SGINT_TCWORD_CALL | SGINT_TCWORD_MRGEN);
-	*tc2p = (SGINT_TCSAMP_COUNTER & 0xff);
-	*tc2p = (SGINT_TCSAMP_COUNTER >> 8);
-
-	/* Get initial counter invariant */
-	ct0 = read_32bit_cp0_register(CP0_COUNT);
-
-	/* Latch and spin until top byte of counter2 is zero */
-	do {
-		*tcwp = (SGINT_TCWORD_CNT2 | SGINT_TCWORD_CLAT);
-		lsb = *tc2p;
-		msb = *tc2p;
-		ct1 = read_32bit_cp0_register(CP0_COUNT);
-	} while(msb);
-
-	/* Stop the counter. */
-	*tcwp = (SGINT_TCWORD_CNT2 | SGINT_TCWORD_CALL | SGINT_TCWORD_MSWST);
-
-	/* Return the difference, this is how far the r4k counter increments
-	 * for every one HZ.
-	 */
-	return ct1 - ct0;
-}
-
-static unsigned long __init get_indy_time(void)
-{
-	struct indy_clock *clock = (struct indy_clock *)INDY_CLOCK_REGS;
-	unsigned int year, mon, day, hour, min, sec;
-
-	/* Freeze it. */
-	clock->cmd &= ~(0x80);
-
-	/* Read regs. */
-	sec = clock->sec;
-	min = clock->min;
-	hour = (clock->hr & 0x3f);
-	day = (clock->date & 0x3f);
-	mon = (clock->month & 0x1f);
-	year = clock->year;
-
-	/* Unfreeze clock. */
-	clock->cmd |= 0x80;
-
-	/* Frob the bits. */
-#define FROB1(x)  (((x) & 0xf) + ((((x) & 0xf0) >> 4) * 10));
-#define FROB2(x)  (((x) & 0xf) + (((((x) & 0xf0) >> 4) & 0x3) * 10));
-
-	/* XXX Should really check that secs register is the same
-	 * XXX as when we first read it and if not go back and
-	 * XXX read the regs above again.
-	 */
-	sec = FROB1(sec); min = FROB1(min); day = FROB1(day);
-	mon = FROB1(mon); year = FROB1(year);
-	hour = FROB2(hour);
-
-#undef FROB1
-#undef FROB2
-
-	/* Wheee... */
-	if(year < 45)
-		year += 30;
-	if ((year += 1940) < 1970)
-		year += 100;
-
-	return mktime(year, mon, day, hour, min, sec);
-}
-
-#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
-
-void __init indy_timer_init(void)
-{
-	struct sgi_ioc_timers *p;
-	volatile unsigned char *tcwp, *tc2p;
-
-	/* Figure out the r4k offset, the algorithm is very simple
-	 * and works in _all_ cases as long as the 8254 counter
-	 * register itself works ok (as an interrupt driving timer
-	 * it does not because of bug, this is why we are using
-	 * the onchip r4k counter/compare register to serve this
-	 * purpose, but for r4k_offset calculation it will work
-	 * ok for us).  There are other very complicated ways
-	 * of performing this calculation but this one works just
-	 * fine so I am not going to futz around. ;-)
-	 */
-	p = ioc_timers;
-	tcwp = &p->tcword;
-	tc2p = &p->tcnt2;
-
-	printk("calculating r4koff... ");
-	dosample(tcwp, tc2p);			/* First sample. */
-	dosample(tcwp, tc2p);			/* Eat one.	*/
-	r4k_offset = dosample(tcwp, tc2p);	/* Second sample. */
-
-	printk("%08lx(%d)\n", r4k_offset, (int) r4k_offset);
-
-	r4k_cur = (read_32bit_cp0_register(CP0_COUNT) + r4k_offset);
-	write_32bit_cp0_register(CP0_COMPARE, r4k_cur);
-	set_cp0_status(ST0_IM, ALLINTS);
-	sti();
-
-	write_lock_irq(&xtime_lock);
-	xtime.tv_sec = get_indy_time();		/* Read time from RTC. */
-	xtime.tv_usec = 0;
-	write_unlock_irq(&xtime_lock);
-}
-
-void indy_8254timer_irq(void)
-{
-	int cpu = smp_processor_id();
-	int irq = 4;
-
-	irq_enter(cpu);
-	kstat.irqs[0][irq]++;
-	printk("indy_8254timer_irq: Whoops, should not have gotten this IRQ\n");
-	prom_getchar();
-	prom_imode();
-	irq_exit(cpu);
-}
-
-void do_gettimeofday(struct timeval *tv)
-{
-	unsigned long flags;
-
-	read_lock_irqsave(&xtime_lock, flags);
-	*tv = xtime;
-	read_unlock_irqrestore(&xtime_lock, flags);
-}
-
-void do_settimeofday(struct timeval *tv)
-{
-	write_lock_irq(&xtime_lock);
-	xtime = *tv;
-	time_state = TIME_BAD;
-	time_maxerror = MAXPHASE;
-	time_esterror = MAXPHASE;
-	write_unlock_irq(&xtime_lock);
-}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/sgi/kernel/promcon.c linux/arch/mips/sgi/kernel/promcon.c
--- v2.4.9/linux/arch/mips/sgi/kernel/promcon.c	Thu Oct 12 14:20:48 2000
+++ linux/arch/mips/sgi/kernel/promcon.c	Wed Dec 31 16:00:00 1969
@@ -1,68 +0,0 @@
-/*
- * Wrap-around code for a console using the
- * SGI PROM io-routines.
- *
- * Copyright (c) 1999 Ulf Carlsson
- *
- * Derived from DECstation promcon.c
- * Copyright (c) 1998 Harald Koerfgen 
- */
-
-#include <linux/tty.h>
-#include <linux/major.h>
-#include <linux/ptrace.h>
-#include <linux/init.h>
-#include <linux/console.h>
-#include <linux/fs.h>
-
-#include <asm/sgialib.h>
-
-static void prom_console_write(struct console *co, const char *s,
-			       unsigned count)
-{
-    unsigned i;
-
-    /*
-     *    Now, do each character
-     */
-    for (i = 0; i < count; i++) {
-	if (*s == 10)
-	    prom_printf("%c", 13);
-	prom_printf("%c", *s++);
-    }
-}
-
-static int prom_console_wait_key(struct console *co)
-{
-    return prom_getchar();
-}
-
-static int __init prom_console_setup(struct console *co, char *options)
-{
-    return 0;
-}
-
-static kdev_t prom_console_device(struct console *c)
-{
-    return MKDEV(TTY_MAJOR, 64 + c->index);
-}
-
-static struct console sercons =
-{
-    name:	"ttyS",
-    write:	prom_console_write,
-    device:	prom_console_device,
-    wait_key:	prom_console_wait_key,
-    setup:	prom_console_setup,
-    flags:	CON_PRINTBUFFER,
-    index:	-1,
-};
-
-/*
- *    Register console.
- */
-
-void __init sgi_prom_console_init(void )
-{
-    register_console(&sercons);
-}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/sgi/kernel/reset.c linux/arch/mips/sgi/kernel/reset.c
--- v2.4.9/linux/arch/mips/sgi/kernel/reset.c	Sat May 13 08:29:14 2000
+++ linux/arch/mips/sgi/kernel/reset.c	Sun Sep  9 10:43:02 2001
@@ -1,12 +1,9 @@
-/* $Id: reset.c,v 1.7 1999/08/11 20:26:51 andrewb Exp $
- *
- * Reset a SGI.
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1997, 1998 by Ralf Baechle
+ * Copyright (C) 1997, 1998, 2001 by Ralf Baechle
  */
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -54,7 +51,7 @@
 {
 	if (shuting_down)
 		sgi_machine_power_off();
-	prom_imode();
+	ArcEnterInteractiveMode();
 }
 
 static void sgi_machine_power_off(void)
diff -u --recursive --new-file v2.4.9/linux/arch/mips/sgi/kernel/setup.c linux/arch/mips/sgi/kernel/setup.c
--- v2.4.9/linux/arch/mips/sgi/kernel/setup.c	Tue Mar  6 19:44:36 2001
+++ linux/arch/mips/sgi/kernel/setup.c	Sun Sep  9 10:43:02 2001
@@ -24,6 +24,7 @@
 #include <asm/sgi/sgimc.h>
 #include <asm/sgi/sgihpc.h>
 #include <asm/sgi/sgint23.h>
+#include <asm/time.h>
 #include <asm/gdb-stub.h>
 
 #ifdef CONFIG_REMOTE_DEBUG
@@ -32,7 +33,7 @@
 static int remote_debug = 0;
 #endif
 
-#if defined(CONFIG_SERIAL_CONSOLE) || defined(CONFIG_SGI_PROM_CONSOLE)
+#if defined(CONFIG_SERIAL_CONSOLE) || defined(CONFIG_ARC_CONSOLE)
 extern void console_setup(char *);
 #endif
 
@@ -117,28 +118,6 @@
 	sgi_read_status
 };
 
-static void __init sgi_irq_setup(void)
-{
-	sgint_init();
-
-#ifdef CONFIG_REMOTE_DEBUG
-	if (remote_debug)
-		set_debug_traps();
-	breakpoint(); /* you may move this line to whereever you want :-) */
-#endif
-}
-
-int __init page_is_ram(unsigned long pagenr)
-{
-	if ((pagenr<<PAGE_SHIFT) < 0x2000UL)
-		return 1;
-	if ((pagenr<<PAGE_SHIFT) > 0x08002000)
-		return 1;
-	return 0;
-}
-
-void (*board_time_init)(struct irqaction *irq);
-
 static unsigned long dosample(volatile unsigned char *tcwp,
                               volatile unsigned char *tc2p)
 {
@@ -161,14 +140,16 @@
                 ct1 = read_32bit_cp0_register(CP0_COUNT);
         } while(msb);
 
-        /* Stop the counter. */
-        *tcwp = (SGINT_TCWORD_CNT2 | SGINT_TCWORD_CALL | SGINT_TCWORD_MSWST);
+	/* Stop the counter. */
+	*tcwp = (SGINT_TCWORD_CNT2 | SGINT_TCWORD_CALL | SGINT_TCWORD_MSWST);
 
-        /* Return the difference, this is how far the r4k counter increments
-         * for every 1/HZ seconds. We round off the nearest 1 MHz of
-	 * master clock (= 1000000 / 100 / 2 = 5000 count).
-         */
-        return ((ct1 - ct0) / 5000) * 5000;
+	/*
+	 * Return the difference, this is how far the r4k counter increments
+	 * for every 1/HZ seconds. We round off the nearest 1 MHz of master
+	 * clock (= 1000000 / 100 / 2 = 5000 count).
+	 */
+
+	return ((ct1 - ct0) / 5000) * 5000;
 }
 
 #define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
@@ -180,7 +161,7 @@
 	 */
         struct sgi_ioc_timers *p;
         volatile unsigned char *tcwp, *tc2p;
-	unsigned long r4k_ticks[3] = { 0, 0, 0 };
+	unsigned long r4k_ticks[3];
 	unsigned long r4k_next;
 
         /* Figure out the r4k offset, the algorithm is very simple
@@ -201,10 +182,12 @@
         dosample(tcwp, tc2p);                   /* Prime cache. */
         dosample(tcwp, tc2p);                   /* Prime cache. */
 	/* Zero is NOT an option. */
-	while (!r4k_ticks[0])
+	do {
 		r4k_ticks[0] = dosample (tcwp, tc2p);
-	while (!r4k_ticks[1])
+	} while (!r4k_ticks[0]);
+	do {
 		r4k_ticks[1] = dosample (tcwp, tc2p);
+	} while (!r4k_ticks[1]);
 
 	if (r4k_ticks[0] != r4k_ticks[1]) {
 		printk ("warning: timer counts differ, retrying...");
@@ -226,7 +209,7 @@
 	/* Set ourselves up for future interrupts */
         r4k_next = (read_32bit_cp0_register(CP0_COUNT) + r4k_interval);
         write_32bit_cp0_register(CP0_COMPARE, r4k_next);
-        set_cp0_status(ST0_IM, ALLINTS);
+        change_cp0_status(ST0_IM, ALLINTS);
 	sti ();
 }
 
@@ -239,8 +222,6 @@
 	char *kgdb_ttyd;
 #endif
 
-
-	irq_setup = sgi_irq_setup;
 	board_time_init = sgi_time_init;
 
 	/* Init the INDY HPC I/O controller.  Need to call this before
@@ -282,7 +263,7 @@
 		       line ? 1 : 2);
 		rs_kgdb_hook(line);
 
-		prom_printf("KGDB: Using serial line /dev/ttyd%d for session, "
+		printk("KGDB: Using serial line /dev/ttyd%d for session, "
 			    "please connect your debugger\n", line ? 1 : 2);
 
 		remote_debug = 1;
@@ -290,7 +271,7 @@
 	}
 #endif
 
-#ifdef CONFIG_SGI_PROM_CONSOLE
+#ifdef CONFIG_ARC_CONSOLE
 	console_setup("ttyS0");
 #endif
  
@@ -324,5 +305,4 @@
 #ifdef CONFIG_VIDEO_VINO
 	init_vino();
 #endif
-
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips/sgi/kernel/time.c linux/arch/mips/sgi/kernel/time.c
--- v2.4.9/linux/arch/mips/sgi/kernel/time.c	Sun Jul  9 22:18:15 2000
+++ linux/arch/mips/sgi/kernel/time.c	Sun Sep  9 10:43:02 2001
@@ -9,13 +9,13 @@
 
 void indy_8254timer_irq(void)
 {
-        int cpu = smp_processor_id();
-        int irq = 4;
+	int cpu = smp_processor_id();
+	int irq = 4;
 
-        irq_enter(cpu);
-        kstat.irqs[0][irq]++;
-        printk("indy_8254timer_irq: Whoops, should not have gotten this IRQ\n");
-        prom_getchar();
-        prom_imode();
-        irq_exit(cpu);
+	irq_enter(cpu, irq);
+	kstat.irqs[0][irq]++;
+	printk("indy_8254timer_irq: Whoops, should not have gotten this IRQ\n");
+	prom_getchar();
+	ArcEnterInteractiveMode();
+	irq_exit(cpu, irq);
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips/sni/dma.c linux/arch/mips/sni/dma.c
--- v2.4.9/linux/arch/mips/sni/dma.c	Sat May 13 08:29:14 2000
+++ linux/arch/mips/sni/dma.c	Wed Dec 31 16:00:00 1969
@@ -1,42 +0,0 @@
-/* $Id: dma.c,v 1.1 2000/02/18 00:24:30 ralf Exp $
- *
- * Dynamic DMA mapping support.
- *
- * On RM200 there is no hardware dynamic DMA address translation,
- * so consistent alloc/free are merely page allocation/freeing.
- * The rest of the dynamic DMA mapping interface is implemented
- * in <asm/pci.h>.
- *
- * These routines assume that the RM has all it's memory at physical
- * addresses of < 512mb.
- */
-#include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/pci.h>
-#include <asm/io.h>
-
-void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
-			   dma_addr_t *dma_handle)
-{
-	void *ret;
-	int gfp = GFP_ATOMIC;
-	int order = get_order(size);
-
-	if (hwdev == NULL || hwdev->dma_mask != 0xffffffff)
-		gfp |= GFP_DMA;
-	ret = (void *)__get_free_pages(gfp, order);
-
-	if (ret != NULL) {
-		memset(ret, 0, size);
-		*dma_handle = virt_to_bus(ret);
-	}
-	dma_cache_wback_inv(ret, PAGE_SIZE << order);
-	return KSEG1ADDR(ret);
-}
-
-void pci_free_consistent(struct pci_dev *hwdev, size_t size,
-			 void *vaddr, dma_addr_t dma_handle)
-{
-	free_pages((unsigned long)vaddr, get_order(size));
-}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/sni/int-handler.S linux/arch/mips/sni/int-handler.S
--- v2.4.9/linux/arch/mips/sni/int-handler.S	Sat May 13 08:29:14 2000
+++ linux/arch/mips/sni/int-handler.S	Sun Sep  9 10:43:02 2001
@@ -1,8 +1,7 @@
-/* $Id: int-handler.S,v 1.4 1999/01/04 16:03:58 ralf Exp $
- *
+/*
  * SNI RM200 PCI specific interrupt handler code.
  *
- * Copyright (C) 1994 - 1997 by Ralf Baechle
+ * Copyright (C) 1994, 95, 96, 97, 98, 1999, 2000 by Ralf Baechle
  */
 #include <asm/asm.h>
 #include <asm/mipsregs.h>
@@ -37,22 +36,14 @@
 		mfc0	t1, CP0_CAUSE
 		and	t0, t1
 
-		/* The following interrupt dispatch tests for hwint 1 /
-		   EISA bridge first such that the timer interrupt get the
-		   highest priority.  */
-		 andi	t1, t0, 0x0800			# hardware interrupt 1
-		bnez	t1, hwint1
-		 andi	t1, t0, 0x4000			# hardware interrupt 4
-		bnez	t1, hwint4
-
+		 andi	t1, t0, 0x4a00			# hardware interrupt 1
+		bnez	t1, _hwint134
 		 andi	t1, t0, 0x1000			# hardware interrupt 2
-		bnez	t1, hwint2
-		 andi	t1, t0, 0x2000			# hardware interrupt 3
-		bnez	t1, hwint3
+		bnez	t1, _hwint2
 		 andi	t1, t0, 0x8000			# hardware interrupt 5
-		bnez	t1, hwint5
+		bnez	t1, _hwint5
 		 andi	t1, t0, 0x0400			# hardware interrupt 0
-		bnez	t1, hwint0
+		bnez	t1, _hwint0
 		 nop
 
 		j	return				# spurious interrupt
@@ -60,66 +51,23 @@
 
  ##############################################################################
 
-swint0:		PANIC("swint0")
-swint1:		PANIC("swint1")
-
- /* ------------------------------------------------------------------------ */
-
-/* hwint1 deals with EISA and SCSI interrupts.  */
-hwint1:		lbu	s0, PCIMT_CSITPEND
-
-		andi	t1, s0, 0x20
-		beqz	t1, 1f
-		 andi	s1, s0, 0x40
-		lbu	a0, PCIMT_INT_ACKNOWLEDGE	# IACK cycle
-		xori	t0, a0, 0xff
-		beqz	t0, 1f				# spurious interrupt?
-		 nop
-		jal	i8259_do_irq			# call real handler
-		 move	a1, sp
-
-1:		bnez	s1, 1f
-		 li	a0, PCIMT_IRQ_SCSI
-		jal	do_IRQ
-		 move	a1, sp
-
-1:		lui	t0, %hi(PCIMT_CSITPEND)
-		j	ret_from_irq
-		 lbu	zero, %lo(PCIMT_CSITPEND)(t0)
-
- /* ------------------------------------------------------------------------ */
-
 /* hwint0 should deal with MP agent, ASIC PCI, EISA NMI and debug
    button interrupts.  */
-hwint0:		PANIC("Received int0 but no handler yet ...\n")
-1:		j	1b
-		 nop
-
-go_spurious:	j	spurious_interrupt		# we got fooled
-		 nop
-
-/* hwint4 is used for only the onboard PCnet 32.  */
-hwint4:		mfc0	s0, CP0_STATUS
-		ori	t0, s0, 0x4000
-		xori	t0, 0x4000
-		mtc0	t0, CP0_STATUS
-
-		li	a0, PCIMT_IRQ_ETHERNET
-		jal	do_IRQ
+_hwint0:	jal	pciasic_hwint0
 		 move	a1, sp
 
-		mtc0	s0, CP0_STATUS
+/*
+ * hwint 1 deals with EISA and SCSI interrupts,
+ * hwint 3 should deal with the PCI A - D interrupts,
+ * hwint 4 is used for only the onboard PCnet 32.
+ */
+_hwint134:	jal	pciasic_hwint134
 
-		j	ret_from_irq
-		 nop
 
 /* This interrupt was used for the com1 console on the first prototypes.  */
-hwint2:		PANIC("hwint2 and no handler yet")
-
-/* hwint3 should deal with the PCI A - D interrupts.  */
-hwint3:		PANIC("hwint3 and no handler yet")
+_hwint2:	jal	pciasic_hwint2
 
 /* hwint5 is the r4k count / compare interrupt  */
-hwint5:		PANIC("hwint5 and no handler yet")
+_hwint5:	jal	pciasic_hwint5
 
 		END(sni_rm200_pci_handle_int)
diff -u --recursive --new-file v2.4.9/linux/arch/mips/sni/irq.c linux/arch/mips/sni/irq.c
--- v2.4.9/linux/arch/mips/sni/irq.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips/sni/irq.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,159 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 1992 Linus Torvalds
+ * Copyright (C) 1994 - 2000 Ralf Baechle
+ */
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/spinlock.h>
+
+#include <asm/io.h>
+#include <asm/sni.h>
+
+spinlock_t pciasic_lock = SPIN_LOCK_UNLOCKED;
+
+extern asmlinkage void sni_rm200_pci_handle_int(void);
+extern void do_IRQ(int irq, struct pt_regs *regs);
+
+static void enable_pciasic_irq(unsigned int irq);
+
+static unsigned int startup_pciasic_irq(unsigned int irq)
+{
+	enable_pciasic_irq(irq);
+	return 0; /* never anything pending */
+}
+
+#define shutdown_pciasic_irq	disable_pciasic_irq
+
+void disable_pciasic_irq(unsigned int irq)
+{
+	unsigned int mask = ~(1 << (irq - PCIMT_IRQ_INT2));
+	unsigned long flags;
+
+	spin_lock_irqsave(&pciasic_lock, flags);
+	*(volatile u8 *) PCIMT_IRQSEL &= mask;
+	spin_unlock_irqrestore(&pciasic_lock, flags);
+}
+
+static void enable_pciasic_irq(unsigned int irq)
+{
+	unsigned int mask = 1 << (irq - PCIMT_IRQ_INT2);
+	unsigned long flags;
+
+	spin_lock_irqsave(&pciasic_lock, flags);
+	*(volatile u8 *) PCIMT_IRQSEL |= mask;
+	spin_unlock_irqrestore(&pciasic_lock, flags);
+}
+
+#define mask_and_ack_pciasic_irq disable_pciasic_irq
+
+static void end_pciasic_irq(unsigned int irq)
+{
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_pciasic_irq(irq);
+}
+
+static struct hw_interrupt_type pciasic_irq_type = {
+	"PCIASIC",
+	startup_pciasic_irq,
+	shutdown_pciasic_irq,
+	enable_pciasic_irq,
+	disable_pciasic_irq,
+	mask_and_ack_pciasic_irq,
+	end_pciasic_irq,
+	NULL
+};
+
+/*
+ * hwint0 should deal with MP agent, ASIC PCI, EISA NMI and debug
+ * button interrupts.  Later ...
+ */
+void pciasic_hwint0(struct pt_regs *regs)
+{
+	panic("Received int0 but no handler yet ...");
+}
+
+/* This interrupt was used for the com1 console on the first prototypes.  */
+void pciasic_hwint2(struct pt_regs *regs)
+{
+	/* I think this shouldn't happen on production machines.  */
+	panic("hwint2 and no handler yet");
+}
+
+/* hwint5 is the r4k count / compare interrupt  */
+void pciasic_hwint5(struct pt_regs *regs)
+{
+	panic("hwint5 and no handler yet");
+}
+
+static inline int ls1bit8(unsigned int x)
+{
+	int b = 8, s;
+
+	x <<= 24;
+	s = 4; if ((x & 0x0f) == 0) s = 0; b -= s; x <<= s;
+	s = 2; if ((x & 0x03) == 0) s = 0; b -= s; x <<= s;
+	s = 1; if ((x & 0x01) == 0) s = 0; b -= s;
+
+	return b;
+}
+
+/*
+ * hwint 1 deals with EISA and SCSI interrupts,
+ * hwint 3 should deal with the PCI A - D interrupts,
+ * hwint 4 is used for only the onboard PCnet 32.
+ */
+void pciasic_hwint134(struct pt_regs *regs)
+{
+	u8 pend = *(volatile char *)PCIMT_CSITPEND;
+	int irq;
+
+	irq = PCIMT_IRQ_INT2 + ls1bit8(pend);
+	if (irq == PCIMT_IRQ_EISA) {
+		pend = *(volatile char *)PCIMT_INT_ACKNOWLEDGE;
+		if (!(pend ^ 0xff))
+			return;
+	}
+	do_IRQ(irq, regs);
+	return;
+}
+
+void __init init_pciasic(void)
+{
+	unsigned int flags;
+
+	spin_lock_irqsave(&pciasic_lock, flags);
+	* (volatile u8 *) PCIMT_IRQSEL =
+		IT_EISA | IT_INTA | IT_INTB | IT_INTC | IT_INTD;
+	spin_unlock_irqrestore(&pciasic_lock, flags);
+}
+
+/*
+ * On systems with i8259-style interrupt controllers we assume for
+ * driver compatibility reasons interrupts 0 - 15 to be the i8295
+ * interrupts even if the hardware uses a different interrupt numbering.
+ */
+void __init init_IRQ (void)
+{
+	int i;
+
+	set_except_vector(0, sni_rm200_pci_handle_int);
+
+	init_generic_irq();
+	init_i8259_irqs();			/* Integrated i8259  */
+	init_pciasic();
+
+	/* Actually we've got more interrupts to handle ...  */
+	for (i = PCIMT_IRQ_INT2; i <= PCIMT_IRQ_ETHERNET; i++) {
+		irq_desc[i].status     = IRQ_DISABLED;
+		irq_desc[i].action     = 0;
+		irq_desc[i].depth      = 1;
+		irq_desc[i].handler    = &pciasic_irq_type;
+	}
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips/sni/pci.c linux/arch/mips/sni/pci.c
--- v2.4.9/linux/arch/mips/sni/pci.c	Mon Aug  7 14:31:40 2000
+++ linux/arch/mips/sni/pci.c	Sun Sep  9 10:43:02 2001
@@ -203,6 +203,11 @@
 {
 }
 
+unsigned __init int pcibios_assign_all_busses(void)
+{
+	return 0;
+}
+
 char * __init
 pcibios_setup(char *str)
 {
diff -u --recursive --new-file v2.4.9/linux/arch/mips/sni/setup.c linux/arch/mips/sni/setup.c
--- v2.4.9/linux/arch/mips/sni/setup.c	Sun Jul  9 22:18:15 2000
+++ linux/arch/mips/sni/setup.c	Sun Sep  9 10:43:02 2001
@@ -31,18 +31,6 @@
 #include <asm/reboot.h>
 #include <asm/sni.h>
 
-/*
- * Initial irq handlers.
- */
-static void no_action(int cpl, void *dev_id, struct pt_regs *regs) { }
-
-/*
- * IRQ2 is cascade interrupt to second interrupt controller
- */
-static struct irqaction irq2  = { no_action, 0, 0, "cascade", NULL, NULL};
-
-extern asmlinkage void sni_rm200_pci_handle_int(void);
-
 extern void sni_machine_restart(char *command);
 extern void sni_machine_halt(void);
 extern void sni_machine_power_off(void);
@@ -51,20 +39,6 @@
 extern struct rtc_ops std_rtc_ops;
 extern struct kbd_ops std_kbd_ops;
 
-static void __init sni_irq_setup(void)
-{
-	set_except_vector(0, sni_rm200_pci_handle_int);
-	request_region(0x20,0x20, "pic1");
-	request_region(0xa0,0x20, "pic2");	
-	i8259_setup_irq(2, &irq2);
-	/*
-	 * IRQ0 seems to be the irq for PC style stuff.
-	 * I don't know how to handle the debug button interrupt, so
-	 * don't use this button yet or bad things happen ...
-	 */
-	set_cp0_status(ST0_IM, IE_IRQ1 | IE_IRQ3 | IE_IRQ4);
-}
-
 void (*board_time_init)(struct irqaction *irq);
 
 static void __init sni_rm200_pci_time_init(struct irqaction *irq)
@@ -73,7 +47,7 @@
 	outb_p(0x34,0x43);		/* binary, mode 2, LSB/MSB, ch 0 */
 	outb_p(LATCH & 0xff , 0x40);	/* LSB */
 	outb(LATCH >> 8 , 0x40);	/* MSB */
-	i8259_setup_irq(0, irq);
+	setup_irq(0, irq);
 }
 
 unsigned char aux_device_present;
@@ -101,45 +75,11 @@
 	printk("%s.\n", boardtype);
 }
 
-int __init page_is_ram(unsigned long pagenr)
-{
-	return 1;
-}
-
 void __init sni_rm200_pci_setup(void)
 {
-#if 0 /* XXX Tag me deeper  */
-	tag *atag;
-
-	/*
-	 * We just check if a tag_screen_info can be gathered
-	 * in setup_arch(), if yes we don't proceed futher...
-	 */
-	atag = bi_TagFind(tag_screen_info);
-	if (!atag) {
-		/*
-		 * If no, we try to find the tag_arc_displayinfo which is
-		 * always created by Milo for an ARC box (for now Milo only
-		 * works on ARC boxes :) -Stoned.
-		 */
-		atag = bi_TagFind(tag_arcdisplayinfo);
-		if (atag) {
-			screen_info.orig_x = 
-				((mips_arc_DisplayInfo*)TAGVALPTR(atag))->cursor_x;
-			screen_info.orig_y = 
-				((mips_arc_DisplayInfo*)TAGVALPTR(atag))->cursor_y;
-			screen_info.orig_video_cols  = 
-				((mips_arc_DisplayInfo*)TAGVALPTR(atag))->columns;
-			screen_info.orig_video_lines  = 
-				((mips_arc_DisplayInfo*)TAGVALPTR(atag))->lines;
-		}
-	}
-#endif
-
 	sni_pcimt_detect();
 	sni_pcimt_sc_init();
 
-	irq_setup = sni_irq_setup;
 	mips_io_port_base = SNI_PORT_BASE;
 
 	/*
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/Makefile linux/arch/mips64/Makefile
--- v2.4.9/linux/arch/mips64/Makefile	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/Makefile	Sun Sep  9 10:43:02 2001
@@ -84,7 +84,8 @@
 endif
 
 ifdef CONFIG_SGI_IP27
-LIBS          += arch/mips64/sgi-ip27/ip27.a arch/mips64/arc/arclib.a
+CORE_FILES    += arch/mips64/sgi-ip27/ip27.o
+LIBS          += arch/mips64/arc/arclib.a
 SUBDIRS       += arch/mips64/sgi-ip27 arch/mips64/arc
 #
 # Set LOADADDR to >= 0xc000000000300000 if you want to leave space for
@@ -97,6 +98,17 @@
 else
 LOADADDR      += 0x8001c000
 endif
+endif
+
+ifdef CONFIG_SGI_IP32
+LIBS		+= arch/mips64/sgi-ip32/ip32-kern.a arch/mips64/arc/arclib.a
+SUBDIRS		+= arch/mips64/sgi-ip32 arch/mips64/arc
+#
+# Set LOADADDR to >= 0x????????? if you want to leave space for symmon,
+# 0x80002000 for production kernels.  Note that the value must be
+# 16kb aligned or the handling of the current variable will break.
+#
+LOADADDR	+= 0x80002000
 endif
 
 #
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/arc/env.c linux/arch/mips64/arc/env.c
--- v2.4.9/linux/arch/mips64/arc/env.c	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/arc/env.c	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: env.c,v 1.4 1999/10/19 20:51:44 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/arc/file.c linux/arch/mips64/arc/file.c
--- v2.4.9/linux/arch/mips64/arc/file.c	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/arc/file.c	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: file.c,v 1.3 1999/10/19 20:51:44 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/arc/init.c linux/arch/mips64/arc/init.c
--- v2.4.9/linux/arch/mips64/arc/init.c	Mon Feb 28 07:18:20 2000
+++ linux/arch/mips64/arc/init.c	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: init.c,v 1.3 1999/11/19 23:29:05 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/arc/memory.c linux/arch/mips64/arc/memory.c
--- v2.4.9/linux/arch/mips64/arc/memory.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/arc/memory.c	Sun Sep  9 10:43:02 2001
@@ -54,7 +54,8 @@
 	"FirmwarePermanent",
 	"FreeContiguous"
 };
-#define mtypes(a) (prom_flags & PROM_FLAG_ARCS) ? arcs_mtypes[a.arcs] : arc_mtypes[a.arc]
+#define mtypes(a) (prom_flags & PROM_FLAG_ARCS) ? arcs_mtypes[a.arcs] \
+						: arc_mtypes[a.arc]
 #endif
 
 static inline int memtype_classify_arcs (union linux_memtypes type)
@@ -138,10 +139,8 @@
 	}
 }
 
-void __init
-prom_free_prom_memory (void)
+void __init prom_free_prom_memory (void)
 {
-	struct prom_pmemblock *p;
 	unsigned long freed = 0;
 	unsigned long addr;
 	int i;
@@ -160,5 +159,5 @@
 			freed += PAGE_SIZE;
 		}
 	}
-	printk("Freeing prom memory: %ldkb freed\n", freed >> 10);
+	printk(KERN_INFO "Freeing prom memory: %ldkb freed\n", freed >> 10);
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/arc/misc.c linux/arch/mips64/arc/misc.c
--- v2.4.9/linux/arch/mips64/arc/misc.c	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/arc/misc.c	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: misc.c,v 1.2 1999/08/21 21:42:59 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/arc/salone.c linux/arch/mips64/arc/salone.c
--- v2.4.9/linux/arch/mips64/arc/salone.c	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/arc/salone.c	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: salone.c,v 1.2 1999/08/21 21:42:59 ralf Exp $
- *
+/*
  * Routines to load into memory and execute stand-along program images using
  * ARCS PROM firmware.
  *
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/arc/time.c linux/arch/mips64/arc/time.c
--- v2.4.9/linux/arch/mips64/arc/time.c	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/arc/time.c	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: time.c,v 1.2 1999/08/21 21:42:59 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/arc/tree.c linux/arch/mips64/arc/tree.c
--- v2.4.9/linux/arch/mips64/arc/tree.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/arc/tree.c	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: tree.c,v 1.3 1999/09/27 16:01:37 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/config.in linux/arch/mips64/config.in
--- v2.4.9/linux/arch/mips64/config.in	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/config.in	Sun Sep  9 10:43:02 2001
@@ -41,6 +41,7 @@
 unset CONFIG_BOOT_ELF64
 unset CONFIG_COHERENT_IO
 unset CONFIG_ISA
+unset CONFIG_MAPPED_PCI_IO
 unset CONFIG_PCI
 
 if [ "$CONFIG_SGI_IP22" = "y" ]; then
@@ -56,6 +57,7 @@
    define_bool CONFIG_BOOT_ELF64 y
    define_bool CONFIG_ARC64 y
    define_bool CONFIG_COHERENT_IO y
+   define_bool CONFIG_MAPPED_PCI_IO y
    define_bool CONFIG_PCI y
    define_bool CONFIG_QL_ISP_A64 y
    define_int CONFIG_L1_CACHE_SHIFT 7
@@ -177,7 +179,7 @@
 fi
 endmenu
 
-source drivers/message/i2o/Config.in
+#source drivers/message/i2o/Config.in
 
 if [ "$CONFIG_NET" = "y" ]; then
    mainmenu_option next_comment
@@ -270,7 +272,7 @@
 fi
 bool 'Remote GDB kernel debugging' CONFIG_REMOTE_DEBUG
 bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ
-if [ "$CONFIG_SMP" != "n" ]; then
+if [ "$CONFIG_SMP" != "y" ]; then
    bool 'Run uncached' CONFIG_MIPS_UNCACHED
 fi
 endmenu
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/defconfig linux/arch/mips64/defconfig
--- v2.4.9/linux/arch/mips64/defconfig	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/defconfig	Sun Sep  9 10:43:02 2001
@@ -24,6 +24,7 @@
 CONFIG_BOOT_ELF64=y
 CONFIG_ARC64=y
 CONFIG_COHERENT_IO=y
+CONFIG_MAPPED_PCI_IO=y
 CONFIG_PCI=y
 CONFIG_QL_ISP_A64=y
 CONFIG_L1_CACHE_SHIFT=7
@@ -142,6 +143,7 @@
 #
 # CONFIG_PHONE is not set
 # CONFIG_PHONE_IXJ is not set
+# CONFIG_PHONE_IXJ_PCMCIA is not set
 
 #
 # ATA/IDE/MFM/RLL support
@@ -184,6 +186,7 @@
 # CONFIG_SCSI_AHA1740 is not set
 # CONFIG_SCSI_AIC7XXX is not set
 # CONFIG_SCSI_AIC7XXX_OLD is not set
+# CONFIG_SCSI_DPT_I2O is not set
 # CONFIG_SCSI_ADVANSYS is not set
 # CONFIG_SCSI_IN2000 is not set
 # CONFIG_SCSI_AM53C974 is not set
@@ -201,6 +204,7 @@
 # CONFIG_SCSI_INITIO is not set
 # CONFIG_SCSI_INIA100 is not set
 # CONFIG_SCSI_NCR53C406A is not set
+# CONFIG_SCSI_NCR_D700 is not set
 # CONFIG_SCSI_NCR53C7xx is not set
 # CONFIG_SCSI_NCR53C8XX is not set
 # CONFIG_SCSI_SYM53C8XX is not set
@@ -219,16 +223,6 @@
 # CONFIG_SCSI_U14_34F is not set
 
 #
-# I2O device support
-#
-# CONFIG_I2O is not set
-# CONFIG_I2O_PCI is not set
-# CONFIG_I2O_BLOCK is not set
-# CONFIG_I2O_LAN is not set
-# CONFIG_I2O_SCSI is not set
-# CONFIG_I2O_PROC is not set
-
-#
 # Network device support
 #
 CONFIG_NETDEVICES=y
@@ -241,18 +235,22 @@
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
-# CONFIG_NET_SB1000 is not set
 
 #
 # Ethernet (10 or 100Mbit)
 #
 CONFIG_NET_ETHERNET=y
 CONFIG_SGI_IOC3_ETH=y
+# CONFIG_SUNLANCE is not set
+# CONFIG_HAPPYMEAL is not set
+# CONFIG_SUNBMAC is not set
+# CONFIG_SUNQE is not set
+# CONFIG_SUNLANCE is not set
+# CONFIG_SUNGEM is not set
 # CONFIG_NET_VENDOR_3COM is not set
 # CONFIG_LANCE is not set
 # CONFIG_NET_VENDOR_SMC is not set
 # CONFIG_NET_VENDOR_RACAL is not set
-# CONFIG_DEPCA is not set
 # CONFIG_HP100 is not set
 # CONFIG_NET_ISA is not set
 # CONFIG_NET_PCI is not set
@@ -262,9 +260,14 @@
 # Ethernet (1000 Mbit)
 #
 # CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_MYRI_SBUS is not set
+# CONFIG_NS83820 is not set
 # CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
 # CONFIG_SK98LIN is not set
 # CONFIG_FDDI is not set
+# CONFIG_PLIP is not set
 # CONFIG_PPP is not set
 # CONFIG_SLIP is not set
 
@@ -329,7 +332,11 @@
 #
 # Joysticks
 #
-# CONFIG_JOYSTICK is not set
+# CONFIG_INPUT_GAMEPORT is not set
+
+#
+# Input core support is needed for gameports
+#
 
 #
 # Input core support is needed for joysticks
@@ -367,24 +374,30 @@
 # CONFIG_AUTOFS4_FS is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
 # CONFIG_ADFS_FS is not set
 # CONFIG_ADFS_FS_RW is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
 # CONFIG_BFS_FS is not set
+# CONFIG_CMS_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_JBD_DEBUG is not set
 # CONFIG_FAT_FS is not set
 # CONFIG_MSDOS_FS is not set
 # CONFIG_UMSDOS_FS is not set
 # CONFIG_VFAT_FS is not set
 # CONFIG_EFS_FS is not set
 # CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
 # CONFIG_CRAMFS is not set
 # CONFIG_TMPFS is not set
 # CONFIG_RAMFS is not set
 # CONFIG_ISO9660_FS is not set
 # CONFIG_JOLIET is not set
 # CONFIG_MINIX_FS is not set
-# CONFIG_VXFS_FS is not set
+# CONFIG_FREEVXFS_FS is not set
 # CONFIG_NTFS_FS is not set
 # CONFIG_NTFS_RW is not set
 # CONFIG_HPFS_FS is not set
@@ -398,7 +411,6 @@
 # CONFIG_ROMFS_FS is not set
 CONFIG_EXT2_FS=y
 # CONFIG_SYSV_FS is not set
-# CONFIG_SYSV_FS_WRITE is not set
 # CONFIG_UDF_FS is not set
 # CONFIG_UDF_RW is not set
 # CONFIG_UFS_FS is not set
@@ -408,6 +420,7 @@
 # Network File Systems
 #
 # CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
 CONFIG_ROOT_NFS=y
@@ -441,6 +454,7 @@
 # CONFIG_MINIX_SUBPARTITION is not set
 # CONFIG_SOLARIS_X86_PARTITION is not set
 # CONFIG_UNIXWARE_DISKLABEL is not set
+# CONFIG_LDM_PARTITION is not set
 CONFIG_SGI_PARTITION=y
 # CONFIG_ULTRIX_PARTITION is not set
 # CONFIG_SUN_PARTITION is not set
@@ -459,9 +473,107 @@
 # CONFIG_USB is not set
 
 #
+# USB Controllers
+#
+# CONFIG_USB_UHCI is not set
+# CONFIG_USB_UHCI_ALT is not set
+# CONFIG_USB_OHCI is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_BLUETOOTH is not set
+# CONFIG_USB_STORAGE is not set
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+
+#
+# USB Human Interface Devices (HID)
+#
+
+#
+#   Input core support is needed for USB HID
+#
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_DC2XX is not set
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_SCANNER is not set
+# CONFIG_USB_MICROTEK is not set
+# CONFIG_USB_HPUSBSCSI is not set
+
+#
+# USB Multimedia devices
+#
+
+#
+#   Video4Linux support is needed for USB Multimedia device support
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# USB Network adaptors
+#
+# CONFIG_USB_PLUSB is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_CDCETHER is not set
+# CONFIG_USB_USBNET is not set
+
+#
+# USB port drivers
+#
+# CONFIG_USB_USS720 is not set
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+# CONFIG_USB_SERIAL_GENERIC is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+
+#
+# Miscellaneous USB drivers
+#
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_ID75 is not set
+
+#
 # Input core support
 #
 # CONFIG_INPUT is not set
+# CONFIG_INPUT_KEYBDEV is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
 
 #
 # Kernel hacking
@@ -469,4 +581,3 @@
 CONFIG_CROSSCOMPILE=y
 # CONFIG_REMOTE_DEBUG is not set
 # CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_MIPS_UNCACHED is not set
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/defconfig-ip22 linux/arch/mips64/defconfig-ip22
--- v2.4.9/linux/arch/mips64/defconfig-ip22	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/defconfig-ip22	Sun Sep  9 10:43:02 2001
@@ -149,6 +149,7 @@
 #
 # CONFIG_PHONE is not set
 # CONFIG_PHONE_IXJ is not set
+# CONFIG_PHONE_IXJ_PCMCIA is not set
 
 #
 # ATA/IDE/MFM/RLL support
@@ -193,6 +194,7 @@
 # CONFIG_SCSI_AHA1740 is not set
 # CONFIG_SCSI_AIC7XXX is not set
 # CONFIG_SCSI_AIC7XXX_OLD is not set
+# CONFIG_SCSI_DPT_I2O is not set
 # CONFIG_SCSI_ADVANSYS is not set
 # CONFIG_SCSI_IN2000 is not set
 # CONFIG_SCSI_AM53C974 is not set
@@ -209,6 +211,7 @@
 # CONFIG_SCSI_INITIO is not set
 # CONFIG_SCSI_INIA100 is not set
 # CONFIG_SCSI_NCR53C406A is not set
+# CONFIG_SCSI_NCR_D700 is not set
 # CONFIG_SCSI_NCR53C7xx is not set
 # CONFIG_SCSI_PAS16 is not set
 # CONFIG_SCSI_PCI2000 is not set
@@ -222,15 +225,6 @@
 # CONFIG_SCSI_DEBUG is not set
 
 #
-# I2O device support
-#
-# CONFIG_I2O is not set
-# CONFIG_I2O_BLOCK is not set
-# CONFIG_I2O_LAN is not set
-# CONFIG_I2O_SCSI is not set
-# CONFIG_I2O_PROC is not set
-
-#
 # Network device support
 #
 CONFIG_NETDEVICES=y
@@ -244,18 +238,20 @@
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
 # CONFIG_ETHERTAP is not set
-# CONFIG_NET_SB1000 is not set
 
 #
 # Ethernet (10 or 100Mbit)
 #
 CONFIG_NET_ETHERNET=y
+# CONFIG_SUNLANCE is not set
+# CONFIG_SUNBMAC is not set
+# CONFIG_SUNQE is not set
+# CONFIG_SUNLANCE is not set
+# CONFIG_SUNGEM is not set
 # CONFIG_NET_VENDOR_3COM is not set
 # CONFIG_LANCE is not set
 # CONFIG_NET_VENDOR_SMC is not set
 # CONFIG_NET_VENDOR_RACAL is not set
-# CONFIG_AT1700 is not set
-# CONFIG_DEPCA is not set
 # CONFIG_NET_ISA is not set
 # CONFIG_NET_PCI is not set
 # CONFIG_NET_POCKET is not set
@@ -265,11 +261,15 @@
 # Ethernet (1000 Mbit)
 #
 # CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_MYRI_SBUS is not set
+# CONFIG_NS83820 is not set
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
 # CONFIG_SK98LIN is not set
 # CONFIG_FDDI is not set
 # CONFIG_HIPPI is not set
+# CONFIG_PLIP is not set
 # CONFIG_PPP is not set
 # CONFIG_SLIP is not set
 
@@ -336,7 +336,11 @@
 #
 # Joysticks
 #
-# CONFIG_JOYSTICK is not set
+# CONFIG_INPUT_GAMEPORT is not set
+
+#
+# Input core support is needed for gameports
+#
 
 #
 # Input core support is needed for joysticks
@@ -353,6 +357,7 @@
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
 # CONFIG_APPLICOM is not set
+# CONFIG_SONYPI is not set
 
 #
 # Ftape, the floppy tape device driver
@@ -374,24 +379,30 @@
 CONFIG_AUTOFS4_FS=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
 # CONFIG_ADFS_FS is not set
 # CONFIG_ADFS_FS_RW is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
 # CONFIG_BFS_FS is not set
+# CONFIG_CMS_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_JBD_DEBUG is not set
 # CONFIG_FAT_FS is not set
 # CONFIG_MSDOS_FS is not set
 # CONFIG_UMSDOS_FS is not set
 # CONFIG_VFAT_FS is not set
 # CONFIG_EFS_FS is not set
 # CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
 # CONFIG_CRAMFS is not set
 # CONFIG_TMPFS is not set
 # CONFIG_RAMFS is not set
 CONFIG_ISO9660_FS=y
 # CONFIG_JOLIET is not set
 # CONFIG_MINIX_FS is not set
-# CONFIG_VXFS_FS is not set
+# CONFIG_FREEVXFS_FS is not set
 # CONFIG_NTFS_FS is not set
 # CONFIG_NTFS_RW is not set
 # CONFIG_HPFS_FS is not set
@@ -405,7 +416,6 @@
 # CONFIG_ROMFS_FS is not set
 CONFIG_EXT2_FS=y
 # CONFIG_SYSV_FS is not set
-# CONFIG_SYSV_FS_WRITE is not set
 # CONFIG_UDF_FS is not set
 # CONFIG_UDF_RW is not set
 # CONFIG_UFS_FS is not set
@@ -415,6 +425,7 @@
 # Network File Systems
 #
 # CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
 CONFIG_NFS_FS=y
 # CONFIG_NFS_V3 is not set
 CONFIG_ROOT_NFS=y
@@ -447,6 +458,7 @@
 # CONFIG_MINIX_SUBPARTITION is not set
 # CONFIG_SOLARIS_X86_PARTITION is not set
 # CONFIG_UNIXWARE_DISKLABEL is not set
+# CONFIG_LDM_PARTITION is not set
 CONFIG_SGI_PARTITION=y
 # CONFIG_ULTRIX_PARTITION is not set
 # CONFIG_SUN_PARTITION is not set
@@ -484,9 +496,107 @@
 # CONFIG_USB is not set
 
 #
+# USB Controllers
+#
+# CONFIG_USB_UHCI is not set
+# CONFIG_USB_UHCI_ALT is not set
+# CONFIG_USB_OHCI is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_BLUETOOTH is not set
+# CONFIG_USB_STORAGE is not set
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+
+#
+# USB Human Interface Devices (HID)
+#
+
+#
+#   Input core support is needed for USB HID
+#
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_DC2XX is not set
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_SCANNER is not set
+# CONFIG_USB_MICROTEK is not set
+# CONFIG_USB_HPUSBSCSI is not set
+
+#
+# USB Multimedia devices
+#
+
+#
+#   Video4Linux support is needed for USB Multimedia device support
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# USB Network adaptors
+#
+# CONFIG_USB_PLUSB is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_CDCETHER is not set
+# CONFIG_USB_USBNET is not set
+
+#
+# USB port drivers
+#
+# CONFIG_USB_USS720 is not set
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+# CONFIG_USB_SERIAL_GENERIC is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+
+#
+# Miscellaneous USB drivers
+#
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_ID75 is not set
+
+#
 # Input core support
 #
 # CONFIG_INPUT is not set
+# CONFIG_INPUT_KEYBDEV is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
 
 #
 # Kernel hacking
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/defconfig-ip27 linux/arch/mips64/defconfig-ip27
--- v2.4.9/linux/arch/mips64/defconfig-ip27	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/defconfig-ip27	Sun Sep  9 10:43:02 2001
@@ -24,6 +24,7 @@
 CONFIG_BOOT_ELF64=y
 CONFIG_ARC64=y
 CONFIG_COHERENT_IO=y
+CONFIG_MAPPED_PCI_IO=y
 CONFIG_PCI=y
 CONFIG_QL_ISP_A64=y
 CONFIG_L1_CACHE_SHIFT=7
@@ -142,6 +143,7 @@
 #
 # CONFIG_PHONE is not set
 # CONFIG_PHONE_IXJ is not set
+# CONFIG_PHONE_IXJ_PCMCIA is not set
 
 #
 # ATA/IDE/MFM/RLL support
@@ -184,6 +186,7 @@
 # CONFIG_SCSI_AHA1740 is not set
 # CONFIG_SCSI_AIC7XXX is not set
 # CONFIG_SCSI_AIC7XXX_OLD is not set
+# CONFIG_SCSI_DPT_I2O is not set
 # CONFIG_SCSI_ADVANSYS is not set
 # CONFIG_SCSI_IN2000 is not set
 # CONFIG_SCSI_AM53C974 is not set
@@ -201,6 +204,7 @@
 # CONFIG_SCSI_INITIO is not set
 # CONFIG_SCSI_INIA100 is not set
 # CONFIG_SCSI_NCR53C406A is not set
+# CONFIG_SCSI_NCR_D700 is not set
 # CONFIG_SCSI_NCR53C7xx is not set
 # CONFIG_SCSI_NCR53C8XX is not set
 # CONFIG_SCSI_SYM53C8XX is not set
@@ -219,16 +223,6 @@
 # CONFIG_SCSI_U14_34F is not set
 
 #
-# I2O device support
-#
-# CONFIG_I2O is not set
-# CONFIG_I2O_PCI is not set
-# CONFIG_I2O_BLOCK is not set
-# CONFIG_I2O_LAN is not set
-# CONFIG_I2O_SCSI is not set
-# CONFIG_I2O_PROC is not set
-
-#
 # Network device support
 #
 CONFIG_NETDEVICES=y
@@ -241,18 +235,22 @@
 # CONFIG_BONDING is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
-# CONFIG_NET_SB1000 is not set
 
 #
 # Ethernet (10 or 100Mbit)
 #
 CONFIG_NET_ETHERNET=y
 CONFIG_SGI_IOC3_ETH=y
+# CONFIG_SUNLANCE is not set
+# CONFIG_HAPPYMEAL is not set
+# CONFIG_SUNBMAC is not set
+# CONFIG_SUNQE is not set
+# CONFIG_SUNLANCE is not set
+# CONFIG_SUNGEM is not set
 # CONFIG_NET_VENDOR_3COM is not set
 # CONFIG_LANCE is not set
 # CONFIG_NET_VENDOR_SMC is not set
 # CONFIG_NET_VENDOR_RACAL is not set
-# CONFIG_DEPCA is not set
 # CONFIG_HP100 is not set
 # CONFIG_NET_ISA is not set
 # CONFIG_NET_PCI is not set
@@ -262,9 +260,14 @@
 # Ethernet (1000 Mbit)
 #
 # CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_MYRI_SBUS is not set
+# CONFIG_NS83820 is not set
 # CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
 # CONFIG_SK98LIN is not set
 # CONFIG_FDDI is not set
+# CONFIG_PLIP is not set
 # CONFIG_PPP is not set
 # CONFIG_SLIP is not set
 
@@ -329,7 +332,11 @@
 #
 # Joysticks
 #
-# CONFIG_JOYSTICK is not set
+# CONFIG_INPUT_GAMEPORT is not set
+
+#
+# Input core support is needed for gameports
+#
 
 #
 # Input core support is needed for joysticks
@@ -367,24 +374,30 @@
 # CONFIG_AUTOFS4_FS is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
 # CONFIG_ADFS_FS is not set
 # CONFIG_ADFS_FS_RW is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
 # CONFIG_BFS_FS is not set
+# CONFIG_CMS_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_JBD_DEBUG is not set
 # CONFIG_FAT_FS is not set
 # CONFIG_MSDOS_FS is not set
 # CONFIG_UMSDOS_FS is not set
 # CONFIG_VFAT_FS is not set
 # CONFIG_EFS_FS is not set
 # CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
 # CONFIG_CRAMFS is not set
 # CONFIG_TMPFS is not set
 # CONFIG_RAMFS is not set
 # CONFIG_ISO9660_FS is not set
 # CONFIG_JOLIET is not set
 # CONFIG_MINIX_FS is not set
-# CONFIG_VXFS_FS is not set
+# CONFIG_FREEVXFS_FS is not set
 # CONFIG_NTFS_FS is not set
 # CONFIG_NTFS_RW is not set
 # CONFIG_HPFS_FS is not set
@@ -398,7 +411,6 @@
 # CONFIG_ROMFS_FS is not set
 CONFIG_EXT2_FS=y
 # CONFIG_SYSV_FS is not set
-# CONFIG_SYSV_FS_WRITE is not set
 # CONFIG_UDF_FS is not set
 # CONFIG_UDF_RW is not set
 # CONFIG_UFS_FS is not set
@@ -408,6 +420,7 @@
 # Network File Systems
 #
 # CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
 CONFIG_ROOT_NFS=y
@@ -441,6 +454,7 @@
 # CONFIG_MINIX_SUBPARTITION is not set
 # CONFIG_SOLARIS_X86_PARTITION is not set
 # CONFIG_UNIXWARE_DISKLABEL is not set
+# CONFIG_LDM_PARTITION is not set
 CONFIG_SGI_PARTITION=y
 # CONFIG_ULTRIX_PARTITION is not set
 # CONFIG_SUN_PARTITION is not set
@@ -459,9 +473,107 @@
 # CONFIG_USB is not set
 
 #
+# USB Controllers
+#
+# CONFIG_USB_UHCI is not set
+# CONFIG_USB_UHCI_ALT is not set
+# CONFIG_USB_OHCI is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_BLUETOOTH is not set
+# CONFIG_USB_STORAGE is not set
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+
+#
+# USB Human Interface Devices (HID)
+#
+
+#
+#   Input core support is needed for USB HID
+#
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_DC2XX is not set
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_SCANNER is not set
+# CONFIG_USB_MICROTEK is not set
+# CONFIG_USB_HPUSBSCSI is not set
+
+#
+# USB Multimedia devices
+#
+
+#
+#   Video4Linux support is needed for USB Multimedia device support
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# USB Network adaptors
+#
+# CONFIG_USB_PLUSB is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_CDCETHER is not set
+# CONFIG_USB_USBNET is not set
+
+#
+# USB port drivers
+#
+# CONFIG_USB_USS720 is not set
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+# CONFIG_USB_SERIAL_GENERIC is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
+# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+
+#
+# Miscellaneous USB drivers
+#
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_ID75 is not set
+
+#
 # Input core support
 #
 # CONFIG_INPUT is not set
+# CONFIG_INPUT_KEYBDEV is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
 
 #
 # Kernel hacking
@@ -469,4 +581,3 @@
 CONFIG_CROSSCOMPILE=y
 # CONFIG_REMOTE_DEBUG is not set
 # CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_MIPS_UNCACHED is not set
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/defconfig-ip32 linux/arch/mips64/defconfig-ip32
--- v2.4.9/linux/arch/mips64/defconfig-ip32	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/defconfig-ip32	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,511 @@
+#
+# Automatically generated make config: don't edit
+#
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+
+#
+# Machine selection
+#
+# CONFIG_SGI_IP22 is not set
+# CONFIG_SGI_IP27 is not set
+CONFIG_SGI_IP32=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_BOOT_ELF32=y
+CONFIG_ARC32=y
+CONFIG_PC_KEYB=y
+CONFIG_PCI=y
+CONFIG_ARC_MEMORY=y
+CONFIG_L1_CACHE_SHIFT=5
+# CONFIG_ISA is not set
+# CONFIG_EISA is not set
+# CONFIG_MCA is not set
+# CONFIG_SBUS is not set
+
+#
+# CPU selection
+#
+# CONFIG_CPU_R4300 is not set
+# CONFIG_CPU_R4X00 is not set
+CONFIG_CPU_R5000=y
+# CONFIG_CPU_NEVADA is not set
+# CONFIG_CPU_R8000 is not set
+# CONFIG_CPU_R10000 is not set
+
+#
+# General setup
+#
+# CONFIG_CPU_LITTLE_ENDIAN is not set
+# CONFIG_MIPS_FPU_EMULATOR is not set
+CONFIG_NET=y
+CONFIG_PCI_NAMES=y
+# CONFIG_HOTPLUG is not set
+# CONFIG_PCMCIA is not set
+CONFIG_SYSVIPC=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_SYSCTL=y
+# CONFIG_PROM_CONSOLE is not set
+CONFIG_BINFMT_ELF=y
+CONFIG_MIPS32_COMPAT=y
+CONFIG_BINFMT_ELF32=y
+CONFIG_BINFMT_MISC=y
+
+#
+# Loadable module support
+#
+# CONFIG_MODULES is not set
+CONFIG_PCI_NAMES=y
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_DEV_XD is not set
+# CONFIG_PARIDE is not set
+# CONFIG_BLK_CPQ_DA is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+CONFIG_BLK_DEV_LOOP=y
+# CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_RAM is not set
+# CONFIG_BLK_DEV_INITRD is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+# CONFIG_BLK_DEV_MD is not set
+# CONFIG_MD_LINEAR is not set
+# CONFIG_MD_RAID0 is not set
+# CONFIG_MD_RAID1 is not set
+# CONFIG_MD_RAID5 is not set
+# CONFIG_BLK_DEV_LVM is not set
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+# CONFIG_NETLINK is not set
+# CONFIG_NETFILTER is not set
+# CONFIG_FILTER is not set
+CONFIG_UNIX=y
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_PNP=y
+# CONFIG_IP_PNP_DHCP is not set
+CONFIG_IP_PNP_BOOTP=y
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_INET_ECN is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_IPV6 is not set
+# CONFIG_KHTTPD is not set
+# CONFIG_ATM is not set
+
+#
+#  
+#
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_DECNET is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_LLC is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_FASTROUTE is not set
+# CONFIG_NET_HW_FLOWCONTROL is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+# CONFIG_PHONE_IXJ is not set
+
+#
+# ATA/IDE/MFM/RLL support
+#
+# CONFIG_IDE is not set
+# CONFIG_BLK_DEV_IDE_MODES is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI support
+#
+CONFIG_SCSI=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+CONFIG_SD_EXTRA_DEVS=40
+CONFIG_CHR_DEV_ST=y
+CONFIG_CHR_DEV_OSST=y
+CONFIG_BLK_DEV_SR=y
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_SR_EXTRA_DEVS=2
+CONFIG_CHR_DEV_SG=y
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+CONFIG_SCSI_DEBUG_QUEUES=y
+CONFIG_SCSI_MULTI_LUN=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
+# CONFIG_SCSI_7000FASST is not set
+# CONFIG_SCSI_ACARD is not set
+# CONFIG_SCSI_AHA152X is not set
+# CONFIG_SCSI_AHA1542 is not set
+# CONFIG_SCSI_AHA1740 is not set
+CONFIG_SCSI_AIC7XXX=y
+CONFIG_AIC7XXX_CMDS_PER_DEVICE=8
+CONFIG_AIC7XXX_RESET_DELAY_MS=15000
+# CONFIG_AIC7XXX_BUILD_FIRMWARE is not set
+# CONFIG_SCSI_ADVANSYS is not set
+# CONFIG_SCSI_IN2000 is not set
+# CONFIG_SCSI_AM53C974 is not set
+# CONFIG_SCSI_MEGARAID is not set
+# CONFIG_SCSI_BUSLOGIC is not set
+# CONFIG_SCSI_CPQFCTS is not set
+# CONFIG_SCSI_DMX3191D is not set
+# CONFIG_SCSI_DTC3280 is not set
+# CONFIG_SCSI_EATA is not set
+# CONFIG_SCSI_EATA_DMA is not set
+# CONFIG_SCSI_EATA_PIO is not set
+# CONFIG_SCSI_FUTURE_DOMAIN is not set
+# CONFIG_SCSI_GDTH is not set
+# CONFIG_SCSI_GENERIC_NCR5380 is not set
+# CONFIG_SCSI_INITIO is not set
+# CONFIG_SCSI_INIA100 is not set
+# CONFIG_SCSI_NCR53C406A is not set
+# CONFIG_SCSI_NCR53C7xx is not set
+# CONFIG_SCSI_NCR53C8XX is not set
+# CONFIG_SCSI_SYM53C8XX is not set
+# CONFIG_SCSI_PAS16 is not set
+# CONFIG_SCSI_PCI2000 is not set
+# CONFIG_SCSI_PCI2220I is not set
+# CONFIG_SCSI_PSI240I is not set
+# CONFIG_SCSI_QLOGIC_FAS is not set
+# CONFIG_SCSI_QLOGIC_ISP is not set
+# CONFIG_SCSI_QLOGIC_FC is not set
+# CONFIG_SCSI_QLOGIC_1280 is not set
+# CONFIG_SCSI_SIM710 is not set
+# CONFIG_SCSI_SYM53C416 is not set
+# CONFIG_SCSI_DC390T is not set
+# CONFIG_SCSI_T128 is not set
+# CONFIG_SCSI_U14_34F is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# I2O device support
+#
+# CONFIG_I2O is not set
+# CONFIG_I2O_PCI is not set
+# CONFIG_I2O_BLOCK is not set
+# CONFIG_I2O_LAN is not set
+# CONFIG_I2O_SCSI is not set
+# CONFIG_I2O_PROC is not set
+
+#
+# Network device support
+#
+CONFIG_NETDEVICES=y
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+# CONFIG_NET_SB1000 is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_LANCE is not set
+# CONFIG_NET_VENDOR_SMC is not set
+# CONFIG_NET_VENDOR_RACAL is not set
+# CONFIG_AT1700 is not set
+# CONFIG_DEPCA is not set
+# CONFIG_HP100 is not set
+# CONFIG_NET_ISA is not set
+CONFIG_NET_PCI=y
+# CONFIG_PCNET32 is not set
+# CONFIG_ADAPTEC_STARFIRE is not set
+# CONFIG_APRICOT is not set
+# CONFIG_CS89x0 is not set
+CONFIG_TULIP=y
+# CONFIG_DE4X5 is not set
+# CONFIG_DGRS is not set
+# CONFIG_DM9102 is not set
+CONFIG_EEPRO100=y
+# CONFIG_EEPRO100_PM is not set
+# CONFIG_LNE390 is not set
+# CONFIG_FEALNX is not set
+# CONFIG_NATSEMI is not set
+# CONFIG_NE2K_PCI is not set
+# CONFIG_NE3210 is not set
+# CONFIG_ES3210 is not set
+# CONFIG_8139TOO is not set
+# CONFIG_8139TOO_PIO is not set
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+# CONFIG_8139TOO_8129 is not set
+# CONFIG_SIS900 is not set
+# CONFIG_EPIC100 is not set
+# CONFIG_SUNDANCE is not set
+# CONFIG_TLAN is not set
+# CONFIG_VIA_RHINE is not set
+# CONFIG_WINBOND_840 is not set
+# CONFIG_HAPPYMEAL is not set
+# CONFIG_LAN_SAA9730 is not set
+# CONFIG_NET_POCKET is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_SK98LIN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+# CONFIG_NET_FC is not set
+# CONFIG_RCPCI is not set
+# CONFIG_SHAPER is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+
+#
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# IrDA (infrared) support
+#
+# CONFIG_IRDA is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Old CD-ROM drivers (not SCSI, not IDE)
+#
+# CONFIG_CD_NO_IDESCSI is not set
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+CONFIG_SERIAL=y
+CONFIG_SERIAL_CONSOLE=y
+# CONFIG_SERIAL_EXTENDED is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Mice
+#
+# CONFIG_BUSMOUSE is not set
+CONFIG_MOUSE=y
+CONFIG_PSMOUSE=y
+# CONFIG_82C710_MOUSE is not set
+# CONFIG_PC110_PAD is not set
+
+#
+# Joysticks
+#
+# CONFIG_JOYSTICK is not set
+
+#
+# Input core support is needed for joysticks
+#
+# CONFIG_QIC02_TAPE is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_INTEL_RNG is not set
+# CONFIG_NVRAM is not set
+# CONFIG_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_FTAPE is not set
+# CONFIG_AGP is not set
+# CONFIG_DRM is not set
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# File systems
+#
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_ADFS_FS is not set
+# CONFIG_ADFS_FS_RW is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_UMSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+# CONFIG_CRAMFS is not set
+CONFIG_TMPFS=y
+# CONFIG_RAMFS is not set
+# CONFIG_ISO9660_FS is not set
+# CONFIG_JOLIET is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_NTFS_FS is not set
+# CONFIG_NTFS_RW is not set
+# CONFIG_HPFS_FS is not set
+CONFIG_PROC_FS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVFS_MOUNT is not set
+# CONFIG_DEVFS_DEBUG is not set
+CONFIG_DEVPTS_FS=y
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_QNX4FS_RW is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_EXT2_FS=y
+# CONFIG_SYSV_FS is not set
+# CONFIG_SYSV_FS_WRITE is not set
+# CONFIG_UDF_FS is not set
+# CONFIG_UDF_RW is not set
+# CONFIG_UFS_FS is not set
+# CONFIG_UFS_FS_WRITE is not set
+
+#
+# Network File Systems
+#
+# CONFIG_CODA_FS is not set
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+CONFIG_ROOT_NFS=y
+# CONFIG_NFSD is not set
+# CONFIG_NFSD_V3 is not set
+CONFIG_SUNRPC=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+# CONFIG_SMB_FS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_NCPFS_PACKET_SIGNING is not set
+# CONFIG_NCPFS_IOCTL_LOCKING is not set
+# CONFIG_NCPFS_STRONG is not set
+# CONFIG_NCPFS_NFS_NS is not set
+# CONFIG_NCPFS_OS2_NS is not set
+# CONFIG_NCPFS_SMALLDOS is not set
+# CONFIG_NCPFS_NLS is not set
+# CONFIG_NCPFS_EXTRAS is not set
+
+#
+# Partition Types
+#
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ACORN_PARTITION is not set
+# CONFIG_OSF_PARTITION is not set
+# CONFIG_AMIGA_PARTITION is not set
+# CONFIG_ATARI_PARTITION is not set
+# CONFIG_MAC_PARTITION is not set
+# CONFIG_MSDOS_PARTITION is not set
+CONFIG_SGI_PARTITION=y
+# CONFIG_ULTRIX_PARTITION is not set
+# CONFIG_SUN_PARTITION is not set
+# CONFIG_SMB_NLS is not set
+# CONFIG_NLS is not set
+CONFIG_KCORE_ELF=y
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB is not set
+
+#
+# Input core support
+#
+# CONFIG_INPUT is not set
+
+#
+# Kernel hacking
+#
+CONFIG_CROSSCOMPILE=y
+# CONFIG_REMOTE_DEBUG is not set
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_MIPS_UNCACHED=y
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/binfmt_elf32.c linux/arch/mips64/kernel/binfmt_elf32.c
--- v2.4.9/linux/arch/mips64/kernel/binfmt_elf32.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/kernel/binfmt_elf32.c	Sun Sep  9 10:43:01 2001
@@ -32,7 +32,7 @@
 
 #define TASK32_SIZE		0x80000000UL
 #undef ELF_ET_DYN_BASE
-#define ELF_ET_DYN_BASE         (2 * TASK32_SIZE / 3)
+#define ELF_ET_DYN_BASE         (TASK32_SIZE / 3 * 2)
 
 #include <asm/processor.h>
 #include <linux/module.h>
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/entry.S linux/arch/mips64/kernel/entry.S
--- v2.4.9/linux/arch/mips64/kernel/entry.S	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/kernel/entry.S	Sun Sep  9 10:43:01 2001
@@ -5,8 +5,9 @@
  *
  * Low level exception handling
  *
- * Copyright (C) 1994 - 2000 by Ralf Baechle
+ * Copyright (C) 1994 - 2000, 2001 Ralf Baechle
  * Copyright (C) 1999, 2000 Silicon Graphics
+ * Copyright (C) 2001 MIPS Technologies, Inc.
  */
 #include <linux/config.h>
 
@@ -15,53 +16,61 @@
 #include <asm/mipsregs.h>
 #include <asm/stackframe.h>
 
+/* This duplicates the definition from <linux/sched.h> */
+#define PT_TRACESYS	0x00000002		/* tracing system calls */
+
+#define KU_USER 0x10
+
 		.text
-		.set	noreorder
 		.align 4
 FEXPORT(ret_from_fork)
+		move	a0, v0			# prev
 		jal	schedule_tail
-		 move	a0, v0					# prev
+		lw	t0, TASK_PTRACE($28)	# syscall tracing enabled?
+		andi	t0, PT_TRACESYS
+		bnez	t0, tracesys_exit
 		j	ret_from_sys_call
-		 nop
-FEXPORT(handle_softirq)
-		jal	do_softirq
-		 nop
-		b	9f
-		 nop
+
+tracesys_exit:
+		jal	syscall_trace
+		b	ret_from_sys_call
+
+EXPORT(ret_from_irq)
+EXPORT(ret_from_exception)
+		lw	t0, PT_STATUS(sp)	# returning to kernel mode?
+		andi	t0, t0, KU_USER
+		bnez	t0, ret_from_sys_call
+		j	restore_all
 
 reschedule:	jal	schedule 
-		 nop
 
 FEXPORT(ret_from_sys_call)
-FEXPORT(ret_from_irq)
-		la	t1, irq_stat		# softirq_active
-#ifdef CONFIG_SMP
-		lwu	t0, TASK_PROCESSOR($28)
-		dsll	t0, t0, 5
-		daddu	t1, t0
-#endif
-		lw	t0, 0 (t1)		# softirq_active
-		lw	t1, 4 (t1)		# softirq_mask.  unused delay slot
-		and	t0, t1
-		bnez	t0, handle_softirq
-9:		 ld	t0, PT_STATUS(sp)	# returning to kernel mode?
-
-		andi	t1, t0, 0x10
-		beqz	t1, return		# -> yes
-		 ld	t1, TASK_NEED_RESCHED($28)
-		bnez	t1, reschedule
-		lw	v0, TASK_SIGPENDING($28)
-		 move	a0, zero
-		beqz	v0, return
-		 nop
-		jal	do_signal
-		 move	a1, sp
+		mfc0	t0, CP0_STATUS	# need_resched and signals atomic test
+		ori	t0, t0, 1
+		xori	t0, t0, 1
+		mtc0	t0, CP0_STATUS
+
+		ld	v0, TASK_NEED_RESCHED($28)
+		lw	v1, TASK_SIGPENDING($28)
+		bnez	v0, reschedule
+		bnez	v1, signal_return
 
-FEXPORT(return)	.set	noat
+restore_all:	.set	noat
 		RESTORE_ALL
 		eret
 		.set	at
 
+signal_return:	.type	signal_return, @function
+
+		mfc0	t0, CP0_STATUS
+		ori	t0, t0, 1
+		mtc0	t0, CP0_STATUS
+
+		move	a0, zero
+		move	a1, sp
+		jal	do_signal
+		b	restore_all
+
 /*
  * Common spurious interrupt handler.
  */
@@ -75,6 +84,6 @@
 		lui     t1,%hi(spurious_count)
 		lw      t0,%lo(spurious_count)(t1)
 		addiu   t0,1
+		sw      t0,%lo(spurious_count)(t1)
 		j	ret_from_irq
-		 sw      t0,%lo(spurious_count)(t1)
 		END(spurious_interrupt)
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/ioctl32.c linux/arch/mips64/kernel/ioctl32.c
--- v2.4.9/linux/arch/mips64/kernel/ioctl32.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/kernel/ioctl32.c	Sat Sep  1 11:01:28 2001
@@ -770,6 +770,8 @@
 	IOCTL32_HANDLER(BLKPG, blkpg_ioctl_trans),
 	IOCTL32_DEFAULT(BLKELVGET),
 	IOCTL32_DEFAULT(BLKELVSET),
+	IOCTL32_DEFAULT(BLKBSZGET),
+	IOCTL32_DEFAULT(BLKBSZSET),
 
 #ifdef CONFIG_MD
 	/* status */
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/linux32.c linux/arch/mips64/kernel/linux32.c
--- v2.4.9/linux/arch/mips64/kernel/linux32.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/kernel/linux32.c	Sun Sep  9 10:43:01 2001
@@ -1538,11 +1538,11 @@
 	err = -EFAULT;
 	if (get_user (pad, (u32 *)uptr))
 		return err;
-	if(third == SETVAL)
+	if ((third & ~IPC_64) == SETVAL)
 		fourth.val = (int)pad;
 	else
 		fourth.__pad = (void *)A(pad);
-	switch (third) {
+	switch (third & ~IPC_64) {
 
 	case IPC_INFO:
 	case IPC_RMID:
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/mips64_ksyms.c linux/arch/mips64/kernel/mips64_ksyms.c
--- v2.4.9/linux/arch/mips64/kernel/mips64_ksyms.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/kernel/mips64_ksyms.c	Sun Sep  9 10:43:01 2001
@@ -17,6 +17,7 @@
 #include <linux/in6.h>
 #include <linux/pci.h>
 
+#include <asm/bootinfo.h>
 #include <asm/dma.h>
 #include <asm/floppy.h>
 #include <asm/io.h>
@@ -37,6 +38,7 @@
 extern long __strnlen_user_nocheck_asm(const char *s);
 extern long __strnlen_user_asm(const char *s);
 
+EXPORT_SYMBOL(mips_machtype);
 EXPORT_SYMBOL(EISA_bus);
 
 /*
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/proc.c linux/arch/mips64/kernel/proc.c
--- v2.4.9/linux/arch/mips64/kernel/proc.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/kernel/proc.c	Sun Sep  9 10:43:01 2001
@@ -1,12 +1,10 @@
-/* $Id: proc.c,v 1.1 1999/09/28 22:25:51 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1995, 1996, 1999 Ralf Baechle
- *
- * XXX Rewrite this mess.
+ * Copyright (C) 1995, 1996, 1999, 2001 Ralf Baechle
+ * Copyright (C) 2001 MIPS Technologies, Inc.
  */
 #include <linux/delay.h>
 #include <linux/kernel.h>
@@ -17,7 +15,7 @@
 #include <asm/processor.h>
 #include <asm/watch.h>
 
-unsigned long unaligned_instructions;
+extern unsigned long unaligned_instructions;
 unsigned int vced_count, vcei_count;
 
 /*
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/ptrace.c linux/arch/mips64/kernel/ptrace.c
--- v2.4.9/linux/arch/mips64/kernel/ptrace.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/kernel/ptrace.c	Sun Sep  9 10:43:01 2001
@@ -104,6 +104,9 @@
 			break;
 		case FPR_BASE ... FPR_BASE + 31:
 			if (child->used_math) {
+				unsigned long *fregs =
+					(void *) child->thread.fpu.hard.fp_regs;
+
 #ifndef CONFIG_SMP
 				if (last_task_used_math == child) {
 					set_cp0_status(ST0_CU1, ST0_CU1);
@@ -112,7 +115,15 @@
 					last_task_used_math = NULL;
 				}
 #endif
-				tmp = child->thread.fpu.hard.fp_regs[addr - 32];
+				/*
+				 * The odd registers are actually the high
+				 * order bits of the values stored in the even
+				 * registers.
+				 */
+				if (addr & 1)
+					tmp = (unsigned long) (fregs[((addr & ~1) - 32)] >> 32);
+				else
+					tmp = (unsigned long) (fregs[(addr - 32)] & 0xffffffff);
 			} else {
 				tmp = -EIO;
 			}
@@ -171,7 +182,8 @@
 			regs->regs[addr] = data;
 			break;
 		case FPR_BASE ... FPR_BASE + 31: {
-			unsigned long *fregs;
+			unsigned long *fregs =
+				(void *) child->thread.fpu.hard.fp_regs;
 			if (child->used_math) {
 #ifndef CONFIG_SMP
 				if (last_task_used_math == child) {
@@ -188,8 +200,18 @@
 				       sizeof(child->thread.fpu.hard));
 				child->thread.fpu.hard.control = 0;
 			}
-			fregs = child->thread.fpu.hard.fp_regs;
-			fregs[addr - FPR_BASE] = data;
+			/*
+			 * The odd registers are actually the high order bits
+			 * of the values stored in the even registers - unless
+			 * we're using r2k_switch.S.
+			 */
+			if (addr & 1) {
+				fregs[(addr & ~1) - FPR_BASE] &= 0xffffffff;
+				fregs[(addr & ~1) - FPR_BASE] |= ((unsigned long) data) << 32;
+			} else {
+				fregs[addr - FPR_BASE] &= ~0xffffffffLL;
+				fregs[addr - FPR_BASE] |= data;
+			}
 			break;
 		}
 		case PC:
@@ -354,6 +376,9 @@
 			break;
 		case FPR_BASE ... FPR_BASE + 31:
 			if (child->used_math) {
+				unsigned long long *fregs
+					= (unsigned long long *)
+					&child->thread.fpu.hard.fp_regs[0];
 #ifndef CONFIG_SMP
 				if (last_task_used_math == child) {
 					set_cp0_status(ST0_CU1, ST0_CU1);
@@ -362,7 +387,15 @@
 					last_task_used_math = NULL;
 				}
 #endif
-				tmp = child->thread.fpu.hard.fp_regs[addr - 32];
+				/*
+				 * The odd registers are actually the high
+				 * order bits of the values stored in the even
+				 * registers.
+				 */
+				if (addr & 1)
+					tmp = (unsigned long) (fregs[((addr & ~1) - 32)] >> 32);
+				else
+					tmp = (unsigned long) (fregs[(addr - 32)] & 0xffffffff);
 			} else {
 				tmp = -EIO;
 			}
@@ -421,7 +454,8 @@
 			regs->regs[addr] = data;
 			break;
 		case FPR_BASE ... FPR_BASE + 31: {
-			unsigned long *fregs;
+			unsigned long *fregs =
+				(void *) child->thread.fpu.hard.fp_regs;
 			if (child->used_math) {
 #ifndef CONFIG_SMP
 				if (last_task_used_math == child) {
@@ -438,8 +472,18 @@
 				       sizeof(child->thread.fpu.hard));
 				child->thread.fpu.hard.control = 0;
 			}
-			fregs = child->thread.fpu.hard.fp_regs;
-			fregs[addr - FPR_BASE] = data;
+			/*
+			 * The odd registers are actually the high order bits
+			 * of the values stored in the even registers - unless
+			 * we're using r2k_switch.S.
+			 */
+			if (addr & 1) {
+				fregs[(addr & ~1) - FPR_BASE] &= 0xffffffff;
+				fregs[(addr & ~1) - FPR_BASE] |= ((unsigned long) data) << 32;
+			} else {
+				fregs[addr - FPR_BASE] &= ~0xffffffffLL;
+				fregs[addr - FPR_BASE] |= data;
+			}
 			break;
 		}
 		case PC:
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/r4k_cache.S linux/arch/mips64/kernel/r4k_cache.S
--- v2.4.9/linux/arch/mips64/kernel/r4k_cache.S	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/kernel/r4k_cache.S	Sun Sep  9 10:43:01 2001
@@ -1,5 +1,4 @@
-/* $Id: r4k_cache.S,v 1.1 1999/10/10 18:49:17 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/r4k_genex.S linux/arch/mips64/kernel/r4k_genex.S
--- v2.4.9/linux/arch/mips64/kernel/r4k_genex.S	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/kernel/r4k_genex.S	Sun Sep  9 10:43:01 2001
@@ -1,5 +1,4 @@
-/* $Id: r4k_genex.S,v 1.3 1999/11/23 17:12:49 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/r4k_switch.S linux/arch/mips64/kernel/r4k_switch.S
--- v2.4.9/linux/arch/mips64/kernel/r4k_switch.S	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/kernel/r4k_switch.S	Sun Sep  9 10:43:01 2001
@@ -1,5 +1,4 @@
-/* $Id: r4k_switch.S,v 1.1 1999/12/04 03:59:00 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/r4k_tlb_debug.c linux/arch/mips64/kernel/r4k_tlb_debug.c
--- v2.4.9/linux/arch/mips64/kernel/r4k_tlb_debug.c	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/kernel/r4k_tlb_debug.c	Sun Sep  9 10:43:01 2001
@@ -1,5 +1,4 @@
-/* $Id: r4k_tlb_debug.c,v 1.2 2000/01/17 23:32:46 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/r4k_tlb_glue.S linux/arch/mips64/kernel/r4k_tlb_glue.S
--- v2.4.9/linux/arch/mips64/kernel/r4k_tlb_glue.S	Tue Jul 11 11:14:48 2000
+++ linux/arch/mips64/kernel/r4k_tlb_glue.S	Sun Sep  9 10:43:01 2001
@@ -1,5 +1,4 @@
-/* $Id: r4k_tlb_glue.S,v 1.5 1999/11/23 17:12:49 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/scall_64.S linux/arch/mips64/kernel/scall_64.S
--- v2.4.9/linux/arch/mips64/kernel/scall_64.S	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/kernel/scall_64.S	Sun Sep  9 10:43:01 2001
@@ -3,8 +3,9 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 by Ralf Baechle
+ * Copyright (C) 1995, 96, 97, 98, 99, 2000, 01 by Ralf Baechle
  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
+ * Copyright (C) 2001 MIPS Technologies, Inc.
  */
 #include <linux/config.h>
 #include <asm/asm.h>
@@ -62,44 +63,39 @@
 	sd	v0, PT_R0(sp)		# set flag for syscall restarting
 1:	sd	v0, PT_R2(sp)		# result
 
-FEXPORT(ret_from_sys_call_64)
-	la	t1, irq_stat		# softirq_active
-#ifdef CONFIG_SMP
-	lwu	t0, TASK_PROCESSOR($28)
-	dsll	t0, t0, 5
-	daddu	t1, t0
-#endif
-	lw	t0, 0(t1)		# softirq_active
-	lw	t1, 4(t1)		# softirq_mask.  unused delay slot
-	and	t0, t1
-	bnez	t0, handle_softirq_64
+ret_from_sys_call:
+	mfc0	t0, CP0_STATUS
+	xori	t0, t0, 1
+	ori	t0, t0, 1
+	mtc0	t0, CP0_STATUS
 
-9:	ld	t0, PT_STATUS(sp)	# returning to kernel mode?
-	andi	t1, t0, 0x10
 	ld	t2, TASK_NEED_RESCHED($28)
-	beqz	t1, return_64		# -> yes
-	bnez	t2, reschedule_64
+	bnez	t2, reschedule
 	lw	v0, TASK_SIGPENDING($28)
-	move	a0, zero
-	beqz	v0, return_64
-	move	a1, sp
-	SAVE_STATIC
-	jal	do_signal
+	bnez	v0, signal_return
 
-return_64:
+restore_all:
 	RESTORE_SOME
 	RESTORE_SP
-	.set	mips3
 	eret
-	.set	mips0
 
-handle_softirq_64:
-	jal	do_softirq
-	b	9b
-reschedule_64:
+/* Put this behind restore_all for the sake of the branch prediction.  */
+signal_return:
+	.type	signal_return, @function
+
+	mfc0	t0, CP0_STATUS
+	ori	t0, t0, 1
+	mtc0	t0, CP0_STATUS
+
+	move	a0, zero
+	move	a1, sp
+	jal	do_signal
+	b	restore_all
+
+reschedule:
 	SAVE_STATIC
 	jal	schedule
-	b	ret_from_sys_call_64
+	b	ret_from_sys_call
 
 /* ------------------------------------------------------------------------ */
 
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/scall_o32.S linux/arch/mips64/kernel/scall_o32.S
--- v2.4.9/linux/arch/mips64/kernel/scall_o32.S	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/kernel/scall_o32.S	Sun Sep  9 10:43:01 2001
@@ -3,8 +3,9 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1995 - 2000 by Ralf Baechle
+ * Copyright (C) 1995 - 2000, 2001 by Ralf Baechle
  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
+ * Copyright (C) 2001 MIPS Technologies, Inc.
  *
  * Hairy, the userspace application uses a different argument passing
  * convention than the kernel, so we have to translate things from o32
@@ -18,6 +19,7 @@
 #include <asm/regdef.h>
 #include <asm/stackframe.h>
 #include <asm/unistd.h>
+#include <asm/sysmips.h>
 
 /* This duplicates the definition from <linux/sched.h> */
 #define PT_TRACESYS	0x00000002	/* tracing system calls */
@@ -34,14 +36,6 @@
 	SAVE_SOME
 	STI
 	.set	at
-#if DEBUG_MIPS64
- jal dodebug
- ld $4, PT_R4(sp)
- ld $5, PT_R5(sp)
- ld $6, PT_R6(sp)
- ld $7, PT_R7(sp)
- ld $2, PT_R2(sp)
-#endif
 	ld	t1, PT_EPC(sp)		# skip syscall on return
 
 	subu	t0, v0, __NR_Linux32	# check syscall number
@@ -60,59 +54,50 @@
 	bgez	t0, stackargs
 
 stack_done:
-	ld	t0, TASK_PTRACE($28)	# syscall tracing enabled?
-	andi	t0, PT_TRACESYS
-	bnez	t0, trace_a_syscall
-
-	jalr	t2			# Do The Real Thing (TM)
-
-	li	t0, -EMAXERRNO - 1	# error?
-	sltu	t0, t0, v0
-	sd	t0, PT_R7(sp)		# set error flag
-	beqz	t0, 1f
+		ld	t0, TASK_PTRACE($28)	# syscall tracing enabled?
+		andi	t0, PT_TRACESYS
+		bnez	t0, trace_a_syscall
+
+		jalr	t2			# Do The Real Thing (TM)
+
+		li	t0, -EMAXERRNO - 1	# error?
+		sltu	t0, t0, v0
+		sd	t0, PT_R7(sp)		# set error flag
+		beqz	t0, 1f
+
+		negu	v0			# error
+		sd	v0, PT_R0(sp)		# flag for syscall restarting
+1:		sd	v0, PT_R2(sp)		# result
 
-	negu	v0			# error
-	sd	v0, PT_R0(sp)		# set flag for syscall restarting
-1:	sd	v0, PT_R2(sp)		# result
-	
 FEXPORT(o32_ret_from_sys_call)
-	la	t1, irq_stat		# softirq_active
-#ifdef CONFIG_SMP
-	lwu	t0, TASK_PROCESSOR($28)
-	dsll	t0, t0, 5
-	daddu	t1, t0
-#endif
-	lw	t0, 0(t1)		# softirq_active
-	lw	t1, 4(t1)		# softirq_mask.  unused delay slot
-	and	t0, t1
-	bnez	t0, o32_handle_softirq
-
-9:	ld	t0,PT_STATUS(sp)	# returning to kernel mode?
-	andi	t1, t0, 0x10
-	ld	t2, TASK_NEED_RESCHED($28)
-	beqz	t1, o32_return		# -> yes
-	bnez	t2, o32_reschedule
-	lw	v0, TASK_SIGPENDING($28)
-	move	a0, zero
-	beqz	v0, o32_return
-	move	a1, sp
-	SAVE_STATIC
-	jal	do_signal
+		mfc0	t0, CP0_STATUS	# need_resched and signals atomic test
+		ori	t0, t0, 1
+		xori	t0, t0, 1
+		mtc0	t0, CP0_STATUS
+
+		ld	t2, TASK_NEED_RESCHED($28)
+		bnez	t2, o32_reschedule
+		lw	v0, TASK_SIGPENDING($28)
+		bnez	v0, signal_return
+
+restore_all:	RESTORE_SOME
+		RESTORE_SP
+		.set	mips3
+		eret
+		.set	mips0
+
+signal_return:	mfc0	t0, CP0_STATUS	# need_resched and signals atomic test
+		ori	t0, t0, 1
+		mtc0	t0, CP0_STATUS
+		move	a0, zero
+		move	a1, sp
+		SAVE_STATIC
+		jal	do_signal
 
-o32_return:
-	RESTORE_SOME
-	RESTORE_SP
-	.set	mips3
-	eret
-	.set	mips0
-
-o32_handle_softirq:
-	jal	do_softirq
-	b	9b
 o32_reschedule:
-	SAVE_STATIC
-	jal	schedule
-	b	o32_ret_from_sys_call
+		SAVE_STATIC
+		jal	schedule
+		b	o32_ret_from_sys_call
 
 /* ------------------------------------------------------------------------ */
 
@@ -205,6 +190,47 @@
 	sd	t0, PT_R7(sp)
 	j	ret_from_sys_call
 	END(handle_sys)
+
+	LEAF(mips_atomic_set)
+	ld	v1, THREAD_CURDS($28)
+	daddiu	a0, a1, 4
+	or	a0, a0, a1
+	li	v0, -EFAULT
+	and	a0, a0, v1
+	bltz	a0, 9f
+
+	/* Ok, this is the ll/sc case.  World is sane :-)  */
+1:	ll	v0, (a1)
+	move	a0, a2
+2:	sc	a0, (a1)
+	beqz	a0, 1b
+
+	.section __ex_table,"a"
+	PTR	1b, bad_stack
+	PTR	2b, bad_stack
+	.previous
+
+1:	sd	v0, PT_R2(sp)		# result
+
+	/* Success, so skip usual error handling garbage.  */
+	ld	t0, TASK_PTRACE($28)	# syscall tracing enabled?
+	andi	t0, PT_TRACESYS
+	bnez	t0, 1f
+	b	o32_ret_from_sys_call
+
+1:	SAVE_STATIC
+	jal	syscall_trace
+	li	a3, 0			# success
+	j	ret_from_sys_call
+
+9:	li	v0, -EFAULT
+	jr	ra
+	END(mips_atomic_set)
+
+	LEAF(sys_sysmips)
+	beq	a0, MIPS_ATOMIC_SET, mips_atomic_set
+	j	_sys_sysmips
+	END(sys_sysmips)
 
 	.macro	syscalltable
 	sys	sys_syscall	0			/* 4000 */
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/setup.c linux/arch/mips64/kernel/setup.c
--- v2.4.9/linux/arch/mips64/kernel/setup.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/kernel/setup.c	Sun Sep  9 10:43:01 2001
@@ -81,7 +81,6 @@
  *
  * These are initialized so they are in the .data section
  */
-unsigned long mips_memory_upper = KSEG0;
 unsigned long mips_cputype = CPU_UNKNOWN;
 unsigned long mips_machtype = MACH_UNKNOWN;
 unsigned long mips_machgroup = MACH_GROUP_UNKNOWN;
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/signal.c linux/arch/mips64/kernel/signal.c
--- v2.4.9/linux/arch/mips64/kernel/signal.c	Wed Jan 24 15:22:55 2001
+++ linux/arch/mips64/kernel/signal.c	Sun Sep  9 10:43:01 2001
@@ -267,8 +267,7 @@
 	struct ucontext rs_uc;
 };
 
-asmlinkage void
-sys_sigreturn(abi64_no_regargs, struct pt_regs regs)
+asmlinkage void sys_sigreturn(abi64_no_regargs, struct pt_regs regs)
 {
 	struct sigframe *frame;
 	sigset_t blocked;
@@ -304,8 +303,7 @@
 	force_sig(SIGSEGV, current);
 }
 
-asmlinkage void
-sys_rt_sigreturn(abi64_no_regargs, struct pt_regs regs)
+asmlinkage void sys_rt_sigreturn(abi64_no_regargs, struct pt_regs regs)
 {
 	struct rt_sigframe *frame;
 	sigset_t set;
@@ -346,8 +344,8 @@
 	force_sig(SIGSEGV, current);
 }
 
-static int inline
-setup_sigcontext(struct pt_regs *regs, struct sigcontext *sc)
+static int inline setup_sigcontext(struct pt_regs *regs,
+				   struct sigcontext *sc)
 {
 	int err = 0;
 
@@ -392,8 +390,8 @@
 /*
  * Determine which stack to use..
  */
-static inline void *
-get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)
+static inline void *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
+				 size_t frame_size)
 {
 	unsigned long sp;
 
@@ -407,9 +405,8 @@
 	return (void *)((sp - frame_size) & ALMASK);
 }
 
-static void inline
-setup_frame(struct k_sigaction * ka, struct pt_regs *regs,
-            int signr, sigset_t *set)
+static void inline setup_frame(struct k_sigaction * ka, struct pt_regs *regs,
+			       int signr, sigset_t *set)
 {
 	struct sigframe *frame;
 	int err = 0;
@@ -470,9 +467,9 @@
 	force_sig(SIGSEGV, current);
 }
 
-static void inline
-setup_rt_frame(struct k_sigaction * ka, struct pt_regs *regs,
-               int signr, sigset_t *set, siginfo_t *info)
+static void inline setup_rt_frame(struct k_sigaction * ka,
+				  struct pt_regs *regs, int signr,
+				  sigset_t *set, siginfo_t *info)
 {
 	struct rt_sigframe *frame;
 	int err = 0;
@@ -489,10 +486,10 @@
 		/*
 		 * Set up the return code ...
 		 *
-		 *         li      v0, __NR_sigreturn
+		 *         li      v0, __NR_rt_sigreturn
 		 *         syscall
 		 */
-		err |= __put_user(0x24020000 + __NR_sigreturn,
+		err |= __put_user(0x24020000 + __NR_rt_sigreturn,
 		                  frame->rs_code + 0);
 		err |= __put_user(0x0000000c                 ,
 		                  frame->rs_code + 1);
@@ -546,9 +543,9 @@
 	force_sig(SIGSEGV, current);
 }
 
-static inline void
-handle_signal(unsigned long sig, struct k_sigaction *ka,
-	siginfo_t *info, sigset_t *oldset, struct pt_regs * regs)
+static inline void handle_signal(unsigned long sig, struct k_sigaction *ka,
+				 siginfo_t *info, sigset_t *oldset,
+				 struct pt_regs *regs)
 {
 	if (ka->sa.sa_flags & SA_SIGINFO)
 		setup_rt_frame(ka, regs, sig, oldset, info);
@@ -566,8 +563,8 @@
 	}
 }
 
-static inline void
-syscall_restart(struct pt_regs *regs, struct k_sigaction *ka)
+static inline void syscall_restart(struct pt_regs *regs,
+				   struct k_sigaction *ka)
 {
 	switch(regs->regs[0]) {
 	case ERESTARTNOHAND:
@@ -599,11 +596,6 @@
 	if (current->thread.mflags & MF_32BIT) {
 		return do_signal32(oldset, regs);
 	}
-#endif
-
-#ifdef CONFIG_BINFMT_IRIX
-	if (current->personality != PER_LINUX)
-		return do_irix_signal(oldset, regs);
 #endif
 
 	if (!oldset)
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/signal32.c linux/arch/mips64/kernel/signal32.c
--- v2.4.9/linux/arch/mips64/kernel/signal32.c	Wed Jan 24 15:22:55 2001
+++ linux/arch/mips64/kernel/signal32.c	Sun Sep  9 10:43:01 2001
@@ -152,10 +152,6 @@
 	sigset32_t *uset;
 	sigset_t newset, saveset;
 
-#if DEBUG_MIPS64
-printk("%s called.\n", __FUNCTION__);
-#endif
-
 	save_static(&regs);
 	uset = (sigset32_t *) regs.regs[4];
 	if (get_sigset(&newset, uset))
@@ -185,10 +181,6 @@
 	sigset_t newset, saveset;
         size_t sigsetsize;
 
-#if DEBUG_MIPS64
-printk("%s called.\n", __FUNCTION__);
-#endif
-
 	save_static(&regs);
 	/* XXX Don't preclude handling different sized sigset_t's.  */
 	sigsetsize = regs.regs[5];
@@ -359,10 +351,6 @@
 	struct sigframe *frame;
 	sigset_t blocked;
 
-#if DEBUG_MIPS64
-printk("%s called.\n", __FUNCTION__);
-#endif
-
 	frame = (struct sigframe *) regs.regs[29];
 	if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
 		goto badframe;
@@ -400,7 +388,6 @@
 	struct rt_sigframe *frame;
 	sigset_t set;
 	stack_t st;
-printk("%s called.\n", __FUNCTION__);
 
 	frame = (struct rt_sigframe *) regs.regs[29];
 	if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
@@ -580,10 +567,10 @@
 		/*
 		 * Set up the return code ...
 		 *
-		 *         li      v0, __NR_Linux32_sigreturn
+		 *         li      v0, __NR_Linux32_rt_sigreturn
 		 *         syscall
 		 */
-		err |= __put_user(0x24020000 + __NR_Linux32_sigreturn,
+		err |= __put_user(0x24020000 + __NR_Linux32_rt_sigreturn,
 		                  frame->rs_code + 0);
 		err |= __put_user(0x0000000c                 ,
 		                  frame->rs_code + 1);
@@ -683,10 +670,6 @@
 	struct k_sigaction *ka;
 	siginfo_t info;
 
-#if DEBUG_MIPS64
-printk("%s: delivering signal.\n", current->comm);
-#endif
-
 	if (!oldset)
 		oldset = &current->blocked;
 
@@ -785,9 +768,6 @@
 		if (regs->regs[0])
 			syscall_restart(regs, ka);
 		/* Whee!  Actually deliver the signal.  */
-#if DEBUG_MIPS64
-printk("%s: delivering signal.\n", __FUNCTION__);
-#endif
 		handle_signal(signr, ka, &info, oldset, regs);
 		return 1;
 	}
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/syscall.c linux/arch/mips64/kernel/syscall.c
--- v2.4.9/linux/arch/mips64/kernel/syscall.c	Mon Mar 19 12:35:10 2001
+++ linux/arch/mips64/kernel/syscall.c	Sun Sep  9 10:43:01 2001
@@ -3,8 +3,9 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1995 - 2000 by Ralf Baechle
+ * Copyright (C) 1995 - 2000, 2001 by Ralf Baechle
  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
+ * Copyright (C) 2001 MIPS Technologies, Inc.
  */
 #include <linux/errno.h>
 #include <linux/linkage.h>
@@ -129,7 +130,7 @@
 }
 
 asmlinkage int
-sys_sysmips(int cmd, long arg1, int arg2, int arg3)
+_sys_sysmips(int cmd, long arg1, int arg2, int arg3)
 {
 	int	*p;
 	char	*name;
@@ -155,50 +156,9 @@
 		return 0;
 	}
 
-	case MIPS_ATOMIC_SET: {
-		unsigned int tmp;
-
-		p = (int *) arg1;
-		errno = verify_area(VERIFY_WRITE, p, sizeof(*p));
-		if (errno)
-			return errno;
-		errno = 0;
-
-		__asm__(".set\tpush\t\t\t# sysmips(MIPS_ATOMIC, ...)\n\t"
-			".set\tnoreorder\n\t"
-			".set\tnoat\n\t"
-			"1:\tll\t%0, %4\n\t"
-			"2:\tmove\t$1, %3\n\t"
-			"3:\tsc\t$1, %1\n\t"
-			"beqzl\t$1, 2b\n\t"
-			"4:\t ll\t%0, %4\n\t"
-			".set\tpop\n\t"
-			".section\t.fixup,\"ax\"\n"
-			"5:\tli\t%2, 1\t\t\t# error\n\t"
-			".previous\n\t"
-			".section\t__ex_table,\"a\"\n\t"
-			".dword\t1b, 5b\n\t"
-			".dword\t3b, 5b\n\t"
-			".dword\t4b, 5b\n\t"
-			".previous\n\t"
-			: "=&r" (tmp), "=o" (* (u32 *) p), "=r" (errno)
-			: "r" (arg2), "o" (* (u32 *) p), "2" (errno)
-			: "$1");
-
-		if (errno)
-			return -EFAULT;
-
-		/* We're skipping error handling etc.  */
-		if (current->ptrace & PT_TRACESYS)
-			syscall_trace();
-
-		__asm__ __volatile__(
-			"move\t$29, %0\n\t"
-			"j\tret_from_sys_call"
-			: /* No outputs */
-			: "r" (&cmd));
-		/* Unreached */
-	}
+	case MIPS_ATOMIC_SET:
+		printk(KERN_CRIT "How did I get here?\n");
+		return -EINVAL;
 
 	case MIPS_FIXADE:
 		tmp = current->thread.mflags & ~3;
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/traps.c linux/arch/mips64/kernel/traps.c
--- v2.4.9/linux/arch/mips64/kernel/traps.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/kernel/traps.c	Sun Sep  9 10:43:01 2001
@@ -258,58 +258,91 @@
 	printk(KERN_DEBUG "Should send SIGFPE to %s\n", current->comm);
 }
 
-static inline int get_insn_opcode(struct pt_regs *regs, unsigned int *opcode)
-{
-	unsigned int *epc;
-
-	epc = (unsigned int *) (unsigned long) regs->cp0_epc;
-	if (regs->cp0_cause & CAUSEF_BD)
-		epc++;
-
-	if (verify_area(VERIFY_READ, epc, 4)) {
-		force_sig(SIGSEGV, current);
-		return 1;
-	}
-	*opcode = *epc;
-
-	return 0;
-}
-
 void do_bp(struct pt_regs *regs)
 {
 	unsigned int opcode, bcode;
+	unsigned int *epc;
+	siginfo_t info;
+
+	epc = (unsigned int *) regs->cp0_epc +
+	      ((regs->cp0_cause & CAUSEF_BD) != 0);
+	if (get_user(opcode, epc))
+		goto sigsegv;
 
 	/*
 	 * There is the ancient bug in the MIPS assemblers that the break
 	 * code starts left to bit 16 instead to bit 6 in the opcode.
 	 * Gas is bug-compatible ...
 	 */
-	if (get_insn_opcode(regs, &opcode))
-		return;
 	bcode = ((opcode >> 16) & ((1 << 20) - 1));
 
 	/*
 	 * (A short test says that IRIX 5.3 sends SIGTRAP for all break
 	 * insns, even for break codes that indicate arithmetic failures.
 	 * Weird ...)
+	 * But should we continue the brokenness???  --macro
 	 */
+	switch (bcode) {
+	case 6:
+	case 7:
+		if (bcode == 7)
+			info.si_code = FPE_INTDIV;
+		else
+			info.si_code = FPE_INTOVF;
+		info.si_signo = SIGFPE;
+		info.si_errno = 0;
+		info.si_addr = (void *)compute_return_epc(regs);
+		force_sig_info(SIGFPE, &info, current);
+		break;
+	default:
+		force_sig(SIGTRAP, current);
+	}
+
 	force_sig(SIGTRAP, current);
+	return;
+
+sigsegv:
+	force_sig(SIGSEGV, current);
 }
 
 void do_tr(struct pt_regs *regs)
 {
 	unsigned int opcode, bcode;
+	unsigned int *epc;
+	siginfo_t info;
+
+	epc = (unsigned int *) regs->cp0_epc +
+	      ((regs->cp0_cause & CAUSEF_BD) != 0);
+	if (get_user(opcode, epc))
+		goto sigsegv;
 
-	if (get_insn_opcode(regs, &opcode))
-		return;
 	bcode = ((opcode >> 6) & ((1 << 20) - 1));
 
 	/*
 	 * (A short test says that IRIX 5.3 sends SIGTRAP for all break
 	 * insns, even for break codes that indicate arithmetic failures.
 	 * Wiered ...)
+	 * But should we continue the brokenness???  --macro
 	 */
-	force_sig(SIGTRAP, current);
+	switch (bcode) {
+	case 6:
+	case 7:
+		if (bcode == 7)
+			info.si_code = FPE_INTDIV;
+		else
+			info.si_code = FPE_INTOVF;
+		info.si_signo = SIGFPE;
+		info.si_errno = 0;
+		info.si_addr = (void *)compute_return_epc(regs);
+		force_sig_info(SIGFPE, &info, current);
+		break;
+	default:
+		force_sig(SIGTRAP, current);
+	}
+	return;
+
+sigsegv:
+	force_sig(SIGSEGV, current);
 }
 
 void do_ri(struct pt_regs *regs)
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/kernel/unaligned.c linux/arch/mips64/kernel/unaligned.c
--- v2.4.9/linux/arch/mips64/kernel/unaligned.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/kernel/unaligned.c	Sun Sep  9 10:43:01 2001
@@ -72,6 +72,7 @@
  *       A store crossing a page boundary might be executed only partially.
  *       Undo the partial store in this case.
  */
+#include <linux/config.h>
 #include <linux/mm.h>
 #include <linux/signal.h>
 #include <linux/smp.h>
@@ -378,7 +379,9 @@
 	return;
 }
 
+#ifdef CONFIG_PROC_FS
 unsigned long unaligned_instructions;
+#endif
 
 asmlinkage void do_ade(struct pt_regs *regs)
 {
@@ -399,7 +402,9 @@
 		goto sigbus;
 
 	emulate_load_store_insn(regs, regs->cp0_badvaddr, pc);
+#ifdef CONFIG_PROC_FS
 	unaligned_instructions++;
+#endif
 
 	return;
 
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/lib/csum_partial.S linux/arch/mips64/lib/csum_partial.S
--- v2.4.9/linux/arch/mips64/lib/csum_partial.S	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/lib/csum_partial.S	Sun Sep  9 10:43:01 2001
@@ -1,5 +1,4 @@
-/* $Id: csum_partial.S,v 1.1 1999/08/21 21:43:00 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/lib/csum_partial_copy.c linux/arch/mips64/lib/csum_partial_copy.c
--- v2.4.9/linux/arch/mips64/lib/csum_partial_copy.c	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/lib/csum_partial_copy.c	Sun Sep  9 10:43:01 2001
@@ -1,5 +1,4 @@
-/* $Id: csum_partial_copy.c,v 1.2 1999/12/04 03:59:00 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/lib/dump_tlb.c linux/arch/mips64/lib/dump_tlb.c
--- v2.4.9/linux/arch/mips64/lib/dump_tlb.c	Sun Jul  9 22:18:16 2000
+++ linux/arch/mips64/lib/dump_tlb.c	Sun Sep  9 10:43:01 2001
@@ -168,14 +168,12 @@
 	printk("\n");
 }
 
-void
-dump_list_current(void *address)
+void dump_list_current(void *address)
 {
 	dump_list_process(current, address);
 }
 
-unsigned int
-vtop(void *address)
+unsigned int vtop(void *address)
 {
 	pgd_t	*pgd;
 	pmd_t	*pmd;
@@ -192,16 +190,17 @@
 	return paddr;
 }
 
-void
-dump16(unsigned long *p)
+void dump16(unsigned long *p)
 {
 	int i;
 
 	for(i=0;i<8;i++)
 	{
 		printk("*%08lx == %08lx, ",
-		       (unsigned long)p, (unsigned long)*p++);
+		       (unsigned long)p, (unsigned long)*p);
+		p++;
 		printk("*%08lx == %08lx\n",
-		       (unsigned long)p, (unsigned long)*p++);
+		       (unsigned long)p, (unsigned long)*p);
+		p++;
 	}
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/lib/floppy-no.c linux/arch/mips64/lib/floppy-no.c
--- v2.4.9/linux/arch/mips64/lib/floppy-no.c	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/lib/floppy-no.c	Sun Sep  9 10:43:01 2001
@@ -1,5 +1,4 @@
-/* $Id: floppy-no.c,v 1.1 1999/08/21 21:43:00 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/lib/ide-no.c linux/arch/mips64/lib/ide-no.c
--- v2.4.9/linux/arch/mips64/lib/ide-no.c	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/lib/ide-no.c	Sun Sep  9 10:43:01 2001
@@ -1,5 +1,4 @@
-/* $Id: ide-no.c,v 1.1 1999/08/21 21:43:00 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/lib/ide-std.c linux/arch/mips64/lib/ide-std.c
--- v2.4.9/linux/arch/mips64/lib/ide-std.c	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/lib/ide-std.c	Sun Sep  9 10:43:01 2001
@@ -1,12 +1,11 @@
-/* $Id: ide-std.c,v 1.1 1999/08/21 21:43:00 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * IDE routines for typical pc-like standard configurations.
  *
- * Copyright (C) 1998, 1999 by Ralf Baechle
+ * Copyright (C) 1998, 1999, 2001 by Ralf Baechle
  */
 #include <linux/sched.h>
 #include <linux/ide.h>
@@ -60,6 +59,7 @@
 	}
 	if (irq != NULL)
 		*irq = 0;
+	hw->io_ports[IDE_IRQ_OFFSET] = 0;
 }
 
 static int std_ide_request_irq(unsigned int irq,
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/lib/kbd-no.c linux/arch/mips64/lib/kbd-no.c
--- v2.4.9/linux/arch/mips64/lib/kbd-no.c	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/lib/kbd-no.c	Sun Sep  9 10:43:01 2001
@@ -1,5 +1,4 @@
-/* $Id: kbd-no.c,v 1.1 1999/08/21 21:43:00 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/lib/kbd-std.c linux/arch/mips64/lib/kbd-std.c
--- v2.4.9/linux/arch/mips64/lib/kbd-std.c	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/lib/kbd-std.c	Sun Sep  9 10:43:01 2001
@@ -1,5 +1,4 @@
-/* $Id: kbd-std.c,v 1.1 1999/08/21 21:43:01 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/lib/memcpy.S linux/arch/mips64/lib/memcpy.S
--- v2.4.9/linux/arch/mips64/lib/memcpy.S	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/lib/memcpy.S	Sun Sep  9 10:43:02 2001
@@ -5,7 +5,7 @@
  *
  * Unified implementation of memcpy, memmove and the __copy_user backend.
  *
- * Copyright (C) 1998, 1999, 2000 Ralf Baechle
+ * Copyright (C) 1998, 1999, 2000, 2001 Ralf Baechle
  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  *
  * For __rmemcpy and memmove an exception is always a kernel bug, therefore
@@ -238,10 +238,8 @@
 	 andi	ta2, a2, 0x40
 
 move_128bytes:
-#if (_MIPS_ISA == _MIPS_ISA_MIPS4)
-	pref	0, 2*128(a0)
-	pref	1, 2*128(a1)
-#endif
+	PREF	(0, 2*128(a0))
+	PREF	(1, 2*128(a1))
 	MOVE_BIGGERCHUNK(a1, a0, 0x00, ta0, ta1, ta3, t0)
 	MOVE_BIGGERCHUNK(a1, a0, 0x40, ta0, ta1, ta3, t0)
 	dsubu	t8, t8, 0x01
@@ -454,16 +452,21 @@
 
 	.align	5
 LEAF(memmove)
-	sltu	ta0, a0, a1			# dst < src -> memcpy
-	bnez	ta0, memcpy
-	 daddu	v0, a0, a2
-	sltu	ta0, v0, a1			# dst + len < src -> non-
-	bnez	ta0, __memcpy			# overlapping, can use memcpy
+	daddu	t0, a0, a2
+	sltu	t0, a1, t0			# dst + len <= src -> memcpy
+	daddu	t1, a1, a2
+	sltu	t1, a0, t1			# dst >= src + len -> memcpy
+	and	t0, t1
+	beqz	t0, __memcpy
+
 	 move	v0, a0				/* return value */
 	beqz	a2, r_out
 	END(memmove)
 
 LEAF(__rmemcpy)					/* a0=dst a1=src a2=len */
+	sltu	t0, a1, a0
+	beqz	t0, r_end_bytes_up		# src >= dst
+	 nop
 	daddu	a0, a2				# dst = dst + len
 	daddu	a1, a2				# src = src + len
 
@@ -615,6 +618,17 @@
 	 dsubu	a0, a0, 0x1
 
 r_out:
+	jr      ra
+	 move   a2, zero
+
+r_end_bytes_up:
+	lb	t0, (a1)
+	dsubu	a2, a2, 0x1
+	sb	t0, (a0)
+	daddu	a1, a1, 0x1
+	bnez	a2, r_end_bytes_up
+	 daddu	a0, a0, 0x1
+
 	jr	ra
 	 move	a2, zero
 
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/lib/strlen_user.S linux/arch/mips64/lib/strlen_user.S
--- v2.4.9/linux/arch/mips64/lib/strlen_user.S	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/lib/strlen_user.S	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: strlen_user.S,v 1.2 1999/11/19 20:35:22 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/lib/strncpy_user.S linux/arch/mips64/lib/strncpy_user.S
--- v2.4.9/linux/arch/mips64/lib/strncpy_user.S	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/lib/strncpy_user.S	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: strncpy_user.S,v 1.2 1999/11/19 20:35:23 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/lib/strnlen_user.S linux/arch/mips64/lib/strnlen_user.S
--- v2.4.9/linux/arch/mips64/lib/strnlen_user.S	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/lib/strnlen_user.S	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: strnlen_user.S,v 1.1 1999/11/19 20:35:23 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/math-emu/cp1emu.c linux/arch/mips64/math-emu/cp1emu.c
--- v2.4.9/linux/arch/mips64/math-emu/cp1emu.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/mips64/math-emu/cp1emu.c	Sun Sep  9 10:43:02 2001
@@ -53,7 +53,9 @@
 
 #include <asm/asm.h>
 #include <asm/branch.h>
+#include <asm/bootinfo.h>
 #include <asm/byteorder.h>
+#include <asm/cpu.h>
 #include <asm/inst.h>
 #include <asm/uaccess.h>
 #include <asm/processor.h>
@@ -851,11 +853,8 @@
 	current->thread.dsemul_epc = (unsigned long) cpc;
 	current->thread.dsemul_aerpc = (unsigned long) &dsemul_insns[1];
 	xcp->cp0_epc = VA_TO_REG & dsemul_insns[0];
+	flush_cache_sigtramp((unsigned long) dsemul_insns);
 
-	/* What we'd really like to do is just flush the line(s) of the */
-	/* icache containing the dsemulret instructions, but there's no */
-	/* mechanism to do this yet...  */
-	flush_cache_all();
 	return SIGILL;		/* force out of emulation loop */
 }
 
@@ -1708,6 +1707,9 @@
 
 	oldepc = xcp->cp0_epc;
 	do {
+		if (current->need_resched)
+			schedule();
+
 		prevepc = xcp->cp0_epc;
 		insn = mips_get_word(xcp, REG_TO_VA(xcp->cp0_epc), &err);
 		if (err) {
@@ -1718,6 +1720,9 @@
 			sig = cop1Emulate(xcptno, xcp, ctx);
 		else
 			xcp->cp0_epc += 4;	/* skip nops */
+
+		if (mips_cpu.options & MIPS_CPU_FPU)
+			break;
 	} while (xcp->cp0_epc > prevepc && sig == 0);
 
 	/* SIGILL indicates a non-fpu instruction */
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mips-boards/atlas/Makefile linux/arch/mips64/mips-boards/atlas/Makefile
--- v2.4.9/linux/arch/mips64/mips-boards/atlas/Makefile	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/mips-boards/atlas/Makefile	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,42 @@
+#
+# Carsten Langgaard, carstenl@mips.com
+# Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+#
+# ########################################################################
+#
+# This program is free software; you can distribute it and/or modify it
+# under the terms of the GNU General Public License (Version 2) as
+# published by the Free Software Foundation.
+# 
+# This program is distributed in the hope it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+#
+# #######################################################################
+#
+# Makefile for the MIPS Atlas specific kernel interface routines
+# under Linux.
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+# Note 2! The CFLAGS definitions are now in the main makefile...
+
+.S.s:
+	$(CPP) $(CFLAGS) $< -o $*.s
+.S.o:
+	$(CC) $(CFLAGS) -c $< -o $*.o
+
+all: atlas.o
+
+O_TARGET := atlas.o
+
+obj-y   := atlas_int.o atlas_rtc.o atlas_setup.o
+
+include $(TOPDIR)/Rules.make
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mips-boards/atlas/atlas_int.c linux/arch/mips64/mips-boards/atlas/atlas_int.c
--- v2.4.9/linux/arch/mips64/mips-boards/atlas/atlas_int.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/mips-boards/atlas/atlas_int.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,249 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ * ########################################################################
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * ########################################################################
+ *
+ * Routines for generic manipulation of the interrupts found on the MIPS 
+ * Atlas board.
+ *
+ */
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/interrupt.h>
+#include <linux/kernel_stat.h>
+
+#include <asm/irq.h>
+#include <asm/mips-boards/atlas.h>
+#include <asm/mips-boards/atlasint.h>
+#ifdef CONFIG_REMOTE_DEBUG
+#include <asm/gdb-stub.h>
+#endif
+
+struct atlas_ictrl_regs *atlas_hw0_icregs
+	= (struct atlas_ictrl_regs *)ATLAS_ICTRL_REGS_BASE;
+
+extern asmlinkage void mipsIRQ(void);
+extern void do_IRQ(int irq, struct pt_regs *regs);
+
+unsigned long spurious_count = 0;
+irq_desc_t irq_desc[NR_IRQS];
+
+#if 0
+#define DEBUG_INT(x...) printk(x)
+#else
+#define DEBUG_INT(x...)
+#endif
+
+void disable_atlas_irq(unsigned int irq_nr)
+{
+	atlas_hw0_icregs->intrsten = (1 << irq_nr);
+}
+
+void enable_atlas_irq(unsigned int irq_nr)
+{
+	atlas_hw0_icregs->intseten = (1 << irq_nr);
+}
+
+static unsigned int startup_atlas_irq(unsigned int irq)
+{
+	enable_atlas_irq(irq);
+	return 0; /* never anything pending */
+}
+
+#define shutdown_atlas_irq	disable_atlas_irq
+
+#define mask_and_ack_atlas_irq disable_atlas_irq
+
+static void end_atlas_irq(unsigned int irq)
+{
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_atlas_irq(irq);
+}
+
+static struct hw_interrupt_type atlas_irq_type = {
+	"Atlas",
+	startup_atlas_irq,
+	shutdown_atlas_irq,
+	enable_atlas_irq,
+	disable_atlas_irq,
+	mask_and_ack_atlas_irq,
+	end_atlas_irq,
+	NULL
+};
+
+int get_irq_list(char *buf)
+{
+	int i, len = 0;
+	int num = 0;
+	struct irqaction *action;
+
+	for (i = 0; i < ATLASINT_END; i++, num++) {
+		action = irq_desc[i].action;
+		if (!action) 
+			continue;
+		len += sprintf(buf+len, "%2d: %8d %c %s",
+			num, kstat.irqs[0][num],
+			(action->flags & SA_INTERRUPT) ? '+' : ' ',
+			action->name);
+		for (action=action->next; action; action = action->next) {
+			len += sprintf(buf+len, ",%s %s",
+				(action->flags & SA_INTERRUPT) ? " +" : "",
+				action->name);
+		}
+		len += sprintf(buf+len, " [hw0]\n");
+	}
+	return len;
+}
+
+int request_irq(unsigned int irq, 
+		void (*handler)(int, void *, struct pt_regs *),
+		unsigned long irqflags, 
+		const char * devname,
+		void *dev_id)
+{  
+        struct irqaction *action;
+
+	DEBUG_INT("request_irq: irq=%d, devname = %s\n", irq, devname);
+
+        if (irq >= ATLASINT_END)
+	        return -EINVAL;
+	if (!handler)
+	        return -EINVAL;
+
+	action = (struct irqaction *)kmalloc(sizeof(struct irqaction), GFP_KERNEL);
+	if(!action)
+	        return -ENOMEM;
+
+	action->handler = handler;
+	action->flags = irqflags;
+	action->mask = 0;
+	action->name = devname;
+	action->dev_id = dev_id;
+	action->next = 0;
+	irq_desc[irq].action = action;
+	enable_atlas_irq(irq);
+
+	return 0;
+}
+
+void free_irq(unsigned int irq, void *dev_id)
+{
+	struct irqaction *action;
+
+	if (irq >= ATLASINT_END) {
+		printk("Trying to free IRQ%d\n",irq);
+		return;
+	}
+
+	action = irq_desc[irq].action;
+	irq_desc[irq].action = NULL;
+	disable_atlas_irq(irq);
+	kfree(action);
+}
+
+static inline int ls1bit32(unsigned int x)
+{
+	int b = 31, s;
+
+	s = 16; if (x << 16 == 0) s = 0; b -= s; x <<= s;
+	s =  8; if (x <<  8 == 0) s = 0; b -= s; x <<= s;
+	s =  4; if (x <<  4 == 0) s = 0; b -= s; x <<= s;
+	s =  2; if (x <<  2 == 0) s = 0; b -= s; x <<= s;
+	s =  1; if (x <<  1 == 0) s = 0; b -= s;
+
+	return b;
+}
+
+void atlas_hw0_irqdispatch(struct pt_regs *regs)
+{
+	struct irqaction *action;
+	unsigned long int_status;
+	int irq, cpu = smp_processor_id();
+
+	int_status = atlas_hw0_icregs->intstatus; 
+
+	/* if int_status == 0, then the interrupt has already been cleared */
+	if (int_status == 0)
+		return;
+
+	irq = ls1bit32(int_status);
+	action = irq_desc[irq].action;
+
+	DEBUG_INT("atlas_hw0_irqdispatch: irq=%d\n", irq);
+
+	/* if action == NULL, then we don't have a handler for the irq */
+	if ( action == NULL ) {
+	        printk("No handler for hw0 irq: %i\n", irq);
+		spurious_count++;
+		return;
+	}
+
+	irq_enter(cpu, irq);
+	kstat.irqs[0][irq]++;
+	action->handler(irq, action->dev_id, regs);
+	irq_exit(cpu, irq);
+
+	return;		
+}
+
+unsigned long probe_irq_on (void)
+{
+	return 0;
+}
+
+
+int probe_irq_off (unsigned long irqs)
+{
+	return 0;
+}
+
+#ifdef CONFIG_REMOTE_DEBUG
+extern void breakpoint(void);
+extern int remote_debug;
+#endif
+
+void __init init_IRQ(void)
+{
+	int i;
+
+	/* 
+	 * Mask out all interrupt by writing "1" to all bit position in 
+	 * the interrupt reset reg. 
+	 */
+	atlas_hw0_icregs->intrsten = 0xffffffff;    
+
+	/* Now safe to set the exception vector. */
+	set_except_vector(0, mipsIRQ);
+
+	for (i = 0; i <= ATLASINT_END; i++) {
+		irq_desc[i].status	= IRQ_DISABLED;
+		irq_desc[i].action	= 0;
+		irq_desc[i].depth	= 1;
+		irq_desc[i].handler	= &atlas_irq_type;
+	}
+
+#ifdef CONFIG_REMOTE_DEBUG
+	if (remote_debug) {
+		set_debug_traps();
+		breakpoint();
+	}
+#endif
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mips-boards/atlas/atlas_rtc.c linux/arch/mips64/mips-boards/atlas/atlas_rtc.c
--- v2.4.9/linux/arch/mips64/mips-boards/atlas/atlas_rtc.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/mips-boards/atlas/atlas_rtc.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,58 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ * ########################################################################
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * ########################################################################
+ *
+ * RTC routines for Atlas style attached Dallas chip.
+ *
+ */
+#include <asm/mc146818rtc.h>
+#include <asm/mips-boards/atlas.h>
+
+
+static unsigned char atlas_rtc_read_data(unsigned long addr)
+{
+	volatile unsigned int *rtc_adr_reg = (void *)ATLAS_RTC_ADR_REG;
+	volatile unsigned int *rtc_dat_reg = (void *)ATLAS_RTC_DAT_REG;
+
+	*rtc_adr_reg = addr;
+
+	return *rtc_dat_reg;
+}
+
+static void atlas_rtc_write_data(unsigned char data, unsigned long addr)
+{
+	volatile unsigned int *rtc_adr_reg = (void *)ATLAS_RTC_ADR_REG;
+	volatile unsigned int *rtc_dat_reg = (void *)ATLAS_RTC_DAT_REG;
+
+	*rtc_adr_reg = addr;
+	*rtc_dat_reg = data;
+}
+
+static int atlas_rtc_bcd_mode(void)
+{
+	return 0;
+}
+
+struct rtc_ops atlas_rtc_ops = {
+	&atlas_rtc_read_data,
+	&atlas_rtc_write_data,
+	&atlas_rtc_bcd_mode
+};
+
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mips-boards/atlas/atlas_setup.c linux/arch/mips64/mips-boards/atlas/atlas_setup.c
--- v2.4.9/linux/arch/mips64/mips-boards/atlas/atlas_setup.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/mips-boards/atlas/atlas_setup.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,123 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ * ########################################################################
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * ########################################################################
+ *
+ * Atlas specific setup, including init of the feature struct.
+ *
+ */
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/mc146818rtc.h>
+#include <linux/ioport.h>
+
+#include <asm/cpu.h>
+#include <asm/bootinfo.h>
+#include <asm/irq.h>
+#include <asm/mips-boards/generic.h>
+#include <asm/mips-boards/prom.h>
+#include <asm/mips-boards/gt64120.h>
+#include <asm/mips-boards/atlasint.h>
+
+#include <asm/mmu_context.h>
+
+#if defined(CONFIG_SERIAL_CONSOLE) || defined(CONFIG_PROM_CONSOLE)
+extern void console_setup(char *, int *);
+char serial_console[20];
+#endif
+
+#ifdef CONFIG_REMOTE_DEBUG
+extern void rs_kgdb_hook(int);
+extern void saa9730_kgdb_hook(void);
+extern void breakpoint(void);
+int remote_debug = 0;
+#endif
+
+extern struct rtc_ops atlas_rtc_ops;
+
+extern void mips_reboot_setup(void);
+
+void __init atlas_setup(void)
+{
+#ifdef CONFIG_REMOTE_DEBUG
+	int rs_putDebugChar(char);
+	char rs_getDebugChar(void);
+	int saa9730_putDebugChar(char);
+	char saa9730_getDebugChar(void);
+	extern int (*putDebugChar)(char);
+	extern char (*getDebugChar)(void);
+#endif
+	char *argptr;
+
+	current_cpu_data.asid_cache = ASID_FIRST_VERSION;
+	TLBMISS_HANDLER_SETUP();
+
+	ioport_resource.end = 0x7fffffff;
+
+#ifdef CONFIG_SERIAL_CONSOLE
+	argptr = prom_getcmdline();
+	if ((argptr = strstr(argptr, "console=ttyS0")) == NULL) {
+		int i = 0;
+		char *s = prom_getenv("modetty0");
+		while(s[i] >= '0' && s[i] <= '9')
+			i++;
+		strcpy(serial_console, "ttyS0,");
+		strncpy(serial_console + 6, s, i);
+		prom_printf("Config serial console: %s\n", serial_console);
+		console_setup(serial_console, NULL);
+	}
+#endif	  
+
+#ifdef CONFIG_REMOTE_DEBUG
+	argptr = prom_getcmdline();
+	if ((argptr = strstr(argptr, "kgdb=ttyS")) != NULL) {
+		int line;
+		argptr += strlen("kgdb=ttyS");
+		if (*argptr != '0' && *argptr != '1')
+			printk("KGDB: Uknown serial line /dev/ttyS%c, "
+			       "falling back to /dev/ttyS1\n", *argptr);
+		line = *argptr == '0' ? 0 : 1;
+		printk("KGDB: Using serial line /dev/ttyS%d for session\n",
+		       line ? 1 : 0);
+
+		if(line == 0) {
+			rs_kgdb_hook(line);
+			putDebugChar = rs_putDebugChar;
+			getDebugChar = rs_getDebugChar;
+		} else {
+			saa9730_kgdb_hook();
+			putDebugChar = saa9730_putDebugChar;
+			getDebugChar = saa9730_getDebugChar;
+		}
+
+		prom_printf("KGDB: Using serial line /dev/ttyS%d for session, "
+			    "please connect your debugger\n", line ? 1 : 0);
+
+		remote_debug = 1;
+		/* Breakpoints and stuff are in atlas_irq_setup() */
+	}
+#endif
+	argptr = prom_getcmdline();
+
+	if ((argptr = strstr(argptr, "nofpu")) != NULL)
+		mips_cpu.options &= ~MIPS_CPU_FPU;
+
+	rtc_ops = &atlas_rtc_ops;
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mips-boards/generic/Makefile linux/arch/mips64/mips-boards/generic/Makefile
--- v2.4.9/linux/arch/mips64/mips-boards/generic/Makefile	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/mips-boards/generic/Makefile	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,43 @@
+#
+# Carsten Langgaard, carstenl@mips.com
+# Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+#
+# ########################################################################
+#
+# This program is free software; you can distribute it and/or modify it
+# under the terms of the GNU General Public License (Version 2) as
+# published by the Free Software Foundation.
+# 
+# This program is distributed in the hope it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+#
+# #######################################################################
+#
+# Makefile for the MIPS boards generic routines under Linux.
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+# Note 2! The CFLAGS definitions are now in the main makefile...
+
+.S.s:
+	$(CPP) $(CFLAGS) $< -o $*.s
+.S.o:
+	$(CC) $(CFLAGS) -c $< -o $*.o
+
+all: mipsboards.o
+
+O_TARGET := mipsboards.o
+
+obj-y                           := mipsIRQ.o pci.o reset.o display.o init.o \
+                                   memory.o printf.o cmdline.o time.o
+obj-$(CONFIG_REMOTE_DEBUG)      += gdb_hook.o
+
+include $(TOPDIR)/Rules.make
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mips-boards/generic/cmdline.c linux/arch/mips64/mips-boards/generic/cmdline.c
--- v2.4.9/linux/arch/mips64/mips-boards/generic/cmdline.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/mips-boards/generic/cmdline.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,71 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ * ########################################################################
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * ########################################################################
+ * 
+ * Kernel command line creation using the prom monitor (YAMON) argc/argv.
+ *
+ */
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/string.h>
+
+#include <asm/bootinfo.h>
+
+/*#define DEBUG_CMDLINE*/
+
+extern int prom_argc;
+extern int *_prom_argv;
+
+/*
+ * A 32-bit PROM pass arguments and environment as 32-bit pointer.
+ * This macro take care of sign extension.
+ */
+#define prom_argv(index) ((char *)(((int *)(int)_prom_argv)[(index)]))
+
+char arcs_cmdline[CL_SIZE];
+
+char * __init prom_getcmdline(void)
+{
+	return &(arcs_cmdline[0]);
+}
+
+
+void  __init prom_init_cmdline(void)
+{
+	char *cp;
+	int actr;
+
+	actr = 1; /* Always ignore argv[0] */
+
+	cp = &(arcs_cmdline[0]);
+	while(actr < prom_argc) {
+	        strcpy(cp, prom_argv(actr));
+		cp += strlen(prom_argv(actr));
+		*cp++ = ' ';
+		actr++;
+	}
+	if (cp != &(arcs_cmdline[0])) /* get rid of trailing space */
+		--cp;
+	*cp = '\0';
+
+#ifdef DEBUG_CMDLINE
+	prom_printf("prom_init_cmdline: %s\n", &(arcs_cmdline[0]));
+#endif
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mips-boards/generic/display.c linux/arch/mips64/mips-boards/generic/display.c
--- v2.4.9/linux/arch/mips64/mips-boards/generic/display.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/mips-boards/generic/display.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,47 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ * ########################################################################
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * ########################################################################
+ * 
+ * Display routines for display messages in MIPS boards ascii display.
+ *
+ */
+
+#include <asm/mips-boards/generic.h>
+
+
+void mips_display_message(const char *str)
+{
+        volatile unsigned int *display = (void *)ASCII_DISPLAY_POS_BASE;
+	int i;
+
+	for (i = 0; i <= 14; i=i+2) {
+	         if (*str)
+		         display[i] = *str++;
+		 else
+		         display[i] = ' ';
+	}
+}
+
+void mips_display_word(unsigned int num)
+{
+        volatile unsigned int *display = (void *)ASCII_DISPLAY_WORD_BASE;
+	
+	*display = num;
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mips-boards/generic/gdb_hook.c linux/arch/mips64/mips-boards/generic/gdb_hook.c
--- v2.4.9/linux/arch/mips64/mips-boards/generic/gdb_hook.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/mips-boards/generic/gdb_hook.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,202 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ * ########################################################################
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * ########################################################################
+ *
+ * This is the interface to the remote debugger stub.
+ *
+ */
+
+#include <linux/serialP.h>
+#include <linux/serial_reg.h>
+
+#include <asm/serial.h>
+#include <asm/io.h>
+
+static struct serial_state rs_table[RS_TABLE_SIZE] = {
+	SERIAL_PORT_DFNS	/* Defined in serial.h */
+};
+
+static struct async_struct kdb_port_info = {0};
+
+
+static __inline__ unsigned int serial_in(struct async_struct *info, int offset)
+{
+	return inb(info->port + offset);
+}
+
+static __inline__ void serial_out(struct async_struct *info, int offset,
+				int value)
+{
+	outb(value, info->port+offset);
+}
+
+void rs_kgdb_hook(int tty_no) {
+	int t;
+	struct serial_state *ser = &rs_table[tty_no];
+
+	kdb_port_info.state = ser;
+	kdb_port_info.magic = SERIAL_MAGIC;
+	kdb_port_info.port = ser->port;
+	kdb_port_info.flags = ser->flags;
+
+	/*
+	 * Clear all interrupts
+	 */
+	serial_in(&kdb_port_info, UART_LSR);
+	serial_in(&kdb_port_info, UART_RX);
+	serial_in(&kdb_port_info, UART_IIR);
+	serial_in(&kdb_port_info, UART_MSR);
+
+	/*
+	 * Now, initialize the UART 
+	 */
+	serial_out(&kdb_port_info, UART_LCR, UART_LCR_WLEN8);	/* reset DLAB */
+	if (kdb_port_info.flags & ASYNC_FOURPORT) {
+		kdb_port_info.MCR = UART_MCR_DTR | UART_MCR_RTS;
+		t = UART_MCR_DTR | UART_MCR_OUT1;
+	} else {
+		kdb_port_info.MCR 
+			= UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2;
+		t = UART_MCR_DTR | UART_MCR_RTS;
+	}
+
+	kdb_port_info.MCR = t;		/* no interrupts, please */
+	serial_out(&kdb_port_info, UART_MCR, kdb_port_info.MCR);
+	
+	/*
+	 * and set the speed of the serial port
+	 * (currently hardwired to 9600 8N1
+	 */
+
+	/* baud rate is fixed to 9600 (is this sufficient?)*/
+	t = kdb_port_info.state->baud_base / 9600;	
+	/* set DLAB */
+	serial_out(&kdb_port_info, UART_LCR, UART_LCR_WLEN8 | UART_LCR_DLAB);
+	serial_out(&kdb_port_info, UART_DLL, t & 0xff);/* LS of divisor */
+	serial_out(&kdb_port_info, UART_DLM, t >> 8);  /* MS of divisor */
+	/* reset DLAB */
+	serial_out(&kdb_port_info, UART_LCR, UART_LCR_WLEN8);
+}
+
+int rs_putDebugChar(char c)
+{
+
+	if (!kdb_port_info.state) { 	/* need to init device first */
+		return 0;
+	}
+
+	while ((serial_in(&kdb_port_info, UART_LSR) & UART_LSR_THRE) == 0)
+		;
+
+	serial_out(&kdb_port_info, UART_TX, c);
+
+	return 1;
+}
+
+char rs_getDebugChar(void)
+{
+	if (!kdb_port_info.state) { 	/* need to init device first */
+		return 0;
+	}
+
+	while (!(serial_in(&kdb_port_info, UART_LSR) & 1))
+		;
+
+	return(serial_in(&kdb_port_info, UART_RX));
+}
+
+
+#ifdef CONFIG_MIPS_ATLAS
+
+#include <asm/mips-boards/atlas.h>
+#include <asm/mips-boards/saa9730_uart.h>
+
+#define INB(a)     inb((unsigned long)a)
+#define OUTB(x,a)  outb(x,(unsigned long)a)
+
+/*
+ * This is the interface to the remote debugger stub
+ * if the Philips part is used for the debug port,
+ * called from the platform setup code.
+ *
+ * PCI init will not have been done yet, we make a
+ * universal assumption about the way the bootloader (YAMON)
+ * have located and set up the chip.
+ */
+static t_uart_saa9730_regmap *kgdb_uart = (void *)(ATLAS_SAA9730_REG + SAA9730_UART_REGS_ADDR);
+
+static int saa9730_kgdb_active = 0;
+
+void saa9730_kgdb_hook(void) 
+{
+        volatile unsigned char t;
+
+        /*
+         * Clear all interrupts
+         */
+	t = INB(&kgdb_uart->Lsr);
+	t += INB(&kgdb_uart->Msr);
+	t += INB(&kgdb_uart->Thr_Rbr);
+	t += INB(&kgdb_uart->Iir_Fcr);
+
+        /*
+         * Now, initialize the UART
+         */
+	/* 8 data bits, one stop bit, no parity */
+	OUTB(SAA9730_LCR_DATA8, &kgdb_uart->Lcr);
+
+        /* baud rate is fixed to 9600 (is this sufficient?)*/
+	OUTB(0, &kgdb_uart->BaudDivMsb); /* HACK - Assumes standard crystal */
+	OUTB(23, &kgdb_uart->BaudDivLsb); /* HACK - known for MIPS Atlas */
+
+	/* Set RTS/DTR active */
+	OUTB(SAA9730_MCR_DTR | SAA9730_MCR_RTS, &kgdb_uart->Mcr);
+	saa9730_kgdb_active = 1;
+}
+
+int saa9730_putDebugChar(char c)
+{
+
+        if (!saa9730_kgdb_active) {     /* need to init device first */
+                return 0;
+        }
+
+        while (!(INB(&kgdb_uart->Lsr) & SAA9730_LSR_THRE))
+                ;
+	OUTB(c, &kgdb_uart->Thr_Rbr);
+
+        return 1;
+}
+
+char saa9730_getDebugChar(void)
+{
+	char c;
+
+        if (!saa9730_kgdb_active) {     /* need to init device first */
+                return 0;
+        }
+        while (!(INB(&kgdb_uart->Lsr) & SAA9730_LSR_DR))
+                ;
+
+	c = INB(&kgdb_uart->Thr_Rbr);
+        return(c);
+}
+
+#endif
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mips-boards/generic/init.c linux/arch/mips64/mips-boards/generic/init.c
--- v2.4.9/linux/arch/mips64/mips-boards/generic/init.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/mips-boards/generic/init.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,152 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ * ########################################################################
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * ########################################################################
+ *
+ * PROM library initialisation code.
+ */
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+
+#include <asm/io.h>
+#include <asm/mips-boards/prom.h>
+#include <asm/mips-boards/generic.h>
+#include <asm/mips-boards/gt64120.h>
+#include <asm/mips-boards/malta.h>
+
+/* Environment variable */
+typedef struct
+{
+    char *name;
+    char *val;
+}t_env_var;
+
+int prom_argc;
+int *_prom_argv, *_prom_envp;
+
+/*
+ * A 32-bit PROM pass arguments and environment as 32-bit pointer.
+ * This macro take care of sign extension.
+ */
+#define prom_envp(index) ((char *)(((int *)(int)_prom_envp)[(index)]))
+
+int init_debug = 0;
+
+char *prom_getenv(char *envname)
+{
+        /*
+	 * Return a pointer to the given environment variable.
+	 * We're using 64-bit pointers, but all pointers in the PROM 
+	 * structures are only 32-bit, so we need some workarounds.
+	 */
+	int i, index=0;
+
+	i = strlen(envname);
+
+	while(prom_envp(index)) {
+		if(strncmp(envname, prom_envp(index), i) == 0) {
+			return(prom_envp(index+1));
+		}
+		index += 2;
+	}
+
+	return(NULL);
+}
+
+static inline unsigned char str2hexnum(unsigned char c)
+{
+	if(c >= '0' && c <= '9')
+		return c - '0';
+	if(c >= 'a' && c <= 'f')
+		return c - 'a' + 10;
+	return 0; /* foo */
+}
+
+static inline void str2eaddr(unsigned char *ea, unsigned char *str)
+{
+	int i;
+
+	for(i = 0; i < 6; i++) {
+		unsigned char num;
+
+		if((*str == '.') || (*str == ':'))
+			str++;
+		num = str2hexnum(*str++) << 4;
+		num |= (str2hexnum(*str++));
+		ea[i] = num;
+	}
+}
+ 
+int get_ethernet_addr(char *ethernet_addr)
+{
+        char *ethaddr_str;
+
+        ethaddr_str = prom_getenv("ethaddr");
+	if (!ethaddr_str) {
+	        printk("ethaddr not set in boot prom\n");
+		return -1;
+	}
+	str2eaddr(ethernet_addr, ethaddr_str);
+
+	if (init_debug > 1)
+	{
+	        int i;
+		printk("get_ethernet_addr: ");
+	        for (i=0; i<5; i++)
+		        printk("%02x:", (unsigned char)*(ethernet_addr+i));
+		printk("%02x\n", *(ethernet_addr+i));
+	}
+
+	return 0;
+}
+
+int __init prom_init(int argc, char **argv, char **envp)
+{
+	prom_argc = argc;
+	_prom_argv = (int *)argv;
+	_prom_envp = (int *)envp;
+
+	mips_display_message("LINUX");
+
+	/*
+	 * Setup the North bridge to do Master byte-lane swapping when 
+	 * running in bigendian.
+	 */
+#if defined(__MIPSEL__)
+	GT_WRITE(GT_PCI0_CMD_OFS, GT_PCI0_CMD_MBYTESWAP_BIT |
+		 GT_PCI0_CMD_SBYTESWAP_BIT);
+#else
+	GT_WRITE(GT_PCI0_CMD_OFS, 0);
+#endif
+
+#if defined(CONFIG_MIPS_MALTA)
+	mips_io_port_base = MALTA_PORT_BASE;
+#else
+	mips_io_port_base = KSEG1;
+#endif
+
+	setup_prom_printf(0);
+	prom_printf("\nLINUX started...\n");
+	prom_init_cmdline();
+	prom_meminit();
+
+	return 0;
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mips-boards/generic/memory.c linux/arch/mips64/mips-boards/generic/memory.c
--- v2.4.9/linux/arch/mips64/mips-boards/generic/memory.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/mips-boards/generic/memory.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,263 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ * ########################################################################
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * ########################################################################
+ *
+ * PROM library functions for acquiring/using memory descriptors given to 
+ * us from the YAMON.
+ * 
+ */
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/bootmem.h>
+
+#include <asm/bootinfo.h>
+#include <asm/page.h>
+
+#include <asm/mips-boards/prom.h>
+
+/*#define DEBUG*/
+
+enum yamon_memtypes {
+	yamon_dontuse,
+	yamon_prom,
+	yamon_free,
+};
+struct prom_pmemblock mdesc[PROM_MAX_PMEMBLOCKS];
+
+#define MEMTYPE_DONTUSE 0
+#define MEMTYPE_PROM    1
+#define MEMTYPE_FREE    2
+
+#ifdef DEBUG
+static char *mtypes[3] = {
+	"Dont use memory",
+	"YAMON PROM memory",
+	"Free memmory",
+};
+#endif
+
+/* References to section boundaries */
+extern char _end;
+
+#define PFN_ALIGN(x)    (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
+
+struct prom_pmemblock * __init prom_getmdesc(void)
+{
+	char *memsize_str;
+	unsigned int memsize;
+
+	memsize_str = prom_getenv("memsize");
+	if (!memsize_str) {
+		prom_printf("memsize not set in boot prom, set to default (32Mb)\n");
+		memsize = 0x02000000;
+	} else {
+#ifdef DEBUG
+		prom_printf("prom_memsize = %s\n", memsize_str);
+#endif
+		memsize = simple_strtol(memsize_str, NULL, 0);
+	}
+
+	memset(mdesc, 0, sizeof(mdesc));
+
+	mdesc[0].type = yamon_dontuse;
+	mdesc[0].base = 0x00000000;
+	mdesc[0].size = 0x00001000;
+
+	mdesc[1].type = yamon_prom;
+	mdesc[1].base = 0x00001000;
+	mdesc[1].size = 0x000ef000;
+
+#if (CONFIG_MIPS_MALTA)
+	/* 
+	 * The area 0x000f0000-0x000fffff is allocated for BIOS memory by the
+	 * south bridge and PCI access always forwarded to the ISA Bus and 
+	 * BIOSCS# is always generated.
+	 * This mean that this area can't be used as DMA memory for PCI 
+	 * devices.
+	 */
+	mdesc[2].type = yamon_dontuse;
+	mdesc[2].base = 0x000f0000;
+	mdesc[2].size = 0x00010000;
+#else
+	mdesc[2].type = yamon_prom;
+	mdesc[2].base = 0x000f0000;
+	mdesc[2].size = 0x00010000;
+#endif
+
+	mdesc[3].type = yamon_dontuse;
+	mdesc[3].base = 0x00100000;
+	mdesc[3].size = CPHYSADDR(PFN_ALIGN(&_end)) - mdesc[3].base;
+
+	mdesc[4].type = yamon_free;
+	mdesc[4].base = CPHYSADDR(PFN_ALIGN(&_end));
+	mdesc[4].size = memsize - mdesc[4].base;
+
+	return &mdesc[0];
+}
+
+int __init page_is_ram(unsigned long pagenr)
+{
+	if ((pagenr << PAGE_SHIFT) < mdesc[4].base + mdesc[4].size)
+		return 1;
+
+	return 0;
+}
+
+static struct prom_pmemblock pblocks[PROM_MAX_PMEMBLOCKS];
+
+static int __init prom_memtype_classify (unsigned int type)
+{
+	switch (type) {
+	case yamon_free:
+		return MEMTYPE_FREE;
+	case yamon_prom:
+		return MEMTYPE_PROM;
+	default:
+		return MEMTYPE_DONTUSE;
+	}
+}
+
+static inline unsigned long find_max_low_pfn(void)
+{
+	struct prom_pmemblock *p, *highest;
+	unsigned long pfn;
+
+	p = pblocks;
+	highest = 0;
+	while (p->size != 0) {
+		if (!highest || p->base > highest->base)
+			highest = p;
+		p++;
+        }
+
+	pfn = (highest->base + highest->size) >> PAGE_SHIFT;
+#ifdef DEBUG
+	prom_printf("find_max_low_pfn: 0x%lx pfns.\n", pfn);
+#endif
+	return pfn;
+}
+
+static inline struct prom_pmemblock *find_largest_memblock(void)
+{
+	struct prom_pmemblock *p, *largest;
+
+	p = pblocks;
+	largest = 0;
+	while (p->size != 0) {
+		if (!largest || p->size > largest->size)
+			largest = p;
+		p++;
+	}
+
+	return largest;
+}
+
+void __init prom_meminit(void)
+{
+	struct prom_pmemblock *largest, *p;
+	unsigned long bootmap_size;
+	int totram;
+	int i = 0;
+
+#ifdef DEBUG
+	prom_printf("YAMON MEMORY DESCRIPTOR dump:\n");
+	p = prom_getmdesc();
+	while (p->size) {
+		prom_printf("[%d,%p]: base<%08lx> size<%08lx> type<%s>\n",
+			    i, p, p->base, p->size, mtypes[p->type]);
+		p++;
+		i++;
+	}
+#endif
+	totram = 0;
+	i = 0;
+	p = prom_getmdesc();
+
+	while (p->size) {
+		pblocks[i].type = prom_memtype_classify (p->type);
+		pblocks[i].base = p->base;
+		pblocks[i].size = p->size;
+		switch (pblocks[i].type) {
+		case MEMTYPE_FREE:
+			totram += pblocks[i].size;
+#ifdef DEBUG
+			prom_printf("free_chunk[%d]: base=%08lx size=%d\n",
+				    i, pblocks[i].base, pblocks[i].size);
+#endif
+			i++;
+			break;
+		case MEMTYPE_PROM:
+#ifdef DEBUG
+		        prom_printf("prom_chunk[%d]: base=%08lx size=%d\n",
+				    i, pblocks[i].base, pblocks[i].size);
+#endif
+			i++;
+			break;
+		default:
+			break;
+		}
+		p++;
+	}
+	pblocks[i].base = 0xdeadbeef;
+	pblocks[i].size = 0; /* indicates last elem. of array */
+
+	max_low_pfn = find_max_low_pfn();
+	largest = find_largest_memblock();
+	bootmap_size = init_bootmem(largest->base >> PAGE_SHIFT, max_low_pfn);
+
+	for (i = 0; pblocks[i].size; i++)
+		if (pblocks[i].type == MEMTYPE_FREE)
+			free_bootmem(pblocks[i].base, pblocks[i].size);
+
+	/* This test is simpleminded.  It will fail if the bootmem bitmap
+	   falls into multiple adjacent PROM memory areas.  */
+	if (bootmap_size > largest->size) {
+		prom_printf("CRITIAL: overwriting PROM data.\n");
+		BUG();
+	}
+
+	/* Reserve the memory bootmap itself */
+	reserve_bootmem(largest->base, bootmap_size);
+	printk("PROMLIB: Total free ram %d bytes (%dK,%dMB)\n",
+	       totram, (totram/1024), (totram/1024/1024));
+}
+
+void prom_free_prom_memory (void)
+{
+	struct prom_pmemblock *p;
+	unsigned long freed = 0;
+	unsigned long addr;
+
+	for (p = pblocks; p->size != 0; p++) {
+		if (p->type != MEMTYPE_PROM)
+			continue;
+
+		addr = p->base;
+		while (addr < p->base + p->size) {
+		        ClearPageReserved(virt_to_page(__va(addr)));
+			set_page_count(virt_to_page(__va(addr)), 1);
+			free_page(__va(addr));
+			addr += PAGE_SIZE;
+			freed += PAGE_SIZE;
+		}
+	}
+	printk("Freeing prom memory: %ldkb freed\n", freed >> 10);
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mips-boards/generic/mipsIRQ.S linux/arch/mips64/mips-boards/generic/mipsIRQ.S
--- v2.4.9/linux/arch/mips64/mips-boards/generic/mipsIRQ.S	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/mips-boards/generic/mipsIRQ.S	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,122 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ * ########################################################################
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * ########################################################################
+ *
+ * Interrupt exception dispatch code.
+ *
+ */
+#include <linux/config.h>
+
+#include <asm/asm.h>
+#include <asm/mipsregs.h>
+#include <asm/regdef.h>
+#include <asm/stackframe.h>
+
+/* A lot of complication here is taken away because:
+ *
+ * 1) We handle one interrupt and return, sitting in a loop and moving across
+ *    all the pending IRQ bits in the cause register is _NOT_ the answer, the
+ *    common case is one pending IRQ so optimize in that direction.
+ *
+ * 2) We need not check against bits in the status register IRQ mask, that
+ *    would make this routine slow as hell.
+ *
+ * 3) Linux only thinks in terms of all IRQs on or all IRQs off, nothing in
+ *    between like BSD spl() brain-damage.
+ *
+ * Furthermore, the IRQs on the MIPS board look basically (barring software
+ * IRQs which we don't use at all and all external interrupt sources are
+ * combined together on hardware interrupt 0 (MIPS IRQ 2)) like:
+ *
+ *	MIPS IRQ	Source
+ *      --------        ------
+ *             0	Software (ignored)
+ *             1        Software (ignored)
+ *             2        Combined hardware interrupt (hw0)
+ *             3        Hardware (ignored)
+ *             4        Hardware (ignored)
+ *             5        Hardware (ignored)
+ *             6        Hardware (ignored)
+ *             7        R4k timer (what we use)
+ *
+ * We handle the IRQ according to _our_ priority which is:
+ *
+ * Highest ----     R4k Timer
+ * Lowest  ----     Combined hardware interrupt
+ *
+ * then we just return, if multiple IRQs are pending then we will just take
+ * another exception, big deal.
+ */
+
+	.text
+	.set	noreorder
+	.set	noat
+	.align	5
+	NESTED(mipsIRQ, PT_SIZE, sp)
+	SAVE_ALL
+	CLI
+	.set	at
+
+	mfc0	s0, CP0_CAUSE		# get irq mask
+
+	/* First we check for r4k counter/timer IRQ. */
+	andi	a0, s0, CAUSEF_IP7
+	beq	a0, zero, 1f
+	 andi	a0, s0, CAUSEF_IP2	# delay slot, check hw0 interrupt
+
+	/* Wheee, a timer interrupt. */
+	move	a0, sp
+	jal	mips_timer_interrupt
+	 nop
+
+	j	ret_from_irq
+	 nop
+
+1:
+	beq	a0, zero, 1f
+	 nop
+
+	/* Wheee, combined hardware level zero interrupt. */
+#if defined(CONFIG_MIPS_ATLAS)
+	jal	atlas_hw0_irqdispatch
+#elif defined(CONFIG_MIPS_MALTA)
+	jal	malta_hw0_irqdispatch
+#else
+#error "MIPS board not supported\n"	
+#endif
+	 move	a0, sp			# delay slot
+
+	j	ret_from_irq
+	 nop				# delay slot
+
+1:
+	/*
+	 * Here by mistake?  This is possible, what can happen is that by the
+	 * time we take the exception the IRQ pin goes low, so just leave if
+	 * this is the case.
+	 */
+	move	a1,s0
+	PRINT("Got interrupt: c0_cause = %08x\n")
+	mfc0	a1, CP0_EPC
+	PRINT("c0_epc = %08x\n")
+
+	j	ret_from_irq
+	 nop
+	END(mipsIRQ)
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mips-boards/generic/pci.c linux/arch/mips64/mips-boards/generic/pci.c
--- v2.4.9/linux/arch/mips64/mips-boards/generic/pci.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/mips-boards/generic/pci.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,337 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ * ########################################################################
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * ########################################################################
+ *
+ * MIPS boards specific PCI support.
+ *
+ */
+#include <linux/config.h>
+
+#ifdef CONFIG_PCI
+
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+
+#include <asm/mips-boards/generic.h>
+#include <asm/mips-boards/gt64120.h>
+#ifdef CONFIG_MIPS_MALTA
+#include <asm/mips-boards/malta.h>
+#endif
+
+#define PCI_ACCESS_READ  0
+#define PCI_ACCESS_WRITE 1
+
+static int
+mips_pcibios_config_access(unsigned char access_type, struct pci_dev *dev,
+                           unsigned char where, u32 *data)
+{
+	unsigned char bus = dev->bus->number;
+	unsigned char dev_fn = dev->devfn;
+        u32 intr;
+
+	if ((bus == 0) && (dev_fn >= PCI_DEVFN(31,0)))
+	        return -1; /* Because of a bug in the galileo (for slot 31). */
+
+	/* Clear cause register bits */
+	GT_WRITE(GT_INTRCAUSE_OFS, ~(GT_INTRCAUSE_MASABORT0_BIT | 
+	                             GT_INTRCAUSE_TARABORT0_BIT));
+
+	/* Setup address */
+	GT_WRITE(GT_PCI0_CFGADDR_OFS, 
+		 (bus         << GT_PCI0_CFGADDR_BUSNUM_SHF)   |
+		 (dev_fn      << GT_PCI0_CFGADDR_FUNCTNUM_SHF) |
+		 ((where / 4) << GT_PCI0_CFGADDR_REGNUM_SHF)   |
+		 GT_PCI0_CFGADDR_CONFIGEN_BIT);
+
+	if (access_type == PCI_ACCESS_WRITE) {
+	        if (bus == 0 && dev_fn == 0) {
+		        /* 
+			 * Galileo is acting differently than other devices. 
+			 */
+		        GT_WRITE(GT_PCI0_CFGDATA_OFS, *data);
+		} else {
+		        GT_PCI_WRITE(GT_PCI0_CFGDATA_OFS, *data);
+		}
+	} else {
+	        if (bus == 0 && dev_fn == 0) {
+		        /* 
+			 * Galileo is acting differently than other devices. 
+			 */
+		        GT_READ(GT_PCI0_CFGDATA_OFS, *data);
+		} else {
+		        GT_PCI_READ(GT_PCI0_CFGDATA_OFS, *data);
+		}
+	}
+
+	/* Check for master or target abort */
+	GT_READ(GT_INTRCAUSE_OFS, intr);
+
+	if (intr & (GT_INTRCAUSE_MASABORT0_BIT | GT_INTRCAUSE_TARABORT0_BIT))
+	{
+	        /* Error occured */
+
+	        /* Clear bits */
+	        GT_WRITE( GT_INTRCAUSE_OFS, ~(GT_INTRCAUSE_MASABORT0_BIT | 
+					      GT_INTRCAUSE_TARABORT0_BIT) );
+
+		return -1;
+	}
+
+	return 0;
+}
+
+
+/*
+ * We can't address 8 and 16 bit words directly.  Instead we have to
+ * read/write a 32bit word and mask/modify the data we actually want.
+ */
+static int
+mips_pcibios_read_config_byte (struct pci_dev *dev, int where, u8 *val)
+{
+	u32 data = 0;
+
+	if (mips_pcibios_config_access(PCI_ACCESS_READ, dev, where, &data))
+		return -1;
+
+	*val = (data >> ((where & 3) << 3)) & 0xff;
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+
+static int
+mips_pcibios_read_config_word (struct pci_dev *dev, int where, u16 *val)
+{
+	u32 data = 0;
+
+	if (where & 1)
+		return PCIBIOS_BAD_REGISTER_NUMBER;
+
+	if (mips_pcibios_config_access(PCI_ACCESS_READ, dev, where, &data))
+	       return -1;
+
+	*val = (data >> ((where & 3) << 3)) & 0xffff;
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int
+mips_pcibios_read_config_dword (struct pci_dev *dev, int where, u32 *val)
+{
+	u32 data = 0;
+
+	if (where & 3)
+		return PCIBIOS_BAD_REGISTER_NUMBER;
+	
+	if (mips_pcibios_config_access(PCI_ACCESS_READ, dev, where, &data))
+		return -1;
+
+	*val = data;
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+
+static int
+mips_pcibios_write_config_byte (struct pci_dev *dev, int where, u8 val)
+{
+	u32 data = 0;
+       
+	if (mips_pcibios_config_access(PCI_ACCESS_READ, dev, where, &data))
+		return -1;
+
+	data = (data & ~(0xff << ((where & 3) << 3))) |
+	       (val << ((where & 3) << 3));
+
+	if (mips_pcibios_config_access(PCI_ACCESS_WRITE, dev, where, &data))
+		return -1;
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int
+mips_pcibios_write_config_word (struct pci_dev *dev, int where, u16 val)
+{
+        u32 data = 0;
+
+	if (where & 1)
+		return PCIBIOS_BAD_REGISTER_NUMBER;
+       
+        if (mips_pcibios_config_access(PCI_ACCESS_READ, dev, where, &data))
+	       return -1;
+
+	data = (data & ~(0xffff << ((where & 3) << 3))) | 
+	       (val << ((where & 3) << 3));
+
+	if (mips_pcibios_config_access(PCI_ACCESS_WRITE, dev, where, &data))
+	       return -1;
+
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int
+mips_pcibios_write_config_dword(struct pci_dev *dev, int where, u32 val)
+{
+	if (where & 3)
+		return PCIBIOS_BAD_REGISTER_NUMBER;
+
+	if (mips_pcibios_config_access(PCI_ACCESS_WRITE, dev, where, &val))
+	       return -1;
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+struct pci_ops mips_pci_ops = {
+	mips_pcibios_read_config_byte,
+        mips_pcibios_read_config_word,
+	mips_pcibios_read_config_dword,
+	mips_pcibios_write_config_byte,
+	mips_pcibios_write_config_word,
+	mips_pcibios_write_config_dword
+};
+
+void __init pcibios_init(void)
+{
+#ifdef CONFIG_MIPS_MALTA
+	struct pci_dev *pdev;
+	unsigned char reg_val;
+#endif
+
+	printk("PCI: Probing PCI hardware on host bus 0.\n");
+	pci_scan_bus(0, &mips_pci_ops, NULL);
+
+	/* 
+	 * Due to a bug in the Galileo system controller, we need to setup 
+	 * the PCI BAR for the Galileo internal registers.
+	 * This should be done in the bios/bootprom and will be fixed in
+	 * a later revision of YAMON (the MIPS boards boot prom).
+	 */
+	GT_WRITE(GT_PCI0_CFGADDR_OFS,
+		 (0 << GT_PCI0_CFGADDR_BUSNUM_SHF)   |  /* Local bus */
+		 (0 << GT_PCI0_CFGADDR_DEVNUM_SHF)   |  /* GT64120 device */
+		 (0 << GT_PCI0_CFGADDR_FUNCTNUM_SHF) |  /* Function 0 */
+		 ((0x20/4) << GT_PCI0_CFGADDR_REGNUM_SHF) |  /* BAR 4 */
+		 GT_PCI0_CFGADDR_CONFIGEN_BIT );
+
+	/* Perform the write */
+	GT_WRITE( GT_PCI0_CFGDATA_OFS, CPHYSADDR(MIPS_GT_BASE)); 
+
+#ifdef CONFIG_MIPS_MALTA
+	pci_for_each_dev(pdev) {
+		if ((pdev->vendor == PCI_VENDOR_ID_INTEL)
+		    && (pdev->device == PCI_DEVICE_ID_INTEL_82371AB)
+		    && (PCI_SLOT(pdev->devfn) == 0x0a)) {
+			/*
+			 * IDE Decode enable.
+			 */
+			pci_read_config_byte(pdev, 0x41, &reg_val);
+        		pci_write_config_byte(pdev, 0x41, reg_val | 0x80);
+			pci_read_config_byte(pdev, 0x43, &reg_val);
+        		pci_write_config_byte(pdev, 0x43, reg_val | 0x80);
+		}
+
+		if ((pdev->vendor == PCI_VENDOR_ID_INTEL)
+		    && (pdev->device == PCI_DEVICE_ID_INTEL_82371AB_0)
+		    && (PCI_SLOT(pdev->devfn) == 0x0a)) {
+			/*
+			 * Set top of main memory accessible by ISA or DMA
+			 * devices to 16 Mb.
+			 */
+			pci_read_config_byte(pdev, 0x69, &reg_val);
+			pci_write_config_byte(pdev, 0x69, reg_val | 0xf0);
+		}
+	}
+
+	/* 
+	 * Activate Floppy Controller in the SMSC FDC37M817 Super I/O 
+	 * Controller.
+	 * This should be done in the bios/bootprom and will be fixed in
+         * a later revision of YAMON (the MIPS boards boot prom).
+	 */
+	/* Entering config state. */
+	SMSC_WRITE(SMSC_CONFIG_ENTER, SMSC_CONFIG_REG); 
+       
+	/* Activate floppy controller. */
+	SMSC_WRITE(SMSC_CONFIG_DEVNUM, SMSC_CONFIG_REG);
+	SMSC_WRITE(SMSC_CONFIG_DEVNUM_FLOPPY, SMSC_DATA_REG);
+	SMSC_WRITE(SMSC_CONFIG_ACTIVATE, SMSC_CONFIG_REG);
+	SMSC_WRITE(SMSC_CONFIG_ACTIVATE_ENABLE, SMSC_DATA_REG);
+
+	/* Exit config state. */
+	SMSC_WRITE(SMSC_CONFIG_EXIT, SMSC_CONFIG_REG);
+#endif
+}
+
+int __init
+pcibios_enable_device(struct pci_dev *dev)
+{
+	/* Not needed, since we enable all devices at startup.  */
+	return 0;
+}
+
+void __init
+pcibios_align_resource(void *data, struct resource *res, unsigned long size)
+{
+}
+
+char * __init
+pcibios_setup(char *str)
+{
+	/* Nothing to do for now.  */
+
+	return str;
+}
+
+struct pci_fixup pcibios_fixups[] = {
+	{ 0 }
+};
+
+void __init
+pcibios_update_resource(struct pci_dev *dev, struct resource *root,
+                        struct resource *res, int resource)
+{
+	unsigned long where, size;
+	u32 reg;
+
+	where = PCI_BASE_ADDRESS_0 + (resource * 4);
+	size = res->end - res->start;
+	pci_read_config_dword(dev, where, &reg);
+	reg = (reg & size) | (((u32)(res->start - root->start)) & ~size);
+	pci_write_config_dword(dev, where, reg);
+}
+
+unsigned __init int pcibios_assign_all_busses(void)
+{
+	return 1;
+}
+
+/*
+ *  Called after each bus is probed, but before its children
+ *  are examined.
+ */
+void __init pcibios_fixup_bus(struct pci_bus *b)
+{
+	pci_read_bridge_bases(b);
+}
+
+#endif /* CONFIG_PCI */
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mips-boards/generic/printf.c linux/arch/mips64/mips-boards/generic/printf.c
--- v2.4.9/linux/arch/mips64/mips-boards/generic/printf.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/mips-boards/generic/printf.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,140 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ * ########################################################################
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * ########################################################################
+ *
+ * Putting things on the screen/serial line using YAMONs facilities.
+ *
+ */
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/serialP.h>
+#include <linux/serial_reg.h>
+#include <asm/system.h>
+#include <asm/io.h>
+#include <asm/serial.h>
+
+
+#ifdef CONFIG_MIPS_ATLAS 
+/* 
+ * Atlas registers are memory mapped on 64-bit aligned boundaries and 
+ * only word access are allowed.
+ * When reading the UART 8 bit registers only the LSB are valid.
+ */
+unsigned int atlas_serial_in(struct async_struct *info, int offset)
+{
+	return (*(volatile unsigned int *)(info->port + mips_io_port_base + offset*8) & 0xff);
+}
+
+void atlas_serial_out(struct async_struct *info, int offset, int value)
+{
+	*(volatile unsigned int *)(info->port + mips_io_port_base + offset*8) = value;
+}
+
+#define serial_in  atlas_serial_in
+#define serial_out atlas_serial_out
+
+#else
+
+static unsigned int serial_in(struct async_struct *info, int offset)
+{
+	return inb(info->port + offset);
+}
+
+static void serial_out(struct async_struct *info, int offset,
+				int value)
+{
+	outb(value, info->port + offset);
+}
+#endif
+
+static struct serial_state rs_table[] = {
+	SERIAL_PORT_DFNS	/* Defined in serial.h */
+};
+
+/*
+ * Hooks to fake "prom" console I/O before devices 
+ * are fully initialized. 
+ */
+static struct async_struct prom_port_info = {0};
+
+void __init setup_prom_printf(int tty_no) {
+	struct serial_state *ser = &rs_table[tty_no];
+
+	prom_port_info.state = ser;
+	prom_port_info.magic = SERIAL_MAGIC;
+	prom_port_info.port = ser->port;
+	prom_port_info.flags = ser->flags;
+
+	/* No setup of UART - assume YAMON left in sane state */
+}
+
+int putPromChar(char c)
+{
+        if (!prom_port_info.state) { 	/* need to init device first */
+		return 0;
+	}
+
+	while ((serial_in(&prom_port_info, UART_LSR) & UART_LSR_THRE) == 0)
+		;
+
+	serial_out(&prom_port_info, UART_TX, c);
+
+	return 1;
+}
+
+char getPromChar(void)
+{
+	if (!prom_port_info.state) { 	/* need to init device first */
+		return 0;
+	}
+
+	while (!(serial_in(&prom_port_info, UART_LSR) & 1))
+		;
+
+	return(serial_in(&prom_port_info, UART_RX));
+}
+
+static char buf[1024];
+
+void __init prom_printf(char *fmt, ...)
+{
+	va_list args;
+	int l;
+	char *p, *buf_end;
+	long flags;
+
+	int putPromChar(char);
+
+	/* Low level, brute force, not SMP safe... */
+	save_and_cli(flags);
+	va_start(args, fmt);
+	l = vsprintf(buf, fmt, args); /* hopefully i < sizeof(buf) */
+	va_end(args);
+
+	buf_end = buf + l;
+
+	for (p = buf; p < buf_end; p++) {
+		/* Crude cr/nl handling is better than none */
+		if(*p == '\n')putPromChar('\r');
+		putPromChar(*p);
+	}
+	restore_flags(flags);
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mips-boards/generic/reset.c linux/arch/mips64/mips-boards/generic/reset.c
--- v2.4.9/linux/arch/mips64/mips-boards/generic/reset.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/mips-boards/generic/reset.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,61 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ * ########################################################################
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * ########################################################################
+ *
+ * Reset the MIPS boards.
+ *
+ */
+#include <linux/config.h>
+
+#include <asm/mips-boards/generic.h>
+#if defined(CONFIG_MIPS_ATLAS)
+#include <asm/mips-boards/atlas.h>
+#endif
+
+void machine_restart(char *command) __attribute__((noreturn));
+void machine_halt(void) __attribute__((noreturn));
+#if defined(CONFIG_MIPS_ATLAS)
+void machine_power_off(void) __attribute__((noreturn));
+#endif
+
+void machine_restart(char *command)
+{
+        volatile unsigned int *softres_reg = (void *)SOFTRES_REG;
+
+	*softres_reg = GORESET;
+}
+
+void machine_halt(void)
+{
+        volatile unsigned int *softres_reg = (void *)SOFTRES_REG;
+
+	*softres_reg = GORESET;
+}
+
+void machine_power_off(void)
+{
+#if defined(CONFIG_MIPS_ATLAS)
+        volatile unsigned int *psustby_reg = (void *)ATLAS_PSUSTBY_REG;
+
+	*psustby_reg = ATLAS_GOSTBY;
+#else
+	machine_halt();
+#endif
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mips-boards/generic/time.c linux/arch/mips64/mips-boards/generic/time.c
--- v2.4.9/linux/arch/mips64/mips-boards/generic/time.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/mips-boards/generic/time.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,399 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ * ########################################################################
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * ########################################################################
+ *
+ * Setting up the clock on the MIPS boards.
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/kernel_stat.h>
+#include <linux/sched.h>
+#include <linux/spinlock.h>
+
+#include <asm/mipsregs.h>
+#include <asm/ptrace.h>
+
+#include <linux/mc146818rtc.h>
+#include <linux/timex.h>
+
+#include <asm/mips-boards/generic.h>
+#include <asm/mips-boards/prom.h>
+
+extern volatile unsigned long wall_jiffies;
+static long last_rtc_update = 0;
+unsigned long missed_heart_beats = 0;
+
+static unsigned long r4k_offset; /* Amount to increment compare reg each time */
+static unsigned long r4k_cur;    /* What counter should be at next timer irq */
+extern rwlock_t xtime_lock;
+
+#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
+
+#if defined(CONFIG_MIPS_ATLAS)
+static char display_string[] = "        LINUX ON ATLAS       ";
+#endif
+#if defined(CONFIG_MIPS_MALTA)
+static char display_string[] = "        LINUX ON MALTA       ";
+#endif
+static unsigned int display_count = 0;
+#define MAX_DISPLAY_COUNT (sizeof(display_string) - 8) 
+
+static unsigned int timer_tick_count=0;
+
+
+static inline void ack_r4ktimer(unsigned long newval)
+{
+	write_32bit_cp0_register(CP0_COMPARE, newval);
+}
+
+
+/*
+ * In order to set the CMOS clock precisely, set_rtc_mmss has to be
+ * called 500 ms after the second nowtime has started, because when
+ * nowtime is written into the registers of the CMOS clock, it will
+ * jump to the next second precisely 500 ms later. Check the Motorola
+ * MC146818A or Dallas DS12887 data sheet for details.
+ *
+ * BUG: This routine does not handle hour overflow properly; it just
+ *      sets the minutes. Usually you won't notice until after reboot!
+ */
+static int set_rtc_mmss(unsigned long nowtime)
+{
+	int retval = 0;
+	int real_seconds, real_minutes, cmos_minutes;
+	unsigned char save_control, save_freq_select;
+
+	save_control = CMOS_READ(RTC_CONTROL); /* tell the clock it's being set */
+	CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
+
+	save_freq_select = CMOS_READ(RTC_FREQ_SELECT); /* stop and reset prescaler */
+	CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
+
+	cmos_minutes = CMOS_READ(RTC_MINUTES);
+
+	/*
+	 * since we're only adjusting minutes and seconds,
+	 * don't interfere with hour overflow. This avoids
+	 * messing with unknown time zones but requires your
+	 * RTC not to be off by more than 15 minutes
+	 */
+	real_seconds = nowtime % 60;
+	real_minutes = nowtime / 60;
+	if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1)
+		real_minutes += 30;		/* correct for half hour time zone */
+	real_minutes %= 60;
+
+	if (abs(real_minutes - cmos_minutes) < 30) {
+		CMOS_WRITE(real_seconds,RTC_SECONDS);
+		CMOS_WRITE(real_minutes,RTC_MINUTES);
+	} else {
+		printk(KERN_WARNING
+		       "set_rtc_mmss: can't update from %d to %d\n",
+		       cmos_minutes, real_minutes);
+ 		retval = -1;
+	}
+
+	/* The following flags have to be released exactly in this order,
+	 * otherwise the DS12887 (popular MC146818A clone with integrated
+	 * battery and quartz) will not reset the oscillator and will not
+	 * update precisely 500 ms later. You won't find this mentioned in
+	 * the Dallas Semiconductor data sheets, but who believes data
+	 * sheets anyway ...                           -- Markus Kuhn
+	 */
+	CMOS_WRITE(save_control, RTC_CONTROL);
+	CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
+
+	return retval;
+}
+
+/*
+ * There are a lot of conceptually broken versions of the MIPS timer interrupt
+ * handler floating around.  This one is rather different, but the algorithm
+ * is provably more robust.
+ */
+void mips_timer_interrupt(struct pt_regs *regs)
+{
+	int irq = 7;
+
+	if (r4k_offset == 0)
+		goto null;
+
+	do {
+		kstat.irqs[0][irq]++;
+		do_timer(regs);
+
+		/* Historical comment/code:
+ 		 * RTC time of day s updated approx. every 11 
+ 		 * minutes.  Because of how the numbers work out 
+ 		 * we need to make absolutely sure we do this update
+ 		 * within 500ms before the * next second starts, 
+ 		 * thus the following code.
+ 		 */
+		read_lock(&xtime_lock);
+		if ((time_status & STA_UNSYNC) == 0 
+		    && xtime.tv_sec > last_rtc_update + 660 
+		    && xtime.tv_usec >= 500000 - (tick >> 1) 
+		    && xtime.tv_usec <= 500000 + (tick >> 1))
+			if (set_rtc_mmss(xtime.tv_sec) == 0)
+				last_rtc_update = xtime.tv_sec;
+			else
+				/* do it again in 60 s */
+	    			last_rtc_update = xtime.tv_sec - 600; 
+		read_unlock(&xtime_lock);
+
+		if ((timer_tick_count++ % HZ) == 0) {
+		    mips_display_message(&display_string[display_count++]);
+		    if (display_count == MAX_DISPLAY_COUNT)
+		        display_count = 0;
+		}
+
+		r4k_cur += r4k_offset;
+		ack_r4ktimer(r4k_cur);
+
+	} while (((unsigned int)read_32bit_cp0_register(CP0_COUNT)
+	         - (unsigned int)r4k_cur) < 0x7fffffff);
+
+	return;
+
+null:
+	ack_r4ktimer(0);
+}
+
+/* 
+ * Figure out the r4k offset, the amount to increment the compare
+ * register for each time tick. 
+ * Use the RTC to calculate offset.
+ */
+static unsigned long __init cal_r4koff(void)
+{
+	unsigned long count;
+	unsigned int flags;
+
+	__save_and_cli(flags);
+
+	/* Start counter exactly on falling edge of update flag */
+	while (CMOS_READ(RTC_REG_A) & RTC_UIP);
+	while (!(CMOS_READ(RTC_REG_A) & RTC_UIP));
+
+	/* Start r4k counter. */
+	write_32bit_cp0_register(CP0_COUNT, 0);
+
+	/* Read counter exactly on falling edge of update flag */
+	while (CMOS_READ(RTC_REG_A) & RTC_UIP);
+	while (!(CMOS_READ(RTC_REG_A) & RTC_UIP));
+
+	count = read_32bit_cp0_register(CP0_COUNT);
+
+	/* restore interrupts */
+	__restore_flags(flags);
+
+	return (count / HZ);
+}
+
+static unsigned long __init get_mips_time(void)
+{
+	unsigned int year, mon, day, hour, min, sec;
+	unsigned char save_control;
+
+	save_control = CMOS_READ(RTC_CONTROL);
+
+	/* Freeze it. */
+	CMOS_WRITE(save_control | RTC_SET, RTC_CONTROL);
+
+	/* Read regs. */
+	sec = CMOS_READ(RTC_SECONDS);
+	min = CMOS_READ(RTC_MINUTES);
+	hour = CMOS_READ(RTC_HOURS);
+
+	if (!(save_control & RTC_24H))
+	{
+		if ((hour & 0xf) == 0xc)
+		        hour &= 0x80;
+	        if (hour & 0x80)
+		        hour = (hour & 0xf) + 12;     
+	}
+	day = CMOS_READ(RTC_DAY_OF_MONTH);
+	mon = CMOS_READ(RTC_MONTH);
+	year = CMOS_READ(RTC_YEAR);
+
+	/* Unfreeze clock. */
+	CMOS_WRITE(save_control, RTC_CONTROL);
+
+	if ((year += 1900) < 1970)
+	        year += 100;
+
+	return mktime(year, mon, day, hour, min, sec);
+}
+
+void __init time_init(void)
+{
+        unsigned int est_freq, flags;
+
+        /* Set Data mode - binary. */ 
+        CMOS_WRITE(CMOS_READ(RTC_CONTROL) | RTC_DM_BINARY, RTC_CONTROL);
+
+	printk("calculating r4koff... ");
+	r4k_offset = cal_r4koff();
+	printk("%08lx(%d)\n", r4k_offset, (int) r4k_offset);
+
+	est_freq = 2*r4k_offset*HZ;	
+	est_freq += 5000;    /* round */
+	est_freq -= est_freq%10000;
+	printk("CPU frequency %d.%02d MHz\n", est_freq/1000000, 
+	       (est_freq%1000000)*100/1000000);
+	r4k_cur = (read_32bit_cp0_register(CP0_COUNT) + r4k_offset);
+
+	write_32bit_cp0_register(CP0_COMPARE, r4k_cur);
+	set_cp0_status(ST0_IM, ALLINTS);
+
+	/* Read time from the RTC chipset. */
+	write_lock_irqsave (&xtime_lock, flags);
+	xtime.tv_sec = get_mips_time();
+	xtime.tv_usec = 0;
+	write_unlock_irqrestore(&xtime_lock, flags);
+}
+
+/* This is for machines which generate the exact clock. */
+#define USECS_PER_JIFFY (1000000/HZ)
+#define USECS_PER_JIFFY_FRAC (0x100000000*1000000/HZ&0xffffffff)
+
+/* Cycle counter value at the previous timer interrupt.. */
+
+static unsigned int timerhi = 0, timerlo = 0;
+
+/*
+ * FIXME: Does playing with the RP bit in c0_status interfere with this code?
+ */
+static unsigned long do_fast_gettimeoffset(void)
+{
+	u32 count;
+	unsigned long res, tmp;
+
+	/* Last jiffy when do_fast_gettimeoffset() was called. */
+	static unsigned long last_jiffies=0;
+	unsigned long quotient;
+
+	/*
+	 * Cached "1/(clocks per usec)*2^32" value.
+	 * It has to be recalculated once each jiffy.
+	 */
+	static unsigned long cached_quotient=0;
+
+	tmp = jiffies;
+
+	quotient = cached_quotient;
+
+	if (tmp && last_jiffies != tmp) {
+		last_jiffies = tmp;
+		__asm__(".set\tnoreorder\n\t"
+			".set\tnoat\n\t"
+			".set\tmips3\n\t"
+			"lwu\t%0,%2\n\t"
+			"dsll32\t$1,%1,0\n\t"
+			"or\t$1,$1,%0\n\t"
+			"ddivu\t$0,$1,%3\n\t"
+			"mflo\t$1\n\t"
+			"dsll32\t%0,%4,0\n\t"
+			"nop\n\t"
+			"ddivu\t$0,%0,$1\n\t"
+			"mflo\t%0\n\t"
+			".set\tmips0\n\t"
+			".set\tat\n\t"
+			".set\treorder"
+			:"=&r" (quotient)
+			:"r" (timerhi),
+			 "m" (timerlo),
+			 "r" (tmp),
+			 "r" (USECS_PER_JIFFY)
+			:"$1");
+		cached_quotient = quotient;
+	}
+
+	/* Get last timer tick in absolute kernel time */
+	count = read_32bit_cp0_register(CP0_COUNT);
+
+	/* .. relative to previous jiffy (32 bits is enough) */
+	count -= timerlo;
+
+	__asm__("multu\t%1,%2\n\t"
+		"mfhi\t%0"
+		:"=r" (res)
+		:"r" (count),
+		 "r" (quotient));
+
+	/*
+ 	 * Due to possible jiffies inconsistencies, we need to check 
+	 * the result so that we'll get a timer that is monotonic.
+	 */
+	if (res >= USECS_PER_JIFFY)
+		res = USECS_PER_JIFFY-1;
+
+	return res;
+}
+
+void do_gettimeofday(struct timeval *tv)
+{
+	unsigned int flags;
+
+	read_lock_irqsave (&xtime_lock, flags);
+	*tv = xtime;
+	tv->tv_usec += do_fast_gettimeoffset();
+
+	/*
+	 * xtime is atomically updated in timer_bh. jiffies - wall_jiffies
+	 * is nonzero if the timer bottom half hasnt executed yet.
+	 */
+	if (jiffies - wall_jiffies)
+		tv->tv_usec += USECS_PER_JIFFY;
+
+	read_unlock_irqrestore (&xtime_lock, flags);
+
+	if (tv->tv_usec >= 1000000) {
+		tv->tv_usec -= 1000000;
+		tv->tv_sec++;
+	}
+}
+
+void do_settimeofday(struct timeval *tv)
+{
+	write_lock_irq (&xtime_lock);
+
+	/* This is revolting. We need to set the xtime.tv_usec correctly.
+	 * However, the value in this location is is value at the last tick.
+	 * Discover what correction gettimeofday would have done, and then
+	 * undo it!
+	 */
+	tv->tv_usec -= do_fast_gettimeoffset();
+
+	if (tv->tv_usec < 0) {
+		tv->tv_usec += 1000000;
+		tv->tv_sec--;
+	}
+
+	xtime = *tv;
+	time_adjust = 0;		/* stop active adjtime() */
+	time_status |= STA_UNSYNC;
+	time_maxerror = NTP_PHASE_LIMIT;
+	time_esterror = NTP_PHASE_LIMIT;
+
+	write_unlock_irq (&xtime_lock);
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mips-boards/malta/Makefile linux/arch/mips64/mips-boards/malta/Makefile
--- v2.4.9/linux/arch/mips64/mips-boards/malta/Makefile	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/mips-boards/malta/Makefile	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,42 @@
+#
+# Carsten Langgaard, carstenl@mips.com
+# Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+#
+# ########################################################################
+#
+# This program is free software; you can distribute it and/or modify it
+# under the terms of the GNU General Public License (Version 2) as
+# published by the Free Software Foundation.
+# 
+# This program is distributed in the hope it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+#
+# #######################################################################
+#
+# Makefile for the MIPS Malta specific kernel interface routines
+# under Linux.
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+# Note 2! The CFLAGS definitions are now in the main makefile...
+
+.S.s:
+	$(CPP) $(CFLAGS) $< -o $*.s
+.S.o:
+	$(CC) $(CFLAGS) -c $< -o $*.o
+
+all: malta.o
+
+O_TARGET := malta.o
+
+obj-y := malta_int.o malta_rtc.o malta_setup.o
+
+include $(TOPDIR)/Rules.make
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mips-boards/malta/malta_int.c linux/arch/mips64/mips-boards/malta/malta_int.c
--- v2.4.9/linux/arch/mips64/mips-boards/malta/malta_int.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/mips-boards/malta/malta_int.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,383 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ * ########################################################################
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * ########################################################################
+ *
+ * Routines for generic manipulation of the interrupts found on the MIPS 
+ * Malta board.
+ * The interrupt controller is located in the South Bridge a PIIX4 device 
+ * with two internal 82C95 interrupt controllers.
+ *
+ */
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/interrupt.h>
+#include <linux/kernel_stat.h>
+#include <linux/random.h>
+
+#include <asm/irq.h>
+#include <asm/io.h>
+#include <asm/mips-boards/malta.h>
+#include <asm/mips-boards/maltaint.h>
+#include <asm/mips-boards/piix4.h>
+#include <asm/mips-boards/gt64120.h>
+#include <asm/mips-boards/generic.h>
+
+extern asmlinkage void mipsIRQ(void);
+
+unsigned int local_bh_count[NR_CPUS];
+unsigned int local_irq_count[NR_CPUS];
+unsigned long spurious_count = 0;
+
+static struct irqaction *hw0_irq_action[MALTAINT_END] = {
+	NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL
+};
+
+static struct irqaction r4ktimer_action = {
+	NULL, 0, 0, "R4000 timer/counter", NULL, NULL,
+};
+
+static struct irqaction *irq_action[8] = {
+	NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, &r4ktimer_action
+};
+
+#if 0
+#define DEBUG_INT(x...) printk(x)
+#else
+#define DEBUG_INT(x...)
+#endif
+
+/*
+ * This contains the interrupt mask for both 82C59 interrupt controllers.
+ */
+static unsigned int cached_int_mask = 0xffff;
+
+
+void disable_irq(unsigned int irq_nr)
+{
+        unsigned long flags;
+
+	if(irq_nr >= MALTAINT_END) {
+		printk("whee, invalid irq_nr %d\n", irq_nr);
+		panic("IRQ, you lose...");
+	}
+
+	save_and_cli(flags);
+	cached_int_mask |= (1 << irq_nr);
+	if (irq_nr & 8) {
+	        outb((cached_int_mask >> 8) & 0xff, PIIX4_ICTLR2_OCW1);
+	} else {
+		outb(cached_int_mask & 0xff, PIIX4_ICTLR1_OCW1);
+	}
+	restore_flags(flags);
+}
+
+
+void enable_irq(unsigned int irq_nr)
+{
+        unsigned long flags;
+
+	if(irq_nr >= MALTAINT_END) {
+		printk("whee, invalid irq_nr %d\n", irq_nr);
+		panic("IRQ, you lose...");
+	}
+
+	save_and_cli(flags);
+	cached_int_mask &= ~(1 << irq_nr);
+	if (irq_nr & 8) {
+		outb((cached_int_mask >> 8) & 0xff, PIIX4_ICTLR2_OCW1);
+
+		/* Enable irq 2 (cascade interrupt). */
+	        cached_int_mask &= ~(1 << 2); 
+		outb(cached_int_mask & 0xff, PIIX4_ICTLR1_OCW1);
+	} else {
+		outb(cached_int_mask & 0xff, PIIX4_ICTLR1_OCW1);
+	}	
+	restore_flags(flags);
+}
+
+
+int get_irq_list(char *buf)
+{
+	int i, len = 0;
+	int num = 0;
+	struct irqaction *action;
+
+	for (i = 0; i < 8; i++, num++) {
+		action = irq_action[i];
+		if (!action) 
+			continue;
+		len += sprintf(buf+len, "%2d: %8d %c %s",
+			num, kstat.irqs[0][num],
+			(action->flags & SA_INTERRUPT) ? '+' : ' ',
+			action->name);
+		for (action=action->next; action; action = action->next) {
+			len += sprintf(buf+len, ",%s %s",
+				(action->flags & SA_INTERRUPT) ? " +" : "",
+				action->name);
+		}
+		len += sprintf(buf+len, " [on-chip]\n");
+	}
+	for (i = 0; i < MALTAINT_END; i++, num++) {
+		action = hw0_irq_action[i];
+		if (!action) 
+			continue;
+		len += sprintf(buf+len, "%2d: %8d %c %s",
+			num, kstat.irqs[0][num],
+			(action->flags & SA_INTERRUPT) ? '+' : ' ',
+			action->name);
+		for (action=action->next; action; action = action->next) {
+			len += sprintf(buf+len, ",%s %s",
+				(action->flags & SA_INTERRUPT) ? " +" : "",
+				action->name);
+		}
+		len += sprintf(buf+len, " [hw0]\n");
+	}
+	return len;
+}
+
+int request_irq(unsigned int irq, 
+		void (*handler)(int, void *, struct pt_regs *),
+		unsigned long irqflags, 
+		const char * devname,
+		void *dev_id)
+{  
+        struct irqaction *action;
+	int retval;
+
+	DEBUG_INT("request_irq: irq=%d, devname = %s\n", irq, devname);
+
+        if (irq >= MALTAINT_END)
+	        return -EINVAL;
+	if (!handler)
+	        return -EINVAL;
+
+	action = (struct irqaction *)kmalloc(sizeof(struct irqaction), GFP_KERNEL);
+	if(!action)
+	        return -ENOMEM;
+
+	action->handler = handler;
+	action->flags = irqflags;
+	action->mask = 0;
+	action->name = devname;
+	action->dev_id = dev_id;
+	action->next = 0;
+
+	retval = setup_irq(irq, action);
+	if (retval)
+		kfree(action);
+
+	return retval;	
+}
+
+
+void free_irq(unsigned int irq, void *dev_id)
+{
+	struct irqaction *action, **p;
+
+	if (irq >= MALTAINT_END) {
+		printk("Trying to free IRQ%d\n",irq);
+		return;
+	}
+	
+	for (p = &hw0_irq_action[irq]; (action = *p) != NULL; 
+	     p = &action->next) 
+	{
+		if (action->dev_id != dev_id)
+			continue;
+
+		/* Found it - now free it */
+		*p = action->next;
+		kfree(action);
+		if (!hw0_irq_action[irq])
+			disable_irq(irq);
+		return;
+	}
+	printk("Trying to free IRQ%d\n",irq);
+}
+
+void __init init_IRQ(void)
+{
+	irq_setup();
+}
+
+static int setup_irq(unsigned int irq, struct irqaction * new)
+{
+	int shared = 0;
+	struct irqaction *old, **p;
+
+	p = &hw0_irq_action[irq];
+	if ((old = *p) != NULL) {
+		/* Can't share interrupts unless both agree to */
+		if (!(old->flags & new->flags & SA_SHIRQ))
+			return -EBUSY;
+
+		/* Can't share interrupts unless both are same type */
+		if ((old->flags ^ new->flags) & SA_INTERRUPT)
+			return -EBUSY;
+
+		/* add new interrupt at end of irq queue */
+		do {
+			p = &old->next;
+			old = *p;
+		} while (old);
+		shared = 1;
+	}
+
+	if (new->flags & SA_SAMPLE_RANDOM)
+		rand_initialize_irq(irq);
+
+	*p = new;
+	if (!shared)
+		enable_irq(irq);
+
+	return 0;
+}
+
+static inline int get_int(int *irq)
+{
+	/*  
+	 * Determine highest priority pending interrupt by performing
+         * a PCI Interrupt Acknowledge cycle.
+	 */
+	GT_READ(GT_PCI0_IACK_OFS, *irq);
+	*irq &= 0xFF;
+
+	/*  
+	 * IRQ7 is used to detect spurious interrupts.
+	 * The interrupt acknowledge cycle returns IRQ7, if no 
+	 * interrupts is requested.
+	 * We can differentiate between this situation and a
+	 * "Normal" IRQ7 by reading the ISR.
+	 */
+	if (*irq == 7) 
+	{
+		outb(PIIX4_OCW3_SEL | PIIX4_OCW3_ISR, PIIX4_ICTLR1_OCW3);
+		if (!(inb(PIIX4_ICTLR1_OCW3) & (1 << 7)))
+		        return -1;    /* Spurious interrupt. */
+	}
+
+	return 0;
+}
+
+static inline void ack_int(int irq)
+{
+	if (irq & 8) {
+	        /* Specific EOI to cascade */
+		outb(PIIX4_OCW2_SEL | PIIX4_OCW2_NSEOI | PIIX4_OCW2_ILS_2, 
+		     PIIX4_ICTLR1_OCW2);
+
+	        /* Non specific EOI to cascade */
+		outb(PIIX4_OCW2_SEL | PIIX4_OCW2_NSEOI, PIIX4_ICTLR2_OCW2);
+	} else {
+	        /* Non specific EOI to cascade */
+		outb(PIIX4_OCW2_SEL | PIIX4_OCW2_NSEOI, PIIX4_ICTLR1_OCW2);
+	}
+}
+
+void malta_hw0_irqdispatch(struct pt_regs *regs)
+{
+        struct irqaction *action;
+	int irq=0, cpu = smp_processor_id();
+
+	DEBUG_INT("malta_hw0_irqdispatch\n");
+	
+	if (get_int(&irq))
+	        return;  /* interrupt has already been cleared */
+
+	disable_irq(irq);
+	ack_int(irq);
+
+	DEBUG_INT("malta_hw0_irqdispatch: irq=%d\n", irq);
+	action = hw0_irq_action[irq];
+
+	/* 
+	 * if action == NULL, then we don't have a handler 
+	 * for the irq 
+	 */
+	if ( action == NULL )
+		return;
+
+	irq_enter(cpu, irq);
+	kstat.irqs[0][irq + 8]++;
+	do {
+	        action->handler(irq, action->dev_id, regs);
+		action = action->next;
+	} while (action);
+
+	enable_irq(irq);
+	irq_exit(cpu, irq);
+}
+
+
+unsigned long probe_irq_on (void)
+{
+	unsigned int i, irqs = 0;
+	unsigned long delay;
+
+	/* first, enable any unassigned irqs */
+	for (i = MALTAINT_END-1; i > 0; i--) {
+		if (!hw0_irq_action[i]) {
+			enable_irq(i);
+			irqs |= (1 << i);
+		}
+	}
+
+	/* wait for spurious interrupts to mask themselves out again */
+	for (delay = jiffies + HZ/10; time_before(jiffies, delay); )
+		/* about 100ms delay */;
+
+	/* now filter out any obviously spurious interrupts */
+	return irqs & ~cached_int_mask;
+}
+
+
+int probe_irq_off (unsigned long irqs)
+{
+	unsigned int i;
+
+	irqs &= cached_int_mask;
+	if (!irqs)
+		return 0;
+	i = ffz(~irqs);
+	if (irqs != (irqs & (1 << i)))
+		i = -i;
+
+	return i;
+}
+
+
+void __init maltaint_init(void)
+{
+        /* 
+	 * Mask out all interrupt by writing "1" to all bit position in 
+	 * the IMR register. 
+	 */
+	outb(cached_int_mask & 0xff, PIIX4_ICTLR1_OCW1);
+	outb((cached_int_mask >> 8) & 0xff, PIIX4_ICTLR2_OCW1);
+
+	/* Now safe to set the exception vector. */
+	set_except_vector(0, mipsIRQ);
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mips-boards/malta/malta_rtc.c linux/arch/mips64/mips-boards/malta/malta_rtc.c
--- v2.4.9/linux/arch/mips64/mips-boards/malta/malta_rtc.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/mips-boards/malta/malta_rtc.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,50 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ * ########################################################################
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * ########################################################################
+ *
+ * RTC routines for Malta style attached PIIX4 device, which contains a
+ * Motorola MC146818A-compatible Real Time Clock.
+ *
+ */
+#include <asm/mc146818rtc.h>
+#include <asm/mips-boards/malta.h>
+
+static unsigned char malta_rtc_read_data(unsigned long addr)
+{
+	outb(addr, MALTA_RTC_ADR_REG);
+	return inb(MALTA_RTC_DAT_REG);
+}
+
+static void malta_rtc_write_data(unsigned char data, unsigned long addr)
+{
+	outb(addr, MALTA_RTC_ADR_REG);
+	outb(data, MALTA_RTC_DAT_REG);
+}
+
+static int malta_rtc_bcd_mode(void)
+{
+	return 0;
+}
+
+struct rtc_ops malta_rtc_ops = {
+	&malta_rtc_read_data,
+	&malta_rtc_write_data,
+	&malta_rtc_bcd_mode
+};
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mips-boards/malta/malta_setup.c linux/arch/mips64/mips-boards/malta/malta_setup.c
--- v2.4.9/linux/arch/mips64/mips-boards/malta/malta_setup.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/mips-boards/malta/malta_setup.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,170 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ * ########################################################################
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * ########################################################################
+ *
+ * Malta specific setup, including init of the feature struct.
+ *
+ */
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/mc146818rtc.h>
+#include <linux/ioport.h>
+#include <linux/pci.h>
+#ifdef CONFIG_BLK_DEV_IDE
+#include <linux/ide.h>
+#endif
+
+#include <asm/cpu.h>
+#include <asm/bootinfo.h>
+#include <asm/irq.h>
+#include <asm/mips-boards/generic.h>
+#include <asm/mips-boards/prom.h>
+#include <asm/mips-boards/gt64120.h>
+#include <asm/mips-boards/malta.h>
+#include <asm/mips-boards/maltaint.h>
+#ifdef CONFIG_BLK_DEV_FD
+#include <asm/floppy.h>
+#endif
+#include <asm/dma.h>
+#include <asm/mmu_context.h>
+
+#if defined(CONFIG_SERIAL_CONSOLE) || defined(CONFIG_PROM_CONSOLE)
+extern void console_setup(char *, int *);
+char serial_console[20];
+#endif
+
+#ifdef CONFIG_REMOTE_DEBUG
+extern void set_debug_traps(void);
+extern void rs_kgdb_hook(int);
+extern void breakpoint(void);
+static int remote_debug = 0;
+#endif
+
+#ifdef CONFIG_BLK_DEV_IDE
+extern struct ide_ops std_ide_ops;
+#endif
+#ifdef CONFIG_BLK_DEV_FD
+extern struct fd_ops std_fd_ops;
+#endif
+extern struct rtc_ops malta_rtc_ops;
+
+extern void mips_reboot_setup(void);
+
+struct resource standard_io_resources[] = {
+	{ "dma1", 0x00, 0x1f, IORESOURCE_BUSY },
+	{ "pic1", 0x20, 0x3f, IORESOURCE_BUSY },
+	{ "timer", 0x40, 0x5f, IORESOURCE_BUSY },
+	{ "dma page reg", 0x80, 0x8f, IORESOURCE_BUSY },
+	{ "pic2", 0xa0, 0xbf, IORESOURCE_BUSY },
+	{ "dma2", 0xc0, 0xdf, IORESOURCE_BUSY },
+};
+
+#define STANDARD_IO_RESOURCES (sizeof(standard_io_resources)/sizeof(struct resource))
+
+static void __init malta_irq_setup(void)
+{
+  	maltaint_init();
+
+#ifdef CONFIG_REMOTE_DEBUG
+	if (remote_debug) {
+		set_debug_traps();
+		breakpoint(); 
+	}
+#endif
+}
+
+
+void __init malta_setup(void)
+{
+#ifdef CONFIG_REMOTE_DEBUG
+	int rs_putDebugChar(char);
+	char rs_getDebugChar(void);
+	extern int (*putDebugChar)(char);
+	extern char (*getDebugChar)(void);
+#endif
+	char *argptr;
+	int i;
+
+	current_cpu_data.asid_cache = ASID_FIRST_VERSION;
+	TLBMISS_HANDLER_SETUP();
+
+	irq_setup = malta_irq_setup;
+
+	/* Request I/O space for devices used on the Malta board. */
+	for (i = 0; i < STANDARD_IO_RESOURCES; i++)
+		request_resource(&ioport_resource, standard_io_resources+i);
+
+	/* 
+	 * Enable DMA channel 4 (cascade channel) in the PIIX4 south bridge.
+	 */
+	enable_dma(4);
+
+#ifdef CONFIG_SERIAL_CONSOLE
+        argptr = prom_getcmdline();
+	if ((argptr = strstr(argptr, "console=ttyS0")) == NULL) 
+	{
+	        int i=0;
+	        char *s = prom_getenv("modetty0");
+		while(s[i] >= '0' && s[i] <= '9')
+			i++;
+		strcpy(serial_console, "ttyS0,");
+		strncpy(serial_console + 6, s, i);
+		prom_printf("Config serial console: %s\n", serial_console);
+	        console_setup(serial_console, NULL);
+	}
+#endif	  
+
+#ifdef CONFIG_REMOTE_DEBUG
+	argptr = prom_getcmdline();
+	if ((argptr = strstr(argptr, "kgdb=ttyS")) != NULL) {
+		int line;
+		argptr += strlen("kgdb=ttyS");
+		if (*argptr != '0' && *argptr != '1')
+			printk("KGDB: Uknown serial line /dev/ttyS%c, "
+			       "falling back to /dev/ttyS1\n", *argptr);
+		line = *argptr == '0' ? 0 : 1;
+		printk("KGDB: Using serial line /dev/ttyS%d for session\n",
+		       line ? 1 : 0);
+
+		rs_kgdb_hook(line);
+		putDebugChar = rs_putDebugChar;
+		getDebugChar = rs_getDebugChar;
+
+		prom_printf("KGDB: Using serial line /dev/ttyS%d for session, "
+			    "please connect your debugger\n", line ? 1 : 0);
+
+		remote_debug = 1;
+		/* Breakpoints and stuff are in malta_irq_setup() */
+	}
+#endif
+
+	argptr = prom_getcmdline();
+	if ((argptr = strstr(argptr, "nofpu")) != NULL)
+		mips_cpu.options &= ~MIPS_CPU_FPU;
+
+	rtc_ops = &malta_rtc_ops;
+#ifdef CONFIG_BLK_DEV_IDE
+        ide_ops = &std_ide_ops;
+#endif
+#ifdef CONFIG_BLK_DEV_FD
+        fd_ops = &std_fd_ops;
+#endif
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mm/andes.c linux/arch/mips64/mm/andes.c
--- v2.4.9/linux/arch/mips64/mm/andes.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/mm/andes.c	Sun Sep  9 10:43:02 2001
@@ -125,14 +125,8 @@
 static void
 andes_flush_cache_sigtramp(unsigned long addr)
 {
-	unsigned long daddr, iaddr;
-
-	daddr = addr & ~(dc_lsize - 1);
-	protected_writeback_dcache_line(daddr);
-	protected_writeback_dcache_line(daddr + dc_lsize);
-	iaddr = addr & ~(ic_lsize - 1);
-	protected_flush_icache_line(iaddr);
-	protected_flush_icache_line(iaddr + ic_lsize);
+	protected_writeback_dcache_line(addr & ~(dc_lsize - 1));
+	protected_flush_icache_line(addr & ~(ic_lsize - 1));
 }
 
 #define NTLB_ENTRIES       64
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mm/extable.c linux/arch/mips64/mm/extable.c
--- v2.4.9/linux/arch/mips64/mm/extable.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/mm/extable.c	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: extable.c,v 1.2 1999/11/23 17:12:50 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -38,8 +37,7 @@
 
 extern spinlock_t modlist_lock;
 
-unsigned long
-search_exception_table(unsigned long addr)
+unsigned long search_exception_table(unsigned long addr)
 {
 	unsigned long ret = 0;
 	unsigned long flags;
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mm/fault.c linux/arch/mips64/mm/fault.c
--- v2.4.9/linux/arch/mips64/mm/fault.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/mm/fault.c	Sun Sep  9 10:43:02 2001
@@ -32,7 +32,6 @@
 #define development_version (LINUX_VERSION_CODE & 0x100)
 
 extern void die(char *, struct pt_regs *, unsigned long write);
-extern int console_loglevel;
 
 /*
  * Macro for exception fixup code to access integer registers.
@@ -59,11 +58,11 @@
 	printk("Got exception 0x%lx at 0x%lx\n", retaddr, regs.cp0_epc);
 }
 
-extern spinlock_t timerlist_lock;
+extern spinlock_t console_lock, timerlist_lock;
 
 /*
  * Unlock any spinlocks which will prevent us from getting the
- * message out (timerlist_lock is aquired through the
+ * message out (timerlist_lock is acquired through the
  * console unblank code)
  */
 void bust_spinlocks(int yes)
@@ -71,12 +70,11 @@
 	spin_lock_init(&timerlist_lock);
 	if (yes) {
 		oops_in_progress = 1;
-#ifdef CONFIG_SMP
-		global_irq_lock = 0;	/* Many serial drivers do __global_cli() */
-#endif
 	} else {
 		int loglevel_save = console_loglevel;
+#ifdef CONFIG_VT
 		unblank_screen();
+#endif
 		oops_in_progress = 0;
 		/*
 		 * OK, the message is on the console.  Now we call printk()
@@ -228,7 +226,6 @@
                (unsigned int) regs->regs[31]);
 	die("Oops", regs, write);
 	do_exit(SIGKILL);
-	bust_spinlocks(0);
 
 /*
  * We ran out of memory, or some other thing happened to us that made
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mm/loadmmu.c linux/arch/mips64/mm/loadmmu.c
--- v2.4.9/linux/arch/mips64/mm/loadmmu.c	Tue Nov 28 21:42:04 2000
+++ linux/arch/mips64/mm/loadmmu.c	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: loadmmu.c,v 1.5 2000/01/27 01:05:24 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mm/r4xx0.c linux/arch/mips64/mm/r4xx0.c
--- v2.4.9/linux/arch/mips64/mm/r4xx0.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/mm/r4xx0.c	Sun Sep  9 10:43:02 2001
@@ -776,9 +776,9 @@
 	__restore_flags(flags);
 }
 
-static void
-r4k_flush_cache_range_s16d16i16(struct mm_struct *mm, unsigned long start,
-                                unsigned long end)
+static void r4k_flush_cache_range_s16d16i16(struct mm_struct *mm,
+					    unsigned long start,
+					    unsigned long end)
 {
 	struct vm_area_struct *vma;
 	unsigned long flags;
@@ -815,9 +815,9 @@
 	}
 }
 
-static void
-r4k_flush_cache_range_s32d16i16(struct mm_struct *mm, unsigned long start,
-                                unsigned long end)
+static void r4k_flush_cache_range_s32d16i16(struct mm_struct *mm,
+					    unsigned long start,
+					    unsigned long end)
 {
 	struct vm_area_struct *vma;
 	unsigned long flags;
@@ -854,9 +854,9 @@
 	}
 }
 
-static void
-r4k_flush_cache_range_s64d16i16(struct mm_struct *mm, unsigned long start,
-                                unsigned long end)
+static void r4k_flush_cache_range_s64d16i16(struct mm_struct *mm,
+					    unsigned long start,
+					    unsigned long end)
 {
 	struct vm_area_struct *vma;
 	unsigned long flags;
@@ -893,9 +893,9 @@
 	}
 }
 
-static void
-r4k_flush_cache_range_s128d16i16(struct mm_struct *mm, unsigned long start,
-                                 unsigned long end)
+static void r4k_flush_cache_range_s128d16i16(struct mm_struct *mm,
+					     unsigned long start,
+					     unsigned long end)
 {
 	struct vm_area_struct *vma;
 	unsigned long flags;
@@ -932,9 +932,9 @@
 	}
 }
 
-static void
-r4k_flush_cache_range_s32d32i32(struct mm_struct *mm, unsigned long start,
-                                unsigned long end)
+static void r4k_flush_cache_range_s32d32i32(struct mm_struct *mm,
+					    unsigned long start,
+					    unsigned long end)
 {
 	struct vm_area_struct *vma;
 	unsigned long flags;
@@ -971,9 +971,9 @@
 	}
 }
 
-static void
-r4k_flush_cache_range_s64d32i32(struct mm_struct *mm, unsigned long start,
-                                unsigned long end)
+static void r4k_flush_cache_range_s64d32i32(struct mm_struct *mm,
+					    unsigned long start,
+					    unsigned long end)
 {
 	struct vm_area_struct *vma;
 	unsigned long flags;
@@ -1010,9 +1010,9 @@
 	}
 }
 
-static void
-r4k_flush_cache_range_s128d32i32(struct mm_struct *mm, unsigned long start,
-                                 unsigned long end)
+static void r4k_flush_cache_range_s128d32i32(struct mm_struct *mm,
+					     unsigned long start,
+					     unsigned long end)
 {
 	struct vm_area_struct *vma;
 	unsigned long flags;
@@ -1049,9 +1049,9 @@
 	}
 }
 
-static void
-r4k_flush_cache_range_d16i16(struct mm_struct *mm, unsigned long start,
-                             unsigned long end)
+static void r4k_flush_cache_range_d16i16(struct mm_struct *mm,
+					 unsigned long start,
+					 unsigned long end)
 {
 	if (CPU_CONTEXT(smp_processor_id(), mm) != 0) {
 		unsigned long flags;
@@ -1065,9 +1065,9 @@
 	}
 }
 
-static void
-r4k_flush_cache_range_d32i32(struct mm_struct *mm, unsigned long start,
-                             unsigned long end)
+static void r4k_flush_cache_range_d32i32(struct mm_struct *mm,
+					 unsigned long start,
+					 unsigned long end)
 {
 	if (CPU_CONTEXT(smp_processor_id(), mm) != 0) {
 		unsigned long flags;
@@ -1176,8 +1176,8 @@
 	}
 }
 
-static void
-r4k_flush_cache_page_s16d16i16(struct vm_area_struct *vma, unsigned long page)
+static void r4k_flush_cache_page_s16d16i16(struct vm_area_struct *vma,
+					   unsigned long page)
 {
 	struct mm_struct *mm = vma->vm_mm;
 	unsigned long flags;
@@ -1213,8 +1213,8 @@
 	 * for every cache flush operation.  So we do indexed flushes
 	 * in that case, which doesn't overly flush the cache too much.
 	 */
-	if (CPU_CONTEXT(smp_processor_id(), mm) != 
-				CPU_CONTEXT(smp_processor_id(), current->mm)) {
+	if (CPU_CONTEXT(smp_processor_id(), mm) !=
+	    CPU_CONTEXT(smp_processor_id(), current->mm)) {
 		/* Do indexed flush, too much work to get the (possible)
 		 * tlb refills to work correctly.
 		 */
@@ -1227,8 +1227,8 @@
 	__restore_flags(flags);
 }
 
-static void
-r4k_flush_cache_page_s32d16i16(struct vm_area_struct *vma, unsigned long page)
+static void r4k_flush_cache_page_s32d16i16(struct vm_area_struct *vma,
+					   unsigned long page)
 {
 	struct mm_struct *mm = vma->vm_mm;
 	unsigned long flags;
@@ -1263,8 +1263,8 @@
 	 * for every cache flush operation.  So we do indexed flushes
 	 * in that case, which doesn't overly flush the cache too much.
 	 */
-	if (CPU_CONTEXT(smp_processor_id(), mm) != 
-				CPU_CONTEXT(smp_processor_id(), current->mm)) {
+	if (CPU_CONTEXT(smp_processor_id(), mm) !=
+	    CPU_CONTEXT(smp_processor_id(), current->mm)) {
 		/* Do indexed flush, too much work to get the (possible)
 		 * tlb refills to work correctly.
 		 */
@@ -1277,8 +1277,8 @@
 	__restore_flags(flags);
 }
 
-static void
-r4k_flush_cache_page_s64d16i16(struct vm_area_struct *vma, unsigned long page)
+static void r4k_flush_cache_page_s64d16i16(struct vm_area_struct *vma,
+					   unsigned long page)
 {
 	struct mm_struct *mm = vma->vm_mm;
 	unsigned long flags;
@@ -1315,7 +1315,7 @@
 	 * in that case, which doesn't overly flush the cache too much.
 	 */
 	if (CPU_CONTEXT(smp_processor_id(), mm) != 
-				CPU_CONTEXT(smp_processor_id(), current->mm)) {
+	    CPU_CONTEXT(smp_processor_id(), current->mm)) {
 		/* Do indexed flush, too much work to get the (possible)
 		 * tlb refills to work correctly.
 		 */
@@ -1328,8 +1328,8 @@
 	__restore_flags(flags);
 }
 
-static void
-r4k_flush_cache_page_s128d16i16(struct vm_area_struct *vma, unsigned long page)
+static void r4k_flush_cache_page_s128d16i16(struct vm_area_struct *vma,
+					    unsigned long page)
 {
 	struct mm_struct *mm = vma->vm_mm;
 	unsigned long flags;
@@ -1366,7 +1366,7 @@
 	 * in that case, which doesn't overly flush the cache too much.
 	 */
 	if (CPU_CONTEXT(smp_processor_id(), mm) != 
-				CPU_CONTEXT(smp_processor_id(), current->mm)) {
+	    CPU_CONTEXT(smp_processor_id(), current->mm)) {
 		/*
 		 * Do indexed flush, too much work to get the (possible)
 		 * tlb refills to work correctly.
@@ -1380,8 +1380,8 @@
 	__restore_flags(flags);
 }
 
-static void
-r4k_flush_cache_page_s32d32i32(struct vm_area_struct *vma, unsigned long page)
+static void r4k_flush_cache_page_s32d32i32(struct vm_area_struct *vma,
+					   unsigned long page)
 {
 	struct mm_struct *mm = vma->vm_mm;
 	unsigned long flags;
@@ -1419,7 +1419,7 @@
 	 * in that case, which doesn't overly flush the cache too much.
 	 */
 	if (CPU_CONTEXT(smp_processor_id(), mm) != 
-				CPU_CONTEXT(smp_processor_id(), current->mm)) {
+	    CPU_CONTEXT(smp_processor_id(), current->mm)) {
 		/*
 		 * Do indexed flush, too much work to get the (possible)
 		 * tlb refills to work correctly.
@@ -1433,8 +1433,8 @@
 	__restore_flags(flags);
 }
 
-static void
-r4k_flush_cache_page_s64d32i32(struct vm_area_struct *vma, unsigned long page)
+static void r4k_flush_cache_page_s64d32i32(struct vm_area_struct *vma,
+					   unsigned long page)
 {
 	struct mm_struct *mm = vma->vm_mm;
 	unsigned long flags;
@@ -1472,7 +1472,7 @@
 	 * in that case, which doesn't overly flush the cache too much.
 	 */
 	if (CPU_CONTEXT(smp_processor_id(), mm) != 
-				CPU_CONTEXT(smp_processor_id(), current->mm)) {
+	    CPU_CONTEXT(smp_processor_id(), current->mm)) {
 		/*
 		 * Do indexed flush, too much work to get the (possible)
 		 * tlb refills to work correctly.
@@ -1486,8 +1486,8 @@
 	__restore_flags(flags);
 }
 
-static void
-r4k_flush_cache_page_s128d32i32(struct vm_area_struct *vma, unsigned long page)
+static void r4k_flush_cache_page_s128d32i32(struct vm_area_struct *vma,
+					    unsigned long page)
 {
 	struct mm_struct *mm = vma->vm_mm;
 	unsigned long flags;
@@ -1524,7 +1524,7 @@
 	 * in that case, which doesn't overly flush the cache too much.
 	 */
 	if (CPU_CONTEXT(smp_processor_id(), mm) != 
-				CPU_CONTEXT(smp_processor_id(), current->mm)) {
+	    CPU_CONTEXT(smp_processor_id(), current->mm)) {
 		/* Do indexed flush, too much work to get the (possible)
 		 * tlb refills to work correctly.
 		 */
@@ -1537,8 +1537,8 @@
 	__restore_flags(flags);
 }
 
-static void
-r4k_flush_cache_page_d16i16(struct vm_area_struct *vma, unsigned long page)
+static void r4k_flush_cache_page_d16i16(struct vm_area_struct *vma,
+					unsigned long page)
 {
 	struct mm_struct *mm = vma->vm_mm;
 	unsigned long flags;
@@ -1587,8 +1587,8 @@
 	__restore_flags(flags);
 }
 
-static void
-r4k_flush_cache_page_d32i32(struct vm_area_struct *vma, unsigned long page)
+static void r4k_flush_cache_page_d32i32(struct vm_area_struct *vma,
+					unsigned long page)
 {
 	struct mm_struct *mm = vma->vm_mm;
 	unsigned long flags;
@@ -1639,9 +1639,8 @@
 	__restore_flags(flags);
 }
 
-static void
-r4k_flush_cache_page_d32i32_r4600(struct vm_area_struct *vma,
-                                  unsigned long page)
+static void r4k_flush_cache_page_d32i32_r4600(struct vm_area_struct *vma,
+					      unsigned long page)
 {
 	struct mm_struct *mm = vma->vm_mm;
 	unsigned long flags;
@@ -1741,8 +1740,7 @@
  * (Revision 2.0 device errata from IDT available on http://www.idt.com/
  * in .pdf format.)
  */
-static void
-r4k_dma_cache_wback_inv_pc(unsigned long addr, unsigned long size)
+static void r4k_dma_cache_wback_inv_pc(unsigned long addr, unsigned long size)
 {
 	unsigned long end, a;
 	unsigned int flags;
@@ -1766,8 +1764,7 @@
 	bc_wback_inv(addr, size);
 }
 
-static void
-r4k_dma_cache_wback_inv_sc(unsigned long addr, unsigned long size)
+static void r4k_dma_cache_wback_inv_sc(unsigned long addr, unsigned long size)
 {
 	unsigned long end, a;
 
@@ -1785,8 +1782,7 @@
 	}
 }
 
-static void
-r4k_dma_cache_inv_pc(unsigned long addr, unsigned long size)
+static void r4k_dma_cache_inv_pc(unsigned long addr, unsigned long size)
 {
 	unsigned long end, a;
 	unsigned int flags;
@@ -1811,8 +1807,7 @@
 	bc_inv(addr, size);
 }
 
-static void
-r4k_dma_cache_inv_sc(unsigned long addr, unsigned long size)
+static void r4k_dma_cache_inv_sc(unsigned long addr, unsigned long size)
 {
 	unsigned long end, a;
 
@@ -1830,8 +1825,7 @@
 	}
 }
 
-static void
-r4k_dma_cache_wback(unsigned long addr, unsigned long size)
+static void r4k_dma_cache_wback(unsigned long addr, unsigned long size)
 {
 	panic("r4k_dma_cache called - should not happen.\n");
 }
@@ -1843,33 +1837,24 @@
  */
 static void r4k_flush_cache_sigtramp(unsigned long addr)
 {
-	unsigned long daddr, iaddr;
-
-	daddr = addr & ~((unsigned long)dc_lsize - 1);
 	__asm__ __volatile__("nop;nop;nop;nop");	/* R4600 V1.7 */
-	protected_writeback_dcache_line(daddr);
-	protected_writeback_dcache_line(daddr + dc_lsize);
-	iaddr = addr & ~((unsigned long)ic_lsize - 1);
-	protected_flush_icache_line(iaddr);
-	protected_flush_icache_line(iaddr + ic_lsize);
+
+	protected_writeback_dcache_line(addr & ~(dc_lsize - 1));
+	protected_flush_icache_line(addr & ~(ic_lsize - 1));
 }
 
 static void r4600v20k_flush_cache_sigtramp(unsigned long addr)
 {
-	unsigned long daddr, iaddr;
 	unsigned int flags;
 
-	daddr = addr & ~((unsigned long)dc_lsize - 1);
 	__save_and_cli(flags);
 
 	/* Clear internal cache refill buffer */
 	*(volatile unsigned int *)KSEG1;
 
-	protected_writeback_dcache_line(daddr);
-	protected_writeback_dcache_line(daddr + dc_lsize);
-	iaddr = addr & ~((unsigned long)ic_lsize - 1);
-	protected_flush_icache_line(iaddr);
-	protected_flush_icache_line(iaddr + ic_lsize);
+	protected_writeback_dcache_line(addr & ~(dc_lsize - 1));
+	protected_flush_icache_line(addr & ~(ic_lsize - 1));
+
 	__restore_flags(flags);
 }
 
@@ -2011,8 +1996,7 @@
 	}
 }
 
-static void
-r4k_flush_cache_l2(void)
+static void r4k_flush_cache_l2(void)
 {
 }
 
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/mm/umap.c linux/arch/mips64/mm/umap.c
--- v2.4.9/linux/arch/mips64/mm/umap.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/mips64/mm/umap.c	Sun Sep  9 10:43:02 2001
@@ -25,8 +25,8 @@
 #include <asm/pgalloc.h>
 #include <asm/page.h>
 
-static inline void
-remove_mapping_pte_range (pmd_t *pmd, unsigned long address, unsigned long size)
+static inline void remove_mapping_pte_range (pmd_t *pmd, unsigned long address,
+					     unsigned long size)
 {
 	pte_t *pte;
 	unsigned long end;
@@ -34,7 +34,8 @@
 	if (pmd_none (*pmd))
 		return;
 	if (pmd_bad (*pmd)){
-		printk ("remove_graphics_pte_range: bad pmd (%08lx)\n", pmd_val (*pmd));
+		printk ("remove_graphics_pte_range: bad pmd (%08lx)\n",
+			pmd_val (*pmd));
 		pmd_clear (pmd);
 		return;
 	}
@@ -53,8 +54,8 @@
 						  
 }
 
-static inline void
-remove_mapping_pmd_range (pgd_t *pgd, unsigned long address, unsigned long size)
+static inline void remove_mapping_pmd_range (pgd_t *pgd, unsigned long address,
+					     unsigned long size)
 {
 	pmd_t *pmd;
 	unsigned long end;
@@ -63,7 +64,8 @@
 		return;
 
 	if (pgd_bad (*pgd)){
-		printk ("remove_graphics_pmd_range: bad pgd (%08lx)\n", pgd_val (*pgd));
+		printk ("remove_graphics_pmd_range: bad pgd (%08lx)\n",
+			pgd_val (*pgd));
 		pgd_clear (pgd);
 		return;
 	}
@@ -84,8 +86,8 @@
  * This routine is called from the page fault handler to remove a
  * range of active mappings at this point
  */
-void
-remove_mapping (struct task_struct *task, unsigned long start, unsigned long end)
+void remove_mapping (struct task_struct *task, unsigned long start,
+		     unsigned long end)
 {
 	unsigned long beg = start;
 	pgd_t *dir;
@@ -137,8 +139,8 @@
  * maps a range of vmalloc()ed memory into the requested pages. the old
  * mappings are removed. 
  */
-static inline void
-vmap_pte_range (pte_t *pte, unsigned long address, unsigned long size, unsigned long vaddr)
+static inline void vmap_pte_range (pte_t *pte, unsigned long address,
+				   unsigned long size, unsigned long vaddr)
 {
 	unsigned long end;
 	pgd_t *vdir;
@@ -167,8 +169,8 @@
 	} while (address < end);
 }
 
-static inline int
-vmap_pmd_range (pmd_t *pmd, unsigned long address, unsigned long size, unsigned long vaddr)
+static inline int vmap_pmd_range (pmd_t *pmd, unsigned long address,
+				  unsigned long size, unsigned long vaddr)
 {
 	unsigned long end;
 
@@ -178,7 +180,7 @@
 		end = PGDIR_SIZE;
 	vaddr -= address;
 	do {
-		pte_t * pte = pte_alloc(pmd, address);
+		pte_t * pte = pte_alloc(current->mm, pmd, address);
 		if (!pte)
 			return -ENOMEM;
 		vmap_pte_range(pte, address, end - address, address + vaddr);
@@ -188,8 +190,8 @@
 	return 0;
 }
 
-int
-vmap_page_range (unsigned long from, unsigned long size, unsigned long vaddr)
+int vmap_page_range (unsigned long from, unsigned long size,
+		     unsigned long vaddr)
 {
 	int error = 0;
 	pgd_t * dir;
@@ -200,7 +202,7 @@
 	dir = pgd_offset(current->mm, from);
 	flush_cache_range(current->mm, beg, end);
 	while (from < end) {
-		pmd_t *pmd = pmd_alloc(dir, from);
+		pmd_t *pmd = pmd_alloc(current->mm, dir, from);
 		error = -ENOMEM;
 		if (!pmd)
 			break;
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip22/ip22-berr.c linux/arch/mips64/sgi-ip22/ip22-berr.c
--- v2.4.9/linux/arch/mips64/sgi-ip22/ip22-berr.c	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/sgi-ip22/ip22-berr.c	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: ip22-berr.c,v 1.1 2000/01/21 22:34:03 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -9,6 +8,9 @@
  */
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/module.h>
+
+#include <asm/module.h>
 #include <asm/uaccess.h>
 #include <asm/paccess.h>
 #include <asm/addrspace.h>
@@ -41,16 +43,43 @@
 	return 0;
 }
 
+extern spinlock_t modlist_lock;
+
 static inline unsigned long
 search_dbe_table(unsigned long addr)
 {
-	unsigned long ret;
+	unsigned long ret = 0;
 
+#ifndef CONFIG_MODULES
 	/* There is only the kernel to search.  */
 	ret = search_one_table(__start___dbe_table, __stop___dbe_table-1, addr);
-	if (ret) return ret;
-
-	return 0;
+	return ret;
+#else
+	unsigned long flags;
+
+	/* The kernel is the last "module" -- no need to treat it special.  */
+	struct module *mp;
+	struct archdata *ap;
+
+	spin_lock_irqsave(&modlist_lock, flags);
+	for (mp = module_list; mp != NULL; mp = mp->next) {
+		if (!mod_member_present(mp, archdata_end) ||
+        	    !mod_archdata_member_present(mp, struct archdata,
+						 dbe_table_end))
+			continue;
+		ap = (struct archdata *)(mod->archdata_start);
+
+		if (ap->dbe_table_start == NULL ||
+		    !(mp->flags & (MOD_RUNNING | MOD_INITIALIZING)))
+			continue;
+		ret = search_one_table(ap->dbe_table_start,
+				       ap->dbe_table_end - 1, addr);
+		if (ret)
+			break;
+	}
+	spin_unlock_irqrestore(&modlist_lock, flags);
+	return ret;
+#endif
 }
 
 void do_ibe(struct pt_regs *regs)
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip22/ip22-hpc.c linux/arch/mips64/sgi-ip22/ip22-hpc.c
--- v2.4.9/linux/arch/mips64/sgi-ip22/ip22-hpc.c	Tue Nov 28 21:42:04 2000
+++ linux/arch/mips64/sgi-ip22/ip22-hpc.c	Sun Sep  9 10:43:02 2001
@@ -1,9 +1,8 @@
-/* $Id: ip22-hpc.c,v 1.2 1999/10/19 20:51:52 ralf Exp $
- *
+/*
  * ip22-hpc.c: Routines for generic manipulation of the HPC controllers.
  *
  * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
- * Copyright (C) 1998, 1999 Ralf Baechle
+ * Copyright (C) 1998, 1999, 2001 Ralf Baechle
  */
 #include <linux/init.h>
 #include <linux/types.h>
@@ -11,7 +10,6 @@
 #include <asm/addrspace.h>
 #include <asm/sgi/sgihpc.h>
 #include <asm/sgi/sgint23.h>
-#include <asm/sgialib.h>
 #include <asm/bootinfo.h>
 
 #undef DEBUG_SGIHPC
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip22/ip22-int.c linux/arch/mips64/sgi-ip22/ip22-int.c
--- v2.4.9/linux/arch/mips64/sgi-ip22/ip22-int.c	Fri Feb  9 11:29:44 2001
+++ linux/arch/mips64/sgi-ip22/ip22-int.c	Sun Sep  9 10:43:02 2001
@@ -34,7 +34,6 @@
 #include <asm/sgi/sgi.h>
 #include <asm/sgi/sgihpc.h>
 #include <asm/sgi/sgint23.h>
-#include <asm/sgialib.h>
 
 /*
  * Linux has a controller-independent x86 interrupt architecture.
@@ -287,9 +286,7 @@
 	irq_enter(cpu, irq);
 	kstat.irqs[0][irq]++;
 
-	printk("Got irq %d, press a key.", irq);
-	prom_getchar();
-	ArcEnterInteractiveMode();
+	panic(KERN_DEBUG "Got irq %d, press a key.", irq);
 
 	/*
 	 * mask and ack quickly, we don't want the irq controller
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip22/ip22-irq.S linux/arch/mips64/sgi-ip22/ip22-irq.S
--- v2.4.9/linux/arch/mips64/sgi-ip22/ip22-irq.S	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/sgi-ip22/ip22-irq.S	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: ip22-irq.S,v 1.1 1999/08/20 21:13:33 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip22/ip22-mc.c linux/arch/mips64/sgi-ip22/ip22-mc.c
--- v2.4.9/linux/arch/mips64/sgi-ip22/ip22-mc.c	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/sgi-ip22/ip22-mc.c	Sun Sep  9 10:43:02 2001
@@ -1,12 +1,10 @@
-/* $Id: ip22-mc.c,v 1.2 1999/10/19 20:51:52 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * indy_mc.c: Routines for manipulating the INDY memory controller.
- *
  * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
+ * Copyright (C) 2001 Ralf Baechle (ralf@gnu.org)
  */
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -15,7 +13,6 @@
 #include <asm/ptrace.h>
 #include <asm/sgi/sgimc.h>
 #include <asm/sgi/sgihpc.h>
-#include <asm/sgialib.h>
 
 /* #define DEBUG_SGIMC */
 
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip22/ip22-reset.c linux/arch/mips64/sgi-ip22/ip22-reset.c
--- v2.4.9/linux/arch/mips64/sgi-ip22/ip22-reset.c	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/sgi-ip22/ip22-reset.c	Sun Sep  9 10:43:02 2001
@@ -1,12 +1,11 @@
-/* $Id: ip22-reset.c,v 1.3 1999/10/08 21:07:51 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * Reset an IP22.
  *
- * Copyright (C) 1997, 1998, 1999 by Ralf Baechle
+ * Copyright (C) 1997, 1998, 1999, 2001 by Ralf Baechle
  */
 #include <linux/kernel.h>
 #include <linux/sched.h>
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip22/ip22-rtc.c linux/arch/mips64/sgi-ip22/ip22-rtc.c
--- v2.4.9/linux/arch/mips64/sgi-ip22/ip22-rtc.c	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/sgi-ip22/ip22-rtc.c	Sun Sep  9 10:43:02 2001
@@ -1,12 +1,11 @@
-/* $Id: ip22-rtc.c,v 1.1 1999/08/20 21:13:34 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * RTC routines for Indy style attached Dallas chip.
  *
- * Copyright (C) 1998 by Ralf Baechle
+ * Copyright (C) 1998, 2001 by Ralf Baechle
  */
 #include <linux/mc146818rtc.h>
 #include <asm/sgi/sgihpc.h>
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip22/ip22-sc.c linux/arch/mips64/sgi-ip22/ip22-sc.c
--- v2.4.9/linux/arch/mips64/sgi-ip22/ip22-sc.c	Tue Mar  6 19:44:36 2001
+++ linux/arch/mips64/sgi-ip22/ip22-sc.c	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: ip22-sc.c,v 1.2 1999/12/04 03:59:01 ralf Exp $
- *
+/*
  * indy_sc.c: Indy cache management functions.
  *
  * Copyright (C) 1997 Ralf Baechle (ralf@gnu.org),
@@ -16,7 +15,6 @@
 #include <asm/pgtable.h>
 #include <asm/system.h>
 #include <asm/bootinfo.h>
-#include <asm/sgialib.h>
 #include <asm/mmu_context.h>
 
 /* Secondary cache size in bytes, if present.  */
@@ -31,17 +29,17 @@
 
 static inline void indy_sc_wipe(unsigned long first, unsigned long last)
 {
-	__asm__ __volatile__("
-		.set	noreorder
-		or	%0, %4		# first line to flush
-		or	%1, %4		# last line to flush
-1:		sw	$0, 0(%0)
-		bne	%0, %1, 1b
-		daddu	%0, 32
-		.set reorder"
-		: "=r" (first), "=r" (last)
-		: "0" (first), "1" (last), "r" (0x9000000080000000)
-		: "$1");
+	__asm__ __volatile__(
+	".set\tnoreorder\n\t"
+	"or\t%0, %4\t\t\t# first line to flush\n\t"
+	"or\t%1, %4\t\t\t# last line to flush\n"
+	"1:\tsw	$0, 0(%0)\n\t"
+	"bne\t%0, %1, 1b\n\t"
+	"daddu\t%0, 32\n\t"
+	".set reorder"
+	: "=r" (first), "=r" (last)
+	: "0" (first), "1" (last), "r" (0x9000000080000000)
+	: "$1");
 }
 
 static void indy_sc_wback_invalidate(unsigned long addr, unsigned long size)
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip22/ip22-setup.c linux/arch/mips64/sgi-ip22/ip22-setup.c
--- v2.4.9/linux/arch/mips64/sgi-ip22/ip22-setup.c	Tue Nov 28 21:42:04 2000
+++ linux/arch/mips64/sgi-ip22/ip22-setup.c	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: ip22-setup.c,v 1.4 1999/10/08 21:07:51 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -145,7 +144,7 @@
 	 * graphics console, it is set to "d" for the first serial
 	 * line and "d2" for the second serial line.
 	 */
-	ctype = ArcArcGetEnvironmentVariable("console");
+	ctype = ArcGetEnvironmentVariable("console");
 	if(*ctype == 'd') {
 		if(*(ctype+1)=='2')
 			console_setup ("ttyS1");
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip22/ip22-timer.c linux/arch/mips64/sgi-ip22/ip22-timer.c
--- v2.4.9/linux/arch/mips64/sgi-ip22/ip22-timer.c	Tue Nov 28 21:42:04 2000
+++ linux/arch/mips64/sgi-ip22/ip22-timer.c	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: ip22-timer.c,v 1.6 2000/02/04 07:40:24 ralf Exp $
- *
+/*
  * indy_timer.c: Setting up the clock on the INDY 8254 controller.
  *
  * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
@@ -238,9 +237,7 @@
 
 	irq_enter(cpu, irq);
 	kstat.irqs[0][irq]++;
-	printk("indy_8254timer_irq: Whoops, should not have gotten this IRQ\n");
-	prom_getchar();
-	ArcEnterInteractiveMode();
+	panic("indy_8254timer_irq: Whoops, should not have gotten this IRQ\n");
 	irq_exit(cpu, irq);
 }
 
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip22/system.c linux/arch/mips64/sgi-ip22/system.c
--- v2.4.9/linux/arch/mips64/sgi-ip22/system.c	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/sgi-ip22/system.c	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: system.c,v 1.3 1999/10/19 20:51:52 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -7,6 +6,7 @@
  * system.c: Probe the system type using ARCS prom interface library.
  *
  * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
+ * Copyright (C) 2000, 2001 Ralf Baechle (ralf@gnu.org)
  */
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -17,8 +17,6 @@
 #include <asm/sgialib.h>
 #include <asm/bootinfo.h>
 
-enum sgi_mach sgimach;
-
 struct smatch {
 	char *name;
 	int type;
@@ -46,10 +44,7 @@
 		if(!strcmp(s, sgi_cputable[i].name))
 			return sgi_cputable[i].type;
 	}
-	prom_printf("\nYeee, could not determine MIPS cpu type <%s>\n", s);
-	prom_printf("press a key to reboot\n");
-	prom_getchar();
-	ArcEnterInteractiveMode();
+	panic("\nYeee, could not determine MIPS cpu type <%s>", s);
 	return 0;
 }
 
@@ -74,23 +69,16 @@
 		int ncpus = 0;
 
 		if(p->type == Cpu) {
-			if(++ncpus > 1) {
-				prom_printf("\nYeee, SGI MP not ready yet\n");
-				prom_printf("press a key to reboot\n");
-				prom_getchar();
-				ArcEnterInteractiveMode();
-			}
+			if (++ncpus > 1)
+				panic("\nYeee, SGI MP not ready yet");
 			printk("CPU: %s ", p->iname);
 			cpup = p;
 			cputype = string_to_cpu(cpup->iname);
 		}
 		p = ArcGetPeer(p);
 	}
-	if(cputype == -1) {
-		prom_printf("\nYeee, could not find cpu ARCS component\n");
-		prom_printf("press a key to reboot\n");
-		prom_getchar();
-		ArcEnterInteractiveMode();
+	if (cputype == -1) {
+		panic("\nYeee, could not find cpu ARCS component");
 	}
 	p = ArcGetChild(cpup);
 	while(p) {
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip22/time.c linux/arch/mips64/sgi-ip22/time.c
--- v2.4.9/linux/arch/mips64/sgi-ip22/time.c	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/sgi-ip22/time.c	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: time.c,v 1.1 1999/08/20 21:13:34 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip27/Makefile linux/arch/mips64/sgi-ip27/Makefile
--- v2.4.9/linux/arch/mips64/sgi-ip27/Makefile	Sun Feb  4 21:48:46 2001
+++ linux/arch/mips64/sgi-ip27/Makefile	Sun Sep  9 10:43:02 2001
@@ -7,7 +7,7 @@
 .S.o:
 	$(CC) $(CFLAGS) -c $< -o $*.o
 
-O_TARGET = ip27.a
+O_TARGET = ip27.o
 
 obj-y	:= ip27-berr.o ip27-console.o ip27-irq.o ip27-init.o ip27-irq-glue.o \
 	   ip27-klconfig.o ip27-klnuma.o ip27-memory.o ip27-nmi.o ip27-pci.o \
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip27/ip27-berr.c linux/arch/mips64/sgi-ip27/ip27-berr.c
--- v2.4.9/linux/arch/mips64/sgi-ip27/ip27-berr.c	Sun Jul  9 22:18:16 2000
+++ linux/arch/mips64/sgi-ip27/ip27-berr.c	Sun Sep  9 10:43:02 2001
@@ -8,6 +8,9 @@
  */
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/module.h>
+
+#include <asm/module.h>
 #include <asm/sn/addrs.h>
 #include <asm/sn/arch.h>
 #include <asm/sn/sn0/hub.h>
@@ -43,16 +46,43 @@
 	return 0;
 }
 
+extern spinlock_t modlist_lock;
+
 static inline unsigned long
 search_dbe_table(unsigned long addr)
 {
 	unsigned long ret;
 
+#ifndef CONFIG_MODULES
 	/* There is only the kernel to search.  */
 	ret = search_one_table(__start___dbe_table, __stop___dbe_table-1, addr);
-	if (ret) return ret;
-
-	return 0;
+	return ret;
+#else
+	unsigned long flags;
+
+	/* The kernel is the last "module" -- no need to treat it special.  */
+	struct module *mp;
+	struct archdata *ap;
+
+	spin_lock_irqsave(&modlist_lock, flags);
+	for (mp = module_list; mp != NULL; mp = mp->next) {
+		if (!mod_member_present(mp, archdata_end) ||
+        	    !mod_archdata_member_present(mp, struct archdata,
+						 dbe_table_end))
+			continue;
+		ap = (struct archdata *)(mod->archdata_start);
+
+		if (ap->dbe_table_start == NULL ||
+		    !(mp->flags & (MOD_RUNNING | MOD_INITIALIZING)))
+			continue;
+		ret = search_one_table(ap->dbe_table_start,
+				       ap->dbe_table_end - 1, addr);
+		if (ret)
+			break;
+	}
+	spin_unlock_irqrestore(&modlist_lock, flags);
+	return ret;
+#endif
 }
 
 void do_ibe(struct pt_regs *regs)
@@ -64,9 +94,43 @@
 	while(1);
 }
 
+static void dump_hub_information(unsigned long errst0, unsigned long errst1)
+{
+	static char *err_type[2][8] = {
+		{ NULL, "Uncached Partial Read PRERR", "DERR", "Read Timeout",
+		  NULL, NULL, NULL, NULL },
+		{ "WERR", "Uncached Partial Write", "PWERR", "Write Timeout",
+		  NULL, NULL, NULL, NULL }
+	};
+	int wrb = errst1 & PI_ERR_ST1_WRBRRB_MASK;
+
+	if (!(errst0 & PI_ERR_ST0_VALID_MASK)) {
+		printk("Hub does not contain valid error information\n");
+		return;
+	}
+
+	
+	printk("Hub has valid error information:\n");
+	if (errst0 & PI_ERR_ST0_OVERRUN_MASK)
+		printk("Overrun is set.  Error stack may contain additional "
+		       "information.\n");
+	printk("Hub error address is %08lx\n",
+	       (errst0 & PI_ERR_ST0_ADDR_MASK) >> (PI_ERR_ST0_ADDR_SHFT - 3));
+	printk("Incoming message command 0x%lx\n",
+	       (errst0 & PI_ERR_ST0_CMD_MASK) >> PI_ERR_ST0_CMD_SHFT);
+	printk("Supplemental field of incoming message is 0x%lx\n",
+	       (errst0 & PI_ERR_ST0_SUPPL_MASK) >> PI_ERR_ST0_SUPPL_SHFT);
+	printk("T5 Rn (for RRB only) is 0x%lx\n",
+	       (errst0 & PI_ERR_ST0_REQNUM_MASK) >> PI_ERR_ST0_REQNUM_SHFT);
+	printk("Error type is %s\n", err_type[wrb]
+	       [(errst0 & PI_ERR_ST0_TYPE_MASK) >> PI_ERR_ST0_TYPE_SHFT]
+		? : "invalid");
+}
+
 void do_dbe(struct pt_regs *regs)
 {
-	unsigned long fixup;
+	unsigned long fixup, errst0, errst1;
+	int cpu = LOCAL_HUB_L(PI_CPU_NUM);
 
 	fixup = search_dbe_table(regs->cp0_epc);
 	if (fixup) {
@@ -77,7 +141,12 @@
 		return;
 	}
 
-	printk("Got dbe at 0x%lx\n", regs->cp0_epc);
+	printk("Slice %c got dbe at 0x%lx\n", 'A' + cpu, regs->cp0_epc);
+	printk("Hub information:\n");
+	printk("ERR_INT_PEND = 0x%06lx\n", LOCAL_HUB_L(PI_ERR_INT_PEND));
+	errst0 = LOCAL_HUB_L(cpu ? PI_ERR_STATUS0_B : PI_ERR_STATUS0_A);
+	errst1 = LOCAL_HUB_L(cpu ? PI_ERR_STATUS1_B : PI_ERR_STATUS1_A);
+	dump_hub_information(errst0, errst1);
 	show_regs(regs);
 	dump_tlb_all();
 	while(1);
@@ -95,7 +164,7 @@
 	set_except_vector(7, handle_dbe);
 
 	LOCAL_HUB_S(PI_ERR_INT_PEND,
-	            cpu ? PI_ERR_CLEAR_ALL_A : PI_ERR_CLEAR_ALL_B);
+	            cpu ? PI_ERR_CLEAR_ALL_B : PI_ERR_CLEAR_ALL_A);
 	LOCAL_HUB_S(PI_ERR_INT_MASK_A + cpuoff, 0);
 	LOCAL_HUB_S(PI_ERR_STACK_ADDR_A + cpuoff, 0);
 	LOCAL_HUB_S(PI_ERR_STACK_SIZE, 0);	/* Disable error stack */
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip27/ip27-console.c linux/arch/mips64/sgi-ip27/ip27-console.c
--- v2.4.9/linux/arch/mips64/sgi-ip27/ip27-console.c	Tue Nov 28 21:42:04 2000
+++ linux/arch/mips64/sgi-ip27/ip27-console.c	Sun Sep  9 10:43:02 2001
@@ -2,6 +2,8 @@
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
+ *
+ * Copyright (C) 2001 Ralf Baechle
  */
 #include <linux/init.h>
 #include <linux/console.h>
@@ -11,7 +13,6 @@
 #include <asm/sn/sn0/hub.h>
 #include <asm/sn/klconfig.h>
 #include <asm/sn/ioc3.h>
-#include <asm/sgialib.h>
 #include <asm/sn/sn_private.h>
 
 void prom_putchar(char c)
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip27/ip27-init.c linux/arch/mips64/sgi-ip27/ip27-init.c
--- v2.4.9/linux/arch/mips64/sgi-ip27/ip27-init.c	Sun Feb  4 21:48:46 2001
+++ linux/arch/mips64/sgi-ip27/ip27-init.c	Sun Sep  9 10:43:02 2001
@@ -1,3 +1,12 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License.  See the file "COPYING" in the main directory of this
+ * archive for more details.
+ *
+ * Copyright (C) 2000 - 2001 by Kanoj Sarcar (kanoj@sgi.com)
+ * Copyright (C) 2000 - 2001 by Silicon Graphics, Inc.
+ */
+
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -23,14 +32,14 @@
 #include <asm/sn/sn_private.h>
 #include <asm/sn/sn0/ip27.h>
 #include <asm/sn/mapped_kernel.h>
+#include <asm/sn/sn0/addrs.h>
+#include <asm/sn/gda.h>
 
 #define CPU_NONE		(cpuid_t)-1
 
-#define	CPUMASK_CLRALL(p)	(p) = 0
-#define CPUMASK_SETB(p, bit)	(p) |= 1 << (bit)
-#define CPUMASK_CLRB(p, bit)	(p) &= ~(1ULL << (bit))
-#define CPUMASK_TSTB(p, bit)	((p) & (1ULL << (bit)))
-
+/*
+ * The following should work till 64 nodes, ie 128p SN0s.
+ */
 #define CNODEMASK_CLRALL(p)	(p) = 0
 #define CNODEMASK_TSTB(p, bit)	((p) & (1ULL << (bit)))
 #define CNODEMASK_SETB(p, bit)	((p) |= 1ULL << (bit))
@@ -42,11 +51,13 @@
 static spinlock_t hub_mask_lock = SPIN_LOCK_UNLOCKED;
 static cnodemask_t hub_init_mask;
 static atomic_t numstarted = ATOMIC_INIT(1);
+static int router_distance;
 nasid_t master_nasid = INVALID_NASID;
 
 cnodeid_t	nasid_to_compact_node[MAX_NASIDS];
 nasid_t		compact_to_nasid_node[MAX_COMPACT_NODES];
 cnodeid_t	cpuid_to_compact_node[MAXCPUS];
+char		node_distances[MAX_COMPACT_NODES][MAX_COMPACT_NODES];
 
 hubreg_t get_region(cnodeid_t cnode)
 {
@@ -89,9 +100,13 @@
 		return brd->brd_nasid;
 }
 
+/* Tweak this for maximum number of CPUs to activate */
+static int max_cpus = NR_CPUS;
+
 int do_cpumask(cnodeid_t cnode, nasid_t nasid, cpumask_t *boot_cpumask, 
 							int *highest)
 {
+	static int tot_cpus_found = 0;
 	lboard_t *brd;
 	klcpu_t *acpu;
 	int cpus_found = 0;
@@ -109,9 +124,11 @@
 			if (cpuid > *highest)
 				*highest = cpuid;
 			/* Only let it join in if it's marked enabled */
-			if (acpu->cpu_info.flags & KLINFO_ENABLE) {
+			if ((acpu->cpu_info.flags & KLINFO_ENABLE) &&
+						(tot_cpus_found != max_cpus)) {
 				CPUMASK_SETB(*boot_cpumask, cpuid);
 				cpus_found++;
+				tot_cpus_found++;
 			}
 			acpu = (klcpu_t *)find_component(brd, (klinfo_t *)acpu, 
 								KLSTRUCT_CPU);
@@ -172,6 +189,9 @@
 void mlreset (void)
 {
 	int i;
+	void init_topology_matrix(void);
+	void dump_topology(void);
+
 
 	master_nasid = get_nasid();
 	fine_mode = is_fine_dirmode();
@@ -184,6 +204,9 @@
 	maxcpus = cpu_node_probe(&boot_cpumask, &numnodes);
 	printk("Discovered %d cpus on %d nodes\n", maxcpus, numnodes);
 
+	init_topology_matrix();
+	dump_topology();
+
 	gen_region_mask(&region_mask, numnodes);
 	CNODEMASK_CLRALL(hub_init_mask);
 
@@ -534,3 +557,284 @@
 #else /* CONFIG_SMP */
 void cboot(void) {}
 #endif /* CONFIG_SMP */
+
+
+#define	rou_rflag	rou_flags
+
+void
+router_recurse(klrou_t *router_a, klrou_t *router_b, int depth)
+{
+	klrou_t *router;
+	lboard_t *brd;
+	int	port;
+
+	if (router_a->rou_rflag == 1)
+		return;
+
+	if (depth >= router_distance)
+		return;
+
+	router_a->rou_rflag = 1;
+
+	for (port = 1; port <= MAX_ROUTER_PORTS; port++) {
+		if (router_a->rou_port[port].port_nasid == INVALID_NASID)
+			continue;
+
+		brd = (lboard_t *)NODE_OFFSET_TO_K0(
+			router_a->rou_port[port].port_nasid,
+			router_a->rou_port[port].port_offset);
+
+		if (brd->brd_type == KLTYPE_ROUTER) {
+			router = (klrou_t *)NODE_OFFSET_TO_K0(NASID_GET(brd), brd->brd_compts[0]);
+			if (router == router_b) {
+				if (depth < router_distance)
+					router_distance = depth;
+			}
+			else
+				router_recurse(router, router_b, depth + 1);
+		}
+	}
+
+	router_a->rou_rflag = 0;
+}
+
+int
+node_distance(nasid_t nasid_a, nasid_t nasid_b)
+{
+	nasid_t nasid;
+	cnodeid_t cnode;
+	lboard_t *brd, *dest_brd;
+	int port;
+	klrou_t *router, *router_a = NULL, *router_b = NULL;
+
+	/* Figure out which routers nodes in question are connected to */
+	for (cnode = 0; cnode < numnodes; cnode++) {
+		nasid = COMPACT_TO_NASID_NODEID(cnode);
+
+		if (nasid == -1) continue;
+
+		brd = find_lboard_class((lboard_t *)KL_CONFIG_INFO(nasid),
+					KLTYPE_ROUTER);
+
+		if (!brd)
+			continue;
+
+		do {
+			if (brd->brd_flags & DUPLICATE_BOARD)
+				continue;
+
+			router = (klrou_t *)NODE_OFFSET_TO_K0(NASID_GET(brd), brd->brd_compts[0]);
+			router->rou_rflag = 0;
+
+			for (port = 1; port <= MAX_ROUTER_PORTS; port++) {
+				if (router->rou_port[port].port_nasid == INVALID_NASID)
+					continue;
+
+				dest_brd = (lboard_t *)NODE_OFFSET_TO_K0(
+					router->rou_port[port].port_nasid,
+					router->rou_port[port].port_offset);
+
+				if (dest_brd->brd_type == KLTYPE_IP27) {
+					if (dest_brd->brd_nasid == nasid_a)
+						router_a = router;
+					if (dest_brd->brd_nasid == nasid_b)
+						router_b = router;
+				}
+			}
+			
+		} while ( (brd = find_lboard_class(KLCF_NEXT(brd), KLTYPE_ROUTER)) );
+	}
+
+	if (router_a == NULL) {
+		printk("node_distance: router_a NULL\n");
+		return -1;
+	}
+	if (router_b == NULL) {
+		printk("node_distance: router_b NULL\n");
+		return -1;
+	}
+
+	if (nasid_a == nasid_b)
+		return 0;
+
+	if (router_a == router_b)
+		return 1;
+
+	router_distance = 100;
+	router_recurse(router_a, router_b, 2);
+
+	return router_distance;
+}
+
+void
+init_topology_matrix(void)
+{
+	nasid_t nasid, nasid2;
+	cnodeid_t row, col;
+
+	for (row = 0; row < MAX_COMPACT_NODES; row++)
+		for (col = 0; col < MAX_COMPACT_NODES; col++)
+			node_distances[row][col] = -1;
+
+	for (row = 0; row < numnodes; row++) {
+		nasid = COMPACT_TO_NASID_NODEID(row);
+		for (col = 0; col < numnodes; col++) {
+			nasid2 = COMPACT_TO_NASID_NODEID(col);
+			node_distances[row][col] = node_distance(nasid, nasid2);
+		}
+	}
+}
+
+void
+dump_topology(void)
+{
+	nasid_t nasid;
+	cnodeid_t cnode;
+	lboard_t *brd, *dest_brd;
+	int port;
+	int router_num = 0;
+	klrou_t *router;
+	cnodeid_t row, col;
+
+	printk("************** Topology ********************\n");
+
+	printk("    ");
+	for (col = 0; col < numnodes; col++)
+		printk("%02d ", col);
+	printk("\n");
+	for (row = 0; row < numnodes; row++) {
+		printk("%02d  ", row);
+		for (col = 0; col < numnodes; col++)
+			printk("%2d ", node_distances[row][col]);
+		printk("\n");
+	}
+
+	for (cnode = 0; cnode < numnodes; cnode++) {
+		nasid = COMPACT_TO_NASID_NODEID(cnode);
+
+		if (nasid == -1) continue;
+
+		brd = find_lboard_class((lboard_t *)KL_CONFIG_INFO(nasid),
+					KLTYPE_ROUTER);
+
+		if (!brd)
+			continue;
+
+		do {
+			if (brd->brd_flags & DUPLICATE_BOARD)
+				continue;
+			printk("Router %d:", router_num);
+			router_num++;
+
+			router = (klrou_t *)NODE_OFFSET_TO_K0(NASID_GET(brd), brd->brd_compts[0]);
+
+			for (port = 1; port <= MAX_ROUTER_PORTS; port++) {
+				if (router->rou_port[port].port_nasid == INVALID_NASID)
+					continue;
+
+				dest_brd = (lboard_t *)NODE_OFFSET_TO_K0(
+					router->rou_port[port].port_nasid,
+					router->rou_port[port].port_offset);
+
+				if (dest_brd->brd_type == KLTYPE_IP27)
+					printk(" %d", dest_brd->brd_nasid);
+				if (dest_brd->brd_type == KLTYPE_ROUTER)
+					printk(" r");
+			}
+			printk("\n");
+			
+		} while ( (brd = find_lboard_class(KLCF_NEXT(brd), KLTYPE_ROUTER)) );
+	}
+}
+
+#if 0
+#define		brd_widgetnum	brd_slot
+#define NODE_OFFSET_TO_KLINFO(n,off)    ((klinfo_t*) TO_NODE_CAC(n,off))
+void
+dump_klcfg(void)
+{
+	cnodeid_t       cnode;
+	int i;
+	nasid_t         nasid;
+	lboard_t        *lbptr;
+	gda_t           *gdap;
+	
+	gdap = (gda_t *)GDA_ADDR(get_nasid());
+	if (gdap->g_magic != GDA_MAGIC) {
+		printk("dumpklcfg_cmd: Invalid GDA MAGIC\n");
+		return;
+	}
+
+	for (cnode = 0; cnode < MAX_COMPACT_NODES; cnode ++) {
+		nasid = gdap->g_nasidtable[cnode];
+
+		if (nasid == INVALID_NASID)
+			continue;
+
+		printk("\nDumpping klconfig Nasid %d:\n", nasid);
+	
+		lbptr = KL_CONFIG_INFO(nasid);
+
+		while (lbptr) {
+			printk("    %s, Nasid %d, Module %d, widget 0x%x, partition %d, NIC 0x%x lboard 0x%lx",
+				"board name here", /* BOARD_NAME(lbptr->brd_type), */
+				lbptr->brd_nasid, lbptr->brd_module, 
+				lbptr->brd_widgetnum,
+				lbptr->brd_partition, 
+				(lbptr->brd_nic), lbptr);
+			if (lbptr->brd_flags & DUPLICATE_BOARD)
+				printk(" -D");
+			printk("\n");
+			for (i = 0; i < lbptr->brd_numcompts; i++) {
+				klinfo_t *kli;
+				kli = NODE_OFFSET_TO_KLINFO(NASID_GET(lbptr), lbptr->brd_compts[i]);                       
+				printk("        type %2d, flags 0x%04x, diagval %3d, physid %4d, virtid %2d: %s\n", 
+					kli->struct_type, 
+					kli->flags,
+					kli->diagval,
+					kli->physid,
+					kli->virtid,
+					"comp. name here");
+					/* COMPONENT_NAME(kli->struct_type)); */
+			}
+			lbptr = KLCF_NEXT(lbptr);
+		}
+	}
+	printk("\n");
+
+	/* Useful to print router maps also */
+
+	for (cnode = 0; cnode < MAX_COMPACT_NODES; cnode ++) {
+		klrou_t *kr;
+		int i;
+
+        	nasid = gdap->g_nasidtable[cnode];
+        	if (nasid == INVALID_NASID)
+            		continue;
+        	lbptr = KL_CONFIG_INFO(nasid);
+
+        	while (lbptr) {
+			
+			lbptr = find_lboard_class(lbptr, KLCLASS_ROUTER);
+			if(!lbptr)
+				break;
+			if (!KL_CONFIG_DUPLICATE_BOARD(lbptr)) {
+				printk("%llx -> \n", lbptr->brd_nic);
+				kr = (klrou_t *)find_first_component(lbptr,
+					KLSTRUCT_ROU);
+				for (i = 1; i <= MAX_ROUTER_PORTS; i++) {
+					printk("[%d, %llx]; ",
+						kr->rou_port[i].port_nasid,
+						kr->rou_port[i].port_offset);
+				}
+				printk("\n");
+			}
+			lbptr = KLCF_NEXT(lbptr);
+        	}
+        	printk("\n");
+    	}
+
+	dump_topology();
+}
+#endif
+
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip27/ip27-irq-glue.S linux/arch/mips64/sgi-ip27/ip27-irq-glue.S
--- v2.4.9/linux/arch/mips64/sgi-ip27/ip27-irq-glue.S	Sat May 13 08:30:17 2000
+++ linux/arch/mips64/sgi-ip27/ip27-irq-glue.S	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip27/ip27-irq.c linux/arch/mips64/sgi-ip27/ip27-irq.c
--- v2.4.9/linux/arch/mips64/sgi-ip27/ip27-irq.c	Fri Feb  9 11:29:44 2001
+++ linux/arch/mips64/sgi-ip27/ip27-irq.c	Sun Sep  9 10:43:02 2001
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 1999, 2000 Ralf Baechle (ralf@gnu.org)
  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
+ * Copyright (C) 1999 - 2001 Kanoj Sarcar
  */
 #include <linux/config.h>
 #include <linux/init.h>
@@ -25,6 +26,7 @@
 #include <asm/io.h>
 #include <asm/mipsregs.h>
 #include <asm/system.h>
+#include <asm/irq.h>
 
 #include <asm/ptrace.h>
 #include <asm/processor.h>
@@ -42,6 +44,10 @@
 #define DBG(x...)
 #endif
 
+/* These should die */
+unsigned char bus_to_wid[256];	/* widget id for linux pci bus */
+unsigned char bus_to_nid[256];	/* nasid for linux pci bus */
+unsigned char num_bridges;	/* number of bridges in the system */
 
 /*
  * Linux has a controller-independent x86 interrupt architecture.
@@ -67,11 +73,11 @@
 unsigned long spurious_count = 0;
 
 /*
- * we need to map irq's up to at least bit 7 of the INT_MASK0_A register
- * since bits 0-6 are pre-allocated for other purposes.
+ * There is a single intpend register per node, and we want to have
+ * distinct levels for intercpu intrs for both cpus A and B on a node.
  */
-#define IRQ_TO_SWLEVEL(cpu, i)	i + 7
-#define SWLEVEL_TO_IRQ(cpu, s)	s - 7
+int node_level_to_irq[MAX_COMPACT_NODES][PERNODE_LEVELS];
+
 /*
  * use these macros to get the encoded nasid and widget id
  * from the irq value
@@ -82,6 +88,41 @@
 #define WID_FROM_PCI_IRQ(i)		bus_to_wid[IRQ_TO_BUS(i)]
 #define	SLOT_FROM_PCI_IRQ(i)		irq_to_slot[i]
 
+static inline int alloc_level(cpuid_t cpunum, int irq)
+{
+	cnodeid_t nodenum = CPUID_TO_COMPACT_NODEID(cpunum);
+	int j = LEAST_LEVEL + 3;	/* resched & crosscall entries taken */
+
+	while (++j < PERNODE_LEVELS) {
+		if (node_level_to_irq[nodenum][j] == -1) {
+			node_level_to_irq[nodenum][j] = irq;
+			return j;
+		}
+	}
+	printk("Cpu %ld flooded with devices\n", cpunum);
+	while(1);
+	return -1;
+}
+
+static inline int find_level(cpuid_t *cpunum, int irq)
+{
+	int j;
+	cnodeid_t nodenum = INVALID_CNODEID;
+
+	while (++nodenum < MAX_COMPACT_NODES) {
+		j = LEAST_LEVEL + 3;	/* resched & crosscall entries taken */
+		while (++j < PERNODE_LEVELS)
+			if (node_level_to_irq[nodenum][j] == irq) {
+				*cpunum = 0;	/* XXX Fixme */
+				return(j);
+			}
+	}
+	printk("Could not identify cpu/level for irq %d\n", irq);
+	while(1);
+	return(-1);
+}
+
+
 void disable_irq(unsigned int irq_nr)
 {
 	panic("disable_irq() called ...");
@@ -146,7 +187,8 @@
 	}
 	irq_exit(thiscpu, irq);
 
-	/* unmasking and bottom half handling is done magically for us. */
+	if (softirq_pending(thiscpu))
+		do_softirq();
 }
 
 /*
@@ -196,7 +238,7 @@
 				swlevel = ms1bit(pend0);
 				LOCAL_HUB_CLR_INTR(swlevel);
 				/* "map" swlevel to irq */
-				irq = SWLEVEL_TO_IRQ(thiscpu, swlevel);
+				irq = LEVEL_TO_IRQ(thiscpu, swlevel);
 				do_IRQ(thiscpu, irq, regs);
 				/* clear bit in pend0 */
 				pend0 ^= 1ULL << swlevel;
@@ -227,7 +269,7 @@
 	 * "map" irq to a swlevel greater than 6 since the first 6 bits
 	 * of INT_PEND0 are taken
 	 */
-	swlevel = IRQ_TO_SWLEVEL(cpu, irq);
+	swlevel = alloc_level(cpu, irq);
 	intr_connect_level(cpu, swlevel);
 
 	bridge->b_int_addr[pin].addr = (0x20000 | swlevel | (master << 8));
@@ -254,6 +296,7 @@
 {
 	bridge_t *bridge;
 	int pin, swlevel;
+	cpuid_t cpu;
 
 	bridge = (bridge_t *) NODE_SWIN_BASE(NASID_FROM_PCI_IRQ(irq), 
 	                                     WID_FROM_PCI_IRQ(irq));
@@ -264,8 +307,9 @@
 	 * map irq to a swlevel greater than 6 since the first 6 bits
 	 * of INT_PEND0 are taken
 	 */
-	swlevel = IRQ_TO_SWLEVEL(cpu, irq);
-	intr_disconnect_level(smp_processor_id(), swlevel);
+	swlevel = find_level(&cpu, irq);
+	intr_disconnect_level(cpu, swlevel);
+	LEVEL_TO_IRQ(cpu, swlevel) = -1;
 
 	bridge->b_int_enable &= ~(1 << pin);
 	bridge->b_widget.w_tflush;                      /* Flush */
@@ -423,7 +467,6 @@
 
 	printk(" ]\nStack dumps:");
 	for(i = 0; i < smp_num_cpus; i++) {
-		unsigned long esp;
 		if (i == cpu)
 			continue;
 		printk("\nCPU %d:",i);
@@ -661,37 +704,50 @@
 #ifdef CONFIG_SMP
 #if (CPUS_PER_NODE == 2)
 	static int done = 0;
-	int irq;
 
 	/*
 	 * This is a hack till we have a pernode irqlist. Currently,
 	 * just have the master cpu set up the handlers for the per
 	 * cpu irqs.
 	 */
+	if (done == 0) {
+		int j;
 
-	irq = CPU_RESCHED_A_IRQ + cputoslice(cpu);
-	intr_connect_level(cpu, IRQ_TO_SWLEVEL(cpu, irq));
-	if (done == 0)
-	if (request_irq(irq, handle_resched_intr, 0, "resched", 0))
-		panic("intercpu intr unconnectible\n");
-	irq = CPU_CALL_A_IRQ + cputoslice(cpu);
-	intr_connect_level(cpu, IRQ_TO_SWLEVEL(cpu, irq));
-	if (done == 0)
-	if (request_irq(irq, smp_call_function_interrupt, 0,
-						"callfunc", 0))
-		panic("intercpu intr unconnectible\n");
-	/* HACK STARTS */
-	if (done)
-		return;
-	irq = CPU_RESCHED_A_IRQ + cputoslice(cpu) + 1;
-	if (request_irq(irq, handle_resched_intr, 0, "resched", 0))
-		panic("intercpu intr unconnectible\n");
-	irq = CPU_CALL_A_IRQ + cputoslice(cpu) + 1;
-	if (request_irq(irq, smp_call_function_interrupt, 0,
-						"callfunc", 0))
-		panic("intercpu intr unconnectible\n");
-	done = 1;
-	/* HACK ENDS */
+		if (request_irq(CPU_RESCHED_A_IRQ, handle_resched_intr, 
+							0, "resched", 0))
+			panic("intercpu intr unconnectible\n");
+		if (request_irq(CPU_RESCHED_B_IRQ, handle_resched_intr, 
+							0, "resched", 0))
+			panic("intercpu intr unconnectible\n");
+		if (request_irq(CPU_CALL_A_IRQ, smp_call_function_interrupt,
+							0, "callfunc", 0))
+			panic("intercpu intr unconnectible\n");
+		if (request_irq(CPU_CALL_B_IRQ, smp_call_function_interrupt,
+							0, "callfunc", 0))
+			panic("intercpu intr unconnectible\n");
+
+		for (j = 0; j < PERNODE_LEVELS; j++)
+			LEVEL_TO_IRQ(0, j) = -1;
+		LEVEL_TO_IRQ(0, FAST_IRQ_TO_LEVEL(CPU_RESCHED_A_IRQ)) = 
+							CPU_RESCHED_A_IRQ;
+		LEVEL_TO_IRQ(0, FAST_IRQ_TO_LEVEL(CPU_RESCHED_B_IRQ)) = 
+							CPU_RESCHED_B_IRQ;
+		LEVEL_TO_IRQ(0, FAST_IRQ_TO_LEVEL(CPU_CALL_A_IRQ)) = 
+							CPU_CALL_A_IRQ;
+		LEVEL_TO_IRQ(0, FAST_IRQ_TO_LEVEL(CPU_CALL_B_IRQ)) = 
+							CPU_CALL_B_IRQ;
+		for (j = 1; j < MAX_COMPACT_NODES; j++)
+			memcpy(&node_level_to_irq[j][0], 
+			&node_level_to_irq[0][0], 
+			sizeof(node_level_to_irq[0][0])*PERNODE_LEVELS);
+
+		done = 1;
+	}
+
+	intr_connect_level(cpu, FAST_IRQ_TO_LEVEL(CPU_RESCHED_A_IRQ + 
+							cputoslice(cpu)));
+	intr_connect_level(cpu, FAST_IRQ_TO_LEVEL(CPU_CALL_A_IRQ +
+							cputoslice(cpu)));
 #else /* CPUS_PER_NODE */
 #error Must redefine this for more than 2 CPUS.
 #endif /* CPUS_PER_NODE */
@@ -700,7 +756,9 @@
 
 void install_tlbintr(int cpu)
 {
+#if 0
 	int intr_bit = N_INTPEND_BITS + TLB_INTR_A + cputoslice(cpu);
 
 	intr_connect_level(cpu, intr_bit);
+#endif
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip27/ip27-klconfig.c linux/arch/mips64/sgi-ip27/ip27-klconfig.c
--- v2.4.9/linux/arch/mips64/sgi-ip27/ip27-klconfig.c	Sun Jul  9 22:18:16 2000
+++ linux/arch/mips64/sgi-ip27/ip27-klconfig.c	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * Copyright (C) 1999, 2000 Ralf Baechle (ralf@gnu.org)
  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  */
@@ -57,6 +56,19 @@
 			return start;
 		start = KLCF_NEXT(start);
 	}
+	/* Didn't find it. */
+	return (lboard_t *)NULL;
+}
+
+lboard_t * find_lboard_class(lboard_t *start, unsigned char brd_type)
+{
+	/* Search all boards stored on this node. */
+	while (start) {
+		if (KLCLASS(start->brd_type) == KLCLASS(brd_type))
+			return start;
+		start = KLCF_NEXT(start);
+	}
+
 	/* Didn't find it. */
 	return (lboard_t *)NULL;
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip27/ip27-klnuma.c linux/arch/mips64/sgi-ip27/ip27-klnuma.c
--- v2.4.9/linux/arch/mips64/sgi-ip27/ip27-klnuma.c	Tue Nov 28 21:42:04 2000
+++ linux/arch/mips64/sgi-ip27/ip27-klnuma.c	Sun Sep  9 10:43:02 2001
@@ -1,6 +1,7 @@
 /*
  * Ported from IRIX to Linux by Kanoj Sarcar, 06/08/00.
- * Copyright 2000 Silicon Graphics, Inc.
+ * Copyright 2000 - 2001 Silicon Graphics, Inc.
+ * Copyright 2000 - 2001 Kanoj Sarcar (kanoj@sgi.com)
  */
 #include <linux/config.h>
 #include <linux/init.h>
@@ -9,6 +10,7 @@
 #include <linux/string.h>
 
 #include <asm/page.h>
+#include <asm/smp.h>
 #include <asm/sn/types.h>
 #include <asm/sn/arch.h>
 #include <asm/sn/gda.h>
@@ -16,10 +18,6 @@
 #include <asm/sn/klkernvars.h>
 #include <asm/sn/mapped_kernel.h>
 #include <asm/sn/sn_private.h>
-
-#define CPUMASK_CLRALL(p)	(p) = 0
-#define CPUMASK_SETB(p, bit)	(p) |= 1 << (bit)
-#define CPUMASK_TSTB(p, bit)	((p) & (1ULL << (bit)))
 
 extern char _end;
 static cpumask_t ktext_repmask;
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip27/ip27-memory.c linux/arch/mips64/sgi-ip27/ip27-memory.c
--- v2.4.9/linux/arch/mips64/sgi-ip27/ip27-memory.c	Tue Nov 28 21:42:04 2000
+++ linux/arch/mips64/sgi-ip27/ip27-memory.c	Sun Sep  9 10:43:02 2001
@@ -20,6 +20,7 @@
 #include <asm/bootinfo.h>
 #include <asm/addrspace.h>
 #include <asm/pgtable.h>
+#include <asm/pgalloc.h>
 #include <asm/sn/types.h>
 #include <asm/sn/addrs.h>
 #include <asm/sn/klconfig.h>
@@ -227,15 +228,24 @@
 
 void __init paging_init(void)
 {
+	pmd_t *pmd = kpmdtbl;
+	pte_t *pte = kptbl;
+
 	cnodeid_t node;
 	unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
+	int i;
 
 	/* Initialize the entire pgd.  */
 	pgd_init((unsigned long)swapper_pg_dir);
 	pmd_init((unsigned long)invalid_pmd_table, (unsigned long)invalid_pte_table);
 	memset((void *)invalid_pte_table, 0, sizeof(pte_t) * PTRS_PER_PTE);
-	pmd_init((unsigned long)empty_bad_pmd_table, (unsigned long)empty_bad_page_table);
-	memset((void *)empty_bad_page_table, 0, sizeof(pte_t) * PTRS_PER_PTE);
+
+	/* This is for vmalloc  */
+	memset((void *)kptbl, 0, PAGE_SIZE << KPTBL_PAGE_ORDER);
+	memset((void *)kpmdtbl, 0, PAGE_SIZE);
+	pgd_set(swapper_pg_dir, kpmdtbl);
+	for (i = 0; i < (1 << KPTBL_PAGE_ORDER); pmd++,i++,pte+=PTRS_PER_PTE)
+		pmd_val(*pmd) = (unsigned long)pte;
 
 	for (node = 0; node < numnodes; node++) {
 		pfn_t start_pfn = slot_getbasepfn(node, 0);
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip27/ip27-pci-dma.c linux/arch/mips64/sgi-ip27/ip27-pci-dma.c
--- v2.4.9/linux/arch/mips64/sgi-ip27/ip27-pci-dma.c	Tue Nov 28 21:42:04 2000
+++ linux/arch/mips64/sgi-ip27/ip27-pci-dma.c	Sun Sep  9 10:43:02 2001
@@ -1,5 +1,4 @@
-/* $Id: ip27-pci-dma.c,v 1.1 2000/02/16 21:22:00 ralf Exp $
- *
+/*
  * Dynamic DMA mapping support.
  *
  * On the Origin there is dynamic DMA address translation for all PCI DMA.
@@ -52,4 +51,114 @@
 			 void *vaddr, dma_addr_t dma_handle)
 {
 	free_pages((unsigned long)vaddr, __get_order(size));
+}
+
+/*
+ * Map a single buffer of the indicated size for DMA in streaming mode.
+ * The 32-bit bus address to use is returned.
+ *
+ * Once the device is given the dma address, the device owns this memory
+ * until either pci_unmap_single or pci_dma_sync_single is performed.
+ */
+dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size,
+                          int direction)
+{
+	if (direction == PCI_DMA_NONE)
+		BUG();
+
+	return (bus_to_baddr[hwdev->bus->number] | __pa(ptr));
+}
+
+/*
+ * Unmap a single streaming mode DMA translation.  The dma_addr and size
+ * must match what was provided for in a previous pci_map_single call.  All
+ * other usages are undefined.
+ *
+ * After this call, reads by the cpu to the buffer are guarenteed to see
+ * whatever the device wrote there.
+ */
+void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
+                     size_t size, int direction)
+{
+	if (direction == PCI_DMA_NONE)
+		BUG();
+
+	/* Nothing to do */
+}
+
+/*
+ * Map a set of buffers described by scatterlist in streaming
+ * mode for DMA.  This is the scather-gather version of the
+ * above pci_map_single interface.  Here the scatter gather list
+ * elements are each tagged with the appropriate dma address
+ * and length.  They are obtained via sg_dma_{address,length}(SG).
+ *
+ * NOTE: An implementation may be able to use a smaller number of
+ *       DMA address/length pairs than there are SG table elements.
+ *       (for example via virtual mapping capabilities)
+ *       The routine returns the number of addr/length pairs actually
+ *       used, at most nents.
+ *
+ * Device ownership issues as mentioned above for pci_map_single are
+ * the same here.
+ */
+int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents,
+               int direction)
+{
+	int i;
+
+	if (direction == PCI_DMA_NONE)
+		BUG();
+
+	/* Make sure that gcc doesn't leave the empty loop body.  */
+	for (i = 0; i < nents; i++, sg++) {
+		sg->address = (char *)(bus_to_baddr[hwdev->bus->number] | __pa(sg->address));
+	}
+
+	return nents;
+}
+
+/*
+ * Unmap a set of streaming mode DMA translations.
+ * Again, cpu read rules concerning calls here are the same as for
+ * pci_unmap_single() above.
+ */
+void pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents,
+                  int direction)
+{
+	if (direction == PCI_DMA_NONE)
+		BUG();
+
+	/* Nothing to do */
+}
+
+/*
+ * Make physical memory consistent for a single
+ * streaming mode DMA translation after a transfer.
+ *
+ * If you perform a pci_map_single() but wish to interrogate the
+ * buffer using the cpu, yet do not wish to teardown the PCI dma
+ * mapping, you must call this function before doing so.  At the
+ * next point you give the PCI dma address back to the card, the
+ * device again owns the buffer.
+ */
+void pci_dma_sync_single(struct pci_dev *hwdev, dma_addr_t dma_handle,
+                         size_t size, int direction)
+{
+	if (direction == PCI_DMA_NONE)
+		BUG();
+}
+
+/*
+ * Make physical memory consistent for a set of streaming
+ * mode DMA translations after a transfer.
+ *
+ * The same as pci_dma_sync_single but for a scatter-gather list,
+ * same rules and usage.
+ */
+void pci_dma_sync_sg(struct pci_dev *hwdev, struct scatterlist *sg,
+                     int nelems, int direction)
+{
+	if (direction == PCI_DMA_NONE)
+		BUG();
 }
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip27/ip27-pci.c linux/arch/mips64/sgi-ip27/ip27-pci.c
--- v2.4.9/linux/arch/mips64/sgi-ip27/ip27-pci.c	Tue Nov 28 21:42:04 2000
+++ linux/arch/mips64/sgi-ip27/ip27-pci.c	Sun Sep  9 10:43:02 2001
@@ -18,7 +18,7 @@
 /*
  * Max #PCI busses we can handle; ie, max #PCI bridges.
  */
-#define MAX_PCI_BUSSES		20
+#define MAX_PCI_BUSSES		40
 
 /*
  * Max #PCI devices (like scsi controllers) we handle on a bus.
@@ -55,8 +55,12 @@
 	bridge = (bridge_t *) NODE_SWIN_BASE(bus_to_nid[bus_id],        \
                                              bus_to_wid[bus_id]);       \
                                                                         \
-	/*if (dev->bus->number)			 */			\
-	/*	return PCIBIOS_DEVICE_NOT_FOUND; */			\
+	if (dev->vendor == PCI_VENDOR_ID_SGI				\
+	    && dev->device == PCI_DEVICE_ID_SGI_IOC3			\
+	    && ((where >= 0x14 && where < 0x40) || (where >= 0x48))) {	\
+		*value = 0;						\
+		return PCIBIOS_SUCCESSFUL;				\
+	}								\
 									\
 	__bit = (((where) & (bm)) << 3);				\
 	addr = &bridge->b_type0_cfg_dev[slot].f[fn].l[where >> 2];	\
@@ -96,11 +100,9 @@
 	bridge = (bridge_t *) NODE_SWIN_BASE(bus_to_nid[bus_id],        \
                                              bus_to_wid[bus_id]);       \
                                                                         \
-	/* if (dev->bus->number)		 */			\
-	/* 	return PCIBIOS_DEVICE_NOT_FOUND; */			\
-									\
 	if (dev->vendor == PCI_VENDOR_ID_SGI				\
-	    && dev->device == PCI_DEVICE_ID_SGI_IOC3)			\
+	    && dev->device == PCI_DEVICE_ID_SGI_IOC3			\
+	    && ((where >= 0x14 && where < 0x40) || (where >= 0x48)))	\
 		return PCIBIOS_SUCCESSFUL;				\
 									\
 	__bit = (((where) & (bm)) << 3);				\
@@ -147,6 +149,7 @@
 	int	i;
 
 	ioport_resource.end = ~0UL;
+	iomem_resource.end = ~0UL;
 
 	for (i=0; i<num_bridges; i++) {
 		printk("PCI: Probing PCI hardware on host bus %2d.\n", i);
@@ -178,7 +181,7 @@
  * All observed requests have pin == 1. We could have a global here, that
  * gets incremented and returned every time - unfortunately, pci_map_irq
  * may be called on the same device over and over, and need to return the
- * same value. On o2000, pin can be 0 or 1, and PCI slots can be [0..7]. 
+ * same value. On O2000, pin can be 0 or 1, and PCI slots can be [0..7]. 
  *
  * A given PCI device, in general, should be able to intr any of the cpus
  * on any one of the hubs connected to its xbow.
@@ -186,25 +189,23 @@
 static int __init
 pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 {
-	if ((dev->bus->number >= MAX_PCI_BUSSES) || (pin != 1) || \
-					(slot >= MAX_DEVICES_PER_PCIBUS)) {
-		printk("Increase supported PCI busses %d,%d,%d\n", \
-						dev->bus->number, slot, pin);
-		while(1);
-	}
+	if ((dev->bus->number >= MAX_PCI_BUSSES)
+	    || (pin != 1)
+	    || (slot >= MAX_DEVICES_PER_PCIBUS))
+		panic("Increase supported PCI busses %d,%d,%d\n",
+		      dev->bus->number, slot, pin);
 
 	/*
 	 * Already assigned? Then return previously assigned value ...
 	 */
 	if (irqstore[dev->bus->number][slot])
-		return(irqstore[dev->bus->number][slot]);
-	else {
-		irq_to_bus[lastirq] = dev->bus->number;
-		irq_to_slot[lastirq] = slot;
-		irqstore[dev->bus->number][slot] = lastirq;
-		lastirq++;
-		return (lastirq - 1);
-	}
+		return irqstore[dev->bus->number][slot];
+
+	irq_to_bus[lastirq] = dev->bus->number;
+	irq_to_slot[lastirq] = slot;
+	irqstore[dev->bus->number][slot] = lastirq;
+	lastirq++;
+	return lastirq - 1;
 }
 
 void __init
@@ -237,10 +238,10 @@
 pcibios_fixup_pbus_ranges(struct pci_bus * bus,
                           struct pbus_set_ranges_data * ranges)
 {
-	ranges->io_start -= bus->resource[0]->start;
-	ranges->io_end -= bus->resource[0]->start;
+	ranges->io_start  -= bus->resource[0]->start;
+	ranges->io_end    -= bus->resource[0]->start;
 	ranges->mem_start -= bus->resource[1]->start;
-	ranges->mem_end -= bus->resource[1]->start;
+	ranges->mem_end   -= bus->resource[1]->start;
 }
 
 int __init
@@ -255,6 +256,11 @@
 {
 }
 
+unsigned __init int pcibios_assign_all_busses(void)
+{
+	return 0;
+}
+
 char * __init
 pcibios_setup(char *str)
 {
@@ -263,19 +269,23 @@
 	return str;
 }
 
+/*
+ * Device might live on a subordinate PCI bus.  XXX Walk up the chain of buses
+ * to find the slot number in sense of the bridge device register.
+ * XXX This also means multiple devices might rely on conflicting bridge
+ * settings.
+ */
+
 static void __init
 pci_disable_swapping(struct pci_dev *dev)
 {
 	unsigned int bus_id = (unsigned) dev->bus->number;
 	bridge_t *bridge = (bridge_t *) NODE_SWIN_BASE(bus_to_nid[bus_id],
-				     bus_to_wid[bus_id]);
+	                                               bus_to_wid[bus_id]);
 	int		slot = PCI_SLOT(dev->devfn);
-	bridgereg_t 	devreg;
-
-	devreg = bridge->b_device[slot].reg;
-	devreg &= ~BRIDGE_DEV_SWAP_DIR;		/* turn off byte swapping */
-	bridge->b_device[slot].reg = devreg;
 
+	/* Turn off byte swapping */
+	bridge->b_device[slot].reg &= ~BRIDGE_DEV_SWAP_DIR;
 	bridge->b_widget.w_tflush;		/* Flush */
 }
 
@@ -284,56 +294,25 @@
 {
 	unsigned int bus_id = (unsigned) dev->bus->number;
 	bridge_t *bridge = (bridge_t *) NODE_SWIN_BASE(bus_to_nid[bus_id],
-				     bus_to_wid[bus_id]);
+	                                               bus_to_wid[bus_id]);
 	int		slot = PCI_SLOT(dev->devfn);
-	bridgereg_t 	devreg;
-
-	devreg = bridge->b_device[slot].reg;
-	devreg |= BRIDGE_DEV_SWAP_DIR;		/* turn on byte swapping */
-	bridge->b_device[slot].reg = devreg;
 
+	/* Turn on byte swapping */
+	bridge->b_device[slot].reg |= BRIDGE_DEV_SWAP_DIR;
 	bridge->b_widget.w_tflush;		/* Flush */
 }
 
 static void __init
 pci_fixup_ioc3(struct pci_dev *d)
 {
-	unsigned int bus_id = (unsigned) d->bus->number;
-	int i;
+	unsigned long bus_id = (unsigned) d->bus->number;
 
-	/* IOC3 only decodes 0x20 bytes of the config space, so we end up
-	   with tons of bogus information in the pci_dev.  On Origins the
-	   INTA, INTB and INTC pins are all wired together as if it'd only
-	   use INTA.  */
 	printk("PCI: Fixing base addresses for IOC3 device %s\n", d->slot_name);
 
 	d->resource[0].start |= NODE_OFFSET(bus_to_nid[bus_id]);
-	d->resource[0].end |= NODE_OFFSET(bus_to_nid[bus_id]);
-
-	for (i = 1; i <= PCI_ROM_RESOURCE; i++) {
-		d->resource[i].start = 0UL;
-		d->resource[i].end = 0UL;
-		d->resource[i].flags = 0UL;
-	}
+	d->resource[0].end   |= NODE_OFFSET(bus_to_nid[bus_id]);
 
 	pci_disable_swapping(d);
-
-	/*
-	 * The serial driver will try to probe for serial ports
-	 * later on. MENET boards dbe out unrecoverably on sio space
-	 * access to the 4th ioc3. (The first 3 iocs work okay, they
-	 * have kbd/ms ports; all have ethernet ports). Catch this
-	 * case now and disable the serial driver from looking at 
-	 * these ioc3s. Identify MENET cards by seeing if an ioc3 is
-	 * at slot 3.
-	 */
-	d->subsystem_vendor = 0xFF00;
-	if (PCI_SLOT(d->devfn) == 3) {
-		struct list_head *p;
-		list_for_each(p, &d->bus->devices) {
-			list_entry(p, struct pci_dev, bus_list)->subsystem_vendor = 0;
-		}
-	}
 }
 
 static void __init
@@ -344,7 +323,8 @@
 	d->resource[0].start |= ((unsigned long)(bus_to_nid[d->bus->number])<<32);
 	printk("PCI: Fixing isp1020 in [bus:slot.fn] %s\n", d->slot_name);
 
-	/* Configure device to allow bus mastering, i/o and memory mapping. 
+	/*
+	 * Configure device to allow bus mastering, i/o and memory mapping. 
 	 * Older qlogicisp driver expects to have the IO space enable 
 	 * bit set. Things stop working if we program the controllers as not 
 	 * having PCI_COMMAND_MEMORY, so we have to fudge the mem_flags.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip27/ip27-setup.c linux/arch/mips64/sgi-ip27/ip27-setup.c
--- v2.4.9/linux/arch/mips64/sgi-ip27/ip27-setup.c	Tue Nov 28 21:42:04 2000
+++ linux/arch/mips64/sgi-ip27/ip27-setup.c	Sun Sep  9 10:43:02 2001
@@ -14,6 +14,7 @@
 #include <linux/spinlock.h>
 #include <linux/sched.h>
 #include <linux/smp.h>
+#include <asm/io.h>
 #include <asm/sn/types.h>
 #include <asm/sn/sn0/addrs.h>
 #include <asm/sn/sn0/hubni.h>
@@ -39,6 +40,7 @@
 #define DBG(x...)
 #endif
 
+unsigned long mips_io_port_base = IO_BASE;
 
 /*
  * get_nasid() returns the physical node id number of the caller.
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip27/ip27-timer.c linux/arch/mips64/sgi-ip27/ip27-timer.c
--- v2.4.9/linux/arch/mips64/sgi-ip27/ip27-timer.c	Tue Nov 28 21:42:04 2000
+++ linux/arch/mips64/sgi-ip27/ip27-timer.c	Sun Sep  9 10:43:02 2001
@@ -145,6 +145,9 @@
         }
 
 	write_unlock(&xtime_lock);
+
+	if (softirq_pending(cpu))
+		do_softirq();
 }
 
 unsigned long inline do_gettimeoffset(void)
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip32/Makefile linux/arch/mips64/sgi-ip32/Makefile
--- v2.4.9/linux/arch/mips64/sgi-ip32/Makefile	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/sgi-ip32/Makefile	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,27 @@
+#
+# Makefile for the SGI specific kernel interface routines
+# under Linux.
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+# Note 2! The CFLAGS definitions are now in the main makefile...
+
+.S.s:
+	$(CPP) $(CFLAGS) $< -o $*.s
+.S.o:
+	$(CC) $(CFLAGS) -c $< -o $*.o
+
+O_TARGET := ip32-kern.a
+
+all: ip32-kern.a ip32-irq-glue.o
+
+obj-y	+= ip32-irq.o ip32-rtc.o ip32-setup.o ip32-irq-glue.o \
+	 ip32-berr.o ip32-timer.o crime.o
+
+ifdef CONFIG_PCI
+obj-y   += ip32-pci.o ip32-pci-dma.o
+endif
+
+include $(TOPDIR)/Rules.make
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip32/crime.c linux/arch/mips64/sgi-ip32/crime.c
--- v2.4.9/linux/arch/mips64/sgi-ip32/crime.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/sgi-ip32/crime.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,50 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2001 Keith M Wesolowski
+ */
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <asm/ip32/crime.h>
+#include <asm/ptrace.h>
+#include <asm/promlib.h>
+
+void __init crime_init (void)
+{
+	u64 id = crime_read_64 (CRIME_ID);
+	u64 rev = id & CRIME_ID_REV;
+
+	id = (id & CRIME_ID_IDBITS) >> 4;
+
+	printk ("CRIME id %1lx rev %ld detected at %016lx\n", id, rev,
+		(unsigned long) CRIME_BASE);
+}
+
+/* XXX Like on Sun, these give us various useful information to printk. */
+void crime_memerr_intr (unsigned int irq, void *dev_id, struct pt_regs *regs)
+{
+	u64 memerr = crime_read_64 (CRIME_MEM_ERROR_STAT);
+	u64 addr = crime_read_64 (CRIME_MEM_ERROR_ADDR);
+	memerr &= CRIME_MEM_ERROR_STAT_MASK;
+	
+	printk ("CRIME memory error at physaddr 0x%08lx status %08lx\n",
+		addr << 2, memerr);
+
+	crime_write_64 (CRIME_MEM_ERROR_STAT, 0);
+}
+
+void crime_cpuerr_intr (unsigned int irq, void *dev_id, struct pt_regs *regs)
+{
+	u64 cpuerr = crime_read_64 (CRIME_CPU_ERROR_STAT);
+	u64 addr = crime_read_64 (CRIME_CPU_ERROR_ADDR);
+	cpuerr &= CRIME_CPU_ERROR_MASK;
+	addr <<= 2UL;
+
+	printk ("CRIME CPU interface error detected at %09lx status %08lx\n",
+		addr, cpuerr);
+
+	crime_write_64 (CRIME_CPU_ERROR_STAT, 0);
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip32/ip32-berr.c linux/arch/mips64/sgi-ip32/ip32-berr.c
--- v2.4.9/linux/arch/mips64/sgi-ip32/ip32-berr.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/sgi-ip32/ip32-berr.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,97 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 1994, 1995, 1996, 1999, 2000 by Ralf Baechle
+ * Copyright (C) 1999, 2000 by Silicon Graphics
+ */
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <asm/uaccess.h>
+#include <asm/paccess.h>
+#include <asm/addrspace.h>
+#include <asm/ptrace.h>
+
+/* XXX I have no idea what this does --kmw */
+
+extern asmlinkage void handle_ibe(void);
+extern asmlinkage void handle_dbe(void);
+
+extern const struct exception_table_entry __start___dbe_table[];
+extern const struct exception_table_entry __stop___dbe_table[];
+
+static inline unsigned long
+search_one_table(const struct exception_table_entry *first,
+                 const struct exception_table_entry *last,
+                 unsigned long value)
+{
+	while (first <= last) {
+		const struct exception_table_entry *mid;
+		long diff;
+
+		mid = (last - first) / 2 + first;
+		diff = mid->insn - value;
+		if (diff == 0)
+			return mid->nextinsn;
+		else if (diff < 0)
+			first = mid+1;
+		else
+			last = mid-1;
+	}
+	return 0;
+}
+
+static inline unsigned long
+search_dbe_table(unsigned long addr)
+{
+	unsigned long ret;
+
+	/* There is only the kernel to search.  */
+	ret = search_one_table(__start___dbe_table, __stop___dbe_table-1, addr);
+	if (ret) return ret;
+
+	return 0;
+}
+
+void do_ibe(struct pt_regs *regs)
+{
+	printk("Got ibe at 0x%lx\n", regs->cp0_epc);
+	show_regs(regs);
+	dump_tlb_addr(regs->cp0_epc);
+	force_sig(SIGBUS, current);
+	while(1);
+}
+
+void do_dbe(struct pt_regs *regs)
+{
+	unsigned long fixup;
+
+	fixup = search_dbe_table(regs->cp0_epc);
+	if (fixup) {
+		long new_epc;
+
+		new_epc = fixup_exception(dpf_reg, fixup, regs->cp0_epc);
+		regs->cp0_epc = new_epc;
+		return;
+	}
+
+	printk("Got dbe at 0x%lx\n", regs->cp0_epc);
+	show_regs(regs);
+	dump_tlb_all();
+	while(1);
+	force_sig(SIGBUS, current);
+}
+
+void __init
+bus_error_init(void)
+{
+	int dummy;
+
+	set_except_vector(6, handle_ibe);
+	set_except_vector(7, handle_dbe);
+
+	/* At this time nothing uses the DBE protection mechanism on the
+	   O2, so this here is needed to make the kernel link.  */
+	get_dbe(dummy, (int *)KSEG0);
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip32/ip32-irq-glue.S linux/arch/mips64/sgi-ip32/ip32-irq-glue.S
--- v2.4.9/linux/arch/mips64/sgi-ip32/ip32-irq-glue.S	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/sgi-ip32/ip32-irq-glue.S	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,87 @@
+/*
+ * Low level interrupt handler for the SGI O2 aka IP32 aka Moosehead
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2000 Harald Koerfgen
+ * Copyright (C) 2001 Keith M Wesolowski
+ */
+#include <asm/asm.h>
+#include <asm/regdef.h>
+#include <asm/mipsregs.h>
+#include <asm/stackframe.h>
+#include <asm/addrspace.h>
+#include <asm/ip32/ip32_ints.h>
+
+		.text
+		.set    noreorder
+		.set    noat
+		.align  5
+		NESTED(ip32_handle_int, PT_SIZE, ra)
+		.set    noat
+		SAVE_ALL
+		CLI			# TEST: interrupts should be off
+		.set    at
+		.set    noreorder
+
+		mfc0	s0,CP0_CAUSE
+
+		andi	t1, s0, IE_IRQ0
+		bnez	t1, handle_irq0
+		 andi	t1, s0, IE_IRQ1
+		bnez	t1, handle_irq1
+		 andi	t1, s0, IE_IRQ2
+		bnez	t1, handle_irq2
+		 andi	t1, s0, IE_IRQ3
+		bnez	t1, handle_irq3
+		 andi	t1, s0, IE_IRQ4
+		bnez	t1, handle_irq4
+		 andi	t1, s0, IE_IRQ5
+		bnez	t1, handle_irq5
+		 nop
+
+		/* Either someone has triggered the "software interrupts"
+		 * or we lost an interrupt somehow.  Ignore it.
+		 */
+		j	ret_from_irq
+		 nop
+
+handle_irq0:
+		jal	ip32_irq0
+		 move	a0, sp
+		j	ret_from_irq
+		 nop
+
+handle_irq1:
+		jal	ip32_irq1
+		 move	a0, sp
+		j	ret_from_irq
+		 nop
+
+handle_irq2:
+		jal	ip32_irq2
+		 move	a0, sp
+		j	ret_from_irq
+		 nop
+
+handle_irq3:
+		jal	ip32_irq3
+		 move	a0, sp
+		j	ret_from_irq
+		 nop
+
+handle_irq4:
+		jal	ip32_irq4
+		 move	a0, sp
+		j	ret_from_irq
+		 nop
+
+handle_irq5:
+		jal	ip32_irq5
+		move	a0, sp
+		j	ret_from_irq
+		 nop
+
+		END(ip32_handle_int)
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip32/ip32-irq.c linux/arch/mips64/sgi-ip32/ip32-irq.c
--- v2.4.9/linux/arch/mips64/sgi-ip32/ip32-irq.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/sgi-ip32/ip32-irq.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,556 @@
+/*
+ * Code to handle IP32 IRQs
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2000 Harald Koerfgen
+ * Copyright (C) 2001 Keith M Wesolowski
+ */
+#include <linux/init.h>
+#include <linux/kernel_stat.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/bitops.h>
+
+#include <asm/bitops.h>
+#include <asm/mipsregs.h>
+#include <asm/system.h>
+#include <asm/ip32/ip32_ints.h>
+#include <asm/ip32/crime.h>
+#include <asm/ip32/mace.h>
+#include <asm/signal.h>
+
+#undef DEBUG_IRQ
+#ifdef DEBUG_IRQ
+#define DBG(x...) printk(x)
+#else
+#define DBG(x...)
+#endif
+
+/* O2 irq map
+ *
+ * IP0 -> software (ignored)
+ * IP1 -> software (ignored)
+ * IP2 -> (irq0) C crime 1.1 all interrupts; crime 1.5 ???
+ * IP3 -> (irq1) X unknown
+ * IP4 -> (irq2) X unknown
+ * IP5 -> (irq3) X unknown
+ * IP6 -> (irq4) X unknown
+ * IP7 -> (irq5) 0 CPU count/compare timer (system timer)
+ *
+ * crime: (C)
+ *
+ * CRIME_INT_STAT 31:0:
+ *
+ * 0 -> 1 Video in 1
+ * 1 -> 2 Video in 2
+ * 2 -> 3 Video out
+ * 3 -> 4 Mace ethernet
+ * 4 -> S  SuperIO sub-interrupt
+ * 5 -> M  Miscellaneous sub-interrupt
+ * 6 -> A  Audio sub-interrupt
+ * 7 -> 8  PCI bridge errors
+ * 8 -> 9  PCI SCSI aic7xxx 0
+ * 9 -> 10  PCI SCSI aic7xxx 1
+ * 10 -> 11 PCI slot 0
+ * 11 -> 12 unused (PCI slot 1)
+ * 12 -> 13 unused (PCI slot 2)
+ * 13 -> 14 unused (PCI shared 0)
+ * 14 -> 15 unused (PCI shared 1)
+ * 15 -> 16 unused (PCI shared 2)
+ * 16 -> 17 GBE0 (E)
+ * 17 -> 18 GBE1 (E)
+ * 18 -> 19 GBE2 (E)
+ * 19 -> 20 GBE3 (E)
+ * 20 -> 21 CPU errors
+ * 21 -> 22 Memory errors
+ * 22 -> 23 RE empty edge (E)
+ * 23 -> 24 RE full edge (E)
+ * 24 -> 25 RE idle edge (E)
+ * 25 -> 26 RE empty level
+ * 26 -> 27 RE full level
+ * 27 -> 28 RE idle level
+ * 28 -> 29  unused (software 0) (E)
+ * 29 -> 30  unused (software 1) (E)
+ * 30 -> 31  unused (software 2) - crime 1.5 CPU SysCorError (E)
+ * 31 -> 32 VICE
+ *
+ * S, M, A: Use the MACE ISA interrupt register
+ * MACE_ISA_INT_STAT 31:0
+ *
+ * 0-7 -> 33-40 Audio
+ * 8 -> 41 RTC
+ * 9 -> 42 Keyboard
+ * 10 -> X Keyboard polled
+ * 11 -> 44 Mouse
+ * 12 -> X Mouse polled
+ * 13-15 -> 46-48 Count/compare timers
+ * 16-19 -> 49-52 Parallel (16 E)
+ * 20-25 -> 53-58 Serial 1 (22 E)
+ * 26-31 -> 59-64 Serial 2 (28 E)
+ *
+ * Note that this means IRQs 5-7, 43, and 45 do not exist.  This is a
+ * different IRQ map than IRIX uses, but that's OK as Linux irq handling
+ * is quite different anyway.
+ */
+
+/* Some initial interrupts to set up */
+extern void crime_memerr_intr (unsigned int irq, void *dev_id,
+			       struct pt_regs *regs);
+extern void crime_cpuerr_intr (unsigned int irq, void *dev_id,
+			       struct pt_regs *regs);
+
+struct irqaction memerr_irq = { crime_memerr_intr, SA_INTERRUPT,
+			       0, "CRIME memory error", NULL,
+			       NULL };
+struct irqaction cpuerr_irq = { crime_cpuerr_intr, SA_INTERRUPT,
+			       0, "CRIME CPU error", NULL,
+			       NULL };
+
+unsigned long spurious_count = 0;
+extern void ip32_handle_int (void);
+extern void do_IRQ (unsigned int irq, struct pt_regs *regs);
+
+/* For interrupts wired from a single device to the CPU.  Only the clock
+ * uses this it seems, which is IRQ 0 and IP7.
+ */
+
+static void enable_cpu_irq (unsigned int irq)
+{
+	set_cp0_status (STATUSF_IP7);
+}
+
+static unsigned int startup_cpu_irq (unsigned int irq) {
+	enable_cpu_irq (irq);
+	return 0;
+}
+
+static void disable_cpu_irq (unsigned int irq)
+{
+	clear_cp0_status (STATUSF_IP7);
+}
+
+static void end_cpu_irq (unsigned int irq)
+{
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_cpu_irq (irq);
+}
+
+#define shutdown_cpu_irq disable_cpu_irq
+#define mask_and_ack_cpu_irq disable_cpu_irq
+
+static struct hw_interrupt_type ip32_cpu_interrupt = {
+	"IP32 CPU",
+	startup_cpu_irq,
+	shutdown_cpu_irq,
+	enable_cpu_irq,
+	disable_cpu_irq,
+	mask_and_ack_cpu_irq,
+	end_cpu_irq,
+	NULL
+};
+
+/*
+ * This is for pure CRIME interrupts - ie not MACE.  The advantage?
+ * We get to split the register in half and do faster lookups.
+ */
+
+static void enable_crime_irq (unsigned int irq)
+{
+	u64 crime_mask;
+	unsigned long flags;
+
+	save_and_cli (flags);
+	crime_mask = crime_read_64 (CRIME_INT_MASK);
+	crime_mask |= 1 << (irq - 1);
+	crime_write_64 (CRIME_INT_MASK, crime_mask);
+	restore_flags (flags);
+}
+
+static unsigned int startup_crime_irq (unsigned int irq)
+{
+	enable_crime_irq (irq);
+	return 0; /* This is probably not right; we could have pending irqs */
+}
+
+static void disable_crime_irq (unsigned int irq)
+{
+	u64 crime_mask;
+	unsigned long flags;
+
+	save_and_cli (flags);
+	crime_mask = crime_read_64 (CRIME_INT_MASK);
+	crime_mask &= ~(1 << (irq - 1));
+	crime_write_64 (CRIME_INT_MASK, crime_mask);
+	restore_flags (flags);
+}
+
+static void mask_and_ack_crime_irq (unsigned int irq)
+{
+	u64 crime_mask;
+	unsigned long flags;
+
+	/* Edge triggered interrupts must be cleared. */
+	if ((irq <= CRIME_GBE0_IRQ && irq >= CRIME_GBE3_IRQ)
+	    || (irq <= CRIME_RE_EMPTY_E_IRQ && irq >= CRIME_RE_IDLE_E_IRQ)
+	    || (irq <= CRIME_SOFT0_IRQ && irq >= CRIME_SOFT2_IRQ)) {
+		save_and_cli (flags);
+		crime_mask = crime_read_64 (CRIME_HARD_INT);
+		crime_mask &= ~(1 << (irq - 1));
+		crime_write_64 (CRIME_HARD_INT, crime_mask);
+		restore_flags (flags);
+	}
+	disable_crime_irq (irq);
+}
+	
+static void end_crime_irq (unsigned int irq)
+{
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_crime_irq (irq);
+}
+
+#define shutdown_crime_irq disable_crime_irq
+
+static struct hw_interrupt_type ip32_crime_interrupt = {
+	"IP32 CRIME",
+	startup_crime_irq,
+	shutdown_crime_irq,
+	enable_crime_irq,
+	disable_crime_irq,
+	mask_and_ack_crime_irq,
+	end_crime_irq,
+	NULL
+};
+
+/* This is for MACE PCI interrupts.  We can decrease bus traffic by masking
+ * as close to the source as possible.  This also means we can take the
+ * next chunk of the CRIME register in one piece.
+ */
+
+static void enable_macepci_irq (unsigned int irq)
+{
+	u32 mace_mask;
+	u64 crime_mask;
+	unsigned long flags;
+
+	save_and_cli (flags);
+	mace_mask = mace_read_32 (MACEPCI_CONTROL);
+	mace_mask |= MACEPCI_CONTROL_INT (irq - 9);
+	mace_write_32 (MACEPCI_CONTROL, mace_mask);
+	/* In case the CRIME interrupt isn't enabled, we must enable it;
+	 * however, we never disable interrupts at that level.
+	 */
+	crime_mask = crime_read_64 (CRIME_INT_MASK);
+	crime_mask |= 1 << (irq - 1);
+	crime_write_64 (CRIME_INT_MASK, crime_mask);
+	restore_flags (flags);
+}
+
+static unsigned int startup_macepci_irq (unsigned int irq) {
+	enable_macepci_irq (irq);
+	return 0; /* XXX */
+}
+
+static void disable_macepci_irq (unsigned int irq)
+{
+	u32 mace_mask;
+	unsigned long flags;
+
+	save_and_cli (flags);
+	mace_mask = mace_read_32 (MACEPCI_CONTROL);
+	mace_mask &= ~MACEPCI_CONTROL_INT (irq - 9);
+	mace_write_32 (MACEPCI_CONTROL, mace_mask);
+	restore_flags (flags);
+}
+
+static void end_macepci_irq (unsigned int irq)
+{
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_macepci_irq (irq);
+}
+
+#define shutdown_macepci_irq disable_macepci_irq
+#define mask_and_ack_macepci_irq disable_macepci_irq
+
+static struct hw_interrupt_type ip32_macepci_interrupt = {
+	"IP32 MACE PCI",
+	startup_macepci_irq,
+	shutdown_macepci_irq,
+	enable_macepci_irq,
+	disable_macepci_irq,
+	mask_and_ack_macepci_irq,
+	end_macepci_irq,
+	NULL
+};
+
+/* This is used for MACE ISA interrupts.  That means bits 4-6 in the
+ * CRIME register.
+ */
+
+static void enable_maceisa_irq (unsigned int irq)
+{
+	u64 crime_mask;
+	u32 mace_mask;
+	unsigned int crime_int = 0;
+	unsigned long flags;
+
+	DBG ("maceisa enable: %u\n", irq);
+	
+	switch (irq) {
+	case MACEISA_AUDIO_SW_IRQ ... MACEISA_AUDIO3_MERR_IRQ:
+		crime_int = MACE_AUDIO_INT;
+		break;
+	case MACEISA_RTC_IRQ ... MACEISA_TIMER2_IRQ:
+		crime_int = MACE_MISC_INT;
+		break;
+	case MACEISA_PARALLEL_IRQ ... MACEISA_SERIAL2_RDMAOR_IRQ:
+		crime_int = MACE_SUPERIO_INT;
+		break;
+	}
+	DBG ("crime_int %016lx enabled\n", crime_int);
+	save_and_cli (flags);
+	crime_mask = crime_read_64 (CRIME_INT_MASK);
+	crime_mask |= crime_int;
+	crime_write_64 (CRIME_INT_MASK, crime_mask);
+	mace_mask = mace_read_32 (MACEISA_INT_MASK);
+	mace_mask |= 1 << (irq - 33);
+	mace_write_32 (MACEISA_INT_MASK, mace_mask);
+	restore_flags (flags);
+}
+
+static unsigned int startup_maceisa_irq (unsigned int irq) {
+	enable_maceisa_irq (irq);
+	return 0;
+}
+
+static void disable_maceisa_irq (unsigned int irq)
+{
+	u32 mace_mask;
+	unsigned long flags;
+
+	save_and_cli (flags);
+	mace_mask = mace_read_32 (MACEISA_INT_MASK);
+	mace_mask &= ~(1 << (irq - 33));
+	mace_write_32 (MACEISA_INT_MASK, mace_mask);
+	restore_flags (flags);
+}
+
+static void mask_and_ack_maceisa_irq (unsigned int irq)
+{
+	u32 mace_mask;
+	unsigned long flags;
+
+	switch (irq) {
+	case MACEISA_PARALLEL_IRQ:
+	case MACEISA_SERIAL1_TDMAPR_IRQ:
+	case MACEISA_SERIAL2_TDMAPR_IRQ:
+		save_and_cli (flags);
+		mace_mask = mace_read_32 (MACEISA_INT_STAT);
+		mace_mask &= ~(1 << (irq - 33));
+		mace_write_32 (MACEISA_INT_STAT, mace_mask);
+		restore_flags (flags);
+		break;
+	}
+	disable_maceisa_irq (irq);
+}
+
+static void end_maceisa_irq (unsigned irq)
+{
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_maceisa_irq (irq);
+}
+
+#define shutdown_maceisa_irq disable_maceisa_irq
+
+static struct hw_interrupt_type ip32_maceisa_interrupt = {
+	"IP32 MACE ISA",
+	startup_maceisa_irq,
+	shutdown_maceisa_irq,
+	enable_maceisa_irq,
+	disable_maceisa_irq,
+	mask_and_ack_maceisa_irq,
+	end_maceisa_irq,
+	NULL
+};
+
+/* This is used for regular non-ISA, non-PCI MACE interrupts.  That means
+ * bits 0-3 and 7 in the CRIME register.
+ */
+
+static void enable_mace_irq (unsigned int irq)
+{
+	u64 crime_mask;
+	unsigned long flags;
+
+	save_and_cli (flags);
+	crime_mask = crime_read_64 (CRIME_INT_MASK);
+	crime_mask |= 1 << (irq - 1);
+	crime_write_64 (CRIME_INT_MASK, crime_mask);
+	restore_flags (flags);
+}
+
+static unsigned int startup_mace_irq (unsigned int irq)
+{
+	enable_mace_irq (irq);
+	return 0;
+}
+
+static void disable_mace_irq (unsigned int irq)
+{
+	u64 crime_mask;
+	unsigned long flags;
+
+	save_and_cli (flags);
+	crime_mask = crime_read_64 (CRIME_INT_MASK);
+	crime_mask &= ~(1 << (irq - 1));
+	crime_write_64 (CRIME_INT_MASK, crime_mask);
+	restore_flags (flags);
+}
+
+static void end_mace_irq (unsigned int irq)
+{
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_mace_irq (irq);
+}
+
+#define shutdown_mace_irq disable_mace_irq
+#define mask_and_ack_mace_irq disable_mace_irq
+
+static struct hw_interrupt_type ip32_mace_interrupt = {
+	"IP32 MACE",
+	startup_mace_irq,
+	shutdown_mace_irq,
+	enable_mace_irq,
+	disable_mace_irq,
+	mask_and_ack_mace_irq,
+	end_mace_irq,
+	NULL
+};
+
+static void ip32_unknown_interrupt (struct pt_regs *regs)
+{
+	u64 crime;
+	u32 mace;
+	
+	printk ("Unknown interrupt occurred!\n");
+	printk ("cp0_status: %08x\tcp0_cause: %08x\n",
+		read_32bit_cp0_register (CP0_STATUS),
+		read_32bit_cp0_register (CP0_CAUSE));
+	crime = crime_read_64 (CRIME_INT_MASK);
+	printk ("CRIME interrupt mask: %016lx\n", crime);
+	crime = crime_read_64 (CRIME_INT_STAT);
+	printk ("CRIME interrupt status: %016lx\n", crime);
+	crime = crime_read_64 (CRIME_HARD_INT);
+	printk ("CRIME hardware interrupt register: %016lx\n", crime);
+	mace = mace_read_32 (MACEISA_INT_MASK);
+	printk ("MACE ISA interrupt mask: %08x\n", mace);
+	mace = mace_read_32 (MACEISA_INT_STAT);
+	printk ("MACE ISA interrupt status: %08x\n", mace);
+	mace = mace_read_32 (MACEPCI_CONTROL);
+	printk ("MACE PCI control register: %08x\n", mace);
+
+	printk ("Register dump:\n");
+	show_regs (regs);
+
+	printk ("Please mail this report to linux-mips@oss.sgi.com\n");
+	printk ("Spinning...");
+	while (1) ;
+}
+
+void __init ip32_irq_init(void)
+{
+	unsigned int irq;
+	extern void init_generic_irq (void);
+	
+	/* Install our interrupt handler, then clear and disable all
+	 * CRIME and MACE interrupts.
+	 */
+	crime_write_64 (CRIME_INT_MASK, 0);
+	crime_write_64 (CRIME_HARD_INT, 0);
+	crime_write_64 (CRIME_SOFT_INT, 0);
+	mace_write_32 (MACEISA_INT_STAT, 0);
+	mace_write_32 (MACEISA_INT_MASK, 0);
+	set_except_vector(0, ip32_handle_int);
+
+	init_generic_irq ();
+
+	for (irq = 0; irq <= IP32_IRQ_MAX; irq++) {
+		hw_irq_controller *controller;
+
+		if (irq == CLOCK_IRQ)
+			controller = &ip32_cpu_interrupt;
+		else if (irq <= MACE_PCI_BRIDGE_IRQ && irq >= MACE_VID_IN1_IRQ)
+			controller = &ip32_mace_interrupt;
+		else if (irq <= MACEPCI_SHARED2_IRQ && irq >= MACEPCI_SCSI0_IRQ)
+			controller = &ip32_macepci_interrupt;
+		else if (irq <= CRIME_VICE_IRQ && irq >= CRIME_GBE0_IRQ)
+			controller = &ip32_crime_interrupt;
+		else
+			controller = &ip32_maceisa_interrupt;
+
+		irq_desc[irq].status = IRQ_DISABLED;
+		irq_desc[irq].action = 0;
+		irq_desc[irq].depth = 0;
+		irq_desc[irq].handler = controller;
+	}
+	setup_irq (CRIME_MEMERR_IRQ, &memerr_irq);
+	setup_irq (CRIME_CPUERR_IRQ, &cpuerr_irq);
+}
+
+/* CRIME 1.1 appears to deliver all interrupts to this one pin. */
+void ip32_irq0 (struct pt_regs *regs)
+{
+	u64 crime_int = crime_read_64 (CRIME_INT_STAT);
+	int irq = 0;
+	
+	if (crime_int & CRIME_MACE_INT_MASK) {
+		crime_int &= CRIME_MACE_INT_MASK;
+		irq = ffs (crime_int);
+	} else if (crime_int & CRIME_MACEISA_INT_MASK) {
+		u32 mace_int;
+		mace_int = mace_read_32 (MACEISA_INT_STAT);
+		if (mace_int == 0)
+			irq = 0;
+		else
+			irq = ffs (mace_int) + 32;
+	} else if (crime_int & CRIME_MACEPCI_INT_MASK) {
+		crime_int &= CRIME_MACEPCI_INT_MASK;
+		crime_int >>= 8;
+		irq = ffs (crime_int) + 8;
+	} else if (crime_int & 0xffff0000) {
+		crime_int >>= 16;
+		irq = ffs (crime_int) + 16;
+	}
+	if (irq == 0)
+		ip32_unknown_interrupt (regs);
+	DBG ("*irq %u*\n", irq);
+	do_IRQ (irq, regs);
+}
+
+void ip32_irq1 (struct pt_regs *regs)
+{
+	ip32_unknown_interrupt (regs);
+}
+
+void ip32_irq2 (struct pt_regs *regs)
+{
+	ip32_unknown_interrupt (regs);
+}
+
+void ip32_irq3 (struct pt_regs *regs)
+{
+	ip32_unknown_interrupt (regs);
+}
+
+void ip32_irq4 (struct pt_regs *regs)
+{
+	ip32_unknown_interrupt (regs);
+}
+
+void ip32_irq5 (struct pt_regs *regs)
+{
+	do_IRQ (CLOCK_IRQ, regs);
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip32/ip32-pci-dma.c linux/arch/mips64/sgi-ip32/ip32-pci-dma.c
--- v2.4.9/linux/arch/mips64/sgi-ip32/ip32-pci-dma.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/sgi-ip32/ip32-pci-dma.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,41 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2000  Ani Joshi <ajoshi@unixbox.com>
+ * Copyright (C) 2000  Ralf Baechle <ralf@gnu.org>
+ * swiped from i386, and cloned for MIPS by Geert, polished by Ralf.
+ */
+#include <linux/types.h>
+#include <linux/mm.h>
+#include <linux/string.h>
+#include <linux/pci.h>
+
+#include <asm/io.h>
+#include <asm/addrspace.h>
+#include <asm/ip32/mace.h>
+
+void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
+			   dma_addr_t * dma_handle)
+{
+	void *ret;
+	int gfp = GFP_ATOMIC;
+
+	if (hwdev == NULL || hwdev->dma_mask != 0xffffffff)
+		gfp |= GFP_DMA;
+	ret = (void *) __get_free_pages(gfp, get_order(size));
+
+	if (ret != NULL) {
+		memset(ret, 0, size);
+		dma_cache_wback_inv((unsigned long) ret, size);
+		*dma_handle = virt_to_bus(ret);
+	}
+	return ret;
+}
+
+void pci_free_consistent(struct pci_dev *hwdev, size_t size,
+			 void *vaddr, dma_addr_t dma_handle)
+{
+	free_pages((unsigned long) vaddr, get_order(size));
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip32/ip32-pci.c linux/arch/mips64/sgi-ip32/ip32-pci.c
--- v2.4.9/linux/arch/mips64/sgi-ip32/ip32-pci.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/sgi-ip32/ip32-pci.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,438 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2000, 2001 Keith M Wesolowski
+ */
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/types.h>
+#include <asm/pci.h>
+#include <asm/ip32/mace.h>
+#include <asm/ip32/crime.h>
+#include <asm/ip32/ip32_ints.h>
+#include <linux/delay.h>
+
+#undef DEBUG_MACE_PCI
+
+/*
+ * O2 has up to 5 PCI devices connected into the MACE bridge.  The device
+ * map looks like this:
+ *
+ * 0  aic7xxx 0
+ * 1  aic7xxx 1
+ * 2  expansion slot
+ * 3  N/C
+ * 4  N/C
+ */
+
+#define chkslot(dev)							\
+do {									\
+	if ((dev)->bus->number > 0 || PCI_SLOT ((dev)->devfn) < 1	\
+	    || PCI_SLOT ((dev)->devfn) > 3)				\
+		return PCIBIOS_DEVICE_NOT_FOUND;			\
+} while (0)
+		
+#define mkaddr(dev, where) \
+((((dev)->devfn & 0xffUL) << 8) | ((where) & 0xfcUL))
+
+void macepci_error (int irq, void *dev, struct pt_regs *regs);
+
+static int macepci_read_config_byte (struct pci_dev *dev, int where,
+				     u8 *val)
+{
+	*val = 0xff;
+	chkslot (dev);
+	mace_write_32 (MACEPCI_CONFIG_ADDR, mkaddr (dev, where));
+	*val = mace_read_8 (MACEPCI_CONFIG_DATA + ((where & 3UL) ^ 3UL));
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int macepci_read_config_word (struct pci_dev *dev, int where,
+				     u16 *val)
+{
+	*val = 0xffff;
+	chkslot (dev);
+	if (where & 1)
+		return PCIBIOS_BAD_REGISTER_NUMBER;
+ 	mace_write_32 (MACEPCI_CONFIG_ADDR, mkaddr (dev, where));
+	*val = mace_read_16 (MACEPCI_CONFIG_DATA + ((where & 2UL) ^ 2UL));
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int macepci_read_config_dword (struct pci_dev *dev, int where,
+				      u32 *val)
+{
+	*val = 0xffffffff;
+	chkslot (dev);
+	if (where & 3)
+		return PCIBIOS_BAD_REGISTER_NUMBER;
+	mace_write_32 (MACEPCI_CONFIG_ADDR, mkaddr (dev, where));
+	*val = mace_read_32 (MACEPCI_CONFIG_DATA);
+	
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int macepci_write_config_byte (struct pci_dev *dev, int where,
+				      u8 val)
+{
+	chkslot (dev);
+	mace_write_32 (MACEPCI_CONFIG_ADDR, mkaddr (dev, where));
+	mace_write_8 (MACEPCI_CONFIG_DATA + ((where & 3UL) ^ 3UL), val);
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int macepci_write_config_word (struct pci_dev *dev, int where,
+				      u16 val)
+{
+	chkslot (dev);
+	if (where & 1)
+		return PCIBIOS_BAD_REGISTER_NUMBER;
+	mace_write_32 (MACEPCI_CONFIG_ADDR, mkaddr (dev, where));
+	mace_write_16 (MACEPCI_CONFIG_DATA + ((where & 2UL) ^ 2UL), val);
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int macepci_write_config_dword (struct pci_dev *dev, int where,
+                                          u32 val)
+{
+	chkslot (dev);
+	if (where & 3)
+		return PCIBIOS_BAD_REGISTER_NUMBER;
+	mace_write_32 (MACEPCI_CONFIG_ADDR, mkaddr (dev, where));
+	mace_write_32 (MACEPCI_CONFIG_DATA, val);
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static struct pci_ops macepci_ops = {
+	macepci_read_config_byte,
+	macepci_read_config_word,
+	macepci_read_config_dword,
+	macepci_write_config_byte,
+	macepci_write_config_word,
+	macepci_write_config_dword
+};
+
+struct pci_fixup pcibios_fixups[] = { { 0 } };
+
+void __init pcibios_init (void)
+{
+	struct pci_dev *dev;
+	u32 start, size;
+	u16 cmd;
+	u32 base_io = 0x3000; /* The first i/o address to assign after SCSI */
+	u32 base_mem = 0x80100000; /* Likewise */
+	u32 rev = mace_read_32 (MACEPCI_REV);
+	int i;
+
+	printk ("MACE: PCI rev %d detected at %016lx\n", rev,
+		(u64) MACE_BASE + MACE_PCI);
+
+	/* These are *bus* addresses */
+	ioport_resource.start = 0;
+	ioport_resource.end = 0xffffffffUL;
+	iomem_resource.start = 0x80000000UL;
+	iomem_resource.end = 0xffffffffUL;
+
+	/* Clear any outstanding errors and enable interrupts */
+	mace_write_32 (MACEPCI_ERROR_ADDR, 0);
+	mace_write_32 (MACEPCI_ERROR_FLAGS, 0);
+	mace_write_32 (MACEPCI_CONTROL, 0xff008500);
+	crime_write_64 (CRIME_HARD_INT, 0UL);
+	crime_write_64 (CRIME_SOFT_INT, 0UL);
+	crime_write_64 (CRIME_INT_STAT, 0x000000000000ff00UL);
+
+	if (request_irq (MACE_PCI_BRIDGE_IRQ, macepci_error, 0,
+			 "MACE PCI error", NULL))
+		panic ("PCI bridge can't get interrupt; can't happen.\n");
+
+	pci_scan_bus (0, &macepci_ops, NULL);
+
+#ifdef DEBUG_MACE_PCI
+	pci_for_each_dev (dev) {
+		printk ("Device: %d/%d/%d ARCS-assigned bus resource map\n",
+			dev->bus->number, PCI_SLOT (dev->devfn),
+			PCI_FUNC (dev->devfn));
+		for (i=0; i < DEVICE_COUNT_RESOURCE; i++) {
+			if (dev->resource[i].start == 0)
+				continue;
+			printk ("%d: %016lx - %016lx (flags %04lx)\n",
+				i, dev->resource[i].start,
+				dev->resource[i].end, dev->resource[i].flags);
+		}
+	}
+#endif
+	/*
+	 * Assign sane resources to and enable all devices.  The requirement
+	 * for the SCSI controllers is well-known: a 256-byte I/O region
+	 * which we must assign, and a 1-page memory region which is
+	 * assigned by the system firmware.
+	 */
+	pci_for_each_dev (dev) {
+		switch (PCI_SLOT (dev->devfn)) {
+		case 1: /* SCSI bus 0 */
+			dev->resource[0].start = 0x1000UL;
+			dev->resource[0].end = 0x10ffUL;
+			break;
+		case 2: /* SCSI bus 1 */
+			dev->resource[0].start = 0x2000UL;
+			dev->resource[0].end = 0x20ffUL;
+			break;
+		default: /* Slots - I guess we have only 1 */
+			for (i=0; i < 6; i++) {
+				size = dev->resource[i].end
+					- dev->resource[i].start;
+				if (!size
+				    || !(dev->resource[i].flags
+					 & (IORESOURCE_IO|IORESOURCE_MEM))) {
+					dev->resource[i].start
+						= dev->resource[i].end = 0UL;
+					continue;
+				}
+				if (dev->resource[i].flags & IORESOURCE_IO) {
+					dev->resource[i].start = base_io;
+					base_io += PAGE_ALIGN (size);
+				} else {
+					dev->resource[i].start = base_mem;
+					base_mem += 0x100000UL;
+				}
+				dev->resource[i].end =
+					dev->resource[i].start + size;
+			}
+			break;
+		}
+		for (i=0; i < 6; i++) {
+			if (dev->resource[i].start == 0)
+				continue;
+			start = dev->resource[i].start;
+			if (dev->resource[i].flags & IORESOURCE_IO)
+				start |= 1;
+			pci_write_config_dword (dev, 
+				PCI_BASE_ADDRESS_0 + (i << 2), (u32) start);
+		}
+		pci_write_config_byte (dev, PCI_CACHE_LINE_SIZE, 0x20);
+		pci_write_config_byte (dev, PCI_LATENCY_TIMER, 0x30);
+		pci_read_config_word (dev, PCI_COMMAND, &cmd);
+		cmd |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_PARITY);
+		pci_write_config_word (dev, PCI_COMMAND, cmd);
+		pci_set_master (dev);
+	}
+
+#ifdef DEBUG_MACE_PCI
+	printk ("Triggering PCI bridge interrupt...\n");
+	mace_write_32 (MACEPCI_ERROR_FLAGS, MACEPCI_ERROR_INTERRUPT_TEST);
+
+	pci_for_each_dev (dev) {
+		printk ("Device: %d/%d/%d final bus resource map\n",
+			dev->bus->number, PCI_SLOT (dev->devfn),
+			PCI_FUNC (dev->devfn));
+		for (i=0; i < DEVICE_COUNT_RESOURCE; i++) {
+			if (dev->resource[i].start == 0)
+				continue;
+			printk ("%d: %016lx - %016lx (flags %04lx)\n",
+				i, dev->resource[i].start,
+				dev->resource[i].end, dev->resource[i].flags);
+		}
+	}
+#endif
+}
+
+/*
+ * Given a PCI slot number (a la PCI_SLOT(...)) and the interrupt pin of
+ * the device (1-4 => A-D), tell what irq to use.  Note that we don't
+ * in theory have slots 4 and 5, and we never normally use the shared
+ * irqs.  I suppose a device without a pin A will thank us for doing it
+ * right if there exists such a broken piece of crap.
+ */
+static int __init macepci_map_irq (struct pci_dev *dev, u8 slot, u8 pin)
+{
+	chkslot (dev);
+	if (pin == 0)
+		pin = 1;
+	switch (slot) {
+	case 1:
+		return MACEPCI_SCSI0_IRQ;
+	case 2:
+		return MACEPCI_SCSI1_IRQ;
+	case 3:
+		switch (pin) {
+		case 2:
+			return MACEPCI_SHARED0_IRQ;
+		case 3:
+			return MACEPCI_SHARED1_IRQ;
+		case 4:
+			return MACEPCI_SHARED2_IRQ;
+		case 1:
+		default:
+			return MACEPCI_SLOT0_IRQ;
+		}
+	case 4:
+		switch (pin) {
+		case 2:
+			return MACEPCI_SHARED2_IRQ;
+		case 3:
+			return MACEPCI_SHARED0_IRQ;
+		case 4:
+			return MACEPCI_SHARED1_IRQ;
+		case 1:
+		default:
+			return MACEPCI_SLOT1_IRQ;
+		}
+		return MACEPCI_SLOT1_IRQ;
+	case 5:
+		switch (pin) {
+		case 2:
+			return MACEPCI_SHARED1_IRQ;
+		case 3:
+			return MACEPCI_SHARED2_IRQ;
+		case 4:
+			return MACEPCI_SHARED0_IRQ;
+		case 1:
+		default:
+			return MACEPCI_SLOT2_IRQ;
+		}
+	default:
+		return 0;
+	}
+}
+
+/*
+ * It's not entirely clear what this does in a system with no bridges.
+ * In any case, bridges are not supported by Linux in O2.
+ */
+static u8 __init macepci_swizzle (struct pci_dev *dev, u8 *pinp)
+{
+	if (PCI_SLOT (dev->devfn) == 2)
+		*pinp = 2;
+	else
+		*pinp = 1;
+	return PCI_SLOT (dev->devfn);
+}
+
+/* All devices are enabled during initialization. */
+int pcibios_enable_device (struct pci_dev *dev)
+{
+	return PCIBIOS_SUCCESSFUL;
+}
+
+char * __init pcibios_setup (char *str)
+{
+	return str;
+}
+
+void __init pcibios_align_resource (void *data, struct resource *res,
+				    unsigned long size)
+{
+}
+
+void __init pcibios_update_resource (struct pci_dev *dev, struct resource *root,
+				     struct resource *res, int resource)
+{
+}
+
+void __init pcibios_update_irq (struct pci_dev *dev, int irq)
+{
+	pci_write_config_byte (dev, PCI_INTERRUPT_LINE, irq);
+}
+
+void __init pcibios_fixup_bus (struct pci_bus *b)
+{
+	pci_fixup_irqs (macepci_swizzle, macepci_map_irq);
+}
+
+/* XXX anybody know what this is supposed to do? */
+void __init pcibios_fixup_pbus_ranges(struct pci_bus * bus,
+				      struct pbus_set_ranges_data * ranges)
+{
+	ranges->io_start -= bus->resource[0]->start;
+	ranges->io_end -= bus->resource[0]->start;
+	ranges->mem_start -= bus->resource[1]->start;
+	ranges->mem_end -= bus->resource[1]->start;
+}
+
+/*
+ * Handle errors from the bridge.  This includes master and target aborts,
+ * various command and address errors, and the interrupt test.  This gets
+ * registered on the bridge error irq.  It's conceivable that some of these
+ * conditions warrant a panic.  Anybody care to say which ones?
+ */
+void macepci_error (int irq, void *dev, struct pt_regs *regs) {
+	u32 flags, error_addr;
+	char space;
+
+	flags = mace_read_32 (MACEPCI_ERROR_FLAGS);
+	error_addr = mace_read_32 (MACEPCI_ERROR_ADDR);
+
+	if (flags & MACEPCI_ERROR_MEMORY_ADDR)
+		space = 'M';
+	else if (flags & MACEPCI_ERROR_CONFIG_ADDR)
+		space = 'C';
+	else space = 'X';
+	
+	if (flags & MACEPCI_ERROR_MASTER_ABORT) {
+		printk ("MACEPCI: Master abort at 0x%08x (%c)\n", error_addr,
+			space);
+		mace_write_32 (MACEPCI_ERROR_FLAGS, flags
+			       & ~MACEPCI_ERROR_MASTER_ABORT);
+	}
+	if (flags & MACEPCI_ERROR_TARGET_ABORT) {
+		printk ("MACEPCI: Target abort at 0x%08x (%c)\n", error_addr,
+			space);
+		mace_write_32 (MACEPCI_ERROR_FLAGS, flags
+			       & ~MACEPCI_ERROR_TARGET_ABORT);
+	}
+	if (flags & MACEPCI_ERROR_DATA_PARITY_ERR) {
+		printk ("MACEPCI: Data parity error at 0x%08x (%c)\n",
+			error_addr, space);
+		mace_write_32 (MACEPCI_ERROR_FLAGS, flags
+			       & ~MACEPCI_ERROR_DATA_PARITY_ERR);
+	}
+	if (flags & MACEPCI_ERROR_RETRY_ERR) {
+		printk ("MACEPCI: Retry error at 0x%08x (%c)\n", error_addr,
+			space);
+		mace_write_32 (MACEPCI_ERROR_FLAGS, flags
+			       & ~MACEPCI_ERROR_RETRY_ERR);
+	}
+	if (flags & MACEPCI_ERROR_ILLEGAL_CMD) {
+		printk ("MACEPCI: Illegal command at 0x%08x (%c)\n",
+			error_addr, space);
+		mace_write_32 (MACEPCI_ERROR_FLAGS,
+			       flags & ~MACEPCI_ERROR_ILLEGAL_CMD);
+	}
+	if (flags & MACEPCI_ERROR_SYSTEM_ERR) {
+		printk ("MACEPCI: System error at 0x%08x (%c)\n",
+			error_addr, space);
+		mace_write_32 (MACEPCI_ERROR_FLAGS, flags
+			       & ~MACEPCI_ERROR_SYSTEM_ERR);
+	}
+	if (flags & MACEPCI_ERROR_PARITY_ERR) {
+		printk ("MACEPCI: Parity error at 0x%08x (%c)\n", error_addr,
+			space);
+		mace_write_32 (MACEPCI_ERROR_FLAGS, flags
+			       & ~MACEPCI_ERROR_PARITY_ERR);
+	}
+	if (flags & MACEPCI_ERROR_OVERRUN) {
+		printk ("MACEPCI: Overrun error at 0x%08x (%c)\n",
+			error_addr, space);
+		mace_write_32 (MACEPCI_ERROR_FLAGS, flags
+			       & ~MACEPCI_ERROR_OVERRUN);
+	}
+	if (flags & MACEPCI_ERROR_SIG_TABORT) {
+		printk ("MACEPCI: Signaled target abort (clearing)\n");
+		mace_write_32 (MACEPCI_ERROR_FLAGS, flags
+			       & ~MACEPCI_ERROR_SIG_TABORT);
+	}
+	if (flags & MACEPCI_ERROR_INTERRUPT_TEST) {
+		printk ("MACEPCI: Interrupt test triggered (clearing)\n");
+		mace_write_32 (MACEPCI_ERROR_FLAGS, flags
+			       & ~MACEPCI_ERROR_INTERRUPT_TEST);
+	}
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip32/ip32-rtc.c linux/arch/mips64/sgi-ip32/ip32-rtc.c
--- v2.4.9/linux/arch/mips64/sgi-ip32/ip32-rtc.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/sgi-ip32/ip32-rtc.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,32 @@
+/*
+ * RTC routines for IP32 style attached Dallas chip.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2000 Harald Koerfgen
+ */
+#include <linux/mc146818rtc.h>
+#include <asm/ip32/mace.h>
+
+static unsigned char ip32_rtc_read_data(unsigned long addr)
+{
+	return (unsigned char) mace_read_8 (MACEISA_RTC_BASE + (addr << 8));
+}
+
+static void ip32_rtc_write_data(unsigned char data, unsigned long addr)
+{
+	mace_write_8 (MACEISA_RTC_BASE + (addr << 8), data);
+}
+
+static int ip32_rtc_bcd_mode(void)
+{
+	return 0;
+}
+
+struct rtc_ops ip32_rtc_ops = {
+	&ip32_rtc_read_data,
+	&ip32_rtc_write_data,
+	&ip32_rtc_bcd_mode
+};
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip32/ip32-setup.c linux/arch/mips64/sgi-ip32/ip32-setup.c
--- v2.4.9/linux/arch/mips64/sgi-ip32/ip32-setup.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/sgi-ip32/ip32-setup.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,62 @@
+/*
+ * IP32 basic setup
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2000 Harald Koerfgen
+ */
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/mc146818rtc.h>
+#include <linux/param.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <asm/mipsregs.h>
+#include <asm/bootinfo.h>
+#include <asm/irq.h>
+#include <asm/mmu_context.h>
+#include <asm/ip32/crime.h>
+#include <asm/ip32/mace.h>
+#include <asm/ip32/ip32_ints.h>
+#include <asm/sgialib.h>
+
+extern struct rtc_ops ip32_rtc_ops;
+extern u32 cc_interval;
+
+void __init ip32_init (int argc, char **argv, char **envp) {
+	arc_meminit ();
+}
+
+void __init ip32_setup(void)
+{
+#ifdef CONFIG_SERIAL_CONSOLE
+	char *ctype;
+#endif
+	TLBMISS_HANDLER_SETUP ();
+
+#ifdef CONFIG_SERIAL_CONSOLE
+	ctype = ArcGetEnvironmentVariable("console");
+	if (*ctype == 'd') {
+		if (ctype[1] == '2')
+			console_setup ("ttyS1");
+		else
+			console_setup ("ttyS0");
+	}
+#endif
+
+#ifdef CONFIG_VT
+	conswitchp = &dummy_con;
+#endif
+
+	rtc_ops = &ip32_rtc_ops;
+
+	crime_init ();
+}
+
+int __init page_is_ram (unsigned long pagenr)
+{
+	/* XXX: to do? */
+	return 1;
+}
diff -u --recursive --new-file v2.4.9/linux/arch/mips64/sgi-ip32/ip32-timer.c linux/arch/mips64/sgi-ip32/ip32-timer.c
--- v2.4.9/linux/arch/mips64/sgi-ip32/ip32-timer.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/mips64/sgi-ip32/ip32-timer.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,47 @@
+/*
+ * IP32 timer calibration
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2001 Keith M Wesolowski
+ */
+#include <linux/irq.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <asm/mipsregs.h>
+#include <asm/param.h>
+#include <asm/ip32/crime.h>
+#include <asm/ip32/ip32_ints.h>
+
+extern u32 cc_interval;
+
+/* An arbitrary time; this can be decreased if reliability looks good */
+#define WAIT_MS 10
+#define PER_MHZ (1000000 / 2 / HZ)
+
+void __init ip32_timer_setup (struct irqaction *irq) {
+	u64 crime_time;
+	u32 cc_tick;
+
+	printk("Calibrating system timer... ");
+
+	crime_time = crime_read_64 (CRIME_TIME) & CRIME_TIME_MASK;
+	cc_tick = read_32bit_cp0_register (CP0_COUNT);
+
+	while ((crime_read_64 (CRIME_TIME) & CRIME_TIME_MASK) - crime_time 
+		< WAIT_MS * 1000000 / CRIME_NS_PER_TICK)
+		;
+	cc_tick = read_32bit_cp0_register (CP0_COUNT) - cc_tick;
+	cc_interval = cc_tick / HZ * (1000 / WAIT_MS);
+	/* The round-off seems unnecessary; in testing, the error of the
+	 * above procedure is < 100 ticks, which means it gets filtered
+	 * out by the HZ adjustment. 
+	 */
+	cc_interval = (cc_interval / PER_MHZ) * PER_MHZ;
+
+	printk("%d MHz CPU detected\n", (int) (cc_interval / PER_MHZ));
+
+	setup_irq (CLOCK_IRQ, irq);
+}
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/8xx_io/Config.in linux/arch/ppc/8xx_io/Config.in
--- v2.4.9/linux/arch/ppc/8xx_io/Config.in	Wed May 16 09:57:20 2001
+++ linux/arch/ppc/8xx_io/Config.in	Sat Sep  8 12:39:33 2001
@@ -31,6 +31,7 @@
 comment 'Generic MPC8xx Options'
 bool 'Copy-Back Data Cache (else Writethrough)' CONFIG_8xx_COPYBACK
 bool 'CPU6 Silicon Errata (860 Pre Rev. C)' CONFIG_8xx_CPU6
+bool 'I2C/SPI Microcode Patch' CONFIG_UCODE_PATCH
 
 if [ "$CONFIG_IDE" = "y" ]; then
 	bool 'MPC8xx direct IDE support on PCMCIA port' CONFIG_BLK_DEV_MPC8xx_IDE
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/8xx_io/Makefile linux/arch/ppc/8xx_io/Makefile
--- v2.4.9/linux/arch/ppc/8xx_io/Makefile	Mon May 21 17:04:46 2001
+++ linux/arch/ppc/8xx_io/Makefile	Sat Sep  8 12:39:33 2001
@@ -1,4 +1,4 @@
-# BK Id: SCCS/s.Makefile 1.3 05/17/01 18:14:20 cort
+# BK Id: SCCS/s.Makefile 1.6 08/30/01 09:33:48 trini
 #
 #
 # Makefile for the linux MPC8xx ppc-specific parts of comm processor
@@ -15,5 +15,6 @@
 
 obj-$(CONFIG_FEC_ENET)	+= fec.o
 obj-$(CONFIG_SCC_ENET)	+= enet.o
+obj-$(CONFIG_UCODE_PATCH) += micropatch.o
 
 include $(TOPDIR)/Rules.make
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/8xx_io/enet.c linux/arch/ppc/8xx_io/enet.c
--- v2.4.9/linux/arch/ppc/8xx_io/enet.c	Mon May 21 17:04:46 2001
+++ linux/arch/ppc/8xx_io/enet.c	Sun Sep  2 07:48:02 2001
@@ -651,11 +651,10 @@
 	volatile	scc_t		*sccp;
 	volatile	scc_enet_t	*ep;
 	volatile	immap_t		*immap;
-	extern unsigned long _get_IMMR(void);
 
 	cp = cpmp;	/* Get pointer to Communication Processor */
 
-	immap = (immap_t *)(_get_IMMR() & 0xFFFF0000);	/* and to internal registers */
+	immap = (immap_t *)(mfspr(IMMR) & 0xFFFF0000);	/* and to internal registers */
 
 	bd = (bd_t *)__res;
 
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/8xx_io/fec.c linux/arch/ppc/8xx_io/fec.c
--- v2.4.9/linux/arch/ppc/8xx_io/fec.c	Mon May 21 17:04:46 2001
+++ linux/arch/ppc/8xx_io/fec.c	Sun Sep  2 07:48:02 2001
@@ -1509,7 +1509,6 @@
 	volatile	immap_t	*immap;
 	volatile	fec_t	*fecp;
 	bd_t		*bd;
-	extern		uint	_get_IMMR(void);
 #ifdef CONFIG_SCC_ENET
 	unsigned char	tmpaddr[6];
 #endif
@@ -1680,7 +1679,7 @@
 
 	/* Bits moved from Rev. D onward.
 	*/
-	if ((_get_IMMR() & 0xffff) < 0x0501)
+	if ((mfspr(IMMR) & 0xffff) < 0x0501)
 		immap->im_ioport.iop_pddir = 0x1c58;	/* Pre rev. D */
 	else
 		immap->im_ioport.iop_pddir = 0x1fff;	/* Rev. D and later */
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/8xx_io/micropatch.c linux/arch/ppc/8xx_io/micropatch.c
--- v2.4.9/linux/arch/ppc/8xx_io/micropatch.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/ppc/8xx_io/micropatch.c	Sat Sep  8 12:39:33 2001
@@ -0,0 +1,777 @@
+
+/* Microcode patches for the CPM as supplied by Motorola.
+ * This is the one for IIC/SPI.  There is a newer one that
+ * also relocates SMC2, but this would require additional changes
+ * to uart.c, so I am holding off on that for a moment.
+ */
+#include <linux/config.h>
+#include <linux/errno.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/param.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/interrupt.h>
+#include <asm/irq.h>
+#include <asm/mpc8xx.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+#include <asm/8xx_immap.h>
+#include "commproc.h"
+
+/* Define this to get SMC patches as well.  You need to modify the uart
+ * driver as well......
+#define USE_SMC_PATCH 1
+ */
+
+#ifdef CONFIG_USB_MPC8xx
+#define USE_USB_SOF_PATCH
+#endif
+
+#ifdef USE_IIC_PATCH
+#define PATCH_DEFINED
+	/* IIC/SPI */
+uint patch_2000[] = {
+	0x7FFFEFD9,
+	0x3FFD0000,
+	0x7FFB49F7,
+	0x7FF90000,
+	0x5FEFADF7,
+	0x5F89ADF7,
+	0x5FEFAFF7,
+	0x5F89AFF7,
+	0x3A9CFBC8,
+	0xE7C0EDF0,
+	0x77C1E1BB,
+	0xF4DC7F1D,
+	0xABAD932F,
+	0x4E08FDCF,
+	0x6E0FAFF8,
+	0x7CCF76CF,
+	0xFD1FF9CF,
+	0xABF88DC6,
+	0xAB5679F7,
+	0xB0937383,
+	0xDFCE79F7,
+	0xB091E6BB,
+	0xE5BBE74F,
+	0xB3FA6F0F,
+	0x6FFB76CE,
+	0xEE0DF9CF,
+	0x2BFBEFEF,
+	0xCFEEF9CF,
+	0x76CEAD24,
+	0x90B2DF9A,
+	0x7FDDD0BF,
+	0x4BF847FD,
+	0x7CCF76CE,
+	0xCFEF7E1F,
+	0x7F1D7DFD,
+	0xF0B6EF71,
+	0x7FC177C1,
+	0xFBC86079,
+	0xE722FBC8,
+	0x5FFFDFFF,
+	0x5FB2FFFB,
+	0xFBC8F3C8,
+	0x94A67F01,
+	0x7F1D5F39,
+	0xAFE85F5E,
+	0xFFDFDF96,
+	0xCB9FAF7D,
+	0x5FC1AFED,
+	0x8C1C5FC1,
+	0xAFDD5FC3,
+	0xDF9A7EFD,
+	0xB0B25FB2,
+	0xFFFEABAD,
+	0x5FB2FFFE,
+	0x5FCE600B,
+	0xE6BB600B,
+	0x5FCEDFC6,
+	0x27FBEFDF,
+	0x5FC8CFDE,
+	0x3A9CE7C0,
+	0xEDF0F3C8,
+	0x7F0154CD,
+	0x7F1D2D3D,
+	0x363A7570,
+	0x7E0AF1CE,
+	0x37EF2E68,
+	0x7FEE10EC,
+	0xADF8EFDE,
+	0xCFEAE52F,
+	0x7D0FE12B,
+	0xF1CE5F65,
+	0x7E0A4DF8,
+	0xCFEA5F72,
+	0x7D0BEFEE,
+	0xCFEA5F74,
+	0xE522EFDE,
+	0x5F74CFDA,
+	0x0B627385,
+	0xDF627E0A,
+	0x30D8145B,
+	0xBFFFF3C8,
+	0x5FFFDFFF,
+	0xA7F85F5E,
+	0xBFFE7F7D,
+	0x10D31450,
+	0x5F36BFFF,
+	0xAF785F5E,
+	0xBFFDA7F8,
+	0x5F36BFFE,
+	0x77FD30C0,
+	0x4E08FDCF,
+	0xE5FF6E0F,
+	0xAFF87E1F,
+	0x7E0FFD1F,
+	0xF1CF5F1B,
+	0xABF80D5E,
+	0x5F5EFFEF,
+	0x79F730A2,
+	0xAFDD5F34,
+	0x47F85F34,
+	0xAFED7FDD,
+	0x50B24978,
+	0x47FD7F1D,
+	0x7DFD70AD,
+	0xEF717EC1,
+	0x6BA47F01,
+	0x2D267EFD,
+	0x30DE5F5E,
+	0xFFFD5F5E,
+	0xFFEF5F5E,
+	0xFFDF0CA0,
+	0xAFED0A9E,
+	0xAFDD0C3A,
+	0x5F3AAFBD,
+	0x7FBDB082,
+	0x5F8247F8
+};
+
+uint patch_2f00[] = {
+	0x3E303430,
+	0x34343737,
+	0xABF7BF9B,
+	0x994B4FBD,
+	0xBD599493,
+	0x349FFF37,
+	0xFB9B177D,
+	0xD9936956,
+	0xBBFDD697,
+	0xBDD2FD11,
+	0x31DB9BB3,
+	0x63139637,
+	0x93733693,
+	0x193137F7,
+	0x331737AF,
+	0x7BB9B999,
+	0xBB197957,
+	0x7FDFD3D5,
+	0x73B773F7,
+	0x37933B99,
+	0x1D115316,
+	0x99315315,
+	0x31694BF4,
+	0xFBDBD359,
+	0x31497353,
+	0x76956D69,
+	0x7B9D9693,
+	0x13131979,
+	0x79376935
+};
+#endif
+
+#ifdef USE_SMC_PATCH
+#define PATCH_DEFINED
+/* SMC2/IIC/SPI Patch */
+/* This is the area from 0x2000 to 0x23ff.
+*/
+uint patch_2000[] = {
+	0x3fff0000,
+	0x3ffd0000,
+	0x3ffb0000,
+	0x3ff90000,
+	0x5f13eff8,
+	0x5eb5eff8,
+	0x5f88adf7,
+	0x5fefadf7,
+	0x3a9cfbc8,
+	0x77cae1bb,
+	0xf4de7fad,
+	0xabae9330,
+	0x4e08fdcf,
+	0x6e0faff8,
+	0x7ccf76cf,
+	0xfdaff9cf,
+	0xabf88dc8,
+	0xab5879f7,
+	0xb0925d8d,
+	0xdfd079f7,
+	0xb090e6bb,
+	0xe5bbe74f,
+	0x9e046f0f,
+	0x6ffb76ce,
+	0xee0cf9cf,
+	0x2bfbefef,
+	0xcfeef9cf,
+	0x76cead23,
+	0x90b3df99,
+	0x7fddd0c1,
+	0x4bf847fd,
+	0x7ccf76ce,
+	0xcfef77ca,
+	0x7eaf7fad,
+	0x7dfdf0b7,
+	0xef7a7fca,
+	0x77cafbc8,
+	0x6079e722,
+	0xfbc85fff,
+	0xdfff5fb3,
+	0xfffbfbc8,
+	0xf3c894a5,
+	0xe7c9edf9,
+	0x7f9a7fad,
+	0x5f36afe8,
+	0x5f5bffdf,
+	0xdf95cb9e,
+	0xaf7d5fc3,
+	0xafed8c1b,
+	0x5fc3afdd,
+	0x5fc5df99,
+	0x7efdb0b3,
+	0x5fb3fffe,
+	0xabae5fb3,
+	0xfffe5fd0,
+	0x600be6bb,
+	0x600b5fd0,
+	0xdfc827fb,
+	0xefdf5fca,
+	0xcfde3a9c,
+	0xe7c9edf9,
+	0xf3c87f9e,
+	0x54ca7fed,
+	0x2d3a3637,
+	0x756f7e9a,
+	0xf1ce37ef,
+	0x2e677fee,
+	0x10ebadf8,
+	0xefdecfea,
+	0xe52f7d9f,
+	0xe12bf1ce,
+	0x5f647e9a,
+	0x4df8cfea,
+	0x5f717d9b,
+	0xefeecfea,
+	0x5f73e522,
+	0xefde5f73,
+	0xcfda0b61,
+	0x5d8fdf61,
+	0xe7c9edf9,
+	0x7e9a30d5,
+	0x1458bfff,
+	0xf3c85fff,
+	0xdfffa7f8,
+	0x5f5bbffe,
+	0x7f7d10d0,
+	0x144d5f33,
+	0xbfffaf78,
+	0x5f5bbffd,
+	0xa7f85f33,
+	0xbffe77fd,
+	0x30bd4e08,
+	0xfdcfe5ff,
+	0x6e0faff8,
+	0x7eef7e9f,
+	0xfdeff1cf,
+	0x5f17abf8,
+	0x0d5b5f5b,
+	0xffef79f7,
+	0x309eafdd,
+	0x5f3147f8,
+	0x5f31afed,
+	0x7fdd50af,
+	0x497847fd,
+	0x7f9e7fed,
+	0x7dfd70a9,
+	0xef7e7ece,
+	0x6ba07f9e,
+	0x2d227efd,
+	0x30db5f5b,
+	0xfffd5f5b,
+	0xffef5f5b,
+	0xffdf0c9c,
+	0xafed0a9a,
+	0xafdd0c37,
+	0x5f37afbd,
+	0x7fbdb081,
+	0x5f8147f8,
+	0x3a11e710,
+	0xedf0ccdd,
+	0xf3186d0a,
+	0x7f0e5f06,
+	0x7fedbb38,
+	0x3afe7468,
+	0x7fedf4fc,
+	0x8ffbb951,
+	0xb85f77fd,
+	0xb0df5ddd,
+	0xdefe7fed,
+	0x90e1e74d,
+	0x6f0dcbf7,
+	0xe7decfed,
+	0xcb74cfed,
+	0xcfeddf6d,
+	0x91714f74,
+	0x5dd2deef,
+	0x9e04e7df,
+	0xefbb6ffb,
+	0xe7ef7f0e,
+	0x9e097fed,
+	0xebdbeffa,
+	0xeb54affb,
+	0x7fea90d7,
+	0x7e0cf0c3,
+	0xbffff318,
+	0x5fffdfff,
+	0xac59efea,
+	0x7fce1ee5,
+	0xe2ff5ee1,
+	0xaffbe2ff,
+	0x5ee3affb,
+	0xf9cc7d0f,
+	0xaef8770f,
+	0x7d0fb0c6,
+	0xeffbbfff,
+	0xcfef5ede,
+	0x7d0fbfff,
+	0x5ede4cf8,
+	0x7fddd0bf,
+	0x49f847fd,
+	0x7efdf0bb,
+	0x7fedfffd,
+	0x7dfdf0b7,
+	0xef7e7e1e,
+	0x5ede7f0e,
+	0x3a11e710,
+	0xedf0ccab,
+	0xfb18ad2e,
+	0x1ea9bbb8,
+	0x74283b7e,
+	0x73c2e4bb,
+	0x2ada4fb8,
+	0xdc21e4bb,
+	0xb2a1ffbf,
+	0x5e2c43f8,
+	0xfc87e1bb,
+	0xe74ffd91,
+	0x6f0f4fe8,
+	0xc7ba32e2,
+	0xf396efeb,
+	0x600b4f78,
+	0xe5bb760b,
+	0x53acaef8,
+	0x4ef88b0e,
+	0xcfef9e09,
+	0xabf8751f,
+	0xefef5bac,
+	0x741f4fe8,
+	0x751e760d,
+	0x7fdbf081,
+	0x741cafce,
+	0xefcc7fce,
+	0x751e70ac,
+	0x741ce7bb,
+	0x3372cfed,
+	0xafdbefeb,
+	0xe5bb760b,
+	0x53f2aef8,
+	0xafe8e7eb,
+	0x4bf8771e,
+	0x7e247fed,
+	0x4fcbe2cc,
+	0x7fbc30a9,
+	0x7b0f7a0f,
+	0x34d577fd,
+	0x308b5db7,
+	0xde553e5f,
+	0xaf78741f,
+	0x741f30f0,
+	0xcfef5e2c,
+	0x741f3eac,
+	0xafb8771e,
+	0x5e677fed,
+	0x0bd3e2cc,
+	0x741ccfec,
+	0xe5ca53cd,
+	0x6fcb4f74,
+	0x5dadde4b,
+	0x2ab63d38,
+	0x4bb3de30,
+	0x751f741c,
+	0x6c42effa,
+	0xefea7fce,
+	0x6ffc30be,
+	0xefec3fca,
+	0x30b3de2e,
+	0xadf85d9e,
+	0xaf7daefd,
+	0x5d9ede2e,
+	0x5d9eafdd,
+	0x761f10ac,
+	0x1da07efd,
+	0x30adfffe,
+	0x4908fb18,
+	0x5fffdfff,
+	0xafbb709b,
+	0x4ef85e67,
+	0xadf814ad,
+	0x7a0f70ad,
+	0xcfef50ad,
+	0x7a0fde30,
+	0x5da0afed,
+	0x3c12780f,
+	0xefef780f,
+	0xefef790f,
+	0xa7f85e0f,
+	0xffef790f,
+	0xefef790f,
+	0x14adde2e,
+	0x5d9eadfd,
+	0x5e2dfffb,
+	0xe79addfd,
+	0xeff96079,
+	0x607ae79a,
+	0xddfceff9,
+	0x60795dff,
+	0x607acfef,
+	0xefefefdf,
+	0xefbfef7f,
+	0xeeffedff,
+	0xebffe7ff,
+	0xafefafdf,
+	0xafbfaf7f,
+	0xaeffadff,
+	0xabffa7ff,
+	0x6fef6fdf,
+	0x6fbf6f7f,
+	0x6eff6dff,
+	0x6bff67ff,
+	0x2fef2fdf,
+	0x2fbf2f7f,
+	0x2eff2dff,
+	0x2bff27ff,
+	0x4e08fd1f,
+	0xe5ff6e0f,
+	0xaff87eef,
+	0x7e0ffdef,
+	0xf11f6079,
+	0xabf8f542,
+	0x7e0af11c,
+	0x37cfae3a,
+	0x7fec90be,
+	0xadf8efdc,
+	0xcfeae52f,
+	0x7d0fe12b,
+	0xf11c6079,
+	0x7e0a4df8,
+	0xcfea5dc4,
+	0x7d0befec,
+	0xcfea5dc6,
+	0xe522efdc,
+	0x5dc6cfda,
+	0x4e08fd1f,
+	0x6e0faff8,
+	0x7c1f761f,
+	0xfdeff91f,
+	0x6079abf8,
+	0x761cee24,
+	0xf91f2bfb,
+	0xefefcfec,
+	0xf91f6079,
+	0x761c27fb,
+	0xefdf5da7,
+	0xcfdc7fdd,
+	0xd09c4bf8,
+	0x47fd7c1f,
+	0x761ccfcf,
+	0x7eef7fed,
+	0x7dfdf093,
+	0xef7e7f1e,
+	0x771efb18,
+	0x6079e722,
+	0xe6bbe5bb,
+	0xae0ae5bb,
+	0x600bae85,
+	0xe2bbe2bb,
+	0xe2bbe2bb,
+	0xaf02e2bb,
+	0xe2bb2ff9,
+	0x6079e2bb
+};
+
+	/* This is from 0x2f00 to 0x2fff
+	*/
+uint patch_2f00[] = {
+	0x30303030,
+	0x3e3e3434,
+	0xabbf9b99,
+	0x4b4fbdbd,
+	0x59949334,
+	0x9fff37fb,
+	0x9b177dd9,
+	0x936956bb,
+	0xfbdd697b,
+	0xdd2fd113,
+	0x1db9f7bb,
+	0x36313963,
+	0x79373369,
+	0x3193137f,
+	0x7331737a,
+	0xf7bb9b99,
+	0x9bb19795,
+	0x77fdfd3d,
+	0x573b773f,
+	0x737933f7,
+	0xb991d115,
+	0x31699315,
+	0x31531694,
+	0xbf4fbdbd,
+	0x35931497,
+	0x35376956,
+	0xbd697b9d,
+	0x96931313,
+	0x19797937,
+	0x6935af78,
+	0xb9b3baa3,
+	0xb8788683,
+	0x368f78f7,
+	0x87778733,
+	0x3ffffb3b,
+	0x8e8f78b8,
+	0x1d118e13,
+	0xf3ff3f8b,
+	0x6bd8e173,
+	0xd1366856,
+	0x68d1687b,
+	0x3daf78b8,
+	0x3a3a3f87,
+	0x8f81378f,
+	0xf876f887,
+	0x77fd8778,
+	0x737de8d6,
+	0xbbf8bfff,
+	0xd8df87f7,
+	0xfd876f7b,
+	0x8bfff8bd,
+	0x8683387d,
+	0xb873d87b,
+	0x3b8fd7f8,
+	0xf7338883,
+	0xbb8ee1f8,
+	0xef837377,
+	0x3337b836,
+	0x817d11f8,
+	0x7378b878,
+	0xd3368b7d,
+	0xed731b7d,
+	0x833731f3,
+	0xf22f3f23
+};
+
+uint patch_2e00[] = {
+	/* This is from 0x2e00 to 0x2e3c
+	*/
+	0x27eeeeee,
+	0xeeeeeeee,
+	0xeeeeeeee,
+	0xeeeeeeee,
+	0xee4bf4fb,
+	0xdbd259bb,
+	0x1979577f,
+	0xdfd2d573,
+	0xb773f737,
+	0x4b4fbdbd,
+	0x25b9b177,
+	0xd2d17376,
+	0x956bbfdd,
+	0x697bdd2f,
+	0xff9f79ff,
+	0xff9ff22f
+};
+#endif
+
+#ifdef USE_USB_SOF_PATCH
+#define PATCH_DEFINED
+uint patch_2000[] = {
+	0x7fff0000,
+	0x7ffd0000,
+	0x7ffb0000,
+	0x49f7ba5b,
+	0xba383ffb,
+	0xf9b8b46d,
+	0xe5ab4e07,
+	0xaf77bffe,
+	0x3f7bbf79,
+	0xba5bba38,
+	0xe7676076,
+	0x60750000
+};
+
+uint patch_2f00[] = {
+	0x3030304c,
+	0xcab9e441,
+	0xa1aaf220
+};
+#endif
+
+/* Load the microcode patch.  This is called early in the CPM initialization
+ * with the controller in the reset state.  We enable the processor after
+ * we load the patch.
+ */
+void
+cpm_load_patch(volatile immap_t *immr)
+{
+#ifdef PATCH_DEFINED
+	volatile uint		*dp;
+	volatile cpm8xx_t	*commproc;
+	volatile iic_t		*iip;
+	volatile spi_t		*spp;
+	int	i;
+
+	commproc = (cpm8xx_t *)&immr->im_cpm;
+
+	/* We work closely with commproc.c.  We know it only allocates
+	 * from data only space.
+	 * For this particular patch, we only use the bottom 512 bytes
+	 * and the upper 256 byte extension.  We will use the space
+	 * starting at 1K for the relocated parameters, as the general
+	 * CPM allocation won't come from that area.
+	 */
+	commproc->cp_rccr = 0;
+
+	/* Copy the patch into DPRAM.
+	*/
+	dp = (uint *)(commproc->cp_dpmem);
+	for (i=0; i<(sizeof(patch_2000)/4); i++)
+		*dp++ = patch_2000[i];
+
+	dp = (uint *)&(commproc->cp_dpmem[0x0f00]);
+	for (i=0; i<(sizeof(patch_2f00)/4); i++)
+		*dp++ = patch_2f00[i];
+
+#ifdef USE_USB_SOF_PATCH
+#if 0 /* usb patch should not relocate iic */
+	iip = (iic_t *)&commproc->cp_dparam[PROFF_IIC];
+#define RPBASE 0x0030
+	iip->iic_rpbase = RPBASE;
+
+	/* Put SPI above the IIC, also 32-byte aligned.
+	*/
+	i = (RPBASE + sizeof(iic_t) + 31) & ~31;
+	spp = (spi_t *)&commproc->cp_dparam[PROFF_SPI];
+	spp->spi_rpbase = i;
+#endif
+
+	/* Enable uCode fetches from DPRAM. */
+	commproc->cp_rccr = 0x0009;
+
+	printk("USB uCode patch installed\n");
+#endif /* USE_USB_SOF_PATCH */
+
+#if defined(USE_SMC_PATCH) || defined(USE_IIC_PATCH)
+
+	iip = (iic_t *)&commproc->cp_dparam[PROFF_IIC];
+#define RPBASE 0x0400
+	iip->iic_rpbase = RPBASE;
+
+	/* Put SPI above the IIC, also 32-byte aligned.
+	*/
+	i = (RPBASE + sizeof(iic_t) + 31) & ~31;
+	spp = (spi_t *)&commproc->cp_dparam[PROFF_SPI];
+	spp->spi_rpbase = i;
+
+#ifdef USE_SMC_PATCH
+	dp = (uint *)&(commproc->cp_dpmem[0x0e00]);
+	for (i=0; i<(sizeof(patch_2e00)/4); i++)
+		*dp++ = patch_2e00[i];
+
+	/* Enable the traps to get to it.
+	*/
+	commproc->cp_cpmcr1 = 0x8080;
+	commproc->cp_cpmcr2 = 0x808a;
+	commproc->cp_cpmcr3 = 0x8028;
+	commproc->cp_cpmcr4 = 0x802a;
+
+	/* Enable uCode fetches from DPRAM.
+	*/
+	commproc->cp_rccr = 3;
+#endif
+
+#ifdef USE_IIC_PATCH
+	/* Enable the traps to get to it.
+	*/
+	commproc->cp_cpmcr1 = 0x802a;
+	commproc->cp_cpmcr2 = 0x8028;
+	commproc->cp_cpmcr3 = 0x802e;
+	commproc->cp_cpmcr4 = 0x802c;
+
+	/* Enable uCode fetches from DPRAM.
+	*/
+	commproc->cp_rccr = 1;
+
+	printk("I2C uCode patch installed\n");
+#endif
+
+	/* Relocate the IIC and SPI parameter areas.  These have to
+	 * aligned on 32-byte boundaries.
+	 */
+	iip = (iic_t *)&commproc->cp_dparam[PROFF_IIC];
+	iip->iic_rpbase = RPBASE;
+
+	/* Put SPI above the IIC, also 32-byte aligned.
+	*/
+	i = (RPBASE + sizeof(iic_t) + 31) & ~31;
+	spp = (spi_t *)&commproc->cp_dparam[PROFF_SPI];
+	spp->spi_rpbase = i;
+
+#endif /* USE_SMC_PATCH || USE_IIC_PATCH */
+#endif /* PATCH_DEFINED */
+}
+
+void
+verify_patch(volatile immap_t *immr)
+{
+#ifdef PATCH_DEFINED
+	volatile uint		*dp;
+	volatile cpm8xx_t	*commproc;
+	int i;
+
+	commproc = (cpm8xx_t *)&immr->im_cpm;
+
+	printk("cp_rccr %x\n", commproc->cp_rccr);
+	commproc->cp_rccr = 0;
+
+	dp = (uint *)(commproc->cp_dpmem);
+	for (i=0; i<(sizeof(patch_2000)/4); i++)
+		if (*dp++ != patch_2000[i]) {
+			printk("patch_2000 bad at %d\n", i);
+			dp--;
+			printk("found 0x%X, wanted 0x%X\n", *dp, patch_2000[i]);
+			break;
+		}
+
+	dp = (uint *)&(commproc->cp_dpmem[0x0f00]);
+	for (i=0; i<(sizeof(patch_2f00)/4); i++)
+		if (*dp++ != patch_2f00[i]) {
+			printk("patch_2f00 bad at %d\n", i);
+			dp--;
+			printk("found 0x%X, wanted 0x%X\n", *dp, patch_2f00[i]);
+			break;
+		}
+
+	commproc->cp_rccr = 0x0009;
+#endif /* PATCH_DEFINED */
+}
+
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/Makefile linux/arch/ppc/Makefile
--- v2.4.9/linux/arch/ppc/Makefile	Wed Jul 25 17:10:18 2001
+++ linux/arch/ppc/Makefile	Tue Aug 28 06:58:33 2001
@@ -1,4 +1,4 @@
-# BK Id: SCCS/s.Makefile 1.18 07/07/01 13:37:26 paulus
+# BK Id: SCCS/s.Makefile 1.21 08/19/01 20:06:47 paulus
 #
 # This file is included by the global makefile so that you can add your own
 # architecture-specific flags and dependencies. Remember to do have actions
@@ -14,6 +14,7 @@
 # Rewritten by Cort Dougan and Paul Mackerras
 #
 
+# Be sure to change PAGE_OFFSET in include/asm-ppc/page.h to match
 KERNELLOAD	=0xc0000000
 
 ifeq ($(shell uname -m),ppc)
@@ -99,5 +100,5 @@
 
 archmrproper:
 
-archdep:
+archdep: scripts/mkdep
 	$(MAKEBOOT) fastdep
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/amiga/config.c linux/arch/ppc/amiga/config.c
--- v2.4.9/linux/arch/ppc/amiga/config.c	Mon May 21 17:04:46 2001
+++ linux/arch/ppc/amiga/config.c	Fri Sep  7 09:28:38 2001
@@ -51,22 +51,22 @@
 unsigned char amiga_psfreq;
 struct amiga_hw_present amiga_hw_present;
 
-static const char s_a500[] __initdata = "A500";
-static const char s_a500p[] __initdata = "A500+";
-static const char s_a600[] __initdata = "A600";
-static const char s_a1000[] __initdata = "A1000";
-static const char s_a1200[] __initdata = "A1200";
-static const char s_a2000[] __initdata = "A2000";
-static const char s_a2500[] __initdata = "A2500";
-static const char s_a3000[] __initdata = "A3000";
-static const char s_a3000t[] __initdata = "A3000T";
-static const char s_a3000p[] __initdata = "A3000+";
-static const char s_a4000[] __initdata = "A4000";
-static const char s_a4000t[] __initdata = "A4000T";
-static const char s_cdtv[] __initdata = "CDTV";
-static const char s_cd32[] __initdata = "CD32";
-static const char s_draco[] __initdata = "Draco";
-static const char *amiga_models[] __initdata = {
+static char s_a500[] __initdata = "A500";
+static char s_a500p[] __initdata = "A500+";
+static char s_a600[] __initdata = "A600";
+static char s_a1000[] __initdata = "A1000";
+static char s_a1200[] __initdata = "A1200";
+static char s_a2000[] __initdata = "A2000";
+static char s_a2500[] __initdata = "A2500";
+static char s_a3000[] __initdata = "A3000";
+static char s_a3000t[] __initdata = "A3000T";
+static char s_a3000p[] __initdata = "A3000+";
+static char s_a4000[] __initdata = "A4000";
+static char s_a4000t[] __initdata = "A4000T";
+static char s_cdtv[] __initdata = "CDTV";
+static char s_cd32[] __initdata = "CD32";
+static char s_draco[] __initdata = "Draco";
+static char *amiga_models[] __initdata = {
     s_a500, s_a500p, s_a600, s_a1000, s_a1200, s_a2000, s_a2500, s_a3000,
     s_a3000t, s_a3000p, s_a4000, s_a4000t, s_cdtv, s_cd32, s_draco,
 };
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/Makefile linux/arch/ppc/boot/Makefile
--- v2.4.9/linux/arch/ppc/boot/Makefile	Wed Jul 25 17:10:18 2001
+++ linux/arch/ppc/boot/Makefile	Tue Aug 28 06:58:33 2001
@@ -12,8 +12,8 @@
 
 GZIP_FLAGS = -v9f
 
-CFLAGS	:= $(CPPFLAGS) -O2 -DSTDC_HEADERS -fno-builtin -D__BOOTER__ \
-		-I$(TOPDIR)/arch/$(ARCH)/boot/include
+CFLAGS	+= -fno-builtin -D__BOOTER__ -I$(TOPDIR)/arch/$(ARCH)/boot/include
+
 AFLAGS	+= -D__BOOTER__
 OBJCOPY_ARGS = -O elf32-powerpc
 
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/chrp/Makefile linux/arch/ppc/boot/chrp/Makefile
--- v2.4.9/linux/arch/ppc/boot/chrp/Makefile	Wed Jul 25 17:10:18 2001
+++ linux/arch/ppc/boot/chrp/Makefile	Tue Aug 28 06:58:33 2001
@@ -1,4 +1,4 @@
-# BK Id: SCCS/s.Makefile 1.10 07/19/01 09:11:27 trini
+# BK Id: SCCS/s.Makefile 1.13 07/27/01 20:24:17 trini
 #
 # Makefile for making ELF bootable images for booting on CHRP
 # using Open Firmware.
@@ -14,8 +14,6 @@
 MSIZE=
 endif
 
-CFLAGS += -fno-builtin
-
 .c.o:
 	$(CC) $(CFLAGS) -DKERNELBASE=$(KERNELBASE) -c -o $*.o $<
 .S.o:
@@ -23,7 +21,8 @@
 
 LD_ARGS = -Ttext 0x00400000
 
-OBJS = ../common/crt0.o start.o main.o misc.o ../common/string.o image.o
+OBJS = ../common/crt0.o start.o main.o misc.o ../common/string.o image.o \
+	../common/ofcommon.o
 LIBS = $(TOPDIR)/lib/lib.a ../lib/zlib.a
 ADDNOTE = ../utils/addnote
 PIGGYBACK = ../utils/piggyback
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/chrp/main.c linux/arch/ppc/boot/chrp/main.c
--- v2.4.9/linux/arch/ppc/boot/chrp/main.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/ppc/boot/chrp/main.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.main.c 1.9 06/12/01 16:42:26 paulus
+ * BK Id: SCCS/s.main.c 1.13 07/27/01 20:24:17 trini
  */
 /*
  * Copyright (C) Paul Mackerras 1997.
@@ -10,14 +10,28 @@
  * 2 of the License, or (at your option) any later version.
  */
 #include "nonstdio.h"
-#include "zlib.h"
-#include <asm/bootinfo.h>
 #include <asm/processor.h>
-#include <asm/page.h>
 
-extern void *finddevice(const char *);
+extern char _end[];
+extern char initrd_data[];
+extern char image_data[];
+extern char sysmap_data[];
 extern int getprop(void *, const char *, void *, int);
-void gunzip(void *, int, unsigned char *, int *);
+extern int initrd_len;
+extern int image_len;
+extern int sysmap_len;
+extern unsigned int heap_max;
+extern void claim(unsigned int virt, unsigned int size, unsigned int align);
+extern void *finddevice(const char *);
+extern void flush_cache(void *, unsigned long);
+extern void gunzip(void *, int, unsigned char *, int *);
+extern void make_bi_recs(unsigned long addr, char *name, unsigned int mach,
+		unsigned int progend);
+extern void pause(void);
+
+char *avail_ram;
+char *begin_avail, *end_avail;
+char *avail_high;
 
 #define RAM_START	0x00000000
 #define RAM_END		(64<<20)
@@ -27,38 +41,28 @@
 
 #define RAM_FREE	((unsigned long)(_end+0x1000)&~0xFFF)
 #define PROG_START	0x00010000
+#define PROG_SIZE	0x00400000 /* 4MB */
 
-char *avail_ram;
-char *end_avail;
-
-extern char _end[];
-extern char image_data[];
-extern int image_len;
-extern char initrd_data[];
-extern int initrd_len;
-extern char sysmap_data[];
-extern int sysmap_len;
+#define SCRATCH_SIZE	(128 << 10)
 
-static char scratch[1024<<10];	/* 1MB of scratch space for gunzip */
+static char scratch[SCRATCH_SIZE];	/* 1MB of scratch space for gunzip */
 
+void
 chrpboot(int a1, int a2, void *prom)
 {
-    int ns, oh, i;
     unsigned sa, len;
     void *dst;
     unsigned char *im;
-    unsigned initrd_start, initrd_size;
+    unsigned initrd_start=0, initrd_size=0;
     extern char _start;
     
-    printf("chrpboot starting: loaded at 0x%x\n\r", &_start);
+    printf("chrpboot starting: loaded at 0x%p\n\r", &_start);
 
     if (initrd_len) {
 	initrd_size = initrd_len;
 	initrd_start = (RAM_END - initrd_size) & ~0xFFF;
-	a1 = initrd_start;
-	a2 = initrd_size;
 	claim(initrd_start, RAM_END - initrd_start, 0);
-	printf("initial ramdisk moving 0x%x <- 0x%x (%x bytes)\n\r",
+	printf("initial ramdisk moving 0x%x <- 0x%p (%x bytes)\n\r",
 	       initrd_start, initrd_data, initrd_size);
 	memcpy((char *)initrd_start, initrd_data, initrd_size);
     }
@@ -66,133 +70,31 @@
     im = image_data;
     len = image_len;
     /* claim 4MB starting at PROG_START */
-    claim(PROG_START, (4<<20) - PROG_START, 0);
+    claim(PROG_START, PROG_SIZE - PROG_START, 0);
     dst = (void *) PROG_START;
     if (im[0] == 0x1f && im[1] == 0x8b) {
 	avail_ram = scratch;
+	begin_avail = avail_high = avail_ram;
 	end_avail = scratch + sizeof(scratch);
-	printf("gunzipping (0x%x <- 0x%x:0x%0x)...", dst, im, im+len);
+	printf("gunzipping (0x%p <- 0x%p:0x%p)...", dst, im, im+len);
 	gunzip(dst, 0x400000, im, &len);
 	printf("done %u bytes\n\r", len);
+	printf("%u bytes of heap consumed, max in use %u\n\r",
+	       avail_high - begin_avail, heap_max);
     } else {
 	memmove(dst, im, len);
     }
 
     flush_cache(dst, len);
+    make_bi_recs(((unsigned long) dst + len), "chrpboot", _MACH_chrp,
+		    (PROG_START + PROG_SIZE));
     
     sa = (unsigned long)PROG_START;
     printf("start address = 0x%x\n\r", sa);
 
-    {
-	    struct bi_record *rec;
-	    
-	    rec = (struct bi_record *)_ALIGN((unsigned long)dst+len+(1<<20)-1,(1<<20));
-
-	    rec->tag = BI_FIRST;
-	    rec->size = sizeof(struct bi_record);
-	    rec = (struct bi_record *)((unsigned long)rec + rec->size);
-	    
-	    rec->tag = BI_BOOTLOADER_ID;
-	    sprintf( (char *)rec->data, "chrpboot");
-	    rec->size = sizeof(struct bi_record) + strlen("chrpboot") + 1;
-	    rec = (struct bi_record *)((unsigned long)rec + rec->size);
-	    
-	    rec->tag = BI_MACHTYPE;
-	    rec->data[0] = _MACH_chrp;
-	    rec->data[1] = 1;
-	    rec->size = sizeof(struct bi_record) + 2 * sizeof(unsigned long);
-	    rec = (struct bi_record *)((unsigned long)rec + rec->size);
-#if 0
-	    rec->tag = BI_SYSMAP;
-	    rec->data[0] = (unsigned long)sysmap_data;
-	    rec->data[1] = sysmap_len;
-	    rec->size = sizeof(struct bi_record) + 2 * sizeof(unsigned long);
-	    rec = (struct bi_record *)((unsigned long)rec + rec->size);
-#endif
-	    rec->tag = BI_LAST;
-	    rec->size = sizeof(struct bi_record);
-	    rec = (struct bi_record *)((unsigned long)rec + rec->size);
-    }
-    (*(void (*)())sa)(a1, a2, prom);
+    (*(void (*)())sa)(a1, a2, prom, initrd_start, initrd_size);
 
     printf("returned?\n\r");
 
     pause();
-}
-
-void *zalloc(void *x, unsigned items, unsigned size)
-{
-    void *p = avail_ram;
-
-    size *= items;
-    size = (size + 7) & -8;
-    avail_ram += size;
-    if (avail_ram > end_avail) {
-	printf("oops... out of memory\n\r");
-	pause();
-    }
-    return p;
-}
-
-void zfree(void *x, void *addr, unsigned nb)
-{
-    nb = (nb + 7) & -8;
-    if (addr == (avail_ram - nb)) {
-	avail_ram -= nb;
-    }
-}
-
-#define HEAD_CRC	2
-#define EXTRA_FIELD	4
-#define ORIG_NAME	8
-#define COMMENT		0x10
-#define RESERVED	0xe0
-
-#define DEFLATED	8
-
-void gunzip(void *dst, int dstlen, unsigned char *src, int *lenp)
-{
-    z_stream s;
-    int r, i, flags;
-
-    /* skip header */
-    i = 10;
-    flags = src[3];
-    if (src[2] != DEFLATED || (flags & RESERVED) != 0) {
-	printf("bad gzipped data\n\r");
-	exit();
-    }
-    if ((flags & EXTRA_FIELD) != 0)
-	i = 12 + src[10] + (src[11] << 8);
-    if ((flags & ORIG_NAME) != 0)
-	while (src[i++] != 0)
-	    ;
-    if ((flags & COMMENT) != 0)
-	while (src[i++] != 0)
-	    ;
-    if ((flags & HEAD_CRC) != 0)
-	i += 2;
-    if (i >= *lenp) {
-	printf("gunzip: ran out of data in header\n\r");
-	exit();
-    }
-
-    s.zalloc = zalloc;
-    s.zfree = zfree;
-    r = inflateInit2(&s, -MAX_WBITS);
-    if (r != Z_OK) {
-	printf("inflateInit2 returned %d\n\r", r);
-	exit();
-    }
-    s.next_in = src + i;
-    s.avail_in = *lenp - i;
-    s.next_out = dst;
-    s.avail_out = dstlen;
-    r = inflate(&s, Z_FINISH);
-    if (r != Z_OK && r != Z_STREAM_END) {
-	printf("inflate returned %d msg: %s\n\r", r, s.msg);
-	exit();
-    }
-    *lenp = s.next_out - (unsigned char *) dst;
-    inflateEnd(&s);
 }
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/chrp/start.c linux/arch/ppc/boot/chrp/start.c
--- v2.4.9/linux/arch/ppc/boot/chrp/start.c	Thu May 24 15:02:06 2001
+++ linux/arch/ppc/boot/chrp/start.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.start.c 1.6 05/18/01 15:16:59 cort
+ * BK Id: SCCS/s.start.c 1.8 07/25/01 18:13:07 trini
  */
 /*
  * Copyright (C) Paul Mackerras 1997.
@@ -24,6 +24,9 @@
 
 void printk(char *fmt, ...);
 
+extern void chrpboot(int a1, int a2, void *prom);
+extern int strlen(const char *s);
+
 void
 start(int a1, int a2, void *promptr)
 {
@@ -91,7 +94,7 @@
 }
 
 void
-exit()
+exit(void)
 {
     struct prom_args {
 	char *service;
@@ -104,7 +107,7 @@
 }
 
 void
-pause()
+pause(void)
 {
     struct prom_args {
 	char *service;
@@ -228,7 +231,7 @@
 static int lineleft;
 
 int
-getchar()
+getchar(void)
 {
     int c;
 
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/common/crt0.S linux/arch/ppc/boot/common/crt0.S
--- v2.4.9/linux/arch/ppc/boot/common/crt0.S	Thu May 24 15:02:06 2001
+++ linux/arch/ppc/boot/common/crt0.S	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.crt0.S 1.10 05/21/01 00:49:49 cort
+ * BK Id: SCCS/s.crt0.S 1.12 08/09/01 17:09:10 paulus
  */
 /*    Copyright (c) 1997 Paul Mackerras <paulus@cs.anu.edu.au>
  *      Initial Power Macintosh COFF version.
@@ -34,7 +34,21 @@
 	.globl	__start
 __start:
 #endif
-#ifdef CONFIG_4xx
+
+	## Flush and invalidate the caches for the range in memory covering
+	## the .text section of the boot loader
+	
+	lis	r9,_start@h		# r9 = &_start
+	lis	r8,_etext@ha		# 
+	addi	r8,r8,_etext@l		# r8 = &_etext
+3:	dcbf	r0,r9			# Flush the data cache
+	icbi	r0,r9			# Invalidate the instruction cache
+	addi	r9,r9,0x10		# Increment by one cache line
+	cmplw	cr0,r9,r8		# Are we at the end yet?
+	blt	3b			# No, keep flushing and invalidating
+	sync				# sync ; isync after flushing the icache
+	isync
+
 	## Clear out the BSS as per ANSI C requirements
 
 	lis	r7,_end@ha
@@ -53,21 +67,7 @@
 	li	r0,0			# r0 = 0
 1:	stwu	r0,4(r8)		# Clear out a word
 	bdnz	1b			# If we are not done yet, keep clearing
-#endif
-
-	## Flush and invalidate the caches for the range in memory covering
-	## the .text section of the boot loader
-	
-2:	lis	r9,_start@h		# r9 = &_start
-	lis	r8,_etext@ha		# 
-	addi	r8,r8,_etext@l		# r8 = &_etext
-3:	dcbf	r0,r9			# Flush the data cache
-	icbi	r0,r9			# Invalidate the instruction cache
-	addi	r9,r9,0x10		# Increment by one cache line
-	cmplw	cr0,r9,r8		# Are we at the end yet?
-	blt	3b			# No, keep flushing and invalidating
-	sync				# sync ; isync after flushing the icache
-	isync
+2:
 
 #ifdef CONFIG_4xx
 	## Set up the stack
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/common/misc-common.c linux/arch/ppc/boot/common/misc-common.c
--- v2.4.9/linux/arch/ppc/boot/common/misc-common.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/ppc/boot/common/misc-common.c	Tue Aug 28 06:58:33 2001
@@ -31,9 +31,10 @@
  * 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <stdarg.h>	/* for va_ bits */
 #include <linux/config.h>
 #include "zlib.h"
-#include <linux/pci.h>
+#include "nonstdio.h"
 
 /* If we're on a ALL_PPC, assume we have a keyboard controller
  * Also note, if we're not ALL_PPC, we assume you are a serial
@@ -71,14 +72,15 @@
 void gunzip(void *, int, unsigned char *, int *);
 static int _cvt(unsigned long val, char *buf, long radix, char *digits);
 
-void _vprintk(void(*)(const char), const char *, va_list);
+void _vprintk(void(*putc)(const char), const char *fmt0, va_list ap);
+unsigned char *ISA_io = NULL;
 
 #if defined(CONFIG_SERIAL_CONSOLE)
 extern unsigned long com_port;
 
-extern int serial_tstc(volatile unsigned long com_port);
-extern unsigned char serial_getc(volatile unsigned long com_port);
-extern void serial_putc(volatile unsigned long com_port, unsigned char c);
+extern int serial_tstc(unsigned long com_port);
+extern unsigned char serial_getc(unsigned long com_port);
+extern void serial_putc(unsigned long com_port, unsigned char c);
 #endif
 
 void pause(void)
@@ -301,7 +303,6 @@
 
 #define FALSE 0
 #define TRUE  1
-#include <stdarg.h>
 
 void
 _printk(char const *fmt, ...)
@@ -528,6 +529,28 @@
 {
 	_printk("\n");
 	_dump_buf_with_offset(p, s, 0);
+}
+
+/* Very simple inb/outb routines.  We declare ISA_io to be 0 above, and
+ * then modify it on platforms which need to.  We do it like this
+ * because on some platforms we give inb/outb an exact location, and
+ * on others it's an offset from a given location. -- Tom
+ */
+
+void
+outb(int port, unsigned char val)
+{
+	/* Ensure I/O operations complete */
+	__asm__ volatile("eieio");
+	ISA_io[port] = val;
+}
+
+unsigned char
+inb(int port)
+{
+	/* Ensure I/O operations complete */
+	__asm__ volatile("eieio");
+	return (ISA_io[port]);
 }
 
 /*
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/common/misc-simple.c linux/arch/ppc/boot/common/misc-simple.c
--- v2.4.9/linux/arch/ppc/boot/common/misc-simple.c	Thu May 24 15:02:06 2001
+++ linux/arch/ppc/boot/common/misc-simple.c	Tue Aug 28 06:58:33 2001
@@ -26,6 +26,7 @@
 #include <asm/processor.h>
 #include <asm/mmu.h>
 
+#include "nonstdio.h"
 #include "zlib.h"
 
 unsigned long com_port;
@@ -47,16 +48,8 @@
 char *zimage_start;
 int zimage_size;
 
-extern void puts(const char *);
-extern void putc(const char c);
-extern void puthex(unsigned long val);
-extern void *memcpy(void * __dest, __const void * __src,
-			    __kernel_size_t __n);
 extern void gunzip(void *, int, unsigned char *, int *);
-extern void udelay(long delay);
-extern int tstc(void);
-extern int getc(void);
-extern volatile unsigned long serial_init(int chan);
+extern unsigned long serial_init(int chan);
 
 void
 decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum)
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/common/ns16550.c linux/arch/ppc/boot/common/ns16550.c
--- v2.4.9/linux/arch/ppc/boot/common/ns16550.c	Thu May 24 15:02:06 2001
+++ linux/arch/ppc/boot/common/ns16550.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.ns16550.c 1.7 05/18/01 06:20:29 patch
+ * BK Id: SCCS/s.ns16550.c 1.9 07/30/01 17:19:40 trini
  */
 /*
  * COM1 NS16550 support
@@ -10,12 +10,9 @@
 #include <linux/serial_reg.h>
 #include <asm/serial.h>
 
-/* Some machines, such as ones with a PReP memory map, initally have
- * their serial port at an offset of 0x80000000 from where they are
- * in <asm/serial.h>.  This tries to take that into account. */
-#ifndef IOOFFSET
-#define IOOFFSET 0
-#endif
+extern void outb(int port, unsigned char val);
+extern unsigned char inb(int port);
+extern unsigned long ISA_io;
 
 static struct serial_state rs_table[RS_TABLE_SIZE] = {
 	SERIAL_PORT_DFNS	/* Defined in <asm/serial.h> */
@@ -23,58 +20,67 @@
 
 static int shift;
 
-volatile unsigned long serial_init(int chan) {
+unsigned long serial_init(int chan) {
 	unsigned long com_port;
 
-	/* Get the base, and add any offset we need to deal with. */
-	com_port = rs_table[chan].port + IOOFFSET;
+	/* We need to find out which type io we're expecting.  If it's
+	 * 'SERIAL_IO_PORT', we get an offset from the isa_io_base.
+	 * If it's 'SERIAL_IO_MEM', we can the exact location.  -- Tom */
+	switch (rs_table[chan].io_type) {
+		case SERIAL_IO_PORT:
+			com_port = rs_table[chan].port;
+			break;
+		case SERIAL_IO_MEM:
+			com_port = (unsigned long)rs_table[chan].iomem_base;
+			break;
+		default:
+			/* We can't deal with it. */
+			return -1;
+	}
 
 	/* How far apart the registers are. */
 	shift = rs_table[chan].iomem_reg_shift;
 
 	/* See if port is present */
-	*((unsigned char *)com_port + (UART_LCR << shift)) = 0x00;
-	*((unsigned char *)com_port + (UART_IER << shift)) = 0x00;
+	outb(com_port + (UART_LCR << shift), 0x00);
+	outb(com_port + (UART_IER << shift), 0x00);
 	/* Access baud rate */
-	*((unsigned char *)com_port + (UART_LCR << shift)) = 0x00;
+	outb(com_port + (UART_LCR << shift), 0x80);
 #ifdef CONFIG_SERIAL_CONSOLE_NONSTD
 	/* Input clock. */
-	*((unsigned char *)com_port + (UART_DLL << shift)) = 
-			(BASE_BAUD / CONFIG_SERIAL_CONSOLE_BAUD);
-	*((unsigned char *)com_port + (UART_DLM << shift)) = 
-		(BASE_BAUD / CONFIG_SERIAL_CONSOLE_BAUD) >> 8;
+	outb(com_port + (UART_DLL << shift), 
+			(BASE_BAUD / CONFIG_SERIAL_CONSOLE_BAUD));
+	outb(com_port + (UART_DLM << shift), 
+		(BASE_BAUD / CONFIG_SERIAL_CONSOLE_BAUD) >> 8);
 #endif
 	 /* 8 data, 1 stop, no parity */
-	*((unsigned char *)com_port + (UART_LCR << shift)) = 0x03;
+	outb(com_port + (UART_LCR << shift), 0x03);
 	/* RTS/DTR */
-	*((unsigned char *)com_port + (UART_MCR << shift)) = 0x03;
+	outb(com_port + (UART_MCR << shift), 0x03);
 	/* Clear & enable FIFOs */
-	*((unsigned char *)com_port + (UART_FCR << shift)) = 0x07;
+	outb(com_port + (UART_FCR << shift), 0x07);
 
 	return (com_port);
 }
 
 void
-serial_putc(volatile unsigned long com_port, unsigned char c)
+serial_putc(unsigned long com_port, unsigned char c)
 {
-	while ((*((volatile unsigned char *)com_port + (UART_LSR << shift)) &
-				UART_LSR_THRE) == 0)
+	while ((inb(com_port + (UART_LSR << shift)) & UART_LSR_THRE) == 0)
 		;
-	*(volatile unsigned char *)com_port = c;
+	outb(com_port, c);
 }
 
 unsigned char
-serial_getc(volatile unsigned long com_port)
+serial_getc(unsigned long com_port)
 {
-	while ((*((volatile unsigned char *)com_port + (UART_LSR << shift))
-			& UART_LSR_DR) == 0)
+	while ((inb(com_port + (UART_LSR << shift)) & UART_LSR_DR) == 0)
 		;
-	return (*(volatile unsigned char *)com_port);
+	return inb(com_port);
 }
 
 int
-serial_tstc(volatile unsigned long com_port)
+serial_tstc(unsigned long com_port)
 {
-	return ((*((volatile unsigned char *)com_port + (UART_LSR << shift))
-				& UART_LSR_DR) != 0);
+	return ((inb(com_port + (UART_LSR << shift)) & UART_LSR_DR) != 0);
 }
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/common/ofcommon.c linux/arch/ppc/boot/common/ofcommon.c
--- v2.4.9/linux/arch/ppc/boot/common/ofcommon.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/ppc/boot/common/ofcommon.c	Tue Aug 28 06:58:33 2001
@@ -0,0 +1,171 @@
+/*
+ * BK Id: SCCS/s.ofcommon.c 1.1 07/27/01 20:24:18 trini
+ *
+ * Copyright (C) Paul Mackerras 1997.
+ *
+ * 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 "zlib.h"
+#include "nonstdio.h"
+#include <asm/bootinfo.h>
+#include <asm/page.h>
+
+extern int strcmp(const char *s1, const char *s2);
+extern char *avail_ram, *avail_high;
+extern char *end_avail;
+extern void claim(unsigned int virt, unsigned int size, unsigned int align);
+extern void pause(void);
+
+unsigned int heap_use, heap_max;
+
+struct memchunk {
+    unsigned int size;
+    struct memchunk *next;
+};
+
+static struct memchunk *freechunks;
+
+static void *zalloc(void *x, unsigned items, unsigned size)
+{
+    void *p;
+    struct memchunk **mpp, *mp;
+
+    size *= items;
+    size = (size + 7) & -8;
+    heap_use += size;
+    if (heap_use > heap_max)
+	heap_max = heap_use;
+    for (mpp = &freechunks; (mp = *mpp) != 0; mpp = &mp->next) {
+	if (mp->size == size) {
+	    *mpp = mp->next;
+	    return mp;
+	}
+    }
+    p = avail_ram;
+    avail_ram += size;
+    if (avail_ram > avail_high)
+	avail_high = avail_ram;
+    if (avail_ram > end_avail) {
+	printf("oops... out of memory\n\r");
+	pause();
+    }
+    return p;
+}
+
+static void zfree(void *x, void *addr, unsigned nb)
+{
+    struct memchunk *mp = addr;
+
+    nb = (nb + 7) & -8;
+    heap_use -= nb;
+    if (avail_ram == addr + nb) {
+	avail_ram = addr;
+	return;
+    }
+    mp->size = nb;
+    mp->next = freechunks;
+    freechunks = mp;
+}
+
+#define HEAD_CRC	2
+#define EXTRA_FIELD	4
+#define ORIG_NAME	8
+#define COMMENT		0x10
+#define RESERVED	0xe0
+
+#define DEFLATED	8
+
+void gunzip(void *dst, int dstlen, unsigned char *src, int *lenp)
+{
+    z_stream s;
+    int r, i, flags;
+
+    /* skip header */
+    i = 10;
+    flags = src[3];
+    if (src[2] != DEFLATED || (flags & RESERVED) != 0) {
+	printf("bad gzipped data\n\r");
+	exit();
+    }
+    if ((flags & EXTRA_FIELD) != 0)
+	i = 12 + src[10] + (src[11] << 8);
+    if ((flags & ORIG_NAME) != 0)
+	while (src[i++] != 0)
+	    ;
+    if ((flags & COMMENT) != 0)
+	while (src[i++] != 0)
+	    ;
+    if ((flags & HEAD_CRC) != 0)
+	i += 2;
+    if (i >= *lenp) {
+	printf("gunzip: ran out of data in header\n\r");
+	exit();
+    }
+
+    s.zalloc = zalloc;
+    s.zfree = zfree;
+    r = inflateInit2(&s, -MAX_WBITS);
+    if (r != Z_OK) {
+	printf("inflateInit2 returned %d\n\r", r);
+	exit();
+    }
+    s.next_in = src + i;
+    s.avail_in = *lenp - i;
+    s.next_out = dst;
+    s.avail_out = dstlen;
+    r = inflate(&s, Z_FINISH);
+    if (r != Z_OK && r != Z_STREAM_END) {
+	printf("inflate returned %d msg: %s\n\r", r, s.msg);
+	exit();
+    }
+    *lenp = s.next_out - (unsigned char *) dst;
+    inflateEnd(&s);
+}
+
+/* Make a bi_rec in OF.  We need to be passed a name for BI_BOOTLOADER_ID, 
+ * a machine type for BI_MACHTYPE, and the location where the end of the
+ * bootloader is (PROG_START + PROG_SIZE)
+ */
+void make_bi_recs(unsigned long addr, char *name, unsigned int mach,
+		unsigned long progend)
+{
+	struct bi_record *rec;
+
+	/* leave a 1MB gap then align to the next 1MB boundary */
+	addr = _ALIGN(addr+ (1<<20) - 1, (1<<20));
+	/* oldworld machine seem very unhappy about this. -- Tom */
+	if (addr >= progend)
+		claim(addr, 0x1000, 0);
+
+	rec = (struct bi_record *)addr;
+	rec->tag = BI_FIRST;
+	rec->size = sizeof(struct bi_record);
+	rec = (struct bi_record *)((unsigned long)rec + rec->size);
+
+	rec->tag = BI_BOOTLOADER_ID;
+	sprintf( (char *)rec->data, name);
+	rec->size = sizeof(struct bi_record) + strlen(name) + 1;
+	rec = (struct bi_record *)((unsigned long)rec + rec->size);
+	    
+	rec->tag = BI_MACHTYPE;
+	rec->data[0] = mach;
+	rec->data[1] = 1;
+	rec->size = sizeof(struct bi_record) + 2 * sizeof(unsigned long);
+	rec = (struct bi_record *)((unsigned long)rec + rec->size);
+
+#ifdef SYSMAP_OFFSET
+	rec->tag = BI_SYSMAP;
+	rec->data[0] = SYSMAP_OFFSET;
+	rec->data[1] = SYSMAP_SIZE;
+	rec->size = sizeof(struct bi_record) + 2 * sizeof(unsigned long);
+	rec = (struct bi_record *)((unsigned long)rec + rec->size);
+#endif /* SYSMAP_OFFSET */
+	
+	rec->tag = BI_LAST;
+	rec->size = sizeof(struct bi_record);
+	rec = (struct bi_record *)((unsigned long)rec + rec->size);
+}
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/include/nonstdio.h linux/arch/ppc/boot/include/nonstdio.h
--- v2.4.9/linux/arch/ppc/boot/include/nonstdio.h	Thu May 24 15:02:06 2001
+++ linux/arch/ppc/boot/include/nonstdio.h	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.nonstdio.h 1.7 05/18/01 15:17:23 cort
+ * BK Id: SCCS/s.nonstdio.h 1.9 07/25/01 18:13:07 trini
  */
 /*
  * Copyright (C) Paul Mackerras 1997.
@@ -8,14 +8,31 @@
  * 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 is sort of a catchall for I/O related functions.  Stuff that
+ * wouldn't be in 'stdio.h' normally is here, and it's 'nonstdio.h'
+ * for a reason.  -- Tom
  */
-typedef int	FILE;
+typedef int FILE;
 extern FILE *stdin, *stdout;
-#define NULL	((void *)0)
-#define EOF	(-1)
-#define fopen(n, m)	NULL
-#define fflush(f)	0
-#define fclose(f)	0
-extern char *fgets();
+#define NULL ((void *)0)
+#define EOF (-1)
+#define fopen(n, m) NULL
+#define fflush(f) 0
+#define fclose(f) 0
+#define perror(s) printf("%s: no files!\n", (s))
 
-#define perror(s)	printf("%s: no files!\n", (s))
+extern int getc(void);
+extern int printf(const char *format, ...);
+extern int strlen(const char *s);
+extern int sprintf(char *str, const char *format, ...);
+extern int tstc(void);
+extern void exit(void);
+extern void *memcpy(void *dest, const void *src, int n);
+extern void *memmove(void *dest, const void *src, int n);
+extern void outb(int port, unsigned char val);
+extern void putc(const char c);
+extern void puthex(unsigned long val);
+extern void puts(const char *);
+extern void udelay(long delay);
+extern unsigned char inb(int port);
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/mbx/misc.c linux/arch/ppc/boot/mbx/misc.c
--- v2.4.9/linux/arch/ppc/boot/mbx/misc.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/ppc/boot/mbx/misc.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.misc.c 1.11 07/18/01 15:46:50 trini
+ * BK Id: SCCS/s.misc.c 1.13 07/27/01 11:44:37 trini
  */
 /*
  * Adapted for PowerPC by Gary Thomas
@@ -23,6 +23,8 @@
 #include <asm/mpc8260.h>
 #endif
 
+#include "nonstdio.h"
+
 /*
  * The following references are needed to cause the linker to pull in the
  * gzimage.o and rdimage.o files.  These object files are special,
@@ -75,14 +77,7 @@
 char *zimage_start;
 int zimage_size;
 
-extern void puts(const char *);
-extern void putc(const char c);
-extern void udelay(long x);
-extern void puthex(unsigned long val);
-extern void * memcpy(void * __dest, __const void * __src, __kernel_size_t __n);
 extern void gunzip(void *, int, unsigned char *, int *);
-extern int tstc(void);
-extern int getc(void);
 
 unsigned long
 decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, bd_t *bp)
@@ -267,33 +262,4 @@
 	puts("done.\n");
 	puts("Now booting the kernel\n");
 	return (unsigned long)hold_residual;
-}
-
-/*
- * PCI/ISA I/O support
- */
-
-volatile unsigned char *ISA_io  = (unsigned char *)0x80000000;
-volatile unsigned char *ISA_mem = (unsigned char *)0xC0000000;
-
-void
-outb(int port, char val)
-{
-	/* Ensure I/O operations complete */
-	__asm__ volatile("eieio");
-	ISA_io[port] = val;
-}
-
-unsigned char
-inb(int port)
-{
-	/* Ensure I/O operations complete */
-	__asm__ volatile("eieio");
-	return (ISA_io[port]);
-}
-
-unsigned long
-local_to_PCI(unsigned long addr)
-{
-	return ((addr & 0x7FFFFFFF) | 0x80000000);
 }
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/pmac/Makefile linux/arch/ppc/boot/pmac/Makefile
--- v2.4.9/linux/arch/ppc/boot/pmac/Makefile	Wed Jul 25 17:10:18 2001
+++ linux/arch/ppc/boot/pmac/Makefile	Tue Aug 28 06:58:33 2001
@@ -1,4 +1,4 @@
-# BK Id: SCCS/s.Makefile 1.12 07/19/01 09:11:28 trini
+# BK Id: SCCS/s.Makefile 1.14 07/27/01 20:24:17 trini
 #
 # Makefile for making XCOFF bootable images for booting on PowerMacs
 # using Open Firmware.
@@ -12,12 +12,10 @@
 COFF_LD_ARGS = -e _start -T ld.script -Ttext 500000 -Tdata 510000 -Bstatic
 CHRP_LD_ARGS = -Ttext 0x01000000
 
-COMMONOBJS = start.o misc.o ../common/string.o image.o
+COMMONOBJS = start.o misc.o ../common/string.o image.o ../common/ofcommon.o
 COFFOBJS = ../common/coffcrt0.o $(COMMONOBJS) coffmain.o
 CHRPOBJS = ../common/crt0.o $(COMMONOBJS) chrpmain.o
 LIBS = $(TOPDIR)/lib/lib.a ../lib/zlib.a
-
-CFLAGS += -fno-builtin
 
 MKNOTE := ../utils/mknote
 SIZE := ../utils/size
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/pmac/chrpmain.c linux/arch/ppc/boot/pmac/chrpmain.c
--- v2.4.9/linux/arch/ppc/boot/pmac/chrpmain.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/ppc/boot/pmac/chrpmain.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.chrpmain.c 1.12 06/12/01 16:42:26 paulus
+ * BK Id: SCCS/s.chrpmain.c 1.16 07/27/01 20:24:18 trini
  */
 /*
  * Copyright (C) Paul Mackerras 1997.
@@ -11,21 +11,26 @@
  */
 #include "nonstdio.h"
 #include "zlib.h"
-#include <asm/bootinfo.h>
 #include <asm/processor.h>
-#include <asm/page.h>
 
-extern void *finddevice(const char *);
+extern char _end[];
+extern char image_data[], initrd_data[];
+extern int image_len, initrd_len;
 extern int getprop(void *, const char *, void *, int);
+extern unsigned int heap_max;
 extern void *claim(unsigned int, unsigned int, unsigned int);
+extern void *finddevice(const char *);
+extern void flush_cache(void *start, unsigned int len);
+extern void gunzip(void *, int, unsigned char *, int *);
+extern void make_bi_recs(unsigned long addr, char *name, unsigned int mach,
+		unsigned int progend);
+extern void pause(void);
 extern void release(void *ptr, unsigned int len);
-void make_bi_recs(unsigned long);
-void gunzip(void *, int, unsigned char *, int *);
-void stop_imac_ethernet(void);
-void stop_imac_usb(void);
 
-#define get_16be(x)	(*(unsigned short *)(x))
-#define get_32be(x)	(*(unsigned *)(x))
+char *avail_ram;
+char *begin_avail, *end_avail;
+char *avail_high;
+
 
 #define RAM_END		(16 << 20)
 
@@ -34,36 +39,22 @@
 
 #define SCRATCH_SIZE	(128 << 10)
 
-char *avail_ram;
-char *begin_avail, *end_avail;
-char *avail_high;
-unsigned int heap_use;
-unsigned int heap_max;
-
-extern char _end[];
-extern char image_data[];
-extern int image_len;
-extern char initrd_data[];
-extern int initrd_len;
-
-
-boot(int a1, int a2, void *prom)
+void boot(int a1, int a2, void *prom)
 {
-    int ns, oh, i;
     unsigned sa, len;
     void *dst;
     unsigned char *im;
     unsigned initrd_start, initrd_size;
     extern char _start;
     
-    printf("chrpboot starting: loaded at 0x%x\n", &_start);
+    printf("chrpboot starting: loaded at 0x%p\n", &_start);
     if (initrd_len) {
 	initrd_size = initrd_len;
 	initrd_start = (RAM_END - initrd_size) & ~0xFFF;
 	a1 = initrd_start;
 	a2 = initrd_size;
 	claim(initrd_start, RAM_END - initrd_start, 0);
-	printf("initial ramdisk moving 0x%x <- 0x%x (%x bytes)\n", initrd_start,
+	printf("initial ramdisk moving 0x%x <- 0x%p (%x bytes)\n", initrd_start,
 	       initrd_data,initrd_size);
 	memcpy((char *)initrd_start, initrd_data, initrd_size);
     }
@@ -77,8 +68,8 @@
 	avail_ram = (char *) claim(0, SCRATCH_SIZE, 0x10);
 	begin_avail = avail_high = avail_ram;
 	end_avail = avail_ram + SCRATCH_SIZE;
-	printf("heap at 0x%x\n", avail_ram);
-	printf("gunzipping (0x%x <- 0x%x:0x%0x)...", dst, im, im+len);
+	printf("heap at 0x%p\n", avail_ram);
+	printf("gunzipping (0x%p <- 0x%p:0x%p)...", dst, im, im+len);
 	gunzip(dst, PROG_SIZE, im, &len);
 	printf("done %u bytes\n", len);
 	printf("%u bytes of heap consumed, max in use %u\n",
@@ -89,7 +80,8 @@
     }
 
     flush_cache(dst, len);
-    make_bi_recs((unsigned long) dst + len);
+    make_bi_recs(((unsigned long) dst + len), "chrpboot", _MACH_Pmac,
+		    (PROG_START + PROG_SIZE));
 
     sa = (unsigned long)PROG_START;
     printf("start address = 0x%x\n", sa);
@@ -99,199 +91,4 @@
     printf("returned?\n");
 
     pause();
-}
-
-void make_bi_recs(unsigned long addr)
-{
-	struct bi_record *rec;
-
-	/* leave a 1MB gap then align to the next 1MB boundary */
-	addr = _ALIGN(addr+ (1<<20) - 1, (1<<20));
-	if (addr >= PROG_START + PROG_SIZE)
-		claim(addr, 0x1000, 0);
-
-	rec = (struct bi_record *)addr;
-	rec->tag = BI_FIRST;
-	rec->size = sizeof(struct bi_record);
-	rec = (struct bi_record *)((unsigned long)rec + rec->size);
-
-	rec->tag = BI_BOOTLOADER_ID;
-	sprintf( (char *)rec->data, "coffboot");
-	rec->size = sizeof(struct bi_record) + strlen("coffboot") + 1;
-	rec = (struct bi_record *)((unsigned long)rec + rec->size);
-	    
-	rec->tag = BI_MACHTYPE;
-	rec->data[0] = _MACH_Pmac;
-	rec->data[1] = 1;
-	rec->size = sizeof(struct bi_record) + 2 * sizeof(unsigned long);
-	rec = (struct bi_record *)((unsigned long)rec + rec->size);
-
-#ifdef SYSMAP_OFFSET
-	rec->tag = BI_SYSMAP;
-	rec->data[0] = SYSMAP_OFFSET;
-	rec->data[1] = SYSMAP_SIZE;
-	rec->size = sizeof(struct bi_record) + 2 * sizeof(unsigned long);
-	rec = (struct bi_record *)((unsigned long)rec + rec->size);
-#endif /* SYSMAP_OFFSET */
-	
-	rec->tag = BI_LAST;
-	rec->size = sizeof(struct bi_record);
-	rec = (struct bi_record *)((unsigned long)rec + rec->size);
-}
-
-#if 0
-#define eieio()	asm volatile("eieio");
-
-void stop_imac_ethernet(void)
-{
-    void *macio, *enet;
-    unsigned int macio_addr[5], enet_reg[6];
-    int len;
-    volatile unsigned int *dbdma;
-
-    macio = finddevice("/pci/mac-io");
-    enet = finddevice("/pci/mac-io/ethernet");
-    if (macio == NULL || enet == NULL)
-	return;
-    len = getprop(macio, "assigned-addresses", macio_addr, sizeof(macio_addr));
-    if (len != sizeof(macio_addr))
-	return;
-    len = getprop(enet, "reg", enet_reg, sizeof(enet_reg));
-    if (len != sizeof(enet_reg))
-	return;
-    printf("macio base %x, dma at %x & %x\n",
-	   macio_addr[2], enet_reg[2], enet_reg[4]);
-
-    /* hope this is mapped... */
-    dbdma = (volatile unsigned int *) (macio_addr[2] + enet_reg[2]);
-    *dbdma = 0x80;	/* clear the RUN bit */
-    eieio();
-    dbdma = (volatile unsigned int *) (macio_addr[2] + enet_reg[4]);
-    *dbdma = 0x80;	/* clear the RUN bit */
-    eieio();
-}
-
-void stop_imac_usb(void)
-{
-    void *usb;
-    unsigned int usb_addr[5];
-    int len;
-    volatile unsigned int *usb_ctrl;
-
-    usb = finddevice("/pci/usb");
-    if (usb == NULL)
-	return;
-    len = getprop(usb, "assigned-addresses", usb_addr, sizeof(usb_addr));
-    if (len != sizeof(usb_addr))
-	return;
-    printf("usb base %x\n", usb_addr[2]);
-
-    usb_ctrl = (volatile unsigned int *) (usb_addr[2] + 8);
-    *usb_ctrl = 0x01000000;	/* cpu_to_le32(1) */
-    eieio();
-}
-#endif
-
-struct memchunk {
-    unsigned int size;
-    struct memchunk *next;
-};
-
-static struct memchunk *freechunks;
-
-void *zalloc(void *x, unsigned items, unsigned size)
-{
-    void *p;
-    struct memchunk **mpp, *mp;
-
-    size *= items;
-    size = (size + 7) & -8;
-    heap_use += size;
-    if (heap_use > heap_max)
-	heap_max = heap_use;
-    for (mpp = &freechunks; (mp = *mpp) != 0; mpp = &mp->next) {
-	if (mp->size == size) {
-	    *mpp = mp->next;
-	    return mp;
-	}
-    }
-    p = avail_ram;
-    avail_ram += size;
-    if (avail_ram > avail_high)
-	avail_high = avail_ram;
-    if (avail_ram > end_avail) {
-	printf("oops... out of memory\n");
-	pause();
-    }
-    return p;
-}
-
-void zfree(void *x, void *addr, unsigned nb)
-{
-    struct memchunk *mp = addr;
-
-    nb = (nb + 7) & -8;
-    heap_use -= nb;
-    if (avail_ram == addr + nb) {
-	avail_ram = addr;
-	return;
-    }
-    mp->size = nb;
-    mp->next = freechunks;
-    freechunks = mp;
-}
-
-#define HEAD_CRC	2
-#define EXTRA_FIELD	4
-#define ORIG_NAME	8
-#define COMMENT		0x10
-#define RESERVED	0xe0
-
-#define DEFLATED	8
-
-void gunzip(void *dst, int dstlen, unsigned char *src, int *lenp)
-{
-    z_stream s;
-    int r, i, flags;
-
-    /* skip header */
-    i = 10;
-    flags = src[3];
-    if (src[2] != DEFLATED || (flags & RESERVED) != 0) {
-	printf("bad gzipped data\n");
-	exit();
-    }
-    if ((flags & EXTRA_FIELD) != 0)
-	i = 12 + src[10] + (src[11] << 8);
-    if ((flags & ORIG_NAME) != 0)
-	while (src[i++] != 0)
-	    ;
-    if ((flags & COMMENT) != 0)
-	while (src[i++] != 0)
-	    ;
-    if ((flags & HEAD_CRC) != 0)
-	i += 2;
-    if (i >= *lenp) {
-	printf("gunzip: ran out of data in header\n");
-	exit();
-    }
-
-    s.zalloc = zalloc;
-    s.zfree = zfree;
-    r = inflateInit2(&s, -MAX_WBITS);
-    if (r != Z_OK) {
-	printf("inflateInit2 returned %d\n", r);
-	exit();
-    }
-    s.next_in = src + i;
-    s.avail_in = *lenp - i;
-    s.next_out = dst;
-    s.avail_out = dstlen;
-    r = inflate(&s, Z_FINISH);
-    if (r != Z_OK && r != Z_STREAM_END) {
-	printf("inflate returned %d msg: %s\n", r, s.msg);
-	exit();
-    }
-    *lenp = s.next_out - (unsigned char *) dst;
-    inflateEnd(&s);
 }
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/pmac/coffmain.c linux/arch/ppc/boot/pmac/coffmain.c
--- v2.4.9/linux/arch/ppc/boot/pmac/coffmain.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/ppc/boot/pmac/coffmain.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.coffmain.c 1.12 06/12/01 16:42:26 paulus
+ * BK Id: SCCS/s.coffmain.c 1.14 07/27/01 20:24:18 trini
  */
 /*
  * Copyright (C) Paul Mackerras 1997.
@@ -11,18 +11,25 @@
  */
 #include "nonstdio.h"
 #include "zlib.h"
-#include <asm/bootinfo.h>
 #include <asm/processor.h>
-#include <asm/page.h>
 
-extern void *finddevice(const char *);
-extern int getprop(void *, const char *, void *, int);
+extern char _start[], _end[];
 extern char *claim(unsigned, unsigned, unsigned);
-void make_bi_recs(unsigned long);
-void gunzip(void *, int, unsigned char *, int *);
+extern char image_data[], initrd_data[];
+extern int initrd_len, image_len;
+extern int getprop(void *, const char *, void *, int);
+extern unsigned int heap_max;
+extern void *finddevice(const char *);
+extern void flush_cache(void *start, unsigned int len);
+extern void gunzip(void *, int, unsigned char *, int *);
+extern void make_bi_recs(unsigned long addr, char *name, unsigned int mach,
+		unsigned int progend);
+extern void pause(void);
+extern void setup_bats(unsigned long start);
 
-#define get_16be(x)	(*(unsigned short *)(x))
-#define get_32be(x)	(*(unsigned *)(x))
+char *avail_ram;
+char *begin_avail, *end_avail;
+char *avail_high;
 
 #define RAM_START	0
 #define RAM_END		(RAM_START + 0x800000)	/* only 8M mapped with BATs */
@@ -32,29 +39,16 @@
 
 #define SCRATCH_SIZE	(128 << 10)
 
-char *avail_ram;
-char *begin_avail, *end_avail;
-char *avail_high;
-unsigned int heap_use;
-unsigned int heap_max;
-
-extern char _start[], _end[];
-extern char image_data[];
-extern int image_len;
-extern char initrd_data[];
-extern int initrd_len;
+static char heap[SCRATCH_SIZE];
 
-char heap[SCRATCH_SIZE];
-
-boot(int a1, int a2, void *prom)
+void boot(int a1, int a2, void *prom)
 {
-    int ns, oh, i;
     unsigned sa, len;
     void *dst;
     unsigned char *im;
     unsigned initrd_start, initrd_size;
     
-    printf("coffboot starting: loaded at 0x%x\n", _start);
+    printf("coffboot starting: loaded at 0x%p\n", &_start);
     setup_bats(RAM_START);
     if (initrd_len) {
 	initrd_size = initrd_len;
@@ -62,21 +56,21 @@
 	a1 = initrd_start;
 	a2 = initrd_size;
 	claim(initrd_start - RAM_START, RAM_END - initrd_start, 0);
-	printf("initial ramdisk moving 0x%x <- 0x%x (%x bytes)\n",
+	printf("initial ramdisk moving 0x%x <- 0x%p (%x bytes)\n",
 	       initrd_start, initrd_data, initrd_size);
 	memcpy((char *)initrd_start, initrd_data, initrd_size);
     }
     im = image_data;
     len = image_len;
-    /* claim 3MB starting at 0 */
+    /* claim 4MB starting at 0 */
     claim(0, PROG_SIZE, 0);
     dst = (void *) RAM_START;
     if (im[0] == 0x1f && im[1] == 0x8b) {
 	/* set up scratch space */
 	begin_avail = avail_high = avail_ram = heap;
 	end_avail = heap + sizeof(heap);
-	printf("heap at 0x%x\n", avail_ram);
-	printf("gunzipping (0x%x <- 0x%x:0x%0x)...", dst, im, im+len);
+	printf("heap at 0x%p\n", avail_ram);
+	printf("gunzipping (0x%p <- 0x%p:0x%p)...", dst, im, im+len);
 	gunzip(dst, PROG_SIZE, im, &len);
 	printf("done %u bytes\n", len);
 	printf("%u bytes of heap consumed, max in use %u\n",
@@ -86,8 +80,9 @@
     }
 
     flush_cache(dst, len);
-    make_bi_recs((unsigned long)dst + len);
-    
+    make_bi_recs(((unsigned long) dst + len), "coffboot", _MACH_Pmac,
+		    (PROG_START + PROG_SIZE));
+
     sa = (unsigned long)PROG_START;
     printf("start address = 0x%x\n", sa);
 
@@ -96,139 +91,4 @@
     printf("returned?\n");
 
     pause();
-}
-
-void make_bi_recs(unsigned long addr)
-{
-	struct bi_record *rec;
-
-	addr = _ALIGN(addr+ (1<<20) - 1, (1<<20));
-#if 0
-	if (addr >= PROG_START + PROG_SIZE)
-		claim(addr, 0x1000, 0);
-#endif
-
-	rec = (struct bi_record *)addr;
-	rec->tag = BI_FIRST;
-	rec->size = sizeof(struct bi_record);
-	rec = (struct bi_record *)((unsigned long)rec + rec->size);
-
-	rec->tag = BI_BOOTLOADER_ID;
-	sprintf( (char *)rec->data, "coffboot");
-	rec->size = sizeof(struct bi_record) + strlen("coffboot") + 1;
-	rec = (struct bi_record *)((unsigned long)rec + rec->size);
-
-	rec->tag = BI_MACHTYPE;
-	rec->data[0] = _MACH_Pmac;
-	rec->data[1] = 1;
-	rec->size = sizeof(struct bi_record) + 2 * sizeof(unsigned long);
-	rec = (struct bi_record *)((unsigned long)rec + rec->size);
-
-	rec->tag = BI_LAST;
-	rec->size = sizeof(struct bi_record);
-	rec = (struct bi_record *)((unsigned long)rec + rec->size);
-}
-
-struct memchunk {
-    unsigned int size;
-    struct memchunk *next;
-};
-
-static struct memchunk *freechunks;
-
-void *zalloc(void *x, unsigned items, unsigned size)
-{
-    void *p;
-    struct memchunk **mpp, *mp;
-
-    size *= items;
-    size = (size + 7) & -8;
-    heap_use += size;
-    if (heap_use > heap_max)
-	heap_max = heap_use;
-    for (mpp = &freechunks; (mp = *mpp) != 0; mpp = &mp->next) {
-	if (mp->size == size) {
-	    *mpp = mp->next;
-	    return mp;
-	}
-    }
-    p = avail_ram;
-    avail_ram += size;
-    if (avail_ram > avail_high)
-	avail_high = avail_ram;
-    if (avail_ram > end_avail) {
-	printf("oops... out of memory\n");
-	pause();
-    }
-    return p;
-}
-
-void zfree(void *x, void *addr, unsigned nb)
-{
-    struct memchunk *mp = addr;
-
-    nb = (nb + 7) & -8;
-    heap_use -= nb;
-    if (avail_ram == addr + nb) {
-	avail_ram = addr;
-	return;
-    }
-    mp->size = nb;
-    mp->next = freechunks;
-    freechunks = mp;
-}
-
-#define HEAD_CRC	2
-#define EXTRA_FIELD	4
-#define ORIG_NAME	8
-#define COMMENT		0x10
-#define RESERVED	0xe0
-
-#define DEFLATED	8
-
-void gunzip(void *dst, int dstlen, unsigned char *src, int *lenp)
-{
-    z_stream s;
-    int r, i, flags;
-
-    /* skip header */
-    i = 10;
-    flags = src[3];
-    if (src[2] != DEFLATED || (flags & RESERVED) != 0) {
-	printf("bad gzipped data\n");
-	exit();
-    }
-    if ((flags & EXTRA_FIELD) != 0)
-	i = 12 + src[10] + (src[11] << 8);
-    if ((flags & ORIG_NAME) != 0)
-	while (src[i++] != 0)
-	    ;
-    if ((flags & COMMENT) != 0)
-	while (src[i++] != 0)
-	    ;
-    if ((flags & HEAD_CRC) != 0)
-	i += 2;
-    if (i >= *lenp) {
-	printf("gunzip: ran out of data in header\n");
-	exit();
-    }
-
-    s.zalloc = zalloc;
-    s.zfree = zfree;
-    r = inflateInit2(&s, -MAX_WBITS);
-    if (r != Z_OK) {
-	printf("inflateInit2 returned %d\n", r);
-	exit();
-    }
-    s.next_in = src + i;
-    s.avail_in = *lenp - i;
-    s.next_out = dst;
-    s.avail_out = dstlen;
-    r = inflate(&s, Z_FINISH);
-    if (r != Z_OK && r != Z_STREAM_END) {
-	printf("inflate returned %d msg: %s\n", r, s.msg);
-	exit();
-    }
-    *lenp = s.next_out - (unsigned char *) dst;
-    inflateEnd(&s);
 }
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/pmac/start.c linux/arch/ppc/boot/pmac/start.c
--- v2.4.9/linux/arch/ppc/boot/pmac/start.c	Thu May 24 15:02:07 2001
+++ linux/arch/ppc/boot/pmac/start.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.start.c 1.8 05/18/01 15:17:15 cort
+ * BK Id: SCCS/s.start.c 1.10 07/25/01 18:13:07 trini
  */
 /*
  * Copyright (C) Paul Mackerras 1997.
@@ -11,6 +11,9 @@
  */
 #include <stdarg.h>
 
+extern int strlen(const char *s);
+extern void boot(int a1, int a2, void *prom);
+
 int (*prom)();
 
 void *chosen_handle;
@@ -109,7 +112,7 @@
 }
 
 void
-exit()
+exit(void)
 {
     struct prom_args {
 	char *service;
@@ -122,7 +125,7 @@
 }
 
 void
-pause()
+pause(void)
 {
     struct prom_args {
 	char *service;
@@ -243,7 +246,7 @@
 }
 
 int
-readchar()
+readchar(void)
 {
     char ch;
 
@@ -263,7 +266,7 @@
 static int lineleft;
 
 int
-getchar()
+getchar(void)
 {
     int c;
 
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/prep/Makefile linux/arch/ppc/boot/prep/Makefile
--- v2.4.9/linux/arch/ppc/boot/prep/Makefile	Wed Jul 25 17:10:18 2001
+++ linux/arch/ppc/boot/prep/Makefile	Tue Aug 28 06:58:33 2001
@@ -1,4 +1,4 @@
-# BK Id: SCCS/s.Makefile 1.19 07/19/01 09:11:28 trini
+# BK Id: SCCS/s.Makefile 1.24 08/01/01 13:25:40 trini
 #
 # arch/ppc/boot/Makefile
 #
@@ -17,8 +17,6 @@
 
 USE_STANDARD_AS_RULE		:= true
 
-CFLAGS				+= -fno-builtin
-
 ifeq ($(CONFIG_SMP),y)
 TFTPIMAGE			= /tftpboot/zImage.prep.smp
 else
@@ -32,7 +30,7 @@
 OBJCOPY_ARGS			= -O elf32-powerpc
 LIBS 				= ../lib/zlib.a
 
-obj-$(CONFIG_SERIAL_CONSOLE)	+= ns16550.o
+obj-$(CONFIG_SERIAL_CONSOLE)	+= ../common/ns16550.o
 obj-$(CONFIG_VGA_CONSOLE)	+= vreset.o kbd.o
 
 # Tools
@@ -45,9 +43,6 @@
 misc.o: misc.c
 	$(CC) $(CFLAGS) -DINITRD_OFFSET=0 -DINITRD_SIZE=0 -DZIMAGE_OFFSET=0 \
 		-DZIMAGE_SIZE=0 -c -o $@ $*.c
-
-ns16550.o: ../common/ns16550.c
-	$(CC) $(CFLAGS) -DIOOFFSET=0x80000000 -c -o $@ ../common/$*.c
 
 zvmlinux.initrd: zvmlinux ../images/vmlinux.gz
 	$(LD) $(ZLINKFLAGS) -o $@.tmp $(obj-y) $(LIBS)
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/prep/head.S linux/arch/ppc/boot/prep/head.S
--- v2.4.9/linux/arch/ppc/boot/prep/head.S	Thu May 24 15:02:07 2001
+++ linux/arch/ppc/boot/prep/head.S	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.head.S 1.8 05/18/01 06:20:29 patch
+ * BK Id: SCCS/s.head.S 1.11 07/31/01 16:36:06 trini
  */
 #include "../../kernel/ppc_defs.h"
 #include "../../kernel/ppc_asm.tmpl"
@@ -95,6 +95,11 @@
 	subi	r1,r1,256
 	li	r2,0x000F		/* Mask pointer to 16-byte boundary */
 	andc	r1,r1,r2
+/* Setup ISA_io */
+	lis	r3,ISA_io@h
+	ori	r3,r3,ISA_io@l
+	lis	r4,0x8000
+	stw	r4,0(r3)
 /* Run loader */
 	mr	r3,r8			/* Load point */
 	mr	r4,r7			/* Program length */
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/prep/misc.c linux/arch/ppc/boot/prep/misc.c
--- v2.4.9/linux/arch/ppc/boot/prep/misc.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/ppc/boot/prep/misc.c	Tue Aug 28 06:58:33 2001
@@ -1,8 +1,7 @@
 /*
- * BK Id: SCCS/s.misc.c 1.14 06/16/01 20:43:20 trini
- */
-/*
- * misc.c
+ * BK Id: SCCS/s.misc.c 1.18 07/30/01 17:19:40 trini
+ *
+ * arch/ppc/boot/prep/misc.c
  *
  * Adapted for PowerPC by Gary Thomas
  *
@@ -11,7 +10,6 @@
  */
 
 #include <linux/types.h>
-#include "zlib.h"
 #include <asm/residual.h>
 #include <linux/config.h>
 #include <linux/threads.h>
@@ -22,9 +20,8 @@
 #include <asm/bootinfo.h>
 #include <asm/mmu.h>
 #include <asm/byteorder.h>
-#if defined(CONFIG_SERIAL_CONSOLE)
-unsigned long com_port;
-#endif /* CONFIG_SERIAL_CONSOLE */
+#include "nonstdio.h"
+#include "zlib.h"
 
 /*
  * Please send me load/board info and such data for hardware not
@@ -53,26 +50,28 @@
 char *zimage_start;
 int zimage_size;
 
+#if defined(CONFIG_SERIAL_CONSOLE)
+unsigned long com_port;
+#endif /* CONFIG_SERIAL_CONSOLE */
+#ifdef CONFIG_VGA_CONSOLE
 char *vidmem = (char *)0xC00B8000;
-int lines, cols;
-int orig_x, orig_y;
+int lines = 25, cols = 80;
+int orig_x, orig_y = 24;
+#endif /* CONFIG_VGA_CONSOLE */
 
-extern void puts(const char *);
-extern void putc(const char c);
-extern int tstc(void);
-extern int getc(void);
-extern void puthex(unsigned long val);
-extern void * memcpy(void * __dest, __const void * __src, __kernel_size_t __n);
 extern int CRT_tstc(void);
 extern void of_init(void *handler);
 extern int of_finddevice(const char *device_specifier, int *phandle);
 extern int of_getprop(int phandle, const char *name, void *buf, int buflen, 
 		int *size);
-extern __kernel_size_t strlen(const char *s);
 extern int vga_init(unsigned char *ISA_mem);
-extern void udelay(long x);
-void gunzip(void *, int, unsigned char *, int *);
-unsigned char inb(int);
+extern void gunzip(void *, int, unsigned char *, int *);
+
+extern void _put_HID0(unsigned int val);
+extern void _put_MSR(unsigned int val);
+extern unsigned int _get_HID0(void);
+extern unsigned int _get_MSR(void);
+extern unsigned long serial_init(int chan);
 
 void
 writel(unsigned int val, unsigned int address)
@@ -105,7 +104,7 @@
 
 #ifdef CONFIG_VGA_CONSOLE
 void
-scroll()
+scroll(void)
 {
 	int i;
 
@@ -120,7 +119,7 @@
  * Motorola dual processor platforms.  
  */
 void
-park_cpus()
+park_cpus(void)
 {
 	volatile void (*go)(RESIDUAL *, int, int, char *, int);
 	unsigned int i;
@@ -154,11 +153,6 @@
 	unsigned char base_mod;
 	int start_multi = 0;
 	unsigned int pci_viddid, pci_did, tulip_pci_base, tulip_base;
-
-	lines = 25;
-	cols = 80;
-	orig_x = 0;
-	orig_y = 24;
 	
 	/*
 	 * IBM's have the MMU on, so we have to disable it or
@@ -438,28 +432,8 @@
 /*
  * PCI/ISA I/O support
  */
-
-volatile unsigned char *ISA_io  = (unsigned char *)0x80000000;
-volatile unsigned char *ISA_mem = (unsigned char *)0xC0000000;
-
-void
-outb(int port, char val)
-{
-	/* Ensure I/O operations complete */
-	__asm__ volatile("eieio");
-	ISA_io[port] = val;
-}
-
-unsigned char
-inb(int port)
-{
-	/* Ensure I/O operations complete */
-	__asm__ volatile("eieio");
-	return (ISA_io[port]);
-}
-
 unsigned long
 local_to_PCI(unsigned long addr)
 {
-	return ((addr & 0x7FFFFFFF) | 0x80000000);
+	return (addr | 0x80000000);
 }
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/boot/prep/vreset.c linux/arch/ppc/boot/prep/vreset.c
--- v2.4.9/linux/arch/ppc/boot/prep/vreset.c	Thu May 24 15:02:07 2001
+++ linux/arch/ppc/boot/prep/vreset.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.vreset.c 1.9 05/18/01 06:20:29 patch
+ * BK Id: SCCS/s.vreset.c 1.11 07/25/01 18:13:07 trini
  */
 /*
  * vreset.c
@@ -22,12 +22,10 @@
  */
 
 #include "iso_font.h"
+#include "nonstdio.h"
 
 extern char *vidmem;
 extern int lines, cols;
-extern void udelay(long x);
-extern void outb(int port, char val);
-extern unsigned char inb(int port);
 struct VaRegs;
 
 /*
@@ -43,7 +41,7 @@
 void unlockVideo(int slot);
 void setTextRegs(struct VgaRegs *svp);
 void setTextCLUT(int shift);
-void clearVideoMemory();
+void clearVideoMemory(void);
 void loadFont(unsigned char *ISA_mem);
 
 static void mdelay(int ms)
@@ -59,100 +57,100 @@
 #define NREGS 54
 #define ENDMK  0xFFFF  /* End marker */
 
-#define S3Vendor        0x5333
+#define S3Vendor	0x5333
 #define CirrusVendor    0x1013
 #define DiamondVendor   0x100E
 #define MatroxVendor    0x102B
 #define ParadiseVendor  0x101C
 
 struct VgaRegs GenVgaTextRegs[NREGS+1] = {
-/*      port    index   value  */
-  /* SR Regs */
-        0x3c4,  0x1,    0x0,
-        0x3c4,  0x2,    0x3,
-        0x3c4,  0x3,    0x0,
-        0x3c4,  0x4,    0x2,
-   /* CR Regs */
-        0x3d4,  0x0,    0x5f,
-        0x3d4,  0x1,    0x4f,
-        0x3d4,  0x2,    0x50,
-        0x3d4,  0x3,    0x82,
-        0x3d4,  0x4,    0x55,
-        0x3d4,  0x5,    0x81,
-        0x3d4,  0x6,    0xbf,
-        0x3d4,  0x7,    0x1f,
-        0x3d4,  0x8,    0x00,
-        0x3d4,  0x9,    0x4f,
-        0x3d4,  0xa,    0x0d,
-        0x3d4,  0xb,    0x0e,
-        0x3d4,  0xc,    0x00,
-        0x3d4,  0xd,    0x00,
-        0x3d4,  0xe,    0x00,
-        0x3d4,  0xf,    0x00,
-        0x3d4,  0x10,   0x9c,
-        0x3d4,  0x11,   0x8e,
-        0x3d4,  0x12,   0x8f,
-        0x3d4,  0x13,   0x28,
-        0x3d4,  0x14,   0x1f,
-        0x3d4,  0x15,   0x96,
-        0x3d4,  0x16,   0xb9,
-        0x3d4,  0x17,   0xa3,
-   /* GR Regs */
-        0x3ce,  0x0,    0x0,
-        0x3ce,  0x1,    0x0,
-        0x3ce,  0x2,    0x0,
-        0x3ce,  0x3,    0x0,
-        0x3ce,  0x4,    0x0,
-        0x3ce,  0x5,    0x10,
-        0x3ce,  0x6,    0xe,
-        0x3ce,  0x7,    0x0,
-        0x3ce,  0x8,    0xff,
-        ENDMK
+	/* port		index	value  */
+	/* SR Regs */
+	{ 0x3c4,	0x1,	0x0 },
+	{ 0x3c4,	0x2,	0x3 },
+	{ 0x3c4,	0x3,	0x0 },
+	{ 0x3c4,	0x4,	0x2 },
+	 /* CR Regs */
+	{ 0x3d4,	0x0,	0x5f },
+	{ 0x3d4,	0x1,	0x4f },
+	{ 0x3d4,	0x2,	0x50 },
+	{ 0x3d4,	0x3,	0x82 },
+	{ 0x3d4,	0x4,	0x55 },
+	{ 0x3d4,	0x5,	0x81 },
+	{ 0x3d4,	0x6,	0xbf },
+	{ 0x3d4,	0x7,	0x1f },
+	{ 0x3d4,	0x8,	0x00 },
+	{ 0x3d4,	0x9,	0x4f },
+	{ 0x3d4,	0xa,	0x0d },
+	{ 0x3d4,	0xb,	0x0e },
+	{ 0x3d4,	0xc,	0x00 },
+	{ 0x3d4,	0xd,	0x00 },
+	{ 0x3d4,	0xe,	0x00 },
+	{ 0x3d4,	0xf,	0x00 },
+	{ 0x3d4,	0x10,	0x9c },
+	{ 0x3d4,	0x11,	0x8e },
+	{ 0x3d4,	0x12,	0x8f },
+	{ 0x3d4,	0x13,	0x28 },
+	{ 0x3d4,	0x14,	0x1f },
+	{ 0x3d4,	0x15,	0x96 },
+	{ 0x3d4,	0x16,	0xb9 },
+	{ 0x3d4,	0x17,	0xa3 },
+	 /* GR Regs */
+	{ 0x3ce,	0x0,	0x0 },
+	{ 0x3ce,	0x1,	0x0 },
+	{ 0x3ce,	0x2,	0x0 },
+	{ 0x3ce,	0x3,	0x0 },
+	{ 0x3ce,	0x4,	0x0 },
+	{ 0x3ce,	0x5,	0x10 },
+	{ 0x3ce,	0x6,	0xe },
+	{ 0x3ce,	0x7,	0x0 },
+	{ 0x3ce,	0x8,	0xff },
+	{ ENDMK }
 };
 
 struct VgaRegs S3TextRegs[NREGS+1] = {
-/*	port	index	value  */
-  /* SR Regs */
-	0x3c4,	0x1,	0x0,
-	0x3c4,	0x2,	0x3,
-	0x3c4,	0x3,	0x0,
-	0x3c4,	0x4,	0x2,
-   /* CR Regs */
-	0x3d4,	0x0,	0x5f,
-	0x3d4,	0x1,	0x4f,
-	0x3d4,	0x2,	0x50,
-	0x3d4,	0x3,	0x82,
-	0x3d4,	0x4,	0x55,
-	0x3d4,	0x5,	0x81,
-	0x3d4,	0x6,	0xbf,
-	0x3d4,	0x7,	0x1f,
-	0x3d4,	0x8,	0x00,
-	0x3d4,	0x9,	0x4f,
-	0x3d4,	0xa,	0x0d,
-	0x3d4,	0xb,	0x0e,
-	0x3d4,	0xc,	0x00,
-	0x3d4,	0xd,	0x00,
-	0x3d4,	0xe,	0x00,
-	0x3d4,	0xf,	0x00,
-	0x3d4,	0x10,	0x9c,
-	0x3d4,	0x11,	0x8e,
-	0x3d4,	0x12,	0x8f,
-	0x3d4,	0x13,	0x28,
-	0x3d4,	0x14,	0x1f,
-	0x3d4,	0x15,	0x96,
-	0x3d4,	0x16,	0xb9,
-	0x3d4,	0x17,	0xa3,
-   /* GR Regs */
-	0x3ce,	0x0,	0x0,
-	0x3ce,	0x1,	0x0,
-	0x3ce,	0x2,	0x0,
-	0x3ce,	0x3,	0x0,
-	0x3ce,	0x4,	0x0,
-	0x3ce,	0x5,	0x10,
-	0x3ce,	0x6,	0xe,
-	0x3ce,	0x7,	0x0,
-	0x3ce,	0x8,	0xff,
-        ENDMK
+	/* port		index	value */
+	/* SR Regs */
+	{ 0x3c4,	0x1,	0x0 },
+	{ 0x3c4,	0x2,	0x3 },
+	{ 0x3c4,	0x3,	0x0 },
+	{ 0x3c4,	0x4,	0x2 },
+	/* CR Regs */
+	{ 0x3d4,	0x0,	0x5f },
+	{ 0x3d4,	0x1,	0x4f },
+	{ 0x3d4,	0x2,	0x50 },
+	{ 0x3d4,	0x3,	0x82 },
+	{ 0x3d4,	0x4,	0x55 },
+	{ 0x3d4,	0x5,	0x81 },
+	{ 0x3d4,	0x6,	0xbf },
+	{ 0x3d4,	0x7,	0x1f },
+	{ 0x3d4,	0x8,	0x00 },
+	{ 0x3d4,	0x9,	0x4f },
+	{ 0x3d4,	0xa,	0x0d },
+	{ 0x3d4,	0xb,	0x0e },
+	{ 0x3d4,	0xc,	0x00 },
+	{ 0x3d4,	0xd,	0x00 },
+	{ 0x3d4,	0xe,	0x00 },
+	{ 0x3d4,	0xf,	0x00 },
+	{ 0x3d4,	0x10,	0x9c },
+	{ 0x3d4,	0x11,	0x8e },
+	{ 0x3d4,	0x12,	0x8f },
+	{ 0x3d4,	0x13,	0x28 },
+	{ 0x3d4,	0x14,	0x1f },
+	{ 0x3d4,	0x15,	0x96 },
+	{ 0x3d4,	0x16,	0xb9 },
+	{ 0x3d4,	0x17,	0xa3 },
+	/* GR Regs */
+	{ 0x3ce,	0x0,	0x0 },
+	{ 0x3ce,	0x1,	0x0 },
+	{ 0x3ce,	0x2,	0x0 },
+	{ 0x3ce,	0x3,	0x0 },
+	{ 0x3ce,	0x4,	0x0 },
+	{ 0x3ce,	0x5,	0x10 },
+	{ 0x3ce,	0x6,	0xe },
+	{ 0x3ce,	0x7,	0x0 },
+	{ 0x3ce,	0x8,	0xff },
+	{ ENDMK }
 };
 
 struct RGBColors
@@ -167,262 +165,262 @@
  */
 struct RGBColors TextCLUT[256] = 
 {
-  /*	red	green	blue  */
-	0x0,	0x0,	0x0,
-	0x0,	0x0,	0x2a,
-	0x0,	0x2a,	0x0,
-	0x0,	0x2a,	0x2a,
-	0x2a,	0x0,	0x0,
-	0x2a,	0x0,	0x2a,
-	0x2a,	0x2a,	0x0,
-	0x2a,	0x2a,	0x2a,
-	0x0,	0x0,	0x15,
-	0x0,	0x0,	0x3f,
-	0x0,	0x2a,	0x15,
-	0x0,	0x2a,	0x3f,
-	0x2a,	0x0,	0x15,
-	0x2a,	0x0,	0x3f,
-	0x2a,	0x2a,	0x15,
-	0x2a,	0x2a,	0x3f,
-	0x0,	0x15,	0x0,
-	0x0,	0x15,	0x2a,
-	0x0,	0x3f,	0x0,
-	0x0,	0x3f,	0x2a,
-	0x2a,	0x15,	0x0,
-	0x2a,	0x15,	0x2a,
-	0x2a,	0x3f,	0x0,
-	0x2a,	0x3f,	0x2a,
-	0x0,	0x15,	0x15,
-	0x0,	0x15,	0x3f,
-	0x0,	0x3f,	0x15,
-	0x0,	0x3f,	0x3f,
-	0x2a,	0x15,	0x15,
-	0x2a,	0x15,	0x3f,
-	0x2a,	0x3f,	0x15,
-	0x2a,	0x3f,	0x3f,
-	0x15,	0x0,	0x0,
-	0x15,	0x0,	0x2a,
-	0x15,	0x2a,	0x0,
-	0x15,	0x2a,	0x2a,
-	0x3f,	0x0,	0x0,
-	0x3f,	0x0,	0x2a,
-	0x3f,	0x2a,	0x0,
-	0x3f,	0x2a,	0x2a,
-	0x15,	0x0,	0x15,
-	0x15,	0x0,	0x3f,
-	0x15,	0x2a,	0x15,
-	0x15,	0x2a,	0x3f,
-	0x3f,	0x0,	0x15,
-	0x3f,	0x0,	0x3f,
-	0x3f,	0x2a,	0x15,
-	0x3f,	0x2a,	0x3f,
-	0x15,	0x15,	0x0,
-	0x15,	0x15,	0x2a,
-	0x15,	0x3f,	0x0,
-	0x15,	0x3f,	0x2a,
-	0x3f,	0x15,	0x0,
-	0x3f,	0x15,	0x2a,
-	0x3f,	0x3f,	0x0,
-	0x3f,	0x3f,	0x2a,
-	0x15,	0x15,	0x15,
-	0x15,	0x15,	0x3f,
-	0x15,	0x3f,	0x15,
-	0x15,	0x3f,	0x3f,
-	0x3f,	0x15,	0x15,
-	0x3f,	0x15,	0x3f,
-	0x3f,	0x3f,	0x15,
-	0x3f,	0x3f,	0x3f,
-	0x39,	0xc,	0x5,
-	0x15,	0x2c,	0xf,
-	0x26,	0x10,	0x3d,
-	0x29,	0x29,	0x38,
-	0x4,	0x1a,	0xe,
-	0x2,	0x1e,	0x3a,
-	0x3c,	0x25,	0x33,
-	0x3c,	0xc,	0x2c,
-	0x3f,	0x3,	0x2b,
-	0x1c,	0x9,	0x13,
-	0x25,	0x2a,	0x35,
-	0x1e,	0xa,	0x38,
-	0x24,	0x8,	0x3,
-	0x3,	0xe,	0x36,
-	0xc,	0x6,	0x2a,
-	0x26,	0x3,	0x32,
-	0x5,	0x2f,	0x33,
-	0x3c,	0x35,	0x2f,
-	0x2d,	0x26,	0x3e,
-	0xd,	0xa,	0x10,
-	0x25,	0x3c,	0x11,
-	0xd,	0x4,	0x2e,
-	0x5,	0x19,	0x3e,
-	0xc,	0x13,	0x34,
-	0x2b,	0x6,	0x24,
-	0x4,	0x3,	0xd,
-	0x2f,	0x3c,	0xc,
-	0x2a,	0x37,	0x1f,
-	0xf,	0x12,	0x38,
-	0x38,	0xe,	0x2a,
-	0x12,	0x2f,	0x19,
-	0x29,	0x2e,	0x31,
-	0x25,	0x13,	0x3e,
-	0x33,	0x3e,	0x33,
-	0x1d,	0x2c,	0x25,
-	0x15,	0x15,	0x5,
-	0x32,	0x25,	0x39,
-	0x1a,	0x7,	0x1f,
-	0x13,	0xe,	0x1d,
-	0x36,	0x17,	0x34,
-	0xf,	0x15,	0x23,
-	0x2,	0x35,	0xd,
-	0x15,	0x3f,	0xc,
-	0x14,	0x2f,	0xf,
-	0x19,	0x21,	0x3e,
-	0x27,	0x11,	0x2f,
-	0x38,	0x3f,	0x3c,
-	0x36,	0x2d,	0x15,
-	0x16,	0x17,	0x2,
-	0x1,	0xa,	0x3d,
-	0x1b,	0x11,	0x3f,
-	0x21,	0x3c,	0xd,
-	0x1a,	0x39,	0x3d,
-	0x8,	0xe,	0xe,
-	0x22,	0x21,	0x23,
-	0x1e,	0x30,	0x5,
-	0x1f,	0x22,	0x3d,
-	0x1e,	0x2f,	0xa,
-	0x0,	0x1c,	0xe,
-	0x0,	0x1c,	0x15,
-	0x0,	0x1c,	0x1c,
-	0x0,	0x15,	0x1c,
-	0x0,	0xe,	0x1c,
-	0x0,	0x7,	0x1c,
-	0xe,	0xe,	0x1c,
-	0x11,	0xe,	0x1c,
-	0x15,	0xe,	0x1c,
-	0x18,	0xe,	0x1c,
-	0x1c,	0xe,	0x1c,
-	0x1c,	0xe,	0x18,
-	0x1c,	0xe,	0x15,
-	0x1c,	0xe,	0x11,
-	0x1c,	0xe,	0xe,
-	0x1c,	0x11,	0xe,
-	0x1c,	0x15,	0xe,
-	0x1c,	0x18,	0xe,
-	0x1c,	0x1c,	0xe,
-	0x18,	0x1c,	0xe,
-	0x15,	0x1c,	0xe,
-	0x11,	0x1c,	0xe,
-	0xe,	0x1c,	0xe,
-	0xe,	0x1c,	0x11,
-	0xe,	0x1c,	0x15,
-	0xe,	0x1c,	0x18,
-	0xe,	0x1c,	0x1c,
-	0xe,	0x18,	0x1c,
-	0xe,	0x15,	0x1c,
-	0xe,	0x11,	0x1c,
-	0x14,	0x14,	0x1c,
-	0x16,	0x14,	0x1c,
-	0x18,	0x14,	0x1c,
-	0x1a,	0x14,	0x1c,
-	0x1c,	0x14,	0x1c,
-	0x1c,	0x14,	0x1a,
-	0x1c,	0x14,	0x18,
-	0x1c,	0x14,	0x16,
-	0x1c,	0x14,	0x14,
-	0x1c,	0x16,	0x14,
-	0x1c,	0x18,	0x14,
-	0x1c,	0x1a,	0x14,
-	0x1c,	0x1c,	0x14,
-	0x1a,	0x1c,	0x14,
-	0x18,	0x1c,	0x14,
-	0x16,	0x1c,	0x14,
-	0x14,	0x1c,	0x14,
-	0x14,	0x1c,	0x16,
-	0x14,	0x1c,	0x18,
-	0x14,	0x1c,	0x1a,
-	0x14,	0x1c,	0x1c,
-	0x14,	0x1a,	0x1c,
-	0x14,	0x18,	0x1c,
-	0x14,	0x16,	0x1c,
-	0x0,	0x0,	0x10,
-	0x4,	0x0,	0x10,
-	0x8,	0x0,	0x10,
-	0xc,	0x0,	0x10,
-	0x10,	0x0,	0x10,
-	0x10,	0x0,	0xc,
-	0x10,	0x0,	0x8,
-	0x10,	0x0,	0x4,
-	0x10,	0x0,	0x0,
-	0x10,	0x4,	0x0,
-	0x10,	0x8,	0x0,
-	0x10,	0xc,	0x0,
-	0x10,	0x10,	0x0,
-	0xc,	0x10,	0x0,
-	0x8,	0x10,	0x0,
-	0x4,	0x10,	0x0,
-	0x0,	0x10,	0x0,
-	0x0,	0x10,	0x4,
-	0x0,	0x10,	0x8,
-	0x0,	0x10,	0xc,
-	0x0,	0x10,	0x10,
-	0x0,	0xc,	0x10,
-	0x0,	0x8,	0x10,
-	0x0,	0x4,	0x10,
-	0x8,	0x8,	0x10,
-	0xa,	0x8,	0x10,
-	0xc,	0x8,	0x10,
-	0xe,	0x8,	0x10,
-	0x10,	0x8,	0x10,
-	0x10,	0x8,	0xe,
-	0x10,	0x8,	0xc,
-	0x10,	0x8,	0xa,
-	0x10,	0x8,	0x8,
-	0x10,	0xa,	0x8,
-	0x10,	0xc,	0x8,
-	0x10,	0xe,	0x8,
-	0x10,	0x10,	0x8,
-	0xe,	0x10,	0x8,
-	0xc,	0x10,	0x8,
-	0xa,	0x10,	0x8,
-	0x8,	0x10,	0x8,
-	0x8,	0x10,	0xa,
-	0x8,	0x10,	0xc,
-	0x8,	0x10,	0xe,
-	0x8,	0x10,	0x10,
-	0x8,	0xe,	0x10,
-	0x8,	0xc,	0x10,
-	0x8,	0xa,	0x10,
-	0xb,	0xb,	0x10,
-	0xc,	0xb,	0x10,
-	0xd,	0xb,	0x10,
-	0xf,	0xb,	0x10,
-	0x10,	0xb,	0x10,
-	0x10,	0xb,	0xf,
-	0x10,	0xb,	0xd,
-	0x10,	0xb,	0xc,
-	0x10,	0xb,	0xb,
-	0x10,	0xc,	0xb,
-	0x10,	0xd,	0xb,
-	0x10,	0xf,	0xb,
-	0x10,	0x10,	0xb,
-	0xf,	0x10,	0xb,
-	0xd,	0x10,	0xb,
-	0xc,	0x10,	0xb,
-	0xb,	0x10,	0xb,
-	0xb,	0x10,	0xc,
-	0xb,	0x10,	0xd,
-	0xb,	0x10,	0xf,
-	0xb,	0x10,	0x10,
-	0xb,	0xf,	0x10,
-	0xb,	0xd,	0x10,
-	0xb,	0xc,	0x10,
-	0x0,	0x0,	0x0,
-	0x0,	0x0,	0x0,
-	0x0,	0x0,	0x0,
-	0x0,	0x0,	0x0,
-	0x0,	0x0,	0x0,
-	0x0,	0x0,	0x0,
-	0x0,	0x0,	0x0
+	/* red	green	blue  */
+	{ 0x0,	0x0,	0x0 },
+	{ 0x0,	0x0,	0x2a },
+	{ 0x0,	0x2a,	0x0 },
+	{ 0x0,	0x2a,	0x2a },
+	{ 0x2a,	0x0,	0x0 },
+	{ 0x2a,	0x0,	0x2a },
+	{ 0x2a,	0x2a,	0x0 },
+	{ 0x2a,	0x2a,	0x2a },
+	{ 0x0,	0x0,	0x15 },
+	{ 0x0,	0x0,	0x3f },
+	{ 0x0,	0x2a,	0x15 },
+	{ 0x0,	0x2a,	0x3f },
+	{ 0x2a,	0x0,	0x15 },
+	{ 0x2a,	0x0,	0x3f },
+	{ 0x2a,	0x2a,	0x15 },
+	{ 0x2a,	0x2a,	0x3f },
+	{ 0x0,	0x15,	0x0 },
+	{ 0x0,	0x15,	0x2a },
+	{ 0x0,	0x3f,	0x0 },
+	{ 0x0,	0x3f,	0x2a },
+	{ 0x2a,	0x15,	0x0 },
+	{ 0x2a,	0x15,	0x2a },
+	{ 0x2a,	0x3f,	0x0 },
+	{ 0x2a,	0x3f,	0x2a },
+	{ 0x0,	0x15,	0x15 },
+	{ 0x0,	0x15,	0x3f },
+	{ 0x0,	0x3f,	0x15 },
+	{ 0x0,	0x3f,	0x3f },
+	{ 0x2a,	0x15,	0x15 },
+	{ 0x2a,	0x15,	0x3f },
+	{ 0x2a,	0x3f,	0x15 },
+	{ 0x2a,	0x3f,	0x3f },
+	{ 0x15,	0x0,	0x0 },
+	{ 0x15,	0x0,	0x2a },
+	{ 0x15,	0x2a,	0x0 },
+	{ 0x15,	0x2a,	0x2a },
+	{ 0x3f,	0x0,	0x0 },
+	{ 0x3f,	0x0,	0x2a },
+	{ 0x3f,	0x2a,	0x0 },
+	{ 0x3f,	0x2a,	0x2a },
+	{ 0x15,	0x0,	0x15 },
+	{ 0x15,	0x0,	0x3f },
+	{ 0x15,	0x2a,	0x15 },
+	{ 0x15,	0x2a,	0x3f },
+	{ 0x3f,	0x0,	0x15 },
+	{ 0x3f,	0x0,	0x3f },
+	{ 0x3f,	0x2a,	0x15 },
+	{ 0x3f,	0x2a,	0x3f },
+	{ 0x15,	0x15,	0x0 },
+	{ 0x15,	0x15,	0x2a },
+	{ 0x15,	0x3f,	0x0 },
+	{ 0x15,	0x3f,	0x2a },
+	{ 0x3f,	0x15,	0x0 },
+	{ 0x3f,	0x15,	0x2a },
+	{ 0x3f,	0x3f,	0x0 },
+	{ 0x3f,	0x3f,	0x2a },
+	{ 0x15,	0x15,	0x15 },
+	{ 0x15,	0x15,	0x3f },
+	{ 0x15,	0x3f,	0x15 },
+	{ 0x15,	0x3f,	0x3f },
+	{ 0x3f,	0x15,	0x15 },
+	{ 0x3f,	0x15,	0x3f },
+	{ 0x3f,	0x3f,	0x15 },
+	{ 0x3f,	0x3f,	0x3f },
+	{ 0x39,	0xc,	0x5 },
+	{ 0x15,	0x2c,	0xf },
+	{ 0x26,	0x10,	0x3d },
+	{ 0x29,	0x29,	0x38 },
+	{ 0x4,	0x1a,	0xe },
+	{ 0x2,	0x1e,	0x3a },
+	{ 0x3c,	0x25,	0x33 },
+	{ 0x3c,	0xc,	0x2c },
+	{ 0x3f,	0x3,	0x2b },
+	{ 0x1c,	0x9,	0x13 },
+	{ 0x25,	0x2a,	0x35 },
+	{ 0x1e,	0xa,	0x38 },
+	{ 0x24,	0x8,	0x3 },
+	{ 0x3,	0xe,	0x36 },
+	{ 0xc,	0x6,	0x2a },
+	{ 0x26,	0x3,	0x32 },
+	{ 0x5,	0x2f,	0x33 },
+	{ 0x3c,	0x35,	0x2f },
+	{ 0x2d,	0x26,	0x3e },
+	{ 0xd,	0xa,	0x10 },
+	{ 0x25,	0x3c,	0x11 },
+	{ 0xd,	0x4,	0x2e },
+	{ 0x5,	0x19,	0x3e },
+	{ 0xc,	0x13,	0x34 },
+	{ 0x2b,	0x6,	0x24 },
+	{ 0x4,	0x3,	0xd },
+	{ 0x2f,	0x3c,	0xc },
+	{ 0x2a,	0x37,	0x1f },
+	{ 0xf,	0x12,	0x38 },
+	{ 0x38,	0xe,	0x2a },
+	{ 0x12,	0x2f,	0x19 },
+	{ 0x29,	0x2e,	0x31 },
+	{ 0x25,	0x13,	0x3e },
+	{ 0x33,	0x3e,	0x33 },
+	{ 0x1d,	0x2c,	0x25 },
+	{ 0x15,	0x15,	0x5 },
+	{ 0x32,	0x25,	0x39 },
+	{ 0x1a,	0x7,	0x1f },
+	{ 0x13,	0xe,	0x1d },
+	{ 0x36,	0x17,	0x34 },
+	{ 0xf,	0x15,	0x23 },
+	{ 0x2,	0x35,	0xd },
+	{ 0x15,	0x3f,	0xc },
+	{ 0x14,	0x2f,	0xf },
+	{ 0x19,	0x21,	0x3e },
+	{ 0x27,	0x11,	0x2f },
+	{ 0x38,	0x3f,	0x3c },
+	{ 0x36,	0x2d,	0x15 },
+	{ 0x16,	0x17,	0x2 },
+	{ 0x1,	0xa,	0x3d },
+	{ 0x1b,	0x11,	0x3f },
+	{ 0x21,	0x3c,	0xd },
+	{ 0x1a,	0x39,	0x3d },
+	{ 0x8,	0xe,	0xe },
+	{ 0x22,	0x21,	0x23 },
+	{ 0x1e,	0x30,	0x5 },
+	{ 0x1f,	0x22,	0x3d },
+	{ 0x1e,	0x2f,	0xa },
+	{ 0x0,	0x1c,	0xe },
+	{ 0x0,	0x1c,	0x15 },
+	{ 0x0,	0x1c,	0x1c },
+	{ 0x0,	0x15,	0x1c },
+	{ 0x0,	0xe,	0x1c },
+	{ 0x0,	0x7,	0x1c },
+	{ 0xe,	0xe,	0x1c },
+	{ 0x11,	0xe,	0x1c },
+	{ 0x15,	0xe,	0x1c },
+	{ 0x18,	0xe,	0x1c },
+	{ 0x1c,	0xe,	0x1c },
+	{ 0x1c,	0xe,	0x18 },
+	{ 0x1c,	0xe,	0x15 },
+	{ 0x1c,	0xe,	0x11 },
+	{ 0x1c,	0xe,	0xe },
+	{ 0x1c,	0x11,	0xe },
+	{ 0x1c,	0x15,	0xe },
+	{ 0x1c,	0x18,	0xe },
+	{ 0x1c,	0x1c,	0xe },
+	{ 0x18,	0x1c,	0xe },
+	{ 0x15,	0x1c,	0xe },
+	{ 0x11,	0x1c,	0xe },
+	{ 0xe,	0x1c,	0xe },
+	{ 0xe,	0x1c,	0x11 },
+	{ 0xe,	0x1c,	0x15 },
+	{ 0xe,	0x1c,	0x18 },
+	{ 0xe,	0x1c,	0x1c },
+	{ 0xe,	0x18,	0x1c },
+	{ 0xe,	0x15,	0x1c },
+	{ 0xe,	0x11,	0x1c },
+	{ 0x14,	0x14,	0x1c },
+	{ 0x16,	0x14,	0x1c },
+	{ 0x18,	0x14,	0x1c },
+	{ 0x1a,	0x14,	0x1c },
+	{ 0x1c,	0x14,	0x1c },
+	{ 0x1c,	0x14,	0x1a },
+	{ 0x1c,	0x14,	0x18 },
+	{ 0x1c,	0x14,	0x16 },
+	{ 0x1c,	0x14,	0x14 },
+	{ 0x1c,	0x16,	0x14 },
+	{ 0x1c,	0x18,	0x14 },
+	{ 0x1c,	0x1a,	0x14 },
+	{ 0x1c,	0x1c,	0x14 },
+	{ 0x1a,	0x1c,	0x14 },
+	{ 0x18,	0x1c,	0x14 },
+	{ 0x16,	0x1c,	0x14 },
+	{ 0x14,	0x1c,	0x14 },
+	{ 0x14,	0x1c,	0x16 },
+	{ 0x14,	0x1c,	0x18 },
+	{ 0x14,	0x1c,	0x1a },
+	{ 0x14,	0x1c,	0x1c },
+	{ 0x14,	0x1a,	0x1c },
+	{ 0x14,	0x18,	0x1c },
+	{ 0x14,	0x16,	0x1c },
+	{ 0x0,	0x0,	0x10 },
+	{ 0x4,	0x0,	0x10 },
+	{ 0x8,	0x0,	0x10 },
+	{ 0xc,	0x0,	0x10 },
+	{ 0x10,	0x0,	0x10 },
+	{ 0x10,	0x0,	0xc },
+	{ 0x10,	0x0,	0x8 },
+	{ 0x10,	0x0,	0x4 },
+	{ 0x10,	0x0,	0x0 },
+	{ 0x10,	0x4,	0x0 },
+	{ 0x10,	0x8,	0x0 },
+	{ 0x10,	0xc,	0x0 },
+	{ 0x10,	0x10,	0x0 },
+	{ 0xc,	0x10,	0x0 },
+	{ 0x8,	0x10,	0x0 },
+	{ 0x4,	0x10,	0x0 },
+	{ 0x0,	0x10,	0x0 },
+	{ 0x0,	0x10,	0x4 },
+	{ 0x0,	0x10,	0x8 },
+	{ 0x0,	0x10,	0xc },
+	{ 0x0,	0x10,	0x10 },
+	{ 0x0,	0xc,	0x10 },
+	{ 0x0,	0x8,	0x10 },
+	{ 0x0,	0x4,	0x10 },
+	{ 0x8,	0x8,	0x10 },
+	{ 0xa,	0x8,	0x10 },
+	{ 0xc,	0x8,	0x10 },
+	{ 0xe,	0x8,	0x10 },
+	{ 0x10,	0x8,	0x10 },
+	{ 0x10,	0x8,	0xe },
+	{ 0x10,	0x8,	0xc },
+	{ 0x10,	0x8,	0xa },
+	{ 0x10,	0x8,	0x8 },
+	{ 0x10,	0xa,	0x8 },
+	{ 0x10,	0xc,	0x8 },
+	{ 0x10,	0xe,	0x8 },
+	{ 0x10,	0x10,	0x8 },
+	{ 0xe,	0x10,	0x8 },
+	{ 0xc,	0x10,	0x8 },
+	{ 0xa,	0x10,	0x8 },
+	{ 0x8,	0x10,	0x8 },
+	{ 0x8,	0x10,	0xa },
+	{ 0x8,	0x10,	0xc },
+	{ 0x8,	0x10,	0xe },
+	{ 0x8,	0x10,	0x10 },
+	{ 0x8,	0xe,	0x10 },
+	{ 0x8,	0xc,	0x10 },
+	{ 0x8,	0xa,	0x10 },
+	{ 0xb,	0xb,	0x10 },
+	{ 0xc,	0xb,	0x10 },
+	{ 0xd,	0xb,	0x10 },
+	{ 0xf,	0xb,	0x10 },
+	{ 0x10,	0xb,	0x10 },
+	{ 0x10,	0xb,	0xf },
+	{ 0x10,	0xb,	0xd },
+	{ 0x10,	0xb,	0xc },
+	{ 0x10,	0xb,	0xb },
+	{ 0x10,	0xc,	0xb },
+	{ 0x10,	0xd,	0xb },
+	{ 0x10,	0xf,	0xb },
+	{ 0x10,	0x10,	0xb },
+	{ 0xf,	0x10,	0xb },
+	{ 0xd,	0x10,	0xb },
+	{ 0xc,	0x10,	0xb },
+	{ 0xb,	0x10,	0xb },
+	{ 0xb,	0x10,	0xc },
+	{ 0xb,	0x10,	0xd },
+	{ 0xb,	0x10,	0xf },
+	{ 0xb,	0x10,	0x10 },
+	{ 0xb,	0xf,	0x10 },
+	{ 0xb,	0xd,	0x10 },
+	{ 0xb,	0xc,	0x10 },
+	{ 0x0,	0x0,	0x0 },
+	{ 0x0,	0x0,	0x0 },
+	{ 0x0,	0x0,	0x0 },
+	{ 0x0,	0x0,	0x0 },
+	{ 0x0,	0x0,	0x0 },
+	{ 0x0,	0x0,	0x0 },
+	{ 0x0,	0x0,	0x0 }
 };
 
 unsigned char AC[21] = {
@@ -721,7 +719,7 @@
 }
 
 void
-clearVideoMemory()
+clearVideoMemory(void)
 {
 	int i, j;
 	for (i = 0;  i < lines;  i++) {
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/config.in linux/arch/ppc/config.in
--- v2.4.9/linux/arch/ppc/config.in	Wed Jul 25 17:10:18 2001
+++ linux/arch/ppc/config.in	Tue Aug 28 07:11:33 2001
@@ -1,4 +1,4 @@
-# BK Id: SCCS/s.config.in 1.34 07/08/01 11:39:11 trini
+# BK Id: SCCS/s.config.in 1.40 08/24/01 20:31:47 paulus
 #
 # For a description of the syntax of this configuration file,
 # see Documentation/kbuild/config-language.txt.
@@ -26,6 +26,7 @@
 mainmenu_option next_comment
 comment 'Platform support'
 define_bool CONFIG_PPC y
+define_bool CONFIG_PPC32 y
 choice 'Processor Type'	\
 	"6xx/7xx/74xx/8260	CONFIG_6xx	\
 	 4xx			CONFIG_4xx	\
@@ -42,6 +43,11 @@
   define_bool CONFIG_ALL_PPC y
 fi
 
+if [ "$CONFIG_6xx" = "y" -o "$CONFIG_POWER3" = "y" -o \
+     "$CONFIG_POWER4" = "y" ]; then
+  define_bool CONFIG_PPC_STD_MMU y
+fi
+
 if [ "$CONFIG_8260" = "y" ]; then
   define_bool CONFIG_SERIAL_CONSOLE y
   bool 'Support for EST8260' CONFIG_EST8260
@@ -93,7 +99,8 @@
   bool 'Workarounds for PPC601 bugs' CONFIG_PPC601_SYNC_FIX
 fi
 
-if [ "$CONFIG_8xx" = "y" -o "$CONFIG_8260" = "y" ]; then
+if [ "$CONFIG_POWER3" = "n" -a "$CONFIG_POWER4" = "n" -a \
+	"$CONFIG_6xx" = "n" ]; then
   define_bool CONFIG_ALL_PPC n
 fi
 
@@ -104,6 +111,11 @@
 
 if [ "$CONFIG_6xx" = "y" -a "$CONFIG_8260" = "n" ];then
   bool 'AltiVec Support' CONFIG_ALTIVEC
+  bool 'Thermal Management Support' CONFIG_TAU
+  if [ "$CONFIG_TAU" = "y" ]; then
+    bool '    Interrupt driven TAU driver (DANGEROUS)' CONFIG_TAU_INT
+    bool '    Average high and low temp' CONFIG_TAU_AVERAGE
+  fi
 fi
 
 if [ "$CONFIG_4xx" = "y" -o "$CONFIG_8xx" = "y" ]; then
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/configs/IVMS8_defconfig linux/arch/ppc/configs/IVMS8_defconfig
--- v2.4.9/linux/arch/ppc/configs/IVMS8_defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/configs/IVMS8_defconfig	Tue Aug 28 06:58:33 2001
@@ -21,6 +21,7 @@
 # Platform support
 #
 CONFIG_PPC=y
+CONFIG_PPC32=y
 # CONFIG_6xx is not set
 # CONFIG_4xx is not set
 # CONFIG_POWER3 is not set
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/configs/SM850_defconfig linux/arch/ppc/configs/SM850_defconfig
--- v2.4.9/linux/arch/ppc/configs/SM850_defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/configs/SM850_defconfig	Tue Aug 28 06:58:33 2001
@@ -21,6 +21,7 @@
 # Platform support
 #
 CONFIG_PPC=y
+CONFIG_PPC32=y
 # CONFIG_6xx is not set
 # CONFIG_4xx is not set
 # CONFIG_POWER3 is not set
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/configs/SPD823TS_defconfig linux/arch/ppc/configs/SPD823TS_defconfig
--- v2.4.9/linux/arch/ppc/configs/SPD823TS_defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/configs/SPD823TS_defconfig	Tue Aug 28 06:58:33 2001
@@ -21,6 +21,7 @@
 # Platform support
 #
 CONFIG_PPC=y
+CONFIG_PPC32=y
 # CONFIG_6xx is not set
 # CONFIG_4xx is not set
 # CONFIG_POWER3 is not set
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/configs/TQM823L_defconfig linux/arch/ppc/configs/TQM823L_defconfig
--- v2.4.9/linux/arch/ppc/configs/TQM823L_defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/configs/TQM823L_defconfig	Tue Aug 28 06:58:33 2001
@@ -21,6 +21,7 @@
 # Platform support
 #
 CONFIG_PPC=y
+CONFIG_PPC32=y
 # CONFIG_6xx is not set
 # CONFIG_4xx is not set
 # CONFIG_POWER3 is not set
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/configs/TQM850L_defconfig linux/arch/ppc/configs/TQM850L_defconfig
--- v2.4.9/linux/arch/ppc/configs/TQM850L_defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/configs/TQM850L_defconfig	Tue Aug 28 06:58:33 2001
@@ -21,6 +21,7 @@
 # Platform support
 #
 CONFIG_PPC=y
+CONFIG_PPC32=y
 # CONFIG_6xx is not set
 # CONFIG_4xx is not set
 # CONFIG_POWER3 is not set
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/configs/TQM860L_defconfig linux/arch/ppc/configs/TQM860L_defconfig
--- v2.4.9/linux/arch/ppc/configs/TQM860L_defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/configs/TQM860L_defconfig	Tue Aug 28 06:58:33 2001
@@ -21,6 +21,7 @@
 # Platform support
 #
 CONFIG_PPC=y
+CONFIG_PPC32=y
 # CONFIG_6xx is not set
 # CONFIG_4xx is not set
 # CONFIG_POWER3 is not set
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/configs/apus_defconfig linux/arch/ppc/configs/apus_defconfig
--- v2.4.9/linux/arch/ppc/configs/apus_defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/configs/apus_defconfig	Tue Aug 28 06:58:33 2001
@@ -21,18 +21,21 @@
 # Platform support
 #
 CONFIG_PPC=y
+CONFIG_PPC32=y
 CONFIG_6xx=y
 # CONFIG_4xx is not set
 # CONFIG_POWER3 is not set
 # CONFIG_POWER4 is not set
 # CONFIG_8xx is not set
 # CONFIG_8260 is not set
+CONFIG_PPC_STD_MMU=y
 # CONFIG_ALL_PPC is not set
 CONFIG_APUS=y
 # CONFIG_GEMINI is not set
 # CONFIG_PPC601_SYNC_FIX is not set
 # CONFIG_SMP is not set
 # CONFIG_ALTIVEC is not set
+# CONFIG_TAU is not set
 
 #
 # General setup
@@ -746,8 +749,10 @@
 CONFIG_SOUND=y
 CONFIG_DMASOUND_PAULA=m
 CONFIG_DMASOUND=m
+# CONFIG_SOUND_BT878 is not set
 # CONFIG_SOUND_CMPCI is not set
 # CONFIG_SOUND_EMU10K1 is not set
+# CONFIG_MIDI_EMU10K1 is not set
 # CONFIG_SOUND_FUSION is not set
 # CONFIG_SOUND_CS4281 is not set
 # CONFIG_SOUND_ES1370 is not set
@@ -756,6 +761,7 @@
 # CONFIG_SOUND_MAESTRO is not set
 # CONFIG_SOUND_MAESTRO3 is not set
 # CONFIG_SOUND_ICH is not set
+# CONFIG_SOUND_RME96XX is not set
 # CONFIG_SOUND_SONICVIBES is not set
 # CONFIG_SOUND_TRIDENT is not set
 # CONFIG_SOUND_MSNDCLAS is not set
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/configs/bseip_defconfig linux/arch/ppc/configs/bseip_defconfig
--- v2.4.9/linux/arch/ppc/configs/bseip_defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/configs/bseip_defconfig	Tue Aug 28 06:58:33 2001
@@ -19,6 +19,7 @@
 # Platform support
 #
 CONFIG_PPC=y
+CONFIG_PPC32=y
 # CONFIG_6xx is not set
 # CONFIG_4xx is not set
 # CONFIG_POWER3 is not set
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/configs/common_defconfig linux/arch/ppc/configs/common_defconfig
--- v2.4.9/linux/arch/ppc/configs/common_defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/configs/common_defconfig	Tue Aug 28 06:58:33 2001
@@ -21,18 +21,23 @@
 # Platform support
 #
 CONFIG_PPC=y
+CONFIG_PPC32=y
 CONFIG_6xx=y
 # CONFIG_4xx is not set
 # CONFIG_POWER3 is not set
 # CONFIG_POWER4 is not set
 # CONFIG_8xx is not set
 # CONFIG_8260 is not set
+CONFIG_PPC_STD_MMU=y
 CONFIG_ALL_PPC=y
 # CONFIG_APUS is not set
 # CONFIG_GEMINI is not set
 CONFIG_PPC601_SYNC_FIX=y
 # CONFIG_SMP is not set
 CONFIG_ALTIVEC=y
+CONFIG_TAU=y
+# CONFIG_TAU_INT is not set
+# CONFIG_TAU_AVERAGE is not set
 
 #
 # General setup
@@ -228,6 +233,7 @@
 CONFIG_BLK_DEV_IDEPCI=y
 CONFIG_IDEPCI_SHARE_IRQ=y
 CONFIG_BLK_DEV_IDEDMA_PCI=y
+CONFIG_BLK_DEV_ADMA=y
 # CONFIG_BLK_DEV_OFFBOARD is not set
 CONFIG_IDEDMA_PCI_AUTO=y
 CONFIG_BLK_DEV_IDEDMA=y
@@ -237,8 +243,8 @@
 # CONFIG_AEC62XX_TUNING is not set
 # CONFIG_BLK_DEV_ALI15X3 is not set
 # CONFIG_WDC_ALI15X3 is not set
-# CONFIG_BLK_DEV_AMD7409 is not set
-# CONFIG_AMD7409_OVERRIDE is not set
+# CONFIG_BLK_DEV_AMD74XX is not set
+# CONFIG_AMD74XX_OVERRIDE is not set
 CONFIG_BLK_DEV_CMD64X=y
 # CONFIG_BLK_DEV_CY82C693 is not set
 # CONFIG_BLK_DEV_CS5530 is not set
@@ -249,7 +255,8 @@
 # CONFIG_BLK_DEV_OPTI621 is not set
 # CONFIG_BLK_DEV_PDC202XX is not set
 # CONFIG_PDC202XX_BURST is not set
-# CONFIG_BLK_DEV_OSB4 is not set
+# CONFIG_PDC202XX_FORCE is not set
+# CONFIG_BLK_DEV_SVWKS is not set
 # CONFIG_BLK_DEV_SIS5513 is not set
 # CONFIG_BLK_DEV_SLC90E66 is not set
 # CONFIG_BLK_DEV_TRM290 is not set
@@ -769,8 +776,10 @@
 CONFIG_SOUND=m
 CONFIG_DMASOUND_AWACS=m
 CONFIG_DMASOUND=m
+# CONFIG_SOUND_BT878 is not set
 # CONFIG_SOUND_CMPCI is not set
 # CONFIG_SOUND_EMU10K1 is not set
+# CONFIG_MIDI_EMU10K1 is not set
 # CONFIG_SOUND_FUSION is not set
 # CONFIG_SOUND_CS4281 is not set
 # CONFIG_SOUND_ES1370 is not set
@@ -779,6 +788,7 @@
 # CONFIG_SOUND_MAESTRO is not set
 # CONFIG_SOUND_MAESTRO3 is not set
 # CONFIG_SOUND_ICH is not set
+# CONFIG_SOUND_RME96XX is not set
 # CONFIG_SOUND_SONICVIBES is not set
 # CONFIG_SOUND_TRIDENT is not set
 # CONFIG_SOUND_MSNDCLAS is not set
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/configs/est8260_defconfig linux/arch/ppc/configs/est8260_defconfig
--- v2.4.9/linux/arch/ppc/configs/est8260_defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/configs/est8260_defconfig	Tue Aug 28 06:58:33 2001
@@ -19,16 +19,17 @@
 # Platform support
 #
 CONFIG_PPC=y
+CONFIG_PPC32=y
 CONFIG_6xx=y
 # CONFIG_4xx is not set
 # CONFIG_POWER3 is not set
 # CONFIG_POWER4 is not set
 # CONFIG_8xx is not set
 CONFIG_8260=y
+CONFIG_PPC_STD_MMU=y
 CONFIG_SERIAL_CONSOLE=y
 CONFIG_EST8260=y
 CONFIG_PPC601_SYNC_FIX=y
-# CONFIG_ALL_PPC is not set
 # CONFIG_SMP is not set
 
 #
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/configs/gemini_defconfig linux/arch/ppc/configs/gemini_defconfig
--- v2.4.9/linux/arch/ppc/configs/gemini_defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/configs/gemini_defconfig	Tue Aug 28 06:58:33 2001
@@ -21,18 +21,23 @@
 # Platform support
 #
 CONFIG_PPC=y
+CONFIG_PPC32=y
 CONFIG_6xx=y
 # CONFIG_4xx is not set
 # CONFIG_POWER3 is not set
 # CONFIG_POWER4 is not set
 # CONFIG_8xx is not set
 # CONFIG_8260 is not set
+CONFIG_PPC_STD_MMU=y
 # CONFIG_ALL_PPC is not set
 # CONFIG_APUS is not set
 CONFIG_GEMINI=y
 # CONFIG_PPC601_SYNC_FIX is not set
 # CONFIG_SMP is not set
 CONFIG_ALTIVEC=y
+CONFIG_TAU=y
+# CONFIG_TAU_INT is not set
+# CONFIG_TAU_AVERAGE is not set
 
 #
 # General setup
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/configs/ibmchrp_defconfig linux/arch/ppc/configs/ibmchrp_defconfig
--- v2.4.9/linux/arch/ppc/configs/ibmchrp_defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/configs/ibmchrp_defconfig	Tue Aug 28 06:58:33 2001
@@ -21,18 +21,21 @@
 # Platform support
 #
 CONFIG_PPC=y
+CONFIG_PPC32=y
 CONFIG_6xx=y
 # CONFIG_4xx is not set
 # CONFIG_POWER3 is not set
 # CONFIG_POWER4 is not set
 # CONFIG_8xx is not set
 # CONFIG_8260 is not set
+CONFIG_PPC_STD_MMU=y
 CONFIG_ALL_PPC=y
 # CONFIG_APUS is not set
 # CONFIG_GEMINI is not set
 # CONFIG_PPC601_SYNC_FIX is not set
 # CONFIG_SMP is not set
 # CONFIG_ALTIVEC is not set
+# CONFIG_TAU is not set
 
 #
 # General setup
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/configs/mbx_defconfig linux/arch/ppc/configs/mbx_defconfig
--- v2.4.9/linux/arch/ppc/configs/mbx_defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/configs/mbx_defconfig	Tue Aug 28 06:58:33 2001
@@ -19,6 +19,7 @@
 # Platform support
 #
 CONFIG_PPC=y
+CONFIG_PPC32=y
 # CONFIG_6xx is not set
 # CONFIG_4xx is not set
 # CONFIG_POWER3 is not set
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/configs/oak_defconfig linux/arch/ppc/configs/oak_defconfig
--- v2.4.9/linux/arch/ppc/configs/oak_defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/configs/oak_defconfig	Tue Aug 28 06:58:33 2001
@@ -21,6 +21,7 @@
 # Platform support
 #
 CONFIG_PPC=y
+CONFIG_PPC32=y
 # CONFIG_6xx is not set
 CONFIG_4xx=y
 # CONFIG_POWER3 is not set
@@ -29,6 +30,7 @@
 CONFIG_OAK=y
 # CONFIG_WALNUT is not set
 CONFIG_PPC601_SYNC_FIX=y
+# CONFIG_ALL_PPC is not set
 # CONFIG_SMP is not set
 # CONFIG_MATH_EMULATION is not set
 
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/configs/power3_defconfig linux/arch/ppc/configs/power3_defconfig
--- v2.4.9/linux/arch/ppc/configs/power3_defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/configs/power3_defconfig	Tue Aug 28 06:58:33 2001
@@ -21,6 +21,7 @@
 # Platform support
 #
 CONFIG_PPC=y
+CONFIG_PPC32=y
 # CONFIG_6xx is not set
 # CONFIG_4xx is not set
 CONFIG_POWER3=y
@@ -28,6 +29,7 @@
 # CONFIG_8xx is not set
 CONFIG_PPC64BRIDGE=y
 CONFIG_ALL_PPC=y
+CONFIG_PPC_STD_MMU=y
 CONFIG_SMP=y
 # CONFIG_IRQ_ALL_CPUS is not set
 
@@ -640,8 +642,10 @@
 #
 CONFIG_SOUND=y
 # CONFIG_DMASOUND_AWACS is not set
+# CONFIG_SOUND_BT878 is not set
 # CONFIG_SOUND_CMPCI is not set
 # CONFIG_SOUND_EMU10K1 is not set
+# CONFIG_MIDI_EMU10K1 is not set
 # CONFIG_SOUND_FUSION is not set
 # CONFIG_SOUND_CS4281 is not set
 # CONFIG_SOUND_ES1370 is not set
@@ -650,6 +654,7 @@
 # CONFIG_SOUND_MAESTRO is not set
 # CONFIG_SOUND_MAESTRO3 is not set
 # CONFIG_SOUND_ICH is not set
+# CONFIG_SOUND_RME96XX is not set
 # CONFIG_SOUND_SONICVIBES is not set
 # CONFIG_SOUND_TRIDENT is not set
 # CONFIG_SOUND_MSNDCLAS is not set
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/configs/rpxcllf_defconfig linux/arch/ppc/configs/rpxcllf_defconfig
--- v2.4.9/linux/arch/ppc/configs/rpxcllf_defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/configs/rpxcllf_defconfig	Tue Aug 28 06:58:33 2001
@@ -19,6 +19,7 @@
 # Platform support
 #
 CONFIG_PPC=y
+CONFIG_PPC32=y
 # CONFIG_6xx is not set
 # CONFIG_4xx is not set
 # CONFIG_POWER3 is not set
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/configs/rpxlite_defconfig linux/arch/ppc/configs/rpxlite_defconfig
--- v2.4.9/linux/arch/ppc/configs/rpxlite_defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/configs/rpxlite_defconfig	Tue Aug 28 06:58:33 2001
@@ -19,6 +19,7 @@
 # Platform support
 #
 CONFIG_PPC=y
+CONFIG_PPC32=y
 # CONFIG_6xx is not set
 # CONFIG_4xx is not set
 # CONFIG_POWER3 is not set
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/configs/walnut_defconfig linux/arch/ppc/configs/walnut_defconfig
--- v2.4.9/linux/arch/ppc/configs/walnut_defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/configs/walnut_defconfig	Tue Aug 28 06:58:33 2001
@@ -21,6 +21,7 @@
 # Platform support
 #
 CONFIG_PPC=y
+CONFIG_PPC32=y
 # CONFIG_6xx is not set
 CONFIG_4xx=y
 # CONFIG_POWER3 is not set
@@ -29,6 +30,7 @@
 # CONFIG_OAK is not set
 CONFIG_WALNUT=y
 CONFIG_PPC601_SYNC_FIX=y
+# CONFIG_ALL_PPC is not set
 # CONFIG_SMP is not set
 # CONFIG_MATH_EMULATION is not set
 
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/defconfig linux/arch/ppc/defconfig
--- v2.4.9/linux/arch/ppc/defconfig	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/defconfig	Tue Aug 28 06:58:33 2001
@@ -21,18 +21,23 @@
 # Platform support
 #
 CONFIG_PPC=y
+CONFIG_PPC32=y
 CONFIG_6xx=y
 # CONFIG_4xx is not set
 # CONFIG_POWER3 is not set
 # CONFIG_POWER4 is not set
 # CONFIG_8xx is not set
 # CONFIG_8260 is not set
+CONFIG_PPC_STD_MMU=y
 CONFIG_ALL_PPC=y
 # CONFIG_APUS is not set
 # CONFIG_GEMINI is not set
 CONFIG_PPC601_SYNC_FIX=y
 # CONFIG_SMP is not set
 CONFIG_ALTIVEC=y
+CONFIG_TAU=y
+# CONFIG_TAU_INT is not set
+# CONFIG_TAU_AVERAGE is not set
 
 #
 # General setup
@@ -228,6 +233,7 @@
 CONFIG_BLK_DEV_IDEPCI=y
 CONFIG_IDEPCI_SHARE_IRQ=y
 CONFIG_BLK_DEV_IDEDMA_PCI=y
+CONFIG_BLK_DEV_ADMA=y
 # CONFIG_BLK_DEV_OFFBOARD is not set
 CONFIG_IDEDMA_PCI_AUTO=y
 CONFIG_BLK_DEV_IDEDMA=y
@@ -237,8 +243,8 @@
 # CONFIG_AEC62XX_TUNING is not set
 # CONFIG_BLK_DEV_ALI15X3 is not set
 # CONFIG_WDC_ALI15X3 is not set
-# CONFIG_BLK_DEV_AMD7409 is not set
-# CONFIG_AMD7409_OVERRIDE is not set
+# CONFIG_BLK_DEV_AMD74XX is not set
+# CONFIG_AMD74XX_OVERRIDE is not set
 CONFIG_BLK_DEV_CMD64X=y
 # CONFIG_BLK_DEV_CY82C693 is not set
 # CONFIG_BLK_DEV_CS5530 is not set
@@ -249,7 +255,8 @@
 # CONFIG_BLK_DEV_OPTI621 is not set
 # CONFIG_BLK_DEV_PDC202XX is not set
 # CONFIG_PDC202XX_BURST is not set
-# CONFIG_BLK_DEV_OSB4 is not set
+# CONFIG_PDC202XX_FORCE is not set
+# CONFIG_BLK_DEV_SVWKS is not set
 # CONFIG_BLK_DEV_SIS5513 is not set
 # CONFIG_BLK_DEV_SLC90E66 is not set
 # CONFIG_BLK_DEV_TRM290 is not set
@@ -769,8 +776,10 @@
 CONFIG_SOUND=m
 CONFIG_DMASOUND_AWACS=m
 CONFIG_DMASOUND=m
+# CONFIG_SOUND_BT878 is not set
 # CONFIG_SOUND_CMPCI is not set
 # CONFIG_SOUND_EMU10K1 is not set
+# CONFIG_MIDI_EMU10K1 is not set
 # CONFIG_SOUND_FUSION is not set
 # CONFIG_SOUND_CS4281 is not set
 # CONFIG_SOUND_ES1370 is not set
@@ -779,6 +788,7 @@
 # CONFIG_SOUND_MAESTRO is not set
 # CONFIG_SOUND_MAESTRO3 is not set
 # CONFIG_SOUND_ICH is not set
+# CONFIG_SOUND_RME96XX is not set
 # CONFIG_SOUND_SONICVIBES is not set
 # CONFIG_SOUND_TRIDENT is not set
 # CONFIG_SOUND_MSNDCLAS is not set
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/Makefile linux/arch/ppc/kernel/Makefile
--- v2.4.9/linux/arch/ppc/kernel/Makefile	Wed Jul 25 17:10:18 2001
+++ linux/arch/ppc/kernel/Makefile	Tue Aug 28 06:58:33 2001
@@ -1,4 +1,4 @@
-# BK Id: SCCS/s.Makefile 1.24 07/10/01 12:12:22 trini
+# BK Id: SCCS/s.Makefile 1.32 08/24/01 20:07:37 paulus
 #
 #
 # Makefile for the linux kernel.
@@ -29,12 +29,13 @@
 
 O_TARGET := kernel.o
 
-export-objs			:= ppc_ksyms.o prep_setup.o 
+export-objs			:= ppc_ksyms.o prep_setup.o time.o
 
 obj-y				:= entry.o traps.o irq.o idle.o time.o misc.o \
 					process.o signal.o ptrace.o \
 					ppc_htab.o semaphore.o syscalls.o  \
-					align.o setup.o
+					align.o setup.o cputable.o
+obj-$(CONFIG_6xx)		+= l2cr.o
 obj-$(CONFIG_MODULES)		+= ppc_ksyms.o
 obj-$(CONFIG_POWER4)		+= xics.o
 obj-$(CONFIG_PCI)		+= pci.o pci-dma.o
@@ -43,6 +44,7 @@
 obj-$(CONFIG_4xx)		+= ppc4xx_pic.o
 obj-$(CONFIG_OAK)		+= oak_setup.o
 obj-$(CONFIG_WALNUT)		+= walnut_setup.o
+obj-$(CONFIG_TAU)		+= temp.o
 ifeq ($(CONFIG_WALNUT),y)
 obj-$(CONFIG_PCI)		+= galaxy_pci.o
 endif
@@ -71,12 +73,17 @@
 obj-$(CONFIG_GEMINI)		+= gemini_prom.o gemini_pci.o gemini_setup.o \
 					open_pic.o
 obj-$(CONFIG_8260)		+= m8260_setup.o ppc8260_pic.o
+obj-$(CONFIG_BOOTX_TEXT)	+= btext.o
 
+ifeq ($(CONFIG_SMP),y)
+obj-$(CONFIG_ALL_PPC)		+= pmac_smp.o chrp_smp.o
+endif
 
 include $(TOPDIR)/Rules.make
 
 entry.o: entry.S ppc_defs.h
 misc.o: misc.S ppc_defs.h
+l2cr.o: l2cr.S ppc_defs.h
 head.o: head.S ppc_defs.h
 head_4xx.o: head_4xx.S ppc_defs.h
 head_8xx.o: head_8xx.S ppc_defs.h
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/apus_pci.c linux/arch/ppc/kernel/apus_pci.c
--- v2.4.9/linux/arch/ppc/kernel/apus_pci.c	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/kernel/apus_pci.c	Sat Sep  8 12:38:41 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.apus_pci.c 1.4 07/06/01 09:19:28 trini
+ * BK Id: SCCS/s.apus_pci.c 1.5 09/08/01 15:47:42 paulus
  */
 /*
  * Copyright (C) Michel Dänzer <michdaen@iiic.ethz.ch>
@@ -21,7 +21,6 @@
 #include <linux/delay.h>
 #include <linux/string.h>
 
-#include <asm/init.h>
 #include <asm/io.h>
 #include <asm/pci-bridge.h>
 #include <asm/machdep.h>
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/apus_setup.c linux/arch/ppc/kernel/apus_setup.c
--- v2.4.9/linux/arch/ppc/kernel/apus_setup.c	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/kernel/apus_setup.c	Sat Sep  8 12:38:41 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.apus_setup.c 1.14 07/06/01 09:19:28 trini
+ * BK Id: SCCS/s.apus_setup.c 1.20 09/08/01 15:47:42 paulus
  */
 /*
  *  linux/arch/ppc/kernel/apus_setup.c
@@ -76,7 +76,6 @@
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/machdep.h>
-#include <asm/init.h>
 
 #include "local_irq.h"
 
@@ -611,32 +610,8 @@
 /*
  * IDE stuff.
  */
-void ide_insw(ide_ioreg_t port, void *buf, int ns);
-void ide_outsw(ide_ioreg_t port, void *buf, int ns);
-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)
-{
-        return 0;
-}
-
-ide_ioreg_t
-apus_ide_default_io_base(int index)
-{
-        return 0;
-}
 
+#if 0	/* no longer used  -- paulus */
 void
 apus_ide_fix_driveid(struct hd_driveid *id)
 {
@@ -682,6 +657,7 @@
       }
    }
 }
+#endif /* 0 */
 
 __init
 void apus_ide_init_hwif_ports (hw_regs_t *hw, ide_ioreg_t data_port, 
@@ -1039,6 +1015,15 @@
 	return total;
 }
 
+static void __init
+apus_map_io(void)
+{
+	/* Map PPC exception vectors. */
+	io_block_mapping(0xfff00000, 0xfff00000, 0x00020000, _PAGE_KERNEL);
+	/* Map chip and ZorroII memory */
+	io_block_mapping(zTwoBase,   0x00000000, 0x01000000, _PAGE_IO);
+}
+
 __init
 void apus_init_IRQ(void)
 {
@@ -1061,8 +1046,8 @@
 }
 
 __init
-void apus_init(unsigned long r3, unsigned long r4, unsigned long r5,
-	       unsigned long r6, unsigned long r7)
+void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+		   unsigned long r6, unsigned long r7)
 {
 	extern int parse_bootinfo(const struct bi_record *);
 	extern char _end[];
@@ -1113,6 +1098,7 @@
 	ppc_md.calibrate_decr = apus_calibrate_decr;
 
 	ppc_md.find_end_of_memory = apus_find_end_of_memory;
+	ppc_md.setup_io_mappings = apus_map_io;
 
 	ppc_md.nvram_read_val = NULL;
 	ppc_md.nvram_write_val = NULL;
@@ -1130,14 +1116,7 @@
 #endif
 
 #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.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.4.9/linux/arch/ppc/kernel/btext.c linux/arch/ppc/kernel/btext.c
--- v2.4.9/linux/arch/ppc/kernel/btext.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/ppc/kernel/btext.c	Sat Sep  8 12:38:41 2001
@@ -0,0 +1,868 @@
+/*
+ * BK Id: %F% %I% %G% %U% %#%
+ */
+/*
+ * Procedures for drawing on the screen early on in the boot process.
+ *
+ * Benjamin Herrenschmidt <benh@kernel.crashing.org>
+ */
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/init.h>
+#include <linux/version.h>
+
+#include <asm/sections.h>
+#include <asm/bootx.h>
+#include <asm/btext.h>
+#include <asm/prom.h>
+#include <asm/page.h>
+#include <asm/mmu.h>
+#include <asm/pgtable.h>
+#include <asm/io.h>
+#include <asm/processor.h>
+
+#define NO_SCROLL
+
+#ifndef NO_SCROLL
+static void scrollscreen(void);
+#endif
+
+static void draw_byte(unsigned char c, long locX, long locY);
+static void draw_byte_32(unsigned char *bits, unsigned long *base, int rb);
+static void draw_byte_16(unsigned char *bits, unsigned long *base, int rb);
+static void draw_byte_8(unsigned char *bits, unsigned long *base, int rb);
+
+static int g_loc_X;
+static int g_loc_Y;
+static int g_max_loc_X;
+static int g_max_loc_Y;
+
+unsigned long disp_BAT[2] __initdata = {0, 0};
+
+#define cmapsz	(16*256)
+
+static unsigned char vga_font[cmapsz];
+
+int boot_text_mapped = 1;
+
+boot_infos_t *disp_bi;
+boot_infos_t fake_bi;
+
+extern char *klimit;
+
+/*
+ * Powermac can use btext_* after boot for xmon,
+ * chrp only uses it during early boot.
+ */
+#ifdef CONFIG_XMON
+#define BTEXT	__pmac
+#define BTDATA	__pmacdata
+#else
+#define BTEXT	__init
+#define BTDATA	__initdata
+#endif /* CONFIG_XMON */
+
+/*
+ * This is called only when we are booted via BootX.
+ */
+void __init
+btext_init(boot_infos_t *bi)
+{
+	unsigned long offset = reloc_offset();
+
+	RELOC(g_loc_X) = 0;
+	RELOC(g_loc_Y) = 0;
+	RELOC(g_max_loc_X) = (bi->dispDeviceRect[2] - bi->dispDeviceRect[0]) / 8;
+	RELOC(g_max_loc_Y) = (bi->dispDeviceRect[3] - bi->dispDeviceRect[1]) / 16;
+	RELOC(disp_bi) = PTRUNRELOC(bi);
+}
+
+void __init
+btext_welcome(boot_infos_t* bi)
+{
+	unsigned long offset = reloc_offset();
+	unsigned long flags;
+	unsigned long pvr;
+	
+	btext_drawstring(RELOC("Welcome to Linux, kernel " UTS_RELEASE "\n"));
+	btext_drawstring(RELOC("\nlinked at        : 0x"));
+	btext_drawhex(KERNELBASE);
+	btext_drawstring(RELOC("\nframe buffer at  : 0x"));
+	btext_drawhex((unsigned long)bi->dispDeviceBase);
+	btext_drawstring(RELOC(" (phys), 0x"));
+	btext_drawhex((unsigned long)bi->logicalDisplayBase);
+	btext_drawstring(RELOC(" (log)"));
+	btext_drawstring(RELOC("\nklimit           : 0x"));
+	btext_drawhex((unsigned long)RELOC(klimit));
+	btext_drawstring(RELOC("\nMSR              : 0x"));
+	__asm__ __volatile__ ("mfmsr %0" : "=r" (flags));
+	btext_drawhex(flags);
+	__asm__ __volatile__ ("mfspr %0, 287" : "=r" (pvr));
+	pvr >>= 16;
+	if (pvr > 1) {
+	    btext_drawstring(RELOC("\nHID0             : 0x"));
+	    __asm__ __volatile__ ("mfspr %0, 1008" : "=r" (flags));
+	    btext_drawhex(flags);
+	}
+	if (pvr == 8 || pvr == 12 || pvr == 0x800c) {
+	    btext_drawstring(RELOC("\nICTC             : 0x"));
+	    __asm__ __volatile__ ("mfspr %0, 1019" : "=r" (flags));
+	    btext_drawhex(flags);
+	}
+	btext_drawstring(RELOC("\n\n"));
+}
+
+/* Calc BAT values for mapping the display and store them
+ * in disp_BAT.  Those values are then used from head.S to map
+ * the display during identify_machine() and MMU_Init()
+ * 
+ * The display is mapped to virtual address 0xD0000000, rather
+ * than 1:1, because some some CHRP machines put the frame buffer
+ * in the region starting at 0xC0000000 (KERNELBASE).
+ * This mapping is temporary and will disappear as soon as the
+ * setup done by MMU_Init() is applied.
+ * 
+ * For now, we align the BAT and then map 8Mb on 601 and 16Mb
+ * on other PPCs. This may cause trouble if the framebuffer
+ * is really badly aligned, but I didn't encounter this case
+ * yet.
+ */
+void __init
+btext_prepare_BAT(void)
+{
+	unsigned long offset = reloc_offset();
+	boot_infos_t* bi = PTRRELOC(RELOC(disp_bi));
+	unsigned long addr = (unsigned long)bi->dispDeviceBase;
+	unsigned long vaddr = KERNELBASE + 0x10000000;
+	unsigned long lowbits;
+
+	if (!RELOC(disp_bi)) {
+		RELOC(boot_text_mapped) = 0;
+		return;
+	}
+	if (PVR_VER(mfspr(PVR)) != 1) {
+		/* 603, 604, G3, G4, ... */
+		lowbits = addr & ~0xFF000000UL;
+		addr &= 0xFF000000UL;
+		RELOC(disp_BAT[0]) = vaddr | (BL_16M<<2) | 2;
+		RELOC(disp_BAT[1]) = addr | (_PAGE_NO_CACHE | _PAGE_GUARDED | BPP_RW);		
+	} else {
+		/* 601 */
+		lowbits = addr & ~0xFF800000UL;
+		addr &= 0xFF800000UL;
+		RELOC(disp_BAT[0]) = vaddr | (_PAGE_NO_CACHE | PP_RWXX) | 4;
+		RELOC(disp_BAT[1]) = addr | BL_8M | 0x40;
+	}
+	bi->logicalDisplayBase = (void *) (vaddr + lowbits);
+}
+
+/* This function will enable the early boot text when doing OF booting. This
+ * way, xmon output should work too
+ */
+void __init
+btext_setup_display(int width, int height, int depth, int pitch,
+		    unsigned long address)
+{
+	unsigned long offset = reloc_offset();
+	boot_infos_t* bi;
+
+	RELOC(disp_bi) = &fake_bi;
+	bi = PTRRELOC((&fake_bi));
+	RELOC(g_loc_X) = 0;
+	RELOC(g_loc_Y) = 0;
+	RELOC(g_max_loc_X) = width / 8;
+	RELOC(g_max_loc_Y) = height / 16;
+	bi->logicalDisplayBase = (unsigned char *)address;
+	bi->dispDeviceBase = (unsigned char *)address;
+	bi->dispDeviceRowBytes = pitch;
+	bi->dispDeviceDepth = depth;
+	bi->dispDeviceRect[0] = bi->dispDeviceRect[1] = 0;
+	bi->dispDeviceRect[2] = width;
+	bi->dispDeviceRect[3] = height;
+}
+
+/* Here's a small text engine to use during early boot
+ * or for debugging purposes
+ * 
+ * todo:
+ * 
+ *  - build some kind of vgacon with it to enable early printk
+ *  - move to a separate file
+ *  - add a few video driver hooks to keep in sync with display
+ *    changes.
+ */
+
+void __openfirmware
+map_boot_text(void)
+{
+	unsigned long base, offset, size;
+	if (disp_bi == 0)
+		return;
+	base = ((unsigned long) disp_bi->dispDeviceBase) & 0xFFFFF000UL;
+	offset = ((unsigned long) disp_bi->dispDeviceBase) - base;
+	size = disp_bi->dispDeviceRowBytes * disp_bi->dispDeviceRect[3] + offset
+		+ disp_bi->dispDeviceRect[0];
+	disp_bi->logicalDisplayBase = ioremap(base, size);
+	if (disp_bi->logicalDisplayBase == 0)
+		return;
+	disp_bi->logicalDisplayBase += offset;
+	boot_text_mapped = 1;
+}
+
+/* Calc the base address of a given point (x,y) */
+static unsigned char * BTEXT
+calc_base(boot_infos_t *bi, int x, int y)
+{
+	unsigned char *base;
+
+	base = bi->logicalDisplayBase;
+	if (base == 0)
+		base = bi->dispDeviceBase;
+	base += (x + bi->dispDeviceRect[0]) * (bi->dispDeviceDepth >> 3);
+	base += (y + bi->dispDeviceRect[1]) * bi->dispDeviceRowBytes;
+	return base;
+}
+
+/* Adjust the display to a new resolution */
+void
+btext_update_display(unsigned long phys, int width, int height,
+		     int depth, int pitch)
+{
+	if (disp_bi == 0)
+		return;
+	/* check it's the same frame buffer (within 64MB) */
+	if ((phys ^ (unsigned long)disp_bi->dispDeviceBase) & 0xfc000000) {
+		return;
+	}
+
+	disp_bi->dispDeviceBase = (__u8 *) phys;
+	disp_bi->dispDeviceRect[0] = 0;
+	disp_bi->dispDeviceRect[1] = 0;
+	disp_bi->dispDeviceRect[2] = width;
+	disp_bi->dispDeviceRect[3] = height;
+	disp_bi->dispDeviceDepth = depth;
+	disp_bi->dispDeviceRowBytes = pitch;
+	if (boot_text_mapped) {
+		iounmap(disp_bi->logicalDisplayBase);
+		boot_text_mapped = 0;
+	}
+	map_boot_text();
+	g_loc_X = 0;
+	g_loc_Y = 0;
+	g_max_loc_X = width / 8;
+	g_max_loc_Y = height / 16;
+}
+
+void BTEXT btext_clearscreen(void)
+{
+	unsigned long offset	= reloc_offset();
+	boot_infos_t* bi	= PTRRELOC(RELOC(disp_bi));
+	unsigned long *base	= (unsigned long *)calc_base(bi, 0, 0);
+	unsigned long width 	= ((bi->dispDeviceRect[2] - bi->dispDeviceRect[0]) *
+					(bi->dispDeviceDepth >> 3)) >> 2;
+	int i,j;
+	
+	for (i=0; i<(bi->dispDeviceRect[3] - bi->dispDeviceRect[1]); i++)
+	{
+		unsigned long *ptr = base;
+		for(j=width; j; --j)
+			*(ptr++) = 0;
+		base += (bi->dispDeviceRowBytes >> 2);
+	}
+}
+
+__inline__ void dcbst(const void* addr)
+{
+	__asm__ __volatile__ ("dcbst 0,%0" :: "r" (addr));
+}
+
+void BTEXT btext_flushscreen(void)
+{
+	unsigned long offset	= reloc_offset();
+	boot_infos_t* bi	= PTRRELOC(RELOC(disp_bi));
+	unsigned long *base	= (unsigned long *)calc_base(bi, 0, 0);
+	unsigned long width 	= ((bi->dispDeviceRect[2] - bi->dispDeviceRect[0]) *
+					(bi->dispDeviceDepth >> 3)) >> 2;
+	int i,j;
+	
+	for (i=0; i<(bi->dispDeviceRect[3] - bi->dispDeviceRect[1]); i++)
+	{
+		unsigned long *ptr = base;
+		for(j=width; j>0; j-=8) {
+			dcbst(ptr);
+			ptr += 8;
+		}
+		base += (bi->dispDeviceRowBytes >> 2);
+	}
+}
+
+#ifndef NO_SCROLL
+static BTEXT void
+scrollscreen(void)
+{
+	unsigned long offset		= reloc_offset();
+	boot_infos_t* bi		= PTRRELOC(RELOC(disp_bi));
+	unsigned long *src		= (unsigned long *)calc_base(bi,0,16);
+	unsigned long *dst		= (unsigned long *)calc_base(bi,0,0);
+	unsigned long width		= ((bi->dispDeviceRect[2] - bi->dispDeviceRect[0]) *
+						(bi->dispDeviceDepth >> 3)) >> 2;
+	int i,j;
+	
+#ifdef CONFIG_ADB_PMU
+	pmu_suspend();	/* PMU will not shut us down ! */
+#endif
+	for (i=0; i<(bi->dispDeviceRect[3] - bi->dispDeviceRect[1] - 16); i++)
+	{
+		unsigned long *src_ptr = src;
+		unsigned long *dst_ptr = dst;
+		for(j=width; j; --j)
+			*(dst_ptr++) = *(src_ptr++);
+		src += (bi->dispDeviceRowBytes >> 2);
+		dst += (bi->dispDeviceRowBytes >> 2);
+	}
+	for (i=0; i<16; i++)
+	{
+		unsigned long *dst_ptr = dst;
+		for(j=width; j; --j)
+			*(dst_ptr++) = 0;
+		dst += (bi->dispDeviceRowBytes >> 2);
+	}
+#ifdef CONFIG_ADB_PMU
+	pmu_resume();	/* PMU will not shut us down ! */
+#endif
+}
+#endif /* ndef NO_SCROLL */
+
+void BTEXT btext_drawchar(char c)
+{
+	unsigned long offset = reloc_offset();
+	int cline = 0, x;
+
+	if (!RELOC(boot_text_mapped))
+		return;
+
+	switch (c) {
+	case '\b':
+		if (RELOC(g_loc_X) > 0)
+			--RELOC(g_loc_X);
+		break;
+	case '\t':
+		RELOC(g_loc_X) = (RELOC(g_loc_X) & -8) + 8;
+		break;
+	case '\r':
+		RELOC(g_loc_X) = 0;
+		break;
+	case '\n':
+		RELOC(g_loc_X) = 0;
+		RELOC(g_loc_Y)++;
+		cline = 1;
+		break;
+	default:
+		draw_byte(c, RELOC(g_loc_X)++, RELOC(g_loc_Y));
+	}
+	if (RELOC(g_loc_X) >= RELOC(g_max_loc_X)) {
+		RELOC(g_loc_X) = 0;
+		RELOC(g_loc_Y)++;
+		cline = 1;
+	}
+#ifndef NO_SCROLL
+	while (RELOC(g_loc_Y) >= RELOC(g_max_loc_Y)) {
+		scrollscreen();
+		RELOC(g_loc_Y)--;
+	}
+#else
+	/* wrap around from bottom to top of screen so we don't
+	   waste time scrolling each line.  -- paulus. */
+	if (RELOC(g_loc_Y) >= RELOC(g_max_loc_Y))
+		RELOC(g_loc_Y) = 0;
+	if (cline) {
+		for (x = 0; x < RELOC(g_max_loc_X); ++x)
+			draw_byte(' ', x, RELOC(g_loc_Y));
+	}
+#endif
+}
+
+void BTEXT
+btext_drawstring(const char *c)
+{
+	unsigned long offset	= reloc_offset();
+
+	if (!RELOC(boot_text_mapped))
+		return;
+	while (*c)
+		btext_drawchar(*c++);
+}
+
+void BTEXT
+btext_drawhex(unsigned long v)
+{
+	static char hex_table[] = "0123456789abcdef";
+	unsigned long offset	= reloc_offset();
+	
+	if (!RELOC(boot_text_mapped))
+		return;
+	btext_drawchar(RELOC(hex_table)[(v >> 28) & 0x0000000FUL]);
+	btext_drawchar(RELOC(hex_table)[(v >> 24) & 0x0000000FUL]);
+	btext_drawchar(RELOC(hex_table)[(v >> 20) & 0x0000000FUL]);
+	btext_drawchar(RELOC(hex_table)[(v >> 16) & 0x0000000FUL]);
+	btext_drawchar(RELOC(hex_table)[(v >> 12) & 0x0000000FUL]);
+	btext_drawchar(RELOC(hex_table)[(v >>  8) & 0x0000000FUL]);
+	btext_drawchar(RELOC(hex_table)[(v >>  4) & 0x0000000FUL]);
+	btext_drawchar(RELOC(hex_table)[(v >>  0) & 0x0000000FUL]);
+	btext_drawchar(' ');
+}
+
+static void BTEXT
+draw_byte(unsigned char c, long locX, long locY)
+{
+	unsigned long offset	= reloc_offset();
+	boot_infos_t* bi	= PTRRELOC(RELOC(disp_bi));
+	unsigned char *base	= calc_base(bi, locX << 3, locY << 4);
+	unsigned char *font	= &RELOC(vga_font)[((unsigned long)c) * 16];
+	int rb			= bi->dispDeviceRowBytes;
+	
+	switch(bi->dispDeviceDepth) {
+	case 32:
+		draw_byte_32(font, (unsigned long *)base, rb);
+		break;
+	case 16:
+		draw_byte_16(font, (unsigned long *)base, rb);
+		break;
+	case 8:
+		draw_byte_8(font, (unsigned long *)base, rb);
+		break;
+	}
+}
+
+static unsigned long expand_bits_8[16] BTDATA = {
+	0x00000000,
+	0x000000ff,
+	0x0000ff00,
+	0x0000ffff,
+	0x00ff0000,
+	0x00ff00ff,
+	0x00ffff00,
+	0x00ffffff,
+	0xff000000,
+	0xff0000ff,
+	0xff00ff00,
+	0xff00ffff,
+	0xffff0000,
+	0xffff00ff,
+	0xffffff00,
+	0xffffffff
+};
+
+static unsigned long expand_bits_16[4] BTDATA = {
+	0x00000000,
+	0x0000ffff,
+	0xffff0000,
+	0xffffffff
+};
+
+
+static void BTEXT
+draw_byte_32(unsigned char *font, unsigned long *base, int rb)
+{
+	int l, bits;	
+	int fg = 0xFFFFFFFFUL;
+	int bg = 0x00000000UL;
+	
+	for (l = 0; l < 16; ++l)
+	{
+		bits = *font++;
+		base[0] = (-(bits >> 7) & fg) ^ bg;
+		base[1] = (-((bits >> 6) & 1) & fg) ^ bg;
+		base[2] = (-((bits >> 5) & 1) & fg) ^ bg;
+		base[3] = (-((bits >> 4) & 1) & fg) ^ bg;
+		base[4] = (-((bits >> 3) & 1) & fg) ^ bg;
+		base[5] = (-((bits >> 2) & 1) & fg) ^ bg;
+		base[6] = (-((bits >> 1) & 1) & fg) ^ bg;
+		base[7] = (-(bits & 1) & fg) ^ bg;
+		base = (unsigned long *) ((char *)base + rb);
+	}
+}
+
+static void BTEXT
+draw_byte_16(unsigned char *font, unsigned long *base, int rb)
+{
+	int l, bits;	
+	int fg = 0xFFFFFFFFUL;
+	int bg = 0x00000000UL;
+	unsigned long offset = reloc_offset();
+	unsigned long *eb = RELOC(expand_bits_16);
+
+	for (l = 0; l < 16; ++l)
+	{
+		bits = *font++;
+		base[0] = (eb[bits >> 6] & fg) ^ bg;
+		base[1] = (eb[(bits >> 4) & 3] & fg) ^ bg;
+		base[2] = (eb[(bits >> 2) & 3] & fg) ^ bg;
+		base[3] = (eb[bits & 3] & fg) ^ bg;
+		base = (unsigned long *) ((char *)base + rb);
+	}
+}
+
+static void BTEXT
+draw_byte_8(unsigned char *font, unsigned long *base, int rb)
+{
+	int l, bits;	
+	int fg = 0x0F0F0F0FUL;
+	int bg = 0x00000000UL;
+	unsigned long offset = reloc_offset();
+	unsigned long *eb = RELOC(expand_bits_8);
+
+	for (l = 0; l < 16; ++l)
+	{
+		bits = *font++;
+		base[0] = (eb[bits >> 4] & fg) ^ bg;
+		base[1] = (eb[bits & 0xf] & fg) ^ bg;
+		base = (unsigned long *) ((char *)base + rb);
+	}
+}
+
+static unsigned char vga_font[cmapsz] BTDATA = {
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 
+0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xff, 
+0xdb, 0xff, 0xff, 0xc3, 0xe7, 0xff, 0xff, 0x7e, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x6c, 0xfe, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x7c, 0xfe, 
+0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 
+0x3c, 0x3c, 0xe7, 0xe7, 0xe7, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x7e, 0x18, 0x18, 0x3c, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 
+0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 
+0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0x99, 0xbd, 
+0xbd, 0x99, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x1e, 0x0e, 
+0x1a, 0x32, 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x18, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x30, 
+0x30, 0x70, 0xf0, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x63, 
+0x7f, 0x63, 0x63, 0x63, 0x63, 0x67, 0xe7, 0xe6, 0xc0, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x18, 0x18, 0xdb, 0x3c, 0xe7, 0x3c, 0xdb, 0x18, 0x18, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfe, 0xf8, 
+0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x0e, 
+0x1e, 0x3e, 0xfe, 0x3e, 0x1e, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 
+0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xdb, 
+0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x7c, 0xc6, 0x60, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x0c, 0xc6, 
+0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0xfe, 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 
+0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
+0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 
+0xc0, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x7c, 0x7c, 0xfe, 0xfe, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x7c, 0x7c, 
+0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 
+0x6c, 0xfe, 0x6c, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 
+0x18, 0x18, 0x7c, 0xc6, 0xc2, 0xc0, 0x7c, 0x06, 0x06, 0x86, 0xc6, 0x7c, 
+0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc2, 0xc6, 0x0c, 0x18, 
+0x30, 0x60, 0xc6, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 
+0x6c, 0x38, 0x76, 0xdc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x30, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 
+0x30, 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x18, 
+0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 
+0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x02, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xce, 0xde, 0xf6, 0xe6, 0xc6, 0xc6, 0x7c, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, 
+0x18, 0x18, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 
+0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x7c, 0xc6, 0x06, 0x06, 0x3c, 0x06, 0x06, 0x06, 0xc6, 0x7c, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 
+0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc0, 
+0xc0, 0xc0, 0xfc, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x38, 0x60, 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc6, 0x06, 0x06, 0x0c, 0x18, 
+0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 
+0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x06, 0x06, 0x0c, 0x78, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 
+0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x06, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 
+0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 
+0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x0c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xde, 0xde, 
+0xde, 0xdc, 0xc0, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 
+0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x66, 0x66, 0x66, 0x66, 0xfc, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 
+0xc0, 0xc2, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x6c, 
+0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xfe, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 
+0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 
+0xc2, 0xc0, 0xc0, 0xde, 0xc6, 0xc6, 0x66, 0x3a, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 
+0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x0c, 
+0x0c, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0xe6, 0x66, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0x66, 0xe6, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x60, 0x60, 0x60, 0x60, 0x60, 
+0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xe7, 
+0xff, 0xff, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0xc6, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 
+0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x66, 
+0x66, 0x66, 0x7c, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 
+0x0c, 0x0e, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x6c, 
+0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 
+0xc6, 0x60, 0x38, 0x0c, 0x06, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0xff, 0xdb, 0x99, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 
+0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xc3, 
+0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xdb, 0xdb, 0xff, 0x66, 0x66, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x18, 
+0x3c, 0x66, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xc3, 
+0xc3, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0xff, 0xc3, 0x86, 0x0c, 0x18, 0x30, 0x60, 0xc1, 0xc3, 0xff, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 
+0x30, 0x30, 0x30, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 
+0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 
+0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 
+0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 
+0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x60, 
+0x60, 0x78, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x0c, 0x0c, 0x3c, 0x6c, 0xcc, 
+0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xf0, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 
+0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xcc, 0x78, 0x00, 0x00, 0x00, 0xe0, 0x60, 
+0x60, 0x6c, 0x76, 0x66, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x18, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x0e, 0x06, 0x06, 
+0x06, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3c, 0x00, 0x00, 0x00, 0xe0, 0x60, 
+0x60, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0xff, 0xdb, 
+0xdb, 0xdb, 0xdb, 0xdb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 
+0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0x0c, 0x1e, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0x60, 0x60, 0xf0, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, 
+0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x30, 
+0x30, 0xfc, 0x30, 0x30, 0x30, 0x30, 0x36, 0x1c, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xc3, 0xc3, 
+0xc3, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0xc3, 0xc3, 0xc3, 0xdb, 0xdb, 0xff, 0x66, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0xc3, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 
+0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0xfe, 0xcc, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x0e, 0x18, 0x18, 0x18, 0x70, 0x18, 0x18, 0x18, 0x18, 0x0e, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 
+0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x18, 
+0x18, 0x18, 0x0e, 0x18, 0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 
+0xc6, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 
+0xc2, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x0c, 0x06, 0x7c, 0x00, 0x00, 
+0x00, 0x00, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x00, 0x7c, 0xc6, 0xfe, 
+0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 
+0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0xcc, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, 0x78, 0x0c, 0x7c, 
+0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x38, 
+0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x60, 0x60, 0x66, 0x3c, 0x0c, 0x06, 
+0x3c, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xfe, 
+0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 
+0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x38, 0x18, 0x18, 
+0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x66, 
+0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 
+0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x38, 0x00, 
+0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 
+0x18, 0x30, 0x60, 0x00, 0xfe, 0x66, 0x60, 0x7c, 0x60, 0x60, 0x66, 0xfe, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, 0x3b, 0x1b, 
+0x7e, 0xd8, 0xdc, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x6c, 
+0xcc, 0xcc, 0xfe, 0xcc, 0xcc, 0xcc, 0xcc, 0xce, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 
+0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 
+0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x30, 0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, 0xcc, 0xcc, 0xcc, 
+0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 
+0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0x78, 0x00, 
+0x00, 0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 
+0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 
+0xc3, 0xc0, 0xc0, 0xc0, 0xc3, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xe6, 0xfc, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18, 0xff, 0x18, 
+0xff, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x66, 0x66, 
+0x7c, 0x62, 0x66, 0x6f, 0x66, 0x66, 0x66, 0xf3, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x0e, 0x1b, 0x18, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 
+0xd8, 0x70, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, 0x00, 0x78, 0x0c, 0x7c, 
+0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 
+0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x18, 0x30, 0x60, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, 0x00, 0xcc, 0xcc, 0xcc, 
+0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 
+0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 
+0x76, 0xdc, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x6c, 
+0x38, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x60, 0xc0, 0xc6, 0xc6, 0x7c, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc0, 
+0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0xfe, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x60, 0xce, 0x9b, 0x06, 
+0x0c, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 
+0x66, 0xce, 0x96, 0x3e, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 
+0x00, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x6c, 0xd8, 0x6c, 0x36, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x6c, 0x36, 
+0x6c, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x44, 0x11, 0x44, 
+0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 
+0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 
+0x55, 0xaa, 0x55, 0xaa, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 
+0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0x18, 0x18, 0x18, 0x18, 
+0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
+0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 
+0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 
+0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, 
+0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36, 0x36, 
+0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0xf8, 
+0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, 
+0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 
+0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 
+0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0xf6, 
+0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 
+0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
+0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
+0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 
+0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 
+0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
+0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 
+0x18, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 
+0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 
+0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 
+0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xff, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 
+0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 
+0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, 
+0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 
+0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 
+0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3f, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 
+0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 
+0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 
+0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 
+0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 
+0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 
+0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
+0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 
+0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 
+0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 
+0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x76, 0xdc, 0xd8, 0xd8, 0xd8, 0xdc, 0x76, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0xd8, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc6, 0xc6, 0xc0, 0xc0, 0xc0, 
+0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0xfe, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0xfe, 0xc6, 0x60, 0x30, 0x18, 0x30, 0x60, 0xc6, 0xfe, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xd8, 0xd8, 
+0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xc0, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x18, 0x3c, 0x66, 0x66, 
+0x66, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 
+0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x6c, 0x6c, 0x6c, 0xee, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x30, 0x18, 0x0c, 0x3e, 0x66, 
+0x66, 0x66, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x7e, 0xdb, 0xdb, 0xdb, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x03, 0x06, 0x7e, 0xdb, 0xdb, 0xf3, 0x7e, 0x60, 0xc0, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x30, 0x60, 0x60, 0x7c, 0x60, 
+0x60, 0x60, 0x30, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 
+0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 
+0x18, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 
+0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x00, 0x7e, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x1b, 0x1b, 0x1b, 0x18, 0x18, 
+0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
+0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x18, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 
+0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x6c, 
+0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0c, 0x0c, 
+0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x6c, 0x3c, 0x1c, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0xd8, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xd8, 0x30, 0x60, 0xc8, 0xf8, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 
+};
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/chrp_pci.c linux/arch/ppc/kernel/chrp_pci.c
--- v2.4.9/linux/arch/ppc/kernel/chrp_pci.c	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/kernel/chrp_pci.c	Sat Sep  8 12:38:41 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.chrp_pci.c 1.20 08/08/01 16:35:43 paulus
+ * BK Id: SCCS/s.chrp_pci.c 1.22 09/08/01 15:47:42 paulus
  */
 /*
  * CHRP pci routines.
@@ -21,7 +21,7 @@
 #include <asm/prom.h>
 #include <asm/gg2.h>
 #include <asm/machdep.h>
-#include <asm/init.h>
+#include <asm/sections.h>
 #include <asm/pci-bridge.h>
 
 #include "open_pic.h"
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/chrp_setup.c linux/arch/ppc/kernel/chrp_setup.c
--- v2.4.9/linux/arch/ppc/kernel/chrp_setup.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/ppc/kernel/chrp_setup.c	Sat Sep  8 12:38:41 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.chrp_setup.c 1.22 07/18/01 22:56:39 paulus
+ * BK Id: SCCS/s.chrp_setup.c 1.36 09/08/01 15:47:42 paulus
  */
 /*
  *  linux/arch/ppc/kernel/setup.c
@@ -51,8 +51,9 @@
 #include <asm/irq.h>
 #include <asm/hydra.h>
 #include <asm/keyboard.h>
-#include <asm/init.h>
+#include <asm/sections.h>
 #include <asm/time.h>
+#include <asm/btext.h>
 
 #include "local_irq.h"
 #include "i8259.h"
@@ -68,7 +69,7 @@
 void chrp_event_scan(void);
 void rtas_display_progress(char *, unsigned short);
 void rtas_indicator_progress(char *, unsigned short);
-void bootx_text_progress(char *, unsigned short);
+void btext_progress(char *, unsigned short);
 
 extern unsigned long pmac_find_end_of_memory(void);
 extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode);
@@ -79,14 +80,7 @@
 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];
+extern void select_adb_keyboard(void);
 
 extern kdev_t boot_dev;
 
@@ -94,9 +88,13 @@
 extern unsigned long Hash_size, Hash_mask;
 extern int probingmem;
 extern unsigned long loops_per_jiffy;
-extern int bootx_text_mapped;
 static int max_width;
 
+#ifdef CONFIG_SMP
+extern struct smp_ops_t chrp_smp_ops;
+extern struct smp_ops_t xics_smp_ops;
+#endif
+
 static const char *gg2_memtypes[4] = {
 	"FPM", "SDRAM", "EDO", "BEDO"
 };
@@ -248,9 +246,6 @@
 	chrp_find_bridges();
 
 #ifndef CONFIG_PPC64BRIDGE
-	/* PCI bridge config space access area -
-	 * appears to be not in devtree on longtrail. */
-	ioremap(GG2_PCI_CONFIG_BASE, 0x80000);
 	/*
 	 *  Temporary fixes for PCI devices.
 	 *  -- Geert
@@ -259,7 +254,6 @@
 
 #endif /* CONFIG_PPC64BRIDGE */
 
-#ifndef CONFIG_POWER4
 	/* Some IBM machines don't have the hydra -- Cort */
 	if (!OpenPIC_Addr) {
 		struct device_node *root;
@@ -276,7 +270,6 @@
 			OpenPIC_Addr = ioremap(opprop[n-1], 0x40000);
 		}
 	}
-#endif
 
 	/*
 	 *  Fix the Super I/O configuration
@@ -401,9 +394,6 @@
 void __init
 chrp_init2(void)
 {
-#if defined(CONFIG_VT) && defined(CONFIG_ADB_KEYBOARD)
-	struct device_node *kbd;
-#endif
 #ifdef CONFIG_NVRAM  
 	pmac_nvram_init();
 #endif
@@ -418,87 +408,35 @@
 	if (ppc_md.progress)
 		ppc_md.progress("  Have fun!    ", 0x7777);
 
-#if defined(CONFIG_VT) && defined(CONFIG_ADB_KEYBOARD)
+#if defined(CONFIG_VT) && (defined(CONFIG_ADB_KEYBOARD) || defined(CONFIG_INPUT))
 	/* see if there is a keyboard in the device tree
 	   with a parent of type "adb" */
-	for (kbd = find_devices("keyboard"); kbd; kbd = kbd->next)
-		if (kbd->parent && kbd->parent->type
-		    && strcmp(kbd->parent->type, "adb") == 0)
-			break;
-	if (kbd) {
-		ppc_md.kbd_setkeycode    = mackbd_setkeycode;
-		ppc_md.kbd_getkeycode    = mackbd_getkeycode;
-		ppc_md.kbd_translate     = mackbd_translate;
-		ppc_md.kbd_unexpected_up = mackbd_unexpected_up;
-		ppc_md.kbd_leds          = mackbd_leds;
-		ppc_md.kbd_init_hw       = mackbd_init_hw;
-#ifdef CONFIG_MAGIC_SYSRQ
-		ppc_md.ppc_kbd_sysrq_xlate	 = mackbd_sysrq_xlate;
-		SYSRQ_KEY = 0x69;
-#endif /* CONFIG_MAGIC_SYSRQ */
+	{
+		struct device_node *kbd;
+
+		for (kbd = find_devices("keyboard"); kbd; kbd = kbd->next) {
+			if (kbd->parent && kbd->parent->type
+			    && strcmp(kbd->parent->type, "adb") == 0) {
+				select_adb_keyboard();
+				break;
+			}
+		}
 	}
-#endif /* CONFIG_VT && CONFIG_ADB_KEYBOARD */
+#endif /* CONFIG_VT && (CONFIG_ADB_KEYBOARD || CONFIG_INPUT) */
 }
 
 #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
-chrp_ide_probe(void)
-{
-        struct pci_dev *pdev = pci_find_device(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105, NULL);
-
-        chrp_ide_ports_known = 1;
-
-        if(pdev) {
-                chrp_ide_regbase[0]=pdev->resource[0].start;
-                chrp_ide_regbase[1]=pdev->resource[2].start;
-                chrp_idedma_regbase=pdev->resource[4].start;
-                chrp_ide_irq=pdev->irq;
-        }
-}
 
-void __chrp
-chrp_ide_insw(ide_ioreg_t port, void *buf, int ns)
-{
-	ide_insw(port+_IO_BASE, buf, ns);
-}
-
-void __chrp
-chrp_ide_outsw(ide_ioreg_t port, void *buf, int ns)
-{
-	ide_outsw(port+_IO_BASE, buf, ns);
-}
-
-int __chrp
-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
-chrp_ide_default_io_base(int index)
-{
-        if (chrp_ide_ports_known == 0)
-	        chrp_ide_probe();
-	return chrp_ide_regbase[index];
-}
-
-int __chrp
+static int __chrp
 chrp_ide_check_region(ide_ioreg_t from, unsigned int extent)
 {
         return check_region(from, extent);
 }
 
-void __chrp
+static void __chrp
 chrp_ide_request_region(ide_ioreg_t from,
 			unsigned int extent,
 			const char *name)
@@ -506,14 +444,14 @@
         request_region(from, extent, name);
 }
 
-void __chrp
+static void __chrp
 chrp_ide_release_region(ide_ioreg_t from,
 			unsigned int extent)
 {
         release_region(from, extent);
 }
 
-void __chrp
+static void __chrp
 chrp_ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq)
 {
 	ide_ioreg_t reg = data_port;
@@ -523,20 +461,42 @@
 		hw->io_ports[i] = reg;
 		reg += 1;
 	}
-	if (ctrl_port) {
-		hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
+	hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
+}
+#endif
+
+/*
+ * One of the main thing these mappings are needed for is so that
+ * xmon can get to the serial port early on.  We probably should
+ * handle the machines with the mpc106 as well as the python (F50)
+ * and the GG2 (longtrail).  Actually we should look in the device
+ * tree and do the right thing.
+ */
+static void __init
+chrp_map_io(void)
+{
+	char *name;
+
+	/*
+	 * The code below tends to get removed, please don't take it out.
+	 * The F50 needs this mapping and it you take it out I'll track you
+	 * down and slap your hands.  If it causes problems please email me.
+	 *  -- Cort <cort@fsmlabs.com>
+	 */
+	name = get_property(find_path_device("/"), "name", NULL);
+	if (name && strncmp(name, "IBM-70", 6) == 0
+	    && strstr(name, "-F50")) {
+		io_block_mapping(0x80000000, 0x80000000, 0x10000000, _PAGE_IO);
+		io_block_mapping(0x90000000, 0x90000000, 0x10000000, _PAGE_IO);
+		return;
 	} else {
-		hw->io_ports[IDE_CONTROL_OFFSET] = 0;
+		io_block_mapping(0xf8000000, 0xf8000000, 0x04000000, _PAGE_IO);
 	}
-	if (irq != NULL)
-		hw->irq = chrp_ide_irq;
 }
 
-#endif
-
 void __init
-	   chrp_init(unsigned long r3, unsigned long r4, unsigned long r5,
-		     unsigned long r6, unsigned long r7)
+chrp_init(unsigned long r3, unsigned long r4, unsigned long r5,
+	  unsigned long r6, unsigned long r7)
 {
 #ifdef CONFIG_BLK_DEV_INITRD
 	/* take care of initrd if we have one */
@@ -576,6 +536,7 @@
 	ppc_md.calibrate_decr = chrp_calibrate_decr;
 
 	ppc_md.find_end_of_memory = pmac_find_end_of_memory;
+	ppc_md.setup_io_mappings = chrp_map_io;
 
 #ifdef CONFIG_VT
 	/* these are adjusted in chrp_init2 if we have an ADB keyboard */
@@ -608,22 +569,23 @@
 		}
 	}
 #ifdef CONFIG_BOOTX_TEXT
-	if (ppc_md.progress == NULL && bootx_text_mapped)
-		ppc_md.progress = bootx_text_progress;
+	if (ppc_md.progress == NULL && boot_text_mapped)
+		ppc_md.progress = btext_progress;
 #endif
 
+#ifdef CONFIG_SMP
+#ifndef CONFIG_POWER4
+	ppc_md.smp_ops = &chrp_smp_ops;
+#else
+	ppc_md.smp_ops = &xics_smp_ops;
+#endif /* CONFIG_POWER4 */
+#endif /* CONFIG_SMP */
+
 #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.ide_check_region = chrp_ide_check_region;
         ppc_ide_md.ide_request_region = chrp_ide_request_region;
         ppc_ide_md.ide_release_region = chrp_ide_release_region;
-        ppc_ide_md.fix_driveid = ppc_generic_ide_fix_driveid;
         ppc_ide_md.ide_init_hwif = chrp_ide_init_hwif_ports;
-
-        ppc_ide_md.io_base = _IO_BASE;
 #endif
 
 	/*
@@ -668,7 +630,7 @@
 
 #ifdef CONFIG_BOOTX_TEXT
 void
-bootx_text_progress(char *s, unsigned short hex)
+btext_progress(char *s, unsigned short hex)
 {
 	prom_print(s);
 	prom_print("\n");
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/chrp_smp.c linux/arch/ppc/kernel/chrp_smp.c
--- v2.4.9/linux/arch/ppc/kernel/chrp_smp.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/ppc/kernel/chrp_smp.c	Sat Sep  8 12:38:41 2001
@@ -0,0 +1,149 @@
+/*
+ * BK Id: %F% %I% %G% %U% %#%
+ */
+/*
+ * Smp support for CHRP machines.
+ *
+ * Written by Cort Dougan (cort@cs.nmt.edu) borrowing a great
+ * deal of code from the sparc and intel versions.
+ *
+ * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/smp.h>
+#include <linux/smp_lock.h>
+#include <linux/interrupt.h>
+#include <linux/kernel_stat.h>
+#include <linux/delay.h>
+#define __KERNEL_SYSCALLS__
+#include <linux/unistd.h>
+#include <linux/init.h>
+#include <linux/spinlock.h>
+
+#include <asm/ptrace.h>
+#include <asm/atomic.h>
+#include <asm/irq.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+#include <asm/hardirq.h>
+#include <asm/softirq.h>
+#include <asm/sections.h>
+#include <asm/io.h>
+#include <asm/prom.h>
+#include <asm/smp.h>
+#include <asm/residual.h>
+#include <asm/feature.h>
+#include <asm/time.h>
+
+#include "open_pic.h"
+
+extern unsigned long smp_chrp_cpu_nr;
+
+static int __init
+smp_chrp_probe(void)
+{
+	if (smp_chrp_cpu_nr > 1)
+		openpic_request_IPIs();
+
+	return smp_chrp_cpu_nr;
+}
+
+static void __init
+smp_chrp_kick_cpu(int nr)
+{
+	*(unsigned long *)KERNELBASE = nr;
+	asm volatile("dcbf 0,%0"::"r"(KERNELBASE):"memory");
+}
+
+static void __init
+smp_chrp_setup_cpu(int cpu_nr)
+{
+	static atomic_t ready = ATOMIC_INIT(1);
+	static volatile int frozen = 0;
+
+	if (cpu_nr == 0) {
+		/* wait for all the others */
+		while (atomic_read(&ready) < smp_num_cpus)
+			barrier();
+		atomic_set(&ready, 1);
+		/* freeze the timebase */
+		call_rtas("freeze-time-base", 0, 1, NULL);
+		mb();
+		frozen = 1;
+		/* XXX assumes this is not a 601 */
+		set_tb(0, 0);
+		last_jiffy_stamp(0) = 0;
+		while (atomic_read(&ready) < smp_num_cpus)
+			barrier();
+		/* thaw the timebase again */
+		call_rtas("thaw-time-base", 0, 1, NULL);
+		mb();
+		frozen = 0;
+		smp_tb_synchronized = 1;
+	} else {
+		atomic_inc(&ready);
+		while (!frozen)
+			barrier();
+		set_tb(0, 0);
+		last_jiffy_stamp(0) = 0;
+		mb();
+		atomic_inc(&ready);
+		while (frozen)
+			barrier();
+	}
+
+	if (OpenPIC_Addr)
+		do_openpic_setup_cpu();
+}
+
+#ifdef CONFIG_POWER4
+static void __chrp
+smp_xics_message_pass(int target, int msg, unsigned long data, int wait)
+{
+	/* for now, only do reschedule messages
+	   since we only have one IPI */
+	if (msg != PPC_MSG_RESCHEDULE)
+		return;
+	for (i = 0; i < smp_num_cpus; ++i) {
+		if (target == MSG_ALL || target == i
+		    || (target == MSG_ALL_BUT_SELF
+			&& i != smp_processor_id()))
+			xics_cause_IPI(i);
+	}
+}
+
+static int __chrp
+smp_xics_probe(void)
+{
+	return smp_chrp_cpu_nr;
+}
+
+static void __chrp
+smp_xics_setup_cpu(int cpu_nr)
+{
+	if (cpu_nr > 0)
+		xics_setup_cpu();
+}
+#endif /* CONFIG_POWER4 */
+
+/* CHRP with openpic */
+struct smp_ops_t chrp_smp_ops __chrpdata = {
+	smp_openpic_message_pass,
+	smp_chrp_probe,
+	smp_chrp_kick_cpu,
+	smp_chrp_setup_cpu,
+};
+
+#ifdef CONFIG_POWER4
+/* CHRP with new XICS interrupt controller */
+struct smp_ops_t xics_smp_ops __chrpdata = {
+	smp_xics_message_pass,
+	smp_xics_probe,
+	smp_chrp_kick_cpu,
+	smp_xics_setup_cpu,
+};
+#endif /* CONFIG_POWER4 */
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/chrp_time.c linux/arch/ppc/kernel/chrp_time.c
--- v2.4.9/linux/arch/ppc/kernel/chrp_time.c	Mon May 21 17:04:46 2001
+++ linux/arch/ppc/kernel/chrp_time.c	Sat Sep  8 12:38:41 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.chrp_time.c 1.7 05/17/01 18:14:21 cort
+ * BK Id: SCCS/s.chrp_time.c 1.10 09/08/01 15:47:42 paulus
  */
 /*
  *  linux/arch/i386/kernel/time.c
@@ -29,7 +29,7 @@
 #include <asm/processor.h>
 #include <asm/nvram.h>
 #include <asm/prom.h>
-#include <asm/init.h>
+#include <asm/sections.h>
 #include <asm/time.h>
 
 extern spinlock_t rtc_lock;
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/cputable.c linux/arch/ppc/kernel/cputable.c
--- v2.4.9/linux/arch/ppc/kernel/cputable.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/ppc/kernel/cputable.c	Tue Aug 28 06:58:33 2001
@@ -0,0 +1,283 @@
+/*
+ * BK Id: %F% %I% %G% %U% %#%
+ */
+/*
+ *  arch/ppc/kernel/cputable.c
+ *
+ *  Copyright (C) 2001 Ben. Herrenschmidt (benh@kernel.crashing.org)
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; either version
+ *  2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/config.h>
+#include <linux/string.h>
+#include <linux/sched.h>
+#include <linux/threads.h>
+#include <linux/init.h>
+#include <asm/cputable.h>
+
+struct cpu_spec* cur_cpu_spec[NR_CPUS];
+
+extern void __setup_cpu_601(int cpu_nr);
+extern void __setup_cpu_603(int cpu_nr);
+extern void __setup_cpu_604(int cpu_nr);
+extern void __setup_cpu_750(int cpu_nr);
+extern void __setup_cpu_7400(int cpu_nr);
+extern void __setup_cpu_7450(int cpu_nr);
+extern void __setup_cpu_power3(int cpu_nr);
+extern void __setup_cpu_power4(int cpu_nr);
+extern void __setup_cpu_8xx(int cpu_nr);
+extern void __setup_cpu_generic(int cpu_nr);
+
+#define CLASSIC_PPC (!defined(CONFIG_8xx) && 	 \
+		     !defined(CONFIG_4xx) && !defined(CONFIG_POWER3) &&  \
+		     !defined(CONFIG_POWER4) && !defined(CONFIG_PPC_ISERIES))
+
+/* This table only contains "desktop" CPUs, it need to be filled with embedded
+ * ones as well...
+ */
+#define COMMON_PPC	(PPC_FEATURE_32 | PPC_FEATURE_HAS_FPU | \
+			 PPC_FEATURE_HAS_MMU)
+
+/* We only set the altivec features if the kernel was compiled with altivec
+ * support
+ */
+#ifdef CONFIG_ALTIVEC
+#define CPU_FTR_ALTIVEC_COMP	CPU_FTR_ALTIVEC
+#else
+#define CPU_FTR_ALTIVEC_COMP	0
+#endif
+
+struct cpu_spec	cpu_specs[] = {
+#if CLASSIC_PPC
+    { 	/* 601 */
+	0xffff0000, 0x00010000, "601",
+	CPU_FTR_601 | CPU_FTR_HPTE_TABLE,
+	COMMON_PPC | PPC_FEATURE_601_INSTR | PPC_FEATURE_UNIFIED_CACHE,
+	32, 32,
+	__setup_cpu_601
+    },
+    {	/* 603 */
+    	0xffff0000, 0x00030000, "603",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB,
+	COMMON_PPC,
+    	32, 32,
+	__setup_cpu_603
+    },
+    {	/* 603e */
+    	0xffff0000, 0x00060000, "603e",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB,
+	COMMON_PPC,
+	32, 32,
+	__setup_cpu_603
+    },
+    {	/* 603ev */
+    	0xffff0000, 0x00070000, "603ev",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB,
+	COMMON_PPC,
+	32, 32,
+	__setup_cpu_603
+    },
+    {	/* 604 */
+    	0xffff0000, 0x00040000, "604",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_604_PERF_MON |
+	CPU_FTR_HPTE_TABLE,
+	COMMON_PPC,
+	32, 32,
+	__setup_cpu_604
+    },
+    {	/* 604e */
+    	0xfffff000, 0x00090000, "604e",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_604_PERF_MON |
+	CPU_FTR_HPTE_TABLE,
+	COMMON_PPC,
+	32, 32,
+	__setup_cpu_604
+    },
+    {	/* 604r */
+    	0xffff0000, 0x00090000, "604r",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_604_PERF_MON |
+	CPU_FTR_HPTE_TABLE,
+	COMMON_PPC,
+	32, 32,
+	__setup_cpu_604
+    },
+    {	/* 604ev */
+    	0xffff0000, 0x000a0000, "604ev",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_604_PERF_MON |
+	CPU_FTR_HPTE_TABLE,
+	COMMON_PPC,
+	32, 32,
+	__setup_cpu_604
+    },
+    {	/* 750 (0x4202, don't support TAU ?) */
+    	0xffffffff, 0x00084202, "750",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB |
+	CPU_FTR_L2CR | CPU_FTR_HPTE_TABLE,
+	COMMON_PPC,
+	32, 32,
+	__setup_cpu_750
+    },
+    {	/* 750CX */
+    	0xffffff00, 0x00082200, "750CX",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB |
+	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE,
+	COMMON_PPC,
+	32, 32,
+	__setup_cpu_750
+    },
+    {	/* 740/750 (L2CR bit need fixup for 740) */
+    	0xffff0000, 0x00080000, "740/750",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB |
+	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE,
+	COMMON_PPC,
+	32, 32,
+	__setup_cpu_750
+    },
+    {	/* 7400 rev 1.1 ? (no TAU) */
+    	0xffffffff, 0x000c1101, "7400 (1.1)",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB |
+	CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_HPTE_TABLE,
+	COMMON_PPC | PPC_FEATURE_HAS_ALTIVEC,
+	32, 32,
+	__setup_cpu_7400
+    },
+    {	/* 7400 */
+    	0xffff0000, 0x000c0000, "7400",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB |
+	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_ALTIVEC_COMP | CPU_FTR_HPTE_TABLE,
+	COMMON_PPC | PPC_FEATURE_HAS_ALTIVEC,
+	32, 32,
+	__setup_cpu_7400
+    },
+    {	/* 7410 */
+    	0xffff0000, 0x800c0000, "7410",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB |
+	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_ALTIVEC_COMP | CPU_FTR_HPTE_TABLE,
+	COMMON_PPC | PPC_FEATURE_HAS_ALTIVEC,
+	32, 32,
+	__setup_cpu_7400
+    },
+    {	/* 7450 */
+    	0xffff0000, 0x80000000, "7450",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB |
+	CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_ALTIVEC_COMP |
+	CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450,
+	COMMON_PPC | PPC_FEATURE_HAS_ALTIVEC,
+	32, 32,
+	__setup_cpu_7450
+    },
+    {	/* 82xx (8240, 8245, 8260 are all 603e cores) */
+	0xffff0000, 0x00810000, "82xx",
+	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB,
+	COMMON_PPC,
+	32, 32,
+	__setup_cpu_603
+    },
+    {	/* default match, we assume split I/D cache & TB (non-601)... */
+    	0x00000000, 0x00000000, "(generic PPC)",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
+	COMMON_PPC,
+	32, 32,
+	__setup_cpu_generic
+    },
+#endif /* CLASSIC_PPC */    
+#ifdef CONFIG_PPC64BRIDGE
+    {	/* Power3 */
+    	0xffff0000, 0x00400000, "Power3 (630)",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
+    	COMMON_PPC | PPC_FEATURE_64,
+	128, 128,
+	__setup_cpu_power3
+    },
+    {	/* Power3+ */
+    	0xffff0000, 0x00410000, "Power3 (630+)",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
+    	COMMON_PPC | PPC_FEATURE_64,
+	128, 128,
+	__setup_cpu_power3
+    },
+	{	/* I-star */
+		0xffff0000, 0x00360000, "I-star",
+		CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
+		COMMON_PPC | PPC_FEATURE_64,
+		128, 128,
+		__setup_cpu_power3
+	},
+	{	/* S-star */
+		0xffff0000, 0x00370000, "S-star",
+		CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
+		COMMON_PPC | PPC_FEATURE_64,
+		128, 128,
+		__setup_cpu_power3
+	},
+#endif /* CONFIG_PPC64BRIDGE */    
+#ifdef CONFIG_POWER4
+    {	/* Power4 */
+    	0xffff0000, 0x00350000, "Power4",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
+    	COMMON_PPC | PPC_FEATURE_64,
+	128, 128,
+	__setup_cpu_power4
+    },
+#endif /* CONFIG_POWER4 */    
+#ifdef CONFIG_8xx
+    {	/* 8xx */
+    	0xffff0000, 0x00500000, "8xx",
+		/* CPU_FTR_CAN_DOZE is possible, if the 8xx code is there.... */
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB,
+    	PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
+ 	16, 16,
+	0, __setup_cpu_8xx
+    },
+#endif /* CONFIG_8xx */
+#ifdef CONFIG_4xx
+    {	/* 403GC */
+    	0xffffff00, 0x00200200, "403GC",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB,
+    	PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
+	16, 16,
+	0, /*__setup_cpu_403 */
+    },
+    {	/* 403GCX */
+    	0xffffff00, 0x00201400, "403GCX",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB,
+    	PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
+	16, 16,
+	0, /*__setup_cpu_403 */
+    },
+    {	/* 403G ?? */
+    	0xffff0000, 0x00200000, "403G ??",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB,
+    	PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
+	16, 16,
+	0, /*__setup_cpu_403 */
+    },
+    {	/* 405GP */
+    	0xffff0000, 0x40110000, "405GP",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB,
+    	PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU | PPC_FEATURE_HAS_4xxMAC,
+	32, 32,
+	0, /*__setup_cpu_405 */
+    },
+    {	/* STB 03xxx */
+    	0xffff0000, 0x40130000, "STB03xxx",
+    	CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB,
+    	PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU | PPC_FEATURE_HAS_4xxMAC,
+	32, 32,
+	0, /*__setup_cpu_405 */
+    },
+#endif /* CONFIG_4xx */
+#if !CLASSIC_PPC
+    {	/* default match */
+    	0x00000000, 0x00000000, "(generic PPC)",
+    	0,
+    	PPC_FEATURE_32,
+	32, 32,
+	0,
+    }
+#endif /* !CLASSIC_PPC */
+};
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/entry.S linux/arch/ppc/kernel/entry.S
--- v2.4.9/linux/arch/ppc/kernel/entry.S	Wed Jul 25 17:10:18 2001
+++ linux/arch/ppc/kernel/entry.S	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.entry.S 1.20 07/19/01 23:02:48 paulus
+ * BK Id: SCCS/s.entry.S 1.22 08/15/01 22:43:06 paulus
  */
 /*
  *  PowerPC version 
@@ -23,12 +23,14 @@
  */
 
 #include "ppc_asm.h"
+#include <linux/config.h>
+#include <linux/errno.h>
+#include <linux/sys.h>
+#include <linux/threads.h>
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
-#include <linux/errno.h>
-#include <linux/sys.h>
-#include <linux/config.h>
+#include <asm/cputable.h>
 
 #undef SHOW_SYSCALLS
 #undef SHOW_SYSCALLS_TASK
@@ -217,7 +219,9 @@
 	mfmsr	r22
 	li	r0,MSR_FP	/* Disable floating-point */
 #ifdef CONFIG_ALTIVEC
-	oris	r0,r0,MSR_VEC@h
+BEGIN_FTR_SECTION
+	oris	r0,r0,MSR_VEC@h	/* Disable altivec */
+END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
 #endif /* CONFIG_ALTIVEC */
 	andc	r22,r22,r0
 	mtmsr	r22
@@ -238,21 +242,6 @@
 	tophys(r0,r4)
 	CLR_TOP32(r0)
 	mtspr	SPRG3,r0	/* Update current THREAD phys addr */
-#ifdef CONFIG_8xx
-	/* XXX it would be nice to find a SPRGx for this on 6xx,7xx too */
-	lwz	r9,PGDIR(r4)	/* cache the page table root */
-        tophys(r9,r9)		/* convert to phys addr */
-#ifdef CONFIG_8xx_CPU6
-	lis	r6, cpu6_errata_word@h
-	ori	r6, r6, cpu6_errata_word@l
-	li	r5, 0x3980
-	stw	r5, 8(r6)
-	lwz	r5, 8(r6)
-#endif
-        mtspr   M_TWB,r9	/* Update MMU base address */
-	tlbia
-	sync
-#endif /* CONFIG_8xx */
 	lwz	r1,KSP(r4)	/* Load new stack pointer */
 	/* save the old current 'last' for return value */
 	mr	r3,r2
@@ -328,19 +317,16 @@
 	andi.	r0,r0,MSR_PR
 	beq+	1f
 #ifdef CONFIG_ALTIVEC
-	mfpvr	r8			/* check if we are on a G4 */
-	srwi	r8,r8,16
-	cmpwi	r8,PVR_7400@h
-	bne	2f
+BEGIN_FTR_SECTION
 	lwz	r0,THREAD+THREAD_VRSAVE(r2)
-	mtspr	SPRN_VRSAVE,r0		/* if so, restore VRSAVE reg */
-2:
+	mtspr	SPRN_VRSAVE,r0		/* if G4, restore VRSAVE reg */
+END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
 #endif /* CONFIG_ALTIVEC */
 	addi	r0,r1,INT_FRAME_SIZE	/* size of frame */
 	stw	r0,THREAD+KSP(r2)	/* save kernel stack pointer */
 	tophys(r8,r1)
 	CLR_TOP32(r8)
-	mtspr	SPRG2,r8		/* phys exception stack pointer */	
+	mtspr	SPRG2,r8		/* phys exception stack pointer */
 1:
 	lwz	r3,_CTR(r1)
 	lwz	r0,_LINK(r1)
@@ -348,15 +334,32 @@
 	mtlr	r0
 	REST_4GPRS(3, r1)
 	REST_2GPRS(7, r1)
+
+	/* We have to "dummy" load from the context save area in case
+	 * these instructions cause an MMU fault.  If this happens
+	 * after we load SRR0/SRR1, our return context is hosed.  -- Dan
+	 */
+	lwz	r0,GPR0(r1)
+	lwz	r0,GPR2(r1)
+	lwz	r0,GPR1(r1)
+
+	/* We re-use r3,r4 here (the load above was to cause the MMU
+	 * fault if necessary).  Using r3,r4 removes the need to "dummy"
+	 * load the CCR and NIP.  Since we load them we may as well
+	 * use them.
+	 */
+	lwz	r3,_CCR(r1)
+	lwz	r4,_NIP(r1)
+
 	lwz	r0,_MSR(r1)
 	FIX_SRR1(r0,r2)
 	mtspr	SRR1,r0
-	lwz	r2,_CCR(r1)
-	mtcrf	0xFF,r2
-	lwz	r2,_NIP(r1)
-	mtspr	SRR0,r2
+	mtcrf	0xFF,r3
+	mtspr	SRR0,r4
 	lwz	r0,GPR0(r1)
 	lwz	r2,GPR2(r1)
+	lwz	r3,GPR3(r1)
+	lwz	r4,GPR4(r1)
 	lwz	r1,GPR1(r1)
 	SYNC
 	RFI
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/feature.c linux/arch/ppc/kernel/feature.c
--- v2.4.9/linux/arch/ppc/kernel/feature.c	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/kernel/feature.c	Sat Sep  8 12:38:41 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.feature.c 1.16 07/06/01 14:42:47 trini
+ * BK Id: SCCS/s.feature.c 1.21 09/08/01 15:47:42 paulus
  */
 /*
  *  arch/ppc/kernel/feature.c
@@ -20,7 +20,7 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/spinlock.h>
-#include <asm/init.h>
+#include <asm/sections.h>
 #include <asm/errno.h>
 #include <asm/ohare.h>
 #include <asm/heathrow.h>
@@ -38,11 +38,15 @@
 #define FREG(c,r)			(&(((c)->reg)[(r)>>2]))
 
 /* Keylargo reg. access. */
-#define KL_FCR(r)	(keylargo_base + ((r) >> 2))
-#define KL_IN(r)	(in_le32(KL_FCR(r)))
-#define KL_OUT(r,v)	(out_le32(KL_FCR(r), (v)))
-#define KL_BIS(r,v)	(KL_OUT((r), KL_IN(r) | (v)))
-#define KL_BIC(r,v)	(KL_OUT((r), KL_IN(r) & ~(v)))
+#define KL_FCR(r)		(keylargo_base + ((r) >> 2))
+#define KL_IN(r)		(in_le32(KL_FCR(r)))
+#define KL_OUT(r,v)		(out_le32(KL_FCR(r), (v)))
+#define KL_BIS(r,v)		(KL_OUT((r), KL_IN(r) | (v)))
+#define KL_BIC(r,v)		(KL_OUT((r), KL_IN(r) & ~(v)))
+#define KL_GPIO_IN(r)		(in_8(((volatile u8 *)keylargo_base)+(r)))
+#define KL_GPIO_OUT(r,v)	(out_8(((volatile u8 *)keylargo_base)+(r), (v)))
+#define KL_LOCK()		spin_lock_irqsave(&keylargo->lock, flags)
+#define KL_UNLOCK()		spin_unlock_irqrestore(&keylargo->lock, flags)
 
 /* Uni-N reg. access. Note that Uni-N regs are big endian */
 #define UN_REG(r)	(uninorth_base + ((r) >> 2))
@@ -259,15 +263,29 @@
 static int				uninorth_rev;
 static int				keylargo_rev;
 static u32				board_features;
-static u8				airport_pwr_regs[5];
 static int				airport_pwr_state;
 static struct device_node*		airport_dev;
+static struct device_node*		uninorth_fw;
 
+/* Feature bits for Apple motherboards */
 #define FTR_NEED_OPENPIC_TWEAK		0x00000001
 #define FTR_CAN_NAP			0x00000002
 #define FTR_HAS_FW_POWER		0x00000004
 #define FTR_CAN_SLEEP			0x00000008
 
+/* This table currently lacks most oldworld machines, but
+ * they currently don't need it so...
+ * 
+ * Todo: The whole feature_xxx mecanism need to be redone
+ * some way to be able to handle the new kind of features
+ * exposed by core99. At this point, the main "tables" will
+ * probably be in this table, which will have to be filled with
+ * all known machines
+ */
+/* Warning: Don't change ordering of entries as some machines
+ * adverstise beeing compatible with several models. In those
+ * case, the "highest" has to be first
+ */
 static struct board_features_t {
 	char*	compatible;
 	u32	features;
@@ -283,17 +301,21 @@
   {	"PowerMac3,1",		FTR_NEED_OPENPIC_TWEAK		}, /* Sawtooth (G4) */
   {	"PowerMac3,2",		0				}, /* G4/Dual G4 */
   {	"PowerMac3,3",		FTR_NEED_OPENPIC_TWEAK		}, /* G4/Dual G4 */
-  {	"PowerMac5,1",		0				}, /* Cube */
+  {	"PowerMac3,4",		0				}, /* QuickSilver G4 */
+  {	"PowerMac3,5",		0				}, /* QuickSilver G4 */
+  {	"PowerMac5,1",		FTR_CAN_NAP			}, /* Cube */
   {	"AAPL,3400/2400",	FTR_CAN_SLEEP			}, /* 2400/3400 PowerBook */
   {	"AAPL,3500",		FTR_CAN_SLEEP			}, /* 3500 PowerBook (G3) */
   {	"AAPL,PowerBook1998",	FTR_CAN_SLEEP			}, /* Wallstreet PowerBook */
   {	"PowerBook1,1",		FTR_CAN_SLEEP			}, /* 101 (Lombard) PowerBook */
+  {	"PowerBook4,1",		FTR_CAN_NAP|FTR_CAN_SLEEP|	   /* New polycarbonate iBook */
+  				0/*FTR_HAS_FW_POWER*/		}, 
   {	"PowerBook2,1",		FTR_CAN_SLEEP 			}, /* iBook */
-  {	"PowerBook4,1",		FTR_CAN_NAP|FTR_CAN_SLEEP	}, /* iBook Dual USB */
   {	"PowerBook2,2",		FTR_CAN_SLEEP /*| FTR_CAN_NAP*/	}, /* iBook FireWire */
   {	"PowerBook3,1",		FTR_CAN_SLEEP|FTR_CAN_NAP|	   /* PowerBook 2000 (Pismo) */
   				FTR_HAS_FW_POWER		}, 
-  {	"PowerBook3,2",		FTR_CAN_NAP|FTR_CAN_SLEEP	}, /* PowerBook Titanium */
+  {	"PowerBook3,2",		FTR_CAN_NAP|FTR_CAN_SLEEP|	   /* PowerBook Titanium */
+  				0/*FTR_HAS_FW_POWER*/		},
   {	NULL, 0 }
 };
 
@@ -305,15 +327,25 @@
 	struct device_node *np;
 	u32 *rev;
 	int i;
-
+	char* model;
+	
 	if (_machine != _MACH_Pmac)
 		return;
 
-	/* Figure out motherboard type & options */
-	for(i=0;board_features_datas[i].compatible;i++) {
-		if (machine_is_compatible(board_features_datas[i].compatible)) {
-			board_features = board_features_datas[i].features;
-			break;
+	np = find_path_device("/");
+	if (!np) {
+		printk(KERN_ERR "feature.c: Can't find device-tree root !\n");
+		return;
+	}
+	model = (char*)get_property(np, "model", NULL);
+	if (model) {
+		printk("PowerMac model: %s\n", model);
+		/* Figure out motherboard type & options */
+		for(i=0;board_features_datas[i].compatible;i++) {
+			if (!strcmp(board_features_datas[i].compatible, model)) {
+				board_features = board_features_datas[i].features;
+				break;
+			}
 		}
 	}
 
@@ -382,8 +414,9 @@
 		printk("Uninorth at 0x%08x\n", np->addrs[0].address);
 	}
 	if (uninorth_base && keylargo_base)
-		printk("Uni-N revision: %d, KeyLargo revision: %d\n",
-			uninorth_rev, keylargo_rev);
+		printk("Uni-N revision: %d, KeyLargo revision: %d %s\n",
+			uninorth_rev, keylargo_rev,
+			(keylargo_rev & KL_PANGEA_REV) ? "(Pangea chipset)" : "");
 
 	if (uninorth_base)
 		uninorth_init();
@@ -402,6 +435,25 @@
 		feature_clear(controllers[0].device, FEATURE_Sound_CLK_enable);
 	}
 #endif
+
+#ifdef CONFIG_PMAC_PBOOK
+	/* On PowerBooks, we disable the serial ports by default, they
+	 * will be re-enabled by the driver
+	 */
+#ifndef CONFIG_XMON
+	if (controller_count && find_devices("via-pmu") != NULL) {
+		feature_set_modem_power(NULL, 0);
+		feature_clear(controllers[0].device, FEATURE_Serial_IO_A);
+		feature_clear(controllers[0].device, FEATURE_Serial_IO_B);
+		feature_clear(controllers[0].device, FEATURE_Serial_enable);
+		if (controller_count > 1) {
+			feature_clear(controllers[1].device, FEATURE_Serial_IO_A);
+			feature_clear(controllers[1].device, FEATURE_Serial_IO_B);
+			feature_clear(controllers[1].device, FEATURE_Serial_enable);
+		}
+	}
+#endif
+#endif
 }
 
 static struct feature_controller __init *
@@ -588,12 +640,16 @@
 	/* TODO: Handle save/restore of PCI config space here
 	 */
 
-	spin_lock_irqsave(&keylargo->lock, flags);
+	/* XXX We use the keylargo spinlock, but we never
+	 * have uninorth without keylargo, so...
+	 */
+	KL_LOCK();
 	if (power)
 		UN_BIS(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_GMAC);
 	else
 		UN_BIC(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_GMAC);
-	spin_unlock_irqrestore(&keylargo->lock, flags);
+	(void)UN_IN(UNI_N_CLOCK_CNTL);
+	KL_UNLOCK();
 	udelay(20);
 }
 
@@ -605,17 +661,16 @@
 	if (!keylargo_base || !keylargo)
 		return;
 		
-	spin_lock_irqsave(&keylargo->lock, flags);
-	out_8((volatile u8 *)KL_FCR(KL_GPIO_ETH_PHY_RESET),
-		KEYLARGO_GPIO_OUTPUT_ENABLE);
-	(void)in_8((volatile u8 *)KL_FCR(KL_GPIO_ETH_PHY_RESET));
-	spin_unlock_irqrestore(&keylargo->lock, flags);
+	KL_LOCK();
+	KL_GPIO_OUT(KL_GPIO_ETH_PHY_RESET, KEYLARGO_GPIO_OUTPUT_ENABLE);
+	(void)KL_GPIO_IN(KL_GPIO_ETH_PHY_RESET);
+	KL_UNLOCK();
 	mdelay(10);
-	spin_lock_irqsave(&keylargo->lock, flags);
-	out_8((volatile u8 *)KL_FCR(KL_GPIO_ETH_PHY_RESET),
+	KL_LOCK();
+	KL_GPIO_OUT(KL_GPIO_ETH_PHY_RESET,
 		KEYLARGO_GPIO_OUTPUT_ENABLE | KEYLARGO_GPIO_OUTOUT_DATA);
-	(void)in_8((volatile u8 *)KL_FCR(KL_GPIO_ETH_PHY_RESET));
-	spin_unlock_irqrestore(&keylargo->lock, flags);
+	(void)KL_GPIO_IN(KL_GPIO_ETH_PHY_RESET);
+	KL_UNLOCK();
 	mdelay(10);
 }
 
@@ -642,17 +697,23 @@
 	else
 		return;
 
-	spin_lock_irqsave(&keylargo->lock, flags);
+	KL_LOCK();
 	if (power) {
 		/* Turn ON */
 			
 		if (number == 0) {
 			KL_BIC(KEYLARGO_FCR0, (KL0_USB0_PAD_SUSPEND0 | KL0_USB0_PAD_SUSPEND1));
+			(void)KL_IN(KEYLARGO_FCR0);
+			KL_UNLOCK();
 			mdelay(1);
+			KL_LOCK();
 			KL_BIS(KEYLARGO_FCR0, KL0_USB0_CELL_ENABLE);
 		} else {
 			KL_BIC(KEYLARGO_FCR0, (KL0_USB1_PAD_SUSPEND0 | KL0_USB1_PAD_SUSPEND1));
+			KL_UNLOCK();
+			(void)KL_IN(KEYLARGO_FCR0);
 			mdelay(1);
+			KL_LOCK();
 			KL_BIS(KEYLARGO_FCR0, KL0_USB1_CELL_ENABLE);
 		}
 		reg = KL_IN(KEYLARGO_FCR4);
@@ -689,7 +750,7 @@
 		}
 		udelay(1);
 	}
-	spin_unlock_irqrestore(&keylargo->lock, flags);
+	KL_UNLOCK();
 }
 
 void  __pmac
@@ -697,18 +758,25 @@
 {
 	unsigned long flags;
 
-	/* TODO: Handle save/restore of PCI config space here
+	/* TODO: should probably handle save/restore of PCI config space here
 	 */
 		
+	if (!uninorth_fw || (device && uninorth_fw != device))
+		return;
 	if (!uninorth_base)
 		return;
-	spin_lock_irqsave(&keylargo->lock, flags);
+
+	/* XXX We use the keylargo spinlock, but we never
+	 * have uninorth without keylargo, so...
+	 */
+	KL_LOCK();
 	if (power)
 		UN_BIS(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_FW);
 	else
 		UN_BIC(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_FW);
+	(void)UN_IN(UNI_N_CLOCK_CNTL);
+	KL_UNLOCK();
 	udelay(20);
-	spin_unlock_irqrestore(&keylargo->lock, flags);
 }
 
 /* Warning: will kill the PHY.. */
@@ -717,79 +785,159 @@
 {
 	unsigned long flags;
 	u8 gpioValue = power ? 0 : 4;
-	
+
+	if (!uninorth_fw || (device && uninorth_fw != device))
+		return;
 	if (!keylargo_base || !(board_features & FTR_HAS_FW_POWER))
 		return;
-	spin_lock_irqsave(&keylargo->lock, flags);
-	out_8((volatile u8 *)KL_FCR(KL_GPIO_FW_CABLE_POWER), gpioValue);
-	(void)in_8((volatile u8 *)KL_FCR(KL_GPIO_FW_CABLE_POWER));
-	spin_unlock_irqrestore(&keylargo->lock, flags);		
+	KL_LOCK();
+	KL_GPIO_OUT(KL_GPIO_FW_CABLE_POWER, gpioValue);
+	(void)KL_GPIO_IN(KL_GPIO_FW_CABLE_POWER);
+	KL_UNLOCK();		
+}
+
+void
+feature_set_modem_power(struct device_node* device, int power)
+{
+	unsigned long flags;
+
+	if (!device) {
+		device = find_devices("ch-a");
+		while(device && !device_is_compatible(device, "cobalt"))
+			device = device->next;
+		if (!device)
+			return;
+	}
+	if (keylargo && (keylargo_rev & KL_PANGEA_REV)) {
+		KL_LOCK();
+		if (power) {
+			/* Assert modem reset */
+			KL_GPIO_OUT(KL_GPIO_MODEM_RESET, KEYLARGO_GPIO_OUTPUT_ENABLE);
+			(void)KL_GPIO_IN(KL_GPIO_MODEM_RESET);
+			udelay(10);
+			/* Power up modem */
+			KL_GPIO_OUT(KL_GPIO_MODEM_POWER, KEYLARGO_GPIO_OUTPUT_ENABLE);
+			(void)KL_GPIO_IN(KL_GPIO_MODEM_POWER);
+			udelay(10);
+			/* Release modem reset */
+			KL_GPIO_OUT(KL_GPIO_MODEM_RESET,
+				KEYLARGO_GPIO_OUTPUT_ENABLE | KEYLARGO_GPIO_OUTOUT_DATA);
+			(void)KL_GPIO_IN(KL_GPIO_MODEM_RESET);
+		} else {
+			/* Power down modem */
+			KL_GPIO_OUT(KL_GPIO_MODEM_POWER,
+				KEYLARGO_GPIO_OUTPUT_ENABLE | KEYLARGO_GPIO_OUTOUT_DATA);
+			(void)KL_GPIO_IN(KL_GPIO_MODEM_POWER);
+		}
+		KL_UNLOCK();
+	} else {
+		if (power) {
+			mdelay(300);
+			feature_set(device, FEATURE_Modem_power);
+	   		mdelay(5);
+			feature_clear(device, FEATURE_Modem_power);
+	   		mdelay(10);
+			feature_set(device, FEATURE_Modem_power);
+		} else {
+			feature_clear(device, FEATURE_Modem_power);
+			mdelay(10);
+		}
+	}
 }
 
 #ifdef CONFIG_SMP
 void __pmac
 feature_core99_kick_cpu(int cpu_nr)
 {
-#if 1 /* New way */
 	const int reset_lines[] = {	KL_GPIO_RESET_CPU0,
 					KL_GPIO_RESET_CPU1,
 					KL_GPIO_RESET_CPU2,
 					KL_GPIO_RESET_CPU3 };
-	volatile u8* reset_io;
-
+	int reset_io;
+	unsigned long flags;
+	
 	if (!keylargo_base || cpu_nr > 3)
 		return;
-	reset_io = (volatile u8*)KL_FCR(reset_lines[cpu_nr]);
-	out_8(reset_io, KEYLARGO_GPIO_OUTPUT_ENABLE);
-	udelay(1);
-	out_8(reset_io, KEYLARGO_GPIO_OUTPUT_ENABLE | KEYLARGO_GPIO_OUTOUT_DATA);
-#else
-	out_8((volatile u8 *)KL_FCR(KL_GPIO_EXTINT_CPU1), KL_GPIO_EXTINT_CPU1_ASSERT);
+	reset_io = reset_lines[cpu_nr];
+	
+	KL_LOCK();
+	KL_GPIO_OUT(reset_io, KEYLARGO_GPIO_OUTPUT_ENABLE);
+	(void)KL_GPIO_IN(reset_io);
 	udelay(1);
-	out_8((volatile u8 *)KL_FCR(KL_GPIO_EXTINT_CPU1), KL_GPIO_EXTINT_CPU1_RELEASE);
-#endif	
+	KL_GPIO_OUT(reset_io, KEYLARGO_GPIO_OUTPUT_ENABLE | KEYLARGO_GPIO_OUTOUT_DATA);
+	(void)KL_GPIO_IN(reset_io);
+	KL_UNLOCK();
 }
 #endif /* CONFIG_SMP */
 
 void __pmac
 feature_set_airport_power(struct device_node* device, int power)
 {
+	unsigned long flags;
+	
 	if (!keylargo_base || !airport_dev || airport_dev != device)
 		return;
 	if (airport_pwr_state == power)
-		return;
+		return;	
 	if (power) {
-		/* Some if this is from Darwin code, some is from tracing of
-		 * MacOS driver with Macsbug. Some real bit definitions would
-		 * really help here...
+		/* This code is a reproduction of OF enable-cardslot
+		 * and init-wireless methods, slightly hacked until
+		 * I got it working.
 		 */
-		out_8((volatile u8*)KL_FCR(KL_GPIO_AIRPORT_0), airport_pwr_regs[0]);
-		out_8((volatile u8*)KL_FCR(KL_GPIO_AIRPORT_1), airport_pwr_regs[1]);
-		out_8((volatile u8*)KL_FCR(KL_GPIO_AIRPORT_2), airport_pwr_regs[2]);
-		out_8((volatile u8*)KL_FCR(KL_GPIO_AIRPORT_3), airport_pwr_regs[3]);
-		out_8((volatile u8*)KL_FCR(KL_GPIO_AIRPORT_4), airport_pwr_regs[4]);
-		udelay(20);
-		out_8((volatile u8*)KL_FCR(KL_GPIO_AIRPORT_4), 5);
-		udelay(20);
-		out_8((volatile u8*)KL_FCR(KL_GPIO_AIRPORT_4), 4);
-		mdelay(20);
+		KL_LOCK();
+		KL_GPIO_OUT(KEYLARGO_GPIO_0+0xf, 5);
+		(void)KL_GPIO_IN(KEYLARGO_GPIO_0+0xf);
+		KL_UNLOCK();
+		mdelay(10);
+		KL_LOCK();
+		KL_GPIO_OUT(KEYLARGO_GPIO_0+0xf, 4);
+		(void)KL_GPIO_IN(KEYLARGO_GPIO_0+0xf);
+		KL_UNLOCK();
+
+		mdelay(10);
+
+		KL_LOCK();
 		KL_BIC(KEYLARGO_FCR2, KL2_AIRPORT_RESET_N);
+		(void)KL_IN(KEYLARGO_FCR2);
+		udelay(10);
+		KL_GPIO_OUT(KEYLARGO_GPIO_EXTINT_0+0xb, 0);
+		(void)KL_GPIO_IN(KEYLARGO_GPIO_EXTINT_0+0xb);
+		udelay(10);
+		KL_GPIO_OUT(KEYLARGO_GPIO_EXTINT_0+0xa, 0x28);
+		(void)KL_GPIO_IN(KEYLARGO_GPIO_EXTINT_0+0xa);
+		udelay(10);
+		KL_GPIO_OUT(KEYLARGO_GPIO_EXTINT_0+0xd, 0x28);
+		(void)KL_GPIO_IN(KEYLARGO_GPIO_EXTINT_0+0xd);
+		udelay(10);
+		KL_GPIO_OUT(KEYLARGO_GPIO_0+0xd, 0x28);
+		(void)KL_GPIO_IN(KEYLARGO_GPIO_0+0xd);
+		udelay(10);
+		KL_GPIO_OUT(KEYLARGO_GPIO_0+0xe, 0x28);
+		(void)KL_GPIO_IN(KEYLARGO_GPIO_0+0xe);
+		KL_UNLOCK();
 		udelay(10);
+		KL_OUT(0x1c000, 0);
+		
+		mdelay(1);
 		out_8((volatile u8*)KL_FCR(0x1a3e0), 0x41);
+		(void)in_8((volatile u8*)KL_FCR(0x1a3e0));
 		udelay(10);
+		KL_LOCK();
 		KL_BIS(KEYLARGO_FCR2, KL2_AIRPORT_RESET_N);
-		udelay(10);
+		(void)KL_IN(KEYLARGO_FCR2);
+		KL_UNLOCK();
+		mdelay(100);
 	} else {
-		airport_pwr_regs[0] = in_8((volatile u8*)KL_FCR(KL_GPIO_AIRPORT_0));
-		airport_pwr_regs[1] = in_8((volatile u8*)KL_FCR(KL_GPIO_AIRPORT_1));
-		airport_pwr_regs[2] = in_8((volatile u8*)KL_FCR(KL_GPIO_AIRPORT_2));
-		airport_pwr_regs[3] = in_8((volatile u8*)KL_FCR(KL_GPIO_AIRPORT_3));
-		airport_pwr_regs[4] = in_8((volatile u8*)KL_FCR(KL_GPIO_AIRPORT_4));
-		out_8((volatile u8*)KL_FCR(KL_GPIO_AIRPORT_0), 0);
-		out_8((volatile u8*)KL_FCR(KL_GPIO_AIRPORT_1), 0);
-		out_8((volatile u8*)KL_FCR(KL_GPIO_AIRPORT_2), 0);
-		out_8((volatile u8*)KL_FCR(KL_GPIO_AIRPORT_3), 0);
-		out_8((volatile u8*)KL_FCR(KL_GPIO_AIRPORT_4), 0);
+		KL_LOCK();
+		KL_BIC(KEYLARGO_FCR2, KL2_AIRPORT_RESET_N);
+		(void)KL_IN(KEYLARGO_FCR2);
+		KL_GPIO_OUT(KL_GPIO_AIRPORT_0, 0);
+		KL_GPIO_OUT(KL_GPIO_AIRPORT_1, 0);
+		KL_GPIO_OUT(KL_GPIO_AIRPORT_2, 0);
+		KL_GPIO_OUT(KL_GPIO_AIRPORT_3, 0);
+		KL_GPIO_OUT(KL_GPIO_AIRPORT_4, 0);
+		(void)KL_GPIO_IN(KL_GPIO_AIRPORT_4);
+		KL_UNLOCK();
 	}
 	airport_pwr_state = power;	
 }
@@ -826,8 +974,11 @@
 	/* Enable FW before PCI probe. Will be disabled later on
 	 */
 	fw = find_devices("firewire");
-	if (fw && device_is_compatible(fw, "pci106b,18"))
+	if (fw && (device_is_compatible(fw, "pci106b,18") || 
+			device_is_compatible(fw, "pci106b,30"))) {
+		uninorth_fw = fw;
 		feature_set_firewire_power(fw, 1);
+	}
 }
 
 /* Initialize the Core99 KeyLargo ASIC. 
@@ -864,7 +1015,7 @@
 		device_is_compatible(ctrler->device, "gatwick"))
 		ctrler = &controllers[1];
 
-	if (ctrler->bits == feature_bits_heathrow ||
+	if (ctrler->bits == feature_bits_wallstreet ||
 		ctrler->bits == feature_bits_paddington) {
 		heathrow_prepare_for_sleep(ctrler);
 		return;
@@ -884,7 +1035,7 @@
 		device_is_compatible(ctrler->device, "gatwick"))
 		ctrler = &controllers[1];
 	
-	if (ctrler->bits == feature_bits_heathrow ||
+	if (ctrler->bits == feature_bits_wallstreet ||
 		ctrler->bits == feature_bits_paddington) {
 		heathrow_wakeup(ctrler);
 		return;
@@ -929,15 +1080,10 @@
 {
 	u32 temp;
 
-	/* For now, suspending the USB ref cause the machine to die on
-	 * wakeup -- BenH
-	 */
-#if 0
 	mdelay(1);
 	KL_BIS(KEYLARGO_FCR0, KL0_USB_REF_SUSPEND);
 	(void)KL_IN(KEYLARGO_FCR0);
-	mdelay(1500);
-#endif
+	mdelay(100);
 
 	KL_BIC(KEYLARGO_FCR0,	KL0_SCCA_ENABLE | KL0_SCCB_ENABLE |
 				KL0_SCC_CELL_ENABLE |
@@ -1014,7 +1160,7 @@
 core99_prepare_for_sleep(struct feature_controller* ctrler)
 {
 	int i;
-	u8* base8;
+	volatile u8* base8;
 	
 	/*
 	 * Save various bits of KeyLargo
@@ -1026,15 +1172,19 @@
 	feature_set_airport_power(airport_dev, 0);
 
 	/* We power off the FW cable. Should be done by the driver... */
+	feature_set_firewire_power(NULL, 0);
 	feature_set_firewire_cable_power(NULL, 0);
+
+	/* We make sure int. modem is off (in case driver lost it) */
+	feature_set_modem_power(NULL, 0);
 	 
 	/* Save the state of the various GPIOs */
 	save_gpio_levels[0] = KL_IN(KEYLARGO_GPIO_LEVELS0);
 	save_gpio_levels[1] = KL_IN(KEYLARGO_GPIO_LEVELS1);
-	base8 = (u8 *)KL_FCR(KEYLARGO_GPIO_EXTINT_0);
+	base8 = ((volatile u8 *)keylargo_base) + KEYLARGO_GPIO_EXTINT_0;
 	for (i=0; i<KEYLARGO_GPIO_EXTINT_CNT; i++)
 		save_gpio_extint[i] = in_8(base8+i);
-	base8 = (u8 *)KL_FCR(KEYLARGO_GPIO_0);
+	base8 = ((volatile u8 *)keylargo_base) + KEYLARGO_GPIO_0;
 	for (i=0; i<KEYLARGO_GPIO_CNT; i++)
 		save_gpio_normal[i] = in_8(base8+i);
 
@@ -1089,7 +1239,7 @@
 core99_wake_up(struct feature_controller* ctrler)
 {
 	int i;
-	u8* base8;
+	volatile u8* base8;
 
 	/*
 	 * Wakeup the host bridge
@@ -1131,10 +1281,10 @@
 
 	KL_OUT(KEYLARGO_GPIO_LEVELS0, save_gpio_levels[0]);
 	KL_OUT(KEYLARGO_GPIO_LEVELS1, save_gpio_levels[1]);
-	base8 = (u8 *)KL_FCR(KEYLARGO_GPIO_EXTINT_0);
+	base8 = ((volatile u8 *)keylargo_base) + KEYLARGO_GPIO_EXTINT_0;
 	for (i=0; i<KEYLARGO_GPIO_EXTINT_CNT; i++)
 		out_8(base8+i, save_gpio_extint[i]);
-	base8 = (u8 *)KL_FCR(KEYLARGO_GPIO_0);
+	base8 = ((volatile u8 *)keylargo_base) + KEYLARGO_GPIO_0;
 	for (i=0; i<KEYLARGO_GPIO_CNT; i++)
 		out_8(base8+i, save_gpio_normal[i]);
 
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/gemini_setup.c linux/arch/ppc/kernel/gemini_setup.c
--- v2.4.9/linux/arch/ppc/kernel/gemini_setup.c	Mon May 21 17:04:47 2001
+++ linux/arch/ppc/kernel/gemini_setup.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.gemini_setup.c 1.7 05/17/01 18:14:21 cort
+ * BK Id: SCCS/s.gemini_setup.c 1.11 08/20/01 14:34:41 paulus
  */
 /*
  *  linux/arch/ppc/kernel/setup.c
@@ -54,17 +54,6 @@
 	0, 0, 14, 0, 0, 13, 5, 9, 6, 11, 8, 10, 0, 12, 7, 0
 };
 
-int chrp_get_irq(struct pt_regs *);
-void chrp_post_irq(struct pt_regs* regs, int);
-
-static inline unsigned long _get_HID1(void)
-{
-	unsigned long val;
-
-	__asm__ __volatile__("mfspr %0,1009" : "=r" (val));
-	return val;
-}
-
 /*
  * prom_init is the Gemini version of prom.c:prom_init.  We only need
  * the BSS clearing code, so I copied that out of prom.c.  This is a
@@ -208,10 +197,11 @@
 int
 gemini_get_clock_speed(void)
 {
-	unsigned long hid1, pvr = _get_PVR();
+	unsigned long hid1, pvr;
 	int clock;
 
-	hid1 = (_get_HID1() >> 28) & 0xf;
+	pvr = mfspr(PVR);
+	hid1 = (mfspr(HID1) >> 28) & 0xf;
 	if (PVR_VER(pvr) == 8 ||
 	    PVR_VER(pvr) == 12)
 		hid1 = cpu_7xx[hid1];
@@ -241,11 +231,12 @@
 {
         unsigned char reg, brev, fam, creg;
         unsigned long cache;
-        unsigned long pvr = _get_PVR();
+        unsigned long pvr;
 
         reg = readb(GEMINI_L2CFG);
         brev = readb(GEMINI_BREV);
         fam = readb(GEMINI_FEAT);
+        pvr = mfspr(PVR);
 
         switch(PVR_VER(pvr)) {
 
@@ -486,11 +477,60 @@
 	return total;
 }
 
-void __init gemini_init(unsigned long r3, unsigned long r4, unsigned long r5,
-			unsigned long r6, unsigned long r7)
+static void __init
+gemini_map_io(void)
+{
+	io_block_mapping(0xf0000000, 0xf0000000, 0x10000000, _PAGE_IO);
+	io_block_mapping(0x80000000, 0x80000000, 0x10000000, _PAGE_IO);
+}
+
+#ifdef CONFIG_SMP
+static int
+smp_gemini_probe(void)
+{
+	int i, nr;
+
+        nr = (readb(GEMINI_CPUSTAT) & GEMINI_CPU_COUNT_MASK) >> 2;
+	if (nr == 0)
+		nr = 4;
+
+	if (nr > 1) {
+		openpic_request_IPIs();
+		for (i = 1; i < nr; ++i)
+			smp_hw_index[i] = i;
+	}
+
+	return nr;
+}
+
+static void
+smp_gemini_kick_cpu(int nr)
+{
+	openpic_init_processor( 1<<nr );
+	openpic_init_processor( 0 );
+}
+
+static void
+smp_gemini_setup_cpu(int cpu_nr)
+{
+	if (OpenPIC_Addr)
+		do_openpic_setup_cpu();
+	if (cpu_nr > 0)
+		gemini_init_l2();
+}
+
+static struct smp_ops_t gemini_smp_ops = {
+	smp_openpic_message_pass,
+	smp_gemini_probe,
+	smp_gemini_kick_cpu,
+	smp_gemini_setup_cpu,
+};
+#endif /* CONFIG_SMP */
+
+void __init platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+			  unsigned long r6, unsigned long r7)
 {
 	int i;
-	int chrp_get_irq( struct pt_regs * );
 
 	for(i = 0; i < GEMINI_LEDS; i++)
 		gemini_led_off(i);
@@ -525,6 +565,7 @@
 	ppc_md.calibrate_decr = gemini_calibrate_decr;
 
 	ppc_md.find_end_of_memory = gemini_find_end_of_memory;
+	ppc_md.setup_io_mappings = gemini_map_io;
 
 	/* no keyboard/mouse/video stuff yet.. */
 	ppc_md.kbd_setkeycode = NULL;
@@ -537,4 +578,8 @@
 	ppc_md.ppc_kbd_sysrq_xlate = NULL;
 #endif
 	ppc_md.pcibios_fixup_bus = gemini_pcibios_fixup;
+
+#ifdef CONFIG_SMP
+	ppc_md.smp_ops = &gemini_smp_ops;
+#endif /* CONFIG_SMP */
 }
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/head.S linux/arch/ppc/kernel/head.S
--- v2.4.9/linux/arch/ppc/kernel/head.S	Wed Jul 25 17:10:18 2001
+++ linux/arch/ppc/kernel/head.S	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.head.S 1.25 07/07/01 17:08:44 paulus
+ * BK Id: SCCS/s.head.S 1.29 08/19/01 22:43:23 paulus
  */
 /*
  *  PowerPC version 
@@ -31,6 +31,7 @@
 #include <asm/page.h>
 #include <asm/mmu.h>
 #include <asm/pgtable.h>
+#include <asm/cputable.h>
 
 #ifdef CONFIG_APUS
 #include <asm/amigappc.h>
@@ -153,7 +154,7 @@
 
 #ifndef CONFIG_GEMINI
 /* Switch MMU off, clear BATs and flush TLB. At this point, r3 contains
- * the physical address we are running at, returned by prom_init()
+ * the physical address we are running at, returned by early_init()
  */
  	bl	mmu_off
 __after_mmu_off:
@@ -761,12 +762,10 @@
 	addi	r24,r1,STACK_FRAME_OVERHEAD
 	stw	r24,PT_REGS(r23)
 #ifdef CONFIG_ALTIVEC
-	mfpvr	r24			/* check if we are on a G4 */
-	srwi	r24,r24,16
-	cmpwi	r24,PVR_7400@h
-	bne	2f
-	mfspr	r22,SPRN_VRSAVE		/* if so, save vrsave register value */
+BEGIN_FTR_SECTION
+	mfspr	r22,SPRN_VRSAVE		/* if G4, save vrsave register value */
 	stw	r22,THREAD_VRSAVE(r23)
+END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
 #endif /* CONFIG_ALTIVEC */
 2:	addi	r2,r23,-THREAD		/* set r2 to current */
 	tovirt(r2,r2)
@@ -1280,10 +1279,13 @@
 	SYNC
 	MTMSRD(r0)
 	isync
-#else
-	bl	enable_caches
 #endif
 
+	lis	r3,-KERNELBASE@h
+	mr	r4,r24
+	bl	identify_cpu
+	bl	call_setup_cpu		/* Call setup_cpu for this CPU */
+
 	/* get current */
 	lis	r2,current_set@h
 	ori	r2,r2,current_set@l
@@ -1322,54 +1324,87 @@
 /*
  * Enable caches and 604-specific features if necessary.
  */
-enable_caches:
-	mfspr	r9,PVR
-	rlwinm	r9,r9,16,16,31
-	cmpi	0,r9,1
-	beq	6f			/* not needed for 601 */
+_GLOBAL(__setup_cpu_601)
+	blr
+_GLOBAL(__setup_cpu_603)
+	b	setup_common_caches
+_GLOBAL(__setup_cpu_604)
+	mflr	r4
+	bl	setup_common_caches
+	bl	setup_604_hid0
+	mtlr	r4
+	blr
+_GLOBAL(__setup_cpu_750)
+	mflr	r4
+	bl	setup_common_caches
+	bl	setup_750_7400_hid0
+	mtlr	r4
+	blr
+_GLOBAL(__setup_cpu_7400)
+	mflr	r4
+	bl	setup_common_caches
+	bl	setup_750_7400_hid0
+	mtlr	r4
+	blr
+_GLOBAL(__setup_cpu_7450)
+	blr
+_GLOBAL(__setup_cpu_power3)
+	blr
+_GLOBAL(__setup_cpu_power4)
+	blr
+_GLOBAL(__setup_cpu_generic)
+	blr
+
+/* Enable caches for 603's, 604, 750 & 7400 */
+setup_common_caches:
 	mfspr	r11,HID0
 	andi.	r0,r11,HID0_DCE
 	ori	r11,r11,HID0_ICE|HID0_DCE
 	ori	r8,r11,HID0_ICFI
-	bne	3f			/* don't invalidate the D-cache */
+	bne	1f			/* don't invalidate the D-cache */
 	ori	r8,r8,HID0_DCI		/* unless it wasn't enabled */
-3:
-	sync
+1:	sync
 	mtspr	HID0,r8			/* enable and invalidate caches */
 	sync
 	mtspr	HID0,r11		/* enable caches */
 	sync
 	isync
-	cmpi	0,r9,4			/* check for 604 */
-	cmpi	1,r9,9			/* or 604e */
-	cmpi	2,r9,10			/* or mach5 / 604r */
-	cmpi	3,r9,8			/* check for 750 (G3) */
-	cmpi	4,r9,12			/* or 7400 (G4) */
-	cror	2,2,6
-	cror	2,2,10
-	bne	4f
-	ori	r11,r11,HID0_SIED|HID0_BHTE /* for 604[e|r], enable */
-	bne	2,5f
-	ori	r11,r11,HID0_BTCD	/* superscalar exec & br history tbl */
-	b	5f
-4:
-	cror	14,14,18
-	bne	3,6f
-	/* for G3/G4:
-	 * enable Store Gathering (SGE), Address Brodcast (ABE),
-	 * Branch History Table (BHTE), Branch Target ICache (BTIC)
-	 */
+	blr
+
+/* 604, 604e, 604ev, ...
+ * Enable superscalar execution & branch history table
+ */
+setup_604_hid0:
+	mfspr	r11,HID0
+	ori	r11,r11,HID0_SIED|HID0_BHTE
+	ori	r8,r11,HID0_BTCD
+	sync
+	mtspr	HID0,r8		/* flush branch target address cache */
+	sync			/* on 604e/604r */
+	mtspr	HID0,r11
+	sync
+	isync
+	blr
+
+/* 740/750/7400/7410
+ * Enable Store Gathering (SGE), Address Brodcast (ABE),
+ * Branch History Table (BHTE), Branch Target ICache (BTIC)
+ * Dynamic Power Management (DPM), Speculative (SPD)
+ * Clear Instruction cache throttling (ICTC)
+ */
+setup_750_7400_hid0:
+	mfspr	r11,HID0
 	ori	r11,r11,HID0_SGE | HID0_ABE | HID0_BHTE | HID0_BTIC
 	oris	r11,r11,HID0_DPM@h	/* enable dynamic power mgmt */
 	li	r3,HID0_SPD
 	andc	r11,r11,r3		/* clear SPD: enable speculative */
  	li	r3,0
  	mtspr	ICTC,r3			/* Instruction Cache Throttling off */
-5:	isync
+	isync
 	mtspr	HID0,r11
 	sync
 	isync
-6:	blr
+	blr
 
 /*
  * Load stuff into the MMU.  Intended to be called with
@@ -1414,9 +1449,10 @@
  * This is where the main kernel code starts.
  */
 start_here:
-#ifndef CONFIG_PPC64BRIDGE
-	bl	enable_caches
-#endif
+	/* Call setup_cpu for CPU 0 */
+	li	r3,0		/* data offset */
+	li	r24,0		/* cpu# */
+	bl	call_setup_cpu
 
 	/* ptr to current */
 	lis	r2,init_task_union@h
@@ -1435,14 +1471,15 @@
 	li	r0,0
 	stwu	r0,-STACK_FRAME_OVERHEAD(r1)
 /*
- * Decide what sort of machine this is and initialize the MMU.
+ * Do early bootinfo parsing, platform-specific initialization,
+ * and set up the MMU.
  */
 	mr	r3,r31
 	mr	r4,r30
 	mr	r5,r29
 	mr	r6,r28
 	mr	r7,r27
-	bl	identify_machine
+	bl	machine_init
 	bl	MMU_init
 
 #ifdef CONFIG_APUS
@@ -1475,12 +1512,10 @@
 /* Load up the kernel context */
 2:
 	sync			/* Force all PTE updates to finish */
+	ISYNC_601
 	tlbia			/* Clear all TLB entries */
 	sync			/* wait for tlbia/tlbie to finish */
-#ifdef CONFIG_SMP
-	tlbsync			/* ... on all CPUs */
-	sync
-#endif
+	TLBSYNC			/* ... on all CPUs */
 
 	bl	load_up_mmu
 /* Now turn on the MMU for real! */
@@ -1500,7 +1535,7 @@
 	mulli	r3,r3,897	/* multiply context by skew factor */
 	rlwinm	r3,r3,4,8,27	/* VSID = (context & 0xfffff) << 4 */
 	addis	r3,r3,0x6000	/* Set Ks, Ku bits */
-	li	r0,12		/* TASK_SIZE / SEGMENT_SIZE */
+	li	r0,NUM_USER_SEGMENTS
 	mtctr	r0
 	li	r4,0
 3:
@@ -1512,7 +1547,8 @@
 	rlwinm	r3,r3,0,8,3	/* clear out any overflow from VSID field */
 	addis	r4,r4,0x1000	/* address of next segment */
 	bdnz	3b
-	SYNC
+	SYNC_601
+	isync
 	blr
 
 /* 
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/head_8xx.S linux/arch/ppc/kernel/head_8xx.S
--- v2.4.9/linux/arch/ppc/kernel/head_8xx.S	Tue Jul  3 17:08:18 2001
+++ linux/arch/ppc/kernel/head_8xx.S	Wed Aug 29 20:49:36 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.head_8xx.S 1.14 06/28/01 15:50:16 paulus
+ * BK Id: SCCS/s.head_8xx.S 1.21 08/28/01 16:27:27 trini
  */
 /*
  *  arch/ppc/kernel/except_8xx.S
@@ -31,6 +31,7 @@
 #include <asm/mmu.h>
 #include <asm/cache.h>
 #include <asm/pgtable.h>
+#include <asm/cputable.h>
 
 	.text
 	.globl	_stext
@@ -87,70 +88,10 @@
 	mr	r27,r7
 	li	r24,0			/* cpu # */
 
-	tlbia			/* Invalidate all TLB entries */
-	li	r8, 0
-	mtspr	MI_CTR, r8	/* Set instruction control to zero */
-	lis	r8, MD_RESETVAL@h
-#ifndef CONFIG_8xx_COPYBACK
-	oris	r8, r8, MD_WTDEF@h
-#endif
-	mtspr	MD_CTR, r8	/* Set data TLB control */
-
-	/* Now map the lower 8 Meg into the TLBs.  For this quick hack,
-	 * we can load the instruction and data TLB registers with the
-	 * same values.
-	 */
-	lis	r8, KERNELBASE@h	/* Create vaddr for TLB */
-	ori	r8, r8, MI_EVALID	/* Mark it valid */
-	mtspr	MI_EPN, r8
-	mtspr	MD_EPN, r8
-	li	r8, MI_PS8MEG		/* Set 8M byte page */
-	ori	r8, r8, MI_SVALID	/* Make it valid */
-	mtspr	MI_TWC, r8
-	mtspr	MD_TWC, r8
-	li	r8, MI_BOOTINIT		/* Create RPN for address 0 */
-	mtspr	MI_RPN, r8		/* Store TLB entry */
-	mtspr	MD_RPN, r8
-	lis	r8, MI_Kp@h		/* Set the protection mode */
-	mtspr	MI_AP, r8
-	mtspr	MD_AP, r8
-
-	/* Map another 8 MByte at the IMMR to get the processor
-	 * internal registers (among other things).
+	/* We have to turn on the MMU right away so we get cache modes
+	 * set correctly.
 	 */
-	mfspr	r9, 638			/* Get current IMMR */
-	andis.	r9, r9, 0xff80		/* Get 8Mbyte boundary */
-
-	mr	r8, r9			/* Create vaddr for TLB */
-	ori	r8, r8, MD_EVALID	/* Mark it valid */
-	mtspr	MD_EPN, r8
-	li	r8, MD_PS8MEG		/* Set 8M byte page */
-	ori	r8, r8, MD_SVALID	/* Make it valid */
-	mtspr	MD_TWC, r8
-	mr	r8, r9			/* Create paddr for TLB */
-	ori	r8, r8, MI_BOOTINIT|0x2 /* Inhibit cache -- Cort */
-	mtspr	MD_RPN, r8
-
-	/* Since the cache is enabled according to the information we
-	 * just loaded into the TLB, invalidate and enable the caches here.
-	 * We should probably check/set other modes....later.
-	 */
-	lis	r8, IDC_INVALL@h
-	mtspr	IC_CST, r8
-	mtspr	DC_CST, r8
-	lis	r8, IDC_ENABLE@h
-	mtspr	IC_CST, r8
-#ifdef CONFIG_8xx_COPYBACK
-	mtspr	DC_CST, r8
-#else
-	/* For a debug option, I left this here to easily enable
-	 * the write through cache mode
-	 */
-	lis	r8, DC_SFWT@h
-	mtspr	DC_CST, r8
-	lis	r8, IDC_ENABLE@h
-	mtspr	DC_CST, r8
-#endif
+	bl	initial_mmu
 
 /* We now have the lower 8 Meg mapped into TLB entries, and the caches
  * ready to work.
@@ -513,6 +454,7 @@
 #else
 	li	r21, 0x00f0
 	rlwimi	r20, r21, 0, 24, 28
+
 #endif
 #ifdef CONFIG_8xx_CPU6
 	li	r3, 0x3d80
@@ -721,131 +663,34 @@
 giveup_fpu:
 	blr
 
-/*
- * This code is jumped to from the startup code to copy
- * the kernel image to physical address 0.
- */
-relocate_kernel:
-	lis	r9,0x426f		/* if booted from BootX, don't */
-	addi	r9,r9,0x6f58		/* translate source addr */
-	cmpw	r31,r9			/* (we have to on chrp) */
-	beq	7f
-	rlwinm	r4,r4,0,8,31		/* translate source address */
-	add	r4,r4,r3		/* to region mapped with BATs */
-7:	addis	r9,r26,klimit@ha	/* fetch klimit */
-	lwz	r25,klimit@l(r9)
-	addis	r25,r25,-KERNELBASE@h
-	li	r6,0			/* Destination offset */
-	li	r5,0x4000		/* # bytes of memory to copy */
-	bl	copy_and_flush		/* copy the first 0x4000 bytes */
-	addi	r0,r3,4f@l		/* jump to the address of 4f */
-	mtctr	r0			/* in copy and do the rest. */
-	bctr				/* jump to the copy */
-4:	mr	r5,r25
-	bl	copy_and_flush		/* copy the rest */
-	b	turn_on_mmu
-
-/*
- * Copy routine used to copy the kernel to start at physical address 0
- * and flush and invalidate the caches as needed.
- * r3 = dest addr, r4 = source addr, r5 = copy limit, r6 = start offset
- * on exit, r3, r4, r5 are unchanged, r6 is updated to be >= r5.
- */
-copy_and_flush:
-	addi	r5,r5,-4
-	addi	r6,r6,-4
-4:	li	r0,CACHE_LINE_SIZE/4
-	mtctr	r0
-3:	addi	r6,r6,4			/* copy a cache line */
-	lwzx	r0,r6,r4
-	stwx	r0,r6,r3
-	bdnz	3b
-	dcbst	r6,r3			/* write it to memory */
-	sync
-	icbi	r6,r3			/* flush the icache line */
-	cmplw	0,r6,r5
-	blt	4b
-	isync
-	addi	r5,r5,4
-	addi	r6,r6,4
+/* Maybe someday.......
+*/
+_GLOBAL(__setup_cpu_8xx)
 	blr
 
-#ifdef CONFIG_SMP
-	.globl	__secondary_start_psurge
-__secondary_start_psurge:
-	li	r24,1			/* cpu # */
-	b	__secondary_start
-
-	.globl	__secondary_hold
-__secondary_hold:
-	/* tell the master we're here */
-	lis	r5,0x4@h
-	ori	r5,r5,0x4@l
-	stw	r3,0(r5)
-	dcbf	0,r5
-100:
-	lis	r5,0
-	dcbi	0,r5
-	lwz	r4,0(r5)
-	/* wait until we're told to start */
-	cmp	0,r4,r3
-	bne	100b
-	/* our cpu # was at addr 0 - go */
-	lis	r5,__secondary_start@h
-	ori	r5,r5,__secondary_start@l
-	tophys(r5,r5)
-	mtlr	r5
-	mr	r24,r3			/* cpu # */
-	blr
-#endif /* CONFIG_SMP */
-	
 /*
  * This is where the main kernel code starts.
  */
 start_here:
-#ifdef CONFIG_SMP
-	/* if we're the second cpu stack and r2 are different
-	* and we want to not clear the bss -- Cort */
-	lis	r5,first_cpu_booted@h
-	ori	r5,r5,first_cpu_booted@l
-	lwz	r5,0(r5)
-	cmpi	0,r5,0
-	beq	99f
-
-	/* get current */
-	lis	r2,current_set@h
-	ori	r2,r2,current_set@l
-	slwi	r24,r24,2			/* cpu # to current_set[cpu#] */
-	add	r2,r2,r24
-	lwz	r2,0(r2)
-	b	10f
-99:	
-#endif /* CONFIG_SMP */
+
 	/* ptr to current */
 	lis	r2,init_task_union@h
 	ori	r2,r2,init_task_union@l
-	/* Clear out the BSS */
-	lis	r11,_end@ha
-	addi	r11,r11,_end@l
-	lis	r8,__bss_start@ha
-	addi	r8,r8,__bss_start@l
-	subf	r11,r8,r11
-	addi	r11,r11,3
-	rlwinm.	r11,r11,30,2,31
-	beq	2f
-	addi	r8,r8,-4
-	mtctr	r11
-	li	r0,0
-3:	stwu	r0,4(r8)
-	bdnz	3b
-2:
-#ifdef CONFIG_SMP	
-10:
-#endif /* CONFIG_SMP */
+
+	/* ptr to phys current thread */
+	tophys(r4,r2)
+	addi	r4,r4,THREAD	/* init task's THREAD */
+	mtspr	SPRG3,r4
+	li	r3,0
+	mtspr	SPRG2,r3	/* 0 => r1 has kernel sp */
+
 	/* stack */
 	addi	r1,r2,TASK_UNION_SIZE
 	li	r0,0
 	stwu	r0,-STACK_FRAME_OVERHEAD(r1)
+
+	bl	early_init	/* We have to do this with MMU on */
+
 /*
  * Decide what sort of machine this is and initialize the MMU.
  */
@@ -854,12 +699,11 @@
 	mr	r5,r29
 	mr	r6,r28
 	mr	r7,r27
-	bl	identify_machine
+	bl	machine_init
 	bl	MMU_init
 
 /*
  * Go back to running unmapped so we can load up new values
- * for SDR1 (hash table pointer) and the segment registers
  * and change to using our exception vectors.
  * On the 8xx, all we have to do is invalidate the TLB to clear
  * the old 8M byte TLB mappings and load the page table base register.
@@ -869,8 +713,8 @@
 	 * easier......until someone changes init's static structures.
 	 */
 	lis	r6, swapper_pg_dir@h
-	tophys(r6,r6)
 	ori	r6, r6, swapper_pg_dir@l
+	tophys(r6,r6)
 #ifdef CONFIG_8xx_CPU6
 	lis	r4, cpu6_errata_word@h
 	ori	r4, r4, cpu6_errata_word@l
@@ -891,65 +735,117 @@
 	SYNC			/* Force all PTE updates to finish */
 	tlbia			/* Clear all TLB entries */
 	sync			/* wait for tlbia/tlbie to finish */
-#ifdef CONFIG_SMP
-	tlbsync			/* ... on all CPUs */
-	sync
-#endif
-/* Set up for using our exception vectors */
-	/* ptr to phys current thread */
-	tophys(r4,r2)
-	addi	r4,r4,THREAD	/* init task's THREAD */
-	mtspr	SPRG3,r4
-	li	r3,0
-	mtspr	SPRG2,r3	/* 0 => r1 has kernel sp */
+	TLBSYNC			/* ... on all CPUs */
+
+	/* set up the PTE pointers for the Abatron bdiGDB.
+	*/
+	tovirt(r6,r6)
+	lis	r5, abatron_pteptrs@h
+	ori	r5, r5, abatron_pteptrs@l
+	stw	r5, 0xf0(r0)	/* Must match your Abatron config file */
+	tophys(r5,r5)
+	stw	r6, 0(r5)
+
 /* Now turn on the MMU for real! */
 	li	r4,MSR_KERNEL
 	lis	r3,start_kernel@h
 	ori	r3,r3,start_kernel@l
-#ifdef CONFIG_SMP
-	/* the second time through here we go to
-	 * start_secondary(). -- Cort
-	 */
-	lis	r5,first_cpu_booted@h
-	ori	r5,r5,first_cpu_booted@l
-	tophys(r5,r5)
-	lwz	r5,0(r5)
-	cmpi	0,r5,0
-	beq	10f
-	lis	r3,start_secondary@h
-	ori	r3,r3,start_secondary@l
-10:	
-#endif /* CONFIG_SMP */
 	mtspr	SRR0,r3
 	mtspr	SRR1,r4
 	rfi			/* enable MMU and jump to start_kernel */
 
+/* Set up the initial MMU state so we can do the first level of
+ * kernel initialization.  This maps the first 8 MBytes of memory 1:1
+ * virtual to physical.  Also, set the cache mode since that is defined
+ * by TLB entries and perform any additional mapping (like of the IMMR).
+ */
+initial_mmu:
+	tlbia			/* Invalidate all TLB entries */
+	li	r8, 0
+	mtspr	MI_CTR, r8	/* Set instruction control to zero */
+	lis	r8, MD_RESETVAL@h
+#ifndef CONFIG_8xx_COPYBACK
+	oris	r8, r8, MD_WTDEF@h
+#endif
+	mtspr	MD_CTR, r8	/* Set data TLB control */
+
+	/* Now map the lower 8 Meg into the TLBs.  For this quick hack,
+	 * we can load the instruction and data TLB registers with the
+	 * same values.
+	 */
+	lis	r8, KERNELBASE@h	/* Create vaddr for TLB */
+	ori	r8, r8, MI_EVALID	/* Mark it valid */
+	mtspr	MI_EPN, r8
+	mtspr	MD_EPN, r8
+	li	r8, MI_PS8MEG		/* Set 8M byte page */
+	ori	r8, r8, MI_SVALID	/* Make it valid */
+	mtspr	MI_TWC, r8
+	mtspr	MD_TWC, r8
+	li	r8, MI_BOOTINIT		/* Create RPN for address 0 */
+	mtspr	MI_RPN, r8		/* Store TLB entry */
+	mtspr	MD_RPN, r8
+	lis	r8, MI_Kp@h		/* Set the protection mode */
+	mtspr	MI_AP, r8
+	mtspr	MD_AP, r8
+
+	/* Map another 8 MByte at the IMMR to get the processor
+	 * internal registers (among other things).
+	 */
+	mfspr	r9, 638			/* Get current IMMR */
+	andis.	r9, r9, 0xff80		/* Get 8Mbyte boundary */
+
+	mr	r8, r9			/* Create vaddr for TLB */
+	ori	r8, r8, MD_EVALID	/* Mark it valid */
+	mtspr	MD_EPN, r8
+	li	r8, MD_PS8MEG		/* Set 8M byte page */
+	ori	r8, r8, MD_SVALID	/* Make it valid */
+	mtspr	MD_TWC, r8
+	mr	r8, r9			/* Create paddr for TLB */
+	ori	r8, r8, MI_BOOTINIT|0x2 /* Inhibit cache -- Cort */
+	mtspr	MD_RPN, r8
+
+	/* Since the cache is enabled according to the information we
+	 * just loaded into the TLB, invalidate and enable the caches here.
+	 * We should probably check/set other modes....later.
+	 */
+	lis	r8, IDC_INVALL@h
+	mtspr	IC_CST, r8
+	mtspr	DC_CST, r8
+	lis	r8, IDC_ENABLE@h
+	mtspr	IC_CST, r8
+#ifdef CONFIG_8xx_COPYBACK
+	mtspr	DC_CST, r8
+#else
+	/* For a debug option, I left this here to easily enable
+	 * the write through cache mode
+	 */
+	lis	r8, DC_SFWT@h
+	mtspr	DC_CST, r8
+	lis	r8, IDC_ENABLE@h
+	mtspr	DC_CST, r8
+#endif
+	blr
+
+
 /*
  * Set up to use a given MMU context.
+ * r3 is context number, r4 is PGD pointer.
  *
- * The MPC8xx has something that currently happens "automagically."
- * Unshared user space address translations are subject to ASID (context)
- * match.  During each task switch, the ASID is incremented.  We can
- * guarantee (I hope :-) that no entries currently match this ASID
- * because every task will cause at least a TLB entry to be loaded for
- * the first instruction and data access, plus the kernel running will
- * have displaced several more TLBs.  The MMU contains 32 entries for
- * each TLB, and there are 16 contexts, so we just need to make sure
- * two pages get replaced for every context switch, which currently
- * happens.  There are other TLB management techniques that I will
- * eventually implement, but this is the easiest for now.  -- Dan
- *
- * On the MPC8xx, we place the physical address of the new task
- * page directory loaded into the MMU base register, and set the
- * ASID compare register with the new "context".
+ * We place the physical address of the new task page directory loaded
+ * into the MMU base register, and set the ASID compare register with
+ * the new "context."
  */
 _GLOBAL(set_context)
-	/* fetch the pgd from the context_mm array */
-	lis	r5, context_mm@ha
-	slwi	r6, r3, 2
-	add	r5, r5, r6
-	lwz	r5, context_mm@l(r5)	/* get the mm */
-	lwz	r4, MM_PGD(r5)		/* get the pgd from the mm */
+
+#ifdef CONFIG_BDI_SWITCH
+	/* Context switch the PTE pointer for the Abatron BDI2000.
+	 * The PGDIR is passed as second argument.
+	 */
+	lis	r5, KERNELBASE@h
+	lwz	r5, 0xf0(r5)
+	stw	r4, 0x4(r5)
+#endif
+
 #ifdef CONFIG_8xx_CPU6
 	lis	r6, cpu6_errata_word@h
 	ori	r6, r6, cpu6_errata_word@l
@@ -967,7 +863,6 @@
 	tophys	(r4, r4)
 	mtspr	M_TWB, r4		/* and pgd */
 #endif
-        tlbia
 	SYNC
 	blr
 
@@ -1012,6 +907,12 @@
 	.globl	cmd_line
 cmd_line:
 	.space	512
+
+/* Room for two PTE table poiners, usually the kernel and current user
+ * pointer to their respective root page table (pgdir).
+ */
+abatron_pteptrs:
+	.space	8
 
 #ifdef CONFIG_8xx_CPU6
 	.globl	cpu6_errata_word
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/idle.c linux/arch/ppc/kernel/idle.c
--- v2.4.9/linux/arch/ppc/kernel/idle.c	Mon May 21 17:04:47 2001
+++ linux/arch/ppc/kernel/idle.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.idle.c 1.11 05/17/01 18:14:21 cort
+ * BK Id: SCCS/s.idle.c 1.14 08/15/01 22:43:06 paulus
  */
 /*
  * Idle daemon for PowerPC.  Idle daemon will handle any action
@@ -31,12 +31,11 @@
 #include <asm/processor.h>
 #include <asm/mmu.h>
 #include <asm/cache.h>
+#include <asm/cputable.h>
 
 void zero_paged(void);
 void power_save(void);
-void inline htab_reclaim(void);
 
-unsigned long htab_reclaim_on = 0;
 unsigned long zero_paged_on = 0;
 unsigned long powersave_nap = 0;
 
@@ -50,27 +49,30 @@
 {
 	int do_power_save = 0;
 
-	/* only sleep on the 603-family/750 processors */
-	switch (_get_PVR() >> 16) {
-	case 3:			/* 603 */
-	case 6:			/* 603e */
-	case 7:			/* 603ev */
-	case 8:			/* 750 */
-	case 12:		/* 7400 */
-	case 0x800c:		/* 7410 */
+	if (cur_cpu_spec[smp_processor_id()]->cpu_features & CPU_FTR_CAN_DOZE)
 		do_power_save = 1;
-	}
 
 	/* endless loop with no priority at all */
 	current->nice = 20;
 	current->counter = -100;
-	init_idle();	
-	for (;;)
-	{
-		/*if ( !current->need_resched && zero_paged_on )
-			zero_paged();*/
-		if (!current->need_resched && htab_reclaim_on)
-			htab_reclaim();
+	init_idle();
+	for (;;) {
+#ifdef CONFIG_SMP
+		int oldval;
+
+		if (!do_power_save) {
+			/*
+			 * Deal with another CPU just having chosen a thread to
+			 * run here:
+			 */
+			oldval = xchg(&current->need_resched, -1);
+
+			if (!oldval) {
+				while(current->need_resched == -1)
+					; /* Do Nothing */
+			}
+		}
+#endif
 		if (do_power_save && !current->need_resched)
 			power_save();
 
@@ -92,68 +94,6 @@
 	return 0; 
 }
 
-/*
- * Mark 'zombie' pte's in the hash table as invalid.
- * This improves performance for the hash table reload code
- * a bit since we don't consider unused pages as valid.
- *  -- Cort
- */
-PTE *reclaim_ptr = 0;
-void inline htab_reclaim(void)
-{
-#ifndef CONFIG_8xx		
-#if 0	
-	PTE *ptr, *start;
-	static int dir = 1;
-#endif	
-	struct task_struct *p;
-	unsigned long valid = 0;
-	extern PTE *Hash, *Hash_end;
-	extern unsigned long Hash_size;
-
-	/* if we don't have a htab */
-	if ( Hash_size == 0 )
-		return;
-#if 0	
-	/* find a random place in the htab to start each time */
-	start = &Hash[jiffies%(Hash_size/sizeof(PTE))];
-	/* go a different direction each time */
-	dir *= -1;
-        for ( ptr = start;
-	      !current->need_resched && (ptr != Hash_end) && (ptr != Hash);
-	      ptr += dir)
-	{
-#else
-	if ( !reclaim_ptr ) reclaim_ptr = Hash;
-	while ( !current->need_resched )
-	{
-		reclaim_ptr++;
-		if ( reclaim_ptr == Hash_end ) reclaim_ptr = Hash;
-#endif	  
-		if (!reclaim_ptr->v)
-			continue;
-		valid = 0;
-		for_each_task(p)
-		{
-			if ( current->need_resched )
-				goto out;
-			/* if this vsid/context is in use */
-			if ( (reclaim_ptr->vsid >> 4) == p->mm->context )
-			{
-				valid = 1;
-				break;
-			}
-		}
-		if ( valid )
-			continue;
-		/* this pte isn't used */
-		reclaim_ptr->v = 0;
-	}
-out:
-	if ( current->need_resched ) printk("need_resched: %lx\n", current->need_resched);
-#endif /* CONFIG_8xx */
-}
-
 #if 0
 /*
  * Returns a pre-zero'd page from the list otherwise returns
@@ -287,7 +227,7 @@
 		atomic_inc((atomic_t *)&zero_cache_total);
 	}
 }
-#endif
+#endif /* 0 */
 
 void power_save(void)
 {
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/indirect_pci.c linux/arch/ppc/kernel/indirect_pci.c
--- v2.4.9/linux/arch/ppc/kernel/indirect_pci.c	Mon May 21 17:04:47 2001
+++ linux/arch/ppc/kernel/indirect_pci.c	Sat Sep  8 12:38:41 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.indirect_pci.c 1.7 05/17/01 18:14:21 cort
+ * BK Id: SCCS/s.indirect_pci.c 1.10 09/08/01 15:47:42 paulus
  */
 /*
  * Support for indirect PCI bridges.
@@ -19,7 +19,6 @@
 #include <linux/init.h>
 #include <linux/bootmem.h>
 
-#include <asm/init.h>
 #include <asm/io.h>
 #include <asm/prom.h>
 #include <asm/pci-bridge.h>
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/irq.c linux/arch/ppc/kernel/irq.c
--- v2.4.9/linux/arch/ppc/kernel/irq.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/ppc/kernel/irq.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.irq.c 1.30 07/19/01 16:51:32 paulus
+ * BK Id: SCCS/s.irq.c 1.32 08/24/01 20:07:37 paulus
  */
 /*
  *  arch/ppc/kernel/irq.c
@@ -93,6 +93,11 @@
 static struct irqaction malloc_cache[IRQ_KMALLOC_ENTRIES];
 extern int mem_init_done;
 
+#if defined(CONFIG_TAU_INT)
+extern int tau_interrupts(unsigned long cpu);
+extern int tau_initialized;
+#endif
+
 void *irq_kmalloc(size_t size, int pri)
 {
 	unsigned int i;
@@ -402,12 +407,14 @@
 		}
 		len += sprintf(buf+len, "\n");
 	}
-#ifdef CONFIG_TAU
-	len += sprintf(buf+len, "TAU: ");
-	for (j = 0; j < smp_num_cpus; j++)
-		len += sprintf(buf+len, "%10u ",
-				tau_interrupts(j));
-	len += sprintf(buf+len, "\n");
+#ifdef CONFIG_TAU_INT
+	if (tau_initialized){
+		len += sprintf(buf+len, "TAU: ");
+		for (j = 0; j < smp_num_cpus; j++)
+			len += sprintf(buf+len, "%10u ",
+					tau_interrupts(j));
+		len += sprintf(buf+len, "  PowerPC             Thermal Assist (cpu temp)\n");
+	}
 #endif
 #ifdef CONFIG_SMP
 	/* should this be per processor send/receive? */
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/l2cr.S linux/arch/ppc/kernel/l2cr.S
--- v2.4.9/linux/arch/ppc/kernel/l2cr.S	Wed Dec 31 16:00:00 1969
+++ linux/arch/ppc/kernel/l2cr.S	Tue Aug 28 06:58:33 2001
@@ -0,0 +1,201 @@
+/*
+	L2CR functions
+	Copyright © 1997-1998 by PowerLogix R & D, Inc.
+	
+	This program is free software; you can redistribute it and/or modify
+	it under the terms of the GNU General Public License as published by
+	the Free Software Foundation; either version 2 of the License, or
+	(at your option) any later version.
+	
+	This 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.
+*/
+/*
+	Thur, Dec. 12, 1998.
+	- First public release, contributed by PowerLogix.
+	***********
+	Sat, Aug. 7, 1999.
+	- Terry: Made sure code disabled interrupts before running. (Previously
+			it was assumed interrupts were already disabled).
+	- Terry: Updated for tentative G4 support.  4MB of memory is now flushed
+			instead of 2MB.  (Prob. only 3 is necessary).
+	- Terry: Updated for workaround to HID0[DPM] processor bug
+			during global invalidates.
+	***********
+	Thu, July 13, 2000.
+	- Terry: Added isync to correct for an errata.
+	
+	Author:	Terry Greeniaus (tgree@phys.ualberta.ca)
+	Please e-mail updates to this file to me, thanks!
+*/
+#include <asm/processor.h>
+#include <asm/cputable.h>
+#include "ppc_asm.h"
+
+/* Usage:
+	
+	When setting the L2CR register, you must do a few special
+	things.  If you are enabling the cache, you must perform a
+	global invalidate.  If you are disabling the cache, you must
+	flush the cache contents first.  This routine takes care of
+	doing these things.  When first enabling the cache, make sure
+	you pass in the L2CR you want, as well as passing in the
+	global invalidate bit set.  A global invalidate will only be
+	performed if the L2I bit is set in applyThis.  When enabling
+	the cache, you should also set the L2E bit in applyThis.  If
+	you want to modify the L2CR contents after the cache has been
+	enabled, the recommended procedure is to first call
+	__setL2CR(0) to disable the cache and then call it again with
+	the new values for L2CR.  Examples:
+
+	_setL2CR(0)		- disables the cache
+	_setL2CR(0xB3A04000)	- enables my G3 upgrade card:
+				- L2E set to turn on the cache
+				- L2SIZ set to 1MB
+				- L2CLK set to 1:1
+				- L2RAM set to pipelined synchronous late-write
+				- L2I set to perform a global invalidation
+				- L2OH set to 0.5 nS
+				- L2DF set because this upgrade card
+				  requires it
+
+	A similar call should work for your card.  You need to know
+	the correct setting for your card and then place them in the
+	fields I have outlined above.  Other fields support optional
+	features, such as L2DO which caches only data, or L2TS which
+	causes cache pushes from the L1 cache to go to the L2 cache
+	instead of to main memory.
+*/
+/*
+ * Summary: this procedure ignores the L2I bit in the value passed in,
+ * flushes the cache if it was already enabled, always invalidates the
+ * cache, then enables the cache if the L2E bit is set in the value
+ * passed in.
+ *   -- paulus.
+ */
+_GLOBAL(_set_L2CR)
+	/* Make sure this is a 750 or 7400 chip */
+BEGIN_FTR_SECTION
+	li	r3,-1
+	blr
+END_FTR_SECTION_IFCLR(CPU_FTR_L2CR)
+
+	/* Turn off interrupts and data relocation. */
+	mfmsr	r7		/* Save MSR in r7 */
+	rlwinm	r4,r7,0,17,15
+	rlwinm	r4,r4,0,28,26	/* Turn off DR bit */
+	sync
+	mtmsr	r4
+	isync
+
+	/* Get the current enable bit of the L2CR into r4 */
+	mfspr	r4,L2CR
+	
+	/* Tweak some bits */
+	rlwinm	r5,r3,0,0,0		/* r5 contains the new enable bit */
+	rlwinm	r3,r3,0,11,9		/* Turn off the invalidate bit */
+	rlwinm	r3,r3,0,1,31		/* Turn off the enable bit */
+
+	/* Check to see if we need to flush */
+	rlwinm.	r4,r4,0,0,0
+	beq	2f
+
+	/* Flush the cache. First, read the first 4MB of memory (physical) to
+	 * put new data in the cache.  (Actually we only need
+	 * the size of the L2 cache plus the size of the L1 cache, but 4MB will
+	 * cover everything just to be safe).
+	 */
+		
+	 /**** Might be a good idea to set L2DO here - to prevent instructions
+	       from getting into the cache.  But since we invalidate
+	       the next time we enable the cache it doesn't really matter.
+	  ****/
+
+	lis	r4,0x0002
+	mtctr	r4
+	li	r4,0
+1:
+	lwzx	r0,r0,r4
+	addi	r4,r4,32		/* Go to start of next cache line */
+	bdnz	1b
+	
+	/* Now, flush the first 4MB of memory */
+	lis	r4,0x0002
+	mtctr	r4
+	li	r4,0
+	sync
+1:
+	dcbf	r0,r4
+	addi	r4,r4,32		/* Go to start of next cache line */
+	bdnz	1b
+
+2:
+	/* Set up the L2CR configuration bits (and switch L2 off) */
+	sync
+	mtspr	L2CR,r3
+	sync
+
+	/* Before we perform the global invalidation, we must disable dynamic
+	 * power management via HID0[DPM] to work around a processor bug where
+	 * DPM can possibly interfere with the state machine in the processor
+	 * that invalidates the L2 cache tags.
+	 */
+	mfspr	r8,HID0			/* Save HID0 in r8 */
+	rlwinm	r4,r8,0,12,10		/* Turn off HID0[DPM] */
+	sync
+	mtspr	HID0,r4			/* Disable DPM */
+	sync
+
+	/* Perform a global invalidation */
+	oris	r3,r3,0x0020
+	sync
+	mtspr	L2CR,r3
+	sync
+	isync				/* For errata */
+
+	/* Wait for the invalidation to complete */
+3:	mfspr	r3,L2CR
+	rlwinm.	r4,r3,0,31,31
+	bne	3b
+	
+	rlwinm	r3,r3,0,11,9		/* Turn off the L2I bit */
+	sync
+	mtspr	L2CR,r3
+	sync
+	
+	/* Restore HID0[DPM] to whatever it was before */
+	sync
+	mtspr	1008,r8
+	sync
+
+	/* See if we need to enable the cache */
+	cmplwi	r5,0
+	beq	4f
+
+	/* Enable the cache */
+	oris	r3,r3,0x8000
+	mtspr	L2CR,r3
+	sync
+
+	/* Restore MSR (restores EE and DR bits to original state) */
+4:	SYNC
+	mtmsr	r7
+	isync
+	blr
+
+_GLOBAL(_get_L2CR)
+	/* Return the L2CR contents */
+	li	r3,0
+BEGIN_FTR_SECTION
+	mfspr	r3,L2CR
+END_FTR_SECTION_IFSET(CPU_FTR_L2CR)
+	blr
+
+/* --- End of PowerLogix code ---
+ */
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/m8260_setup.c linux/arch/ppc/kernel/m8260_setup.c
--- v2.4.9/linux/arch/ppc/kernel/m8260_setup.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/ppc/kernel/m8260_setup.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.m8260_setup.c 1.20 07/18/01 22:56:39 paulus
+ * BK Id: SCCS/s.m8260_setup.c 1.24 08/20/01 15:25:16 paulus
  */
 /*
  *  linux/arch/ppc/kernel/setup.c
@@ -52,17 +52,6 @@
 unsigned long m8260_get_rtc_time(void);
 void m8260_calibrate_decr(void);
 
-#if 0
-extern int mackbd_setkeycode(unsigned int scancode, unsigned int keycode);
-extern int mackbd_getkeycode(unsigned int scancode);
-extern int mackbd_pretranslate(unsigned char scancode, char raw_mode);
-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);
-#endif
-
 extern unsigned long loops_per_jiffy;
 
 unsigned char __res[sizeof(bd_t)];
@@ -72,10 +61,6 @@
 extern unsigned long find_available_memory(void);
 extern void m8260_cpm_reset(void);
 
-void __init adbdev_init(void)
-{
-}
-
 void __init
 m8260_setup_arch(void)
 {
@@ -102,7 +87,7 @@
 	bd_t	*binfo = (bd_t *)__res;
 	int freq, divisor;
 
-	freq = (binfo->bi_busfreq * 1000000);
+	freq = binfo->bi_busfreq;
         divisor = 4;
         tb_ticks_per_jiffy = freq / HZ / divisor;
 	tb_to_us = mulhwu_scale_factor(freq / divisor, 1000000);
@@ -111,7 +96,8 @@
 /* The 8260 has an internal 1-second timer update register that
  * we should use for this purpose.
  */
-static uint	rtc_time;
+static uint rtc_time;
+
 static int
 m8260_set_rtc_time(unsigned long time)
 {
@@ -145,7 +131,7 @@
 			startaddr = simple_strtoul(&cmd[10], NULL, 0);
 	}
 
-	m8260_gorom((uint)__pa(__res), startaddr);
+	m8260_gorom((unsigned int)__pa(__res), startaddr);
 }
 
 void
@@ -171,9 +157,9 @@
 	len += sprintf(len+buffer,"core clock\t: %d MHz\n"
 		       "CPM  clock\t: %d MHz\n"
 		       "bus  clock\t: %d MHz\n",
-		       bp->bi_intfreq /*/ 1000000*/,
-		       bp->bi_cpmfreq /*/ 1000000*/,
-		       bp->bi_busfreq /*/ 1000000*/);
+		       bp->bi_intfreq / 1000000,
+		       bp->bi_cpmfreq / 1000000,
+		       bp->bi_busfreq / 1000000);
 
 	return len;
 }
@@ -219,9 +205,21 @@
 	return binfo->bi_memsize;
 }
 
+/* Map the IMMR, plus anything else we can cover
+ * in that upper space according to the memory controller
+ * chip select mapping.  Grab another bunch of space
+ * below that for stuff we can't cover in the upper.
+ */
+static void __init
+m8260_map_io(void)
+{
+	io_block_mapping(0xf0000000, 0xf0000000, 0x10000000, _PAGE_IO);
+	io_block_mapping(0xe0000000, 0xe0000000, 0x10000000, _PAGE_IO);
+}
+
 void __init
-m8260_init(unsigned long r3, unsigned long r4, unsigned long r5,
-	 unsigned long r6, unsigned long r7)
+platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+	      unsigned long r6, unsigned long r7)
 {
 
 	if ( r3 )
@@ -261,6 +259,7 @@
 	ppc_md.calibrate_decr = m8260_calibrate_decr;
 
 	ppc_md.find_end_of_memory = m8260_find_end_of_memory;
+	ppc_md.setup_io_mappings = m8260_map_io;
 
 	ppc_md.kbd_setkeycode    = NULL;
 	ppc_md.kbd_getkeycode    = NULL;
@@ -273,51 +272,11 @@
 #endif
 
 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
-        ppc_ide_md.insw = m8xx_ide_insw;
-        ppc_ide_md.outsw = m8xx_ide_outsw;
         ppc_ide_md.default_irq = m8xx_ide_default_irq;
         ppc_ide_md.default_io_base = m8xx_ide_default_io_base;
-        ppc_ide_md.fix_driveid = ppc_generic_ide_fix_driveid;
         ppc_ide_md.ide_init_hwif = m8xx_ide_init_hwif_ports;
         ppc_ide_md.ide_request_irq = m8xx_ide_request_irq;
-
-        ppc_ide_md.io_base = _IO_BASE;
 #endif		
-}
-
-/*
- * Copied from prom.c so I don't have include all of that crap.
- *				-- Dan
- *
- * prom_init() is called very early on, before the kernel text
- * and data have been mapped to KERNELBASE.  At this point the code
- * is running at whatever address it has been loaded at, so
- * references to extern and static variables must be relocated
- * explicitly.  The procedure reloc_offset() returns the address
- * we're currently running at minus the address we were linked at.
- * (Note that strings count as static variables.)
- */
-extern unsigned long reloc_offset(void);
-#define PTRRELOC(x)	((typeof(x))((unsigned long)(x) + offset))
-
-__init
-unsigned long
-prom_init(uint r3, uint r4, uint r5, uint r6)
-{
-	unsigned long offset = reloc_offset();
- 	unsigned long phys;
-	extern char __bss_start, _end;
-
-	/* First zero the BSS -- use memset, some arches don't have
-	 * caches on yet */
-	memset_io(PTRRELOC(&__bss_start),0 , &_end - &__bss_start);
-
- 	/* Default */
- 	phys = offset + KERNELBASE;
-
-	/* We are done.
-	*/
-	return phys;
 }
 
 /* Mainly for ksyms.
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/m8xx_setup.c linux/arch/ppc/kernel/m8xx_setup.c
--- v2.4.9/linux/arch/ppc/kernel/m8xx_setup.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/ppc/kernel/m8xx_setup.c	Sat Sep  8 12:39:33 2001
@@ -1,7 +1,6 @@
 /*
- * BK Id: SCCS/s.m8xx_setup.c 1.23 07/18/01 22:56:39 paulus
- */
-/*
+ * BK Id: SCCS/s.m8xx_setup.c 1.29 08/30/01 09:01:04 trini
+ *
  *  linux/arch/ppc/kernel/setup.c
  *
  *  Copyright (C) 1995  Linus Torvalds
@@ -172,8 +171,7 @@
 	machine_restart(NULL);
 }
 
-/* A place holder for time base interrupts, if they are ever enabled.
-*/
+/* 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");
@@ -188,13 +186,11 @@
 	bd_t	*binfo = (bd_t *)__res;
 	int freq, fp, divisor;
 
-	/* Unlock the SCCR.
-	*/
+	/* Unlock the SCCR. */
 	((volatile immap_t *)IMAP_ADDR)->im_clkrstk.cark_sccrk = ~KAPWR_KEY;
 	((volatile immap_t *)IMAP_ADDR)->im_clkrstk.cark_sccrk = KAPWR_KEY;
 
-	/* Force all 8xx processors to use divide by 16 processor clock.
-	*/
+	/* Force all 8xx processors to use divide by 16 processor clock. */
 	((volatile immap_t *)IMAP_ADDR)->im_clkrst.car_sccr |= 0x02000000;
 
 	/* Processor frequency is MHz.
@@ -224,15 +220,17 @@
 	 */
 	((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_tbscrk = ~KAPWR_KEY;
 	((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_rtcsck = ~KAPWR_KEY;
-	((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_tbk = ~KAPWR_KEY;
+	((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_tbk    = ~KAPWR_KEY;
 	((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_tbscrk = KAPWR_KEY;
 	((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_rtcsck = KAPWR_KEY;
-	((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_tbk = KAPWR_KEY;
+	((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_tbk    = KAPWR_KEY;
 
-	/* Disable the RTC one second and alarm interrupts.
-	*/
+	/* Disable the RTC one second and alarm interrupts. */
 	((volatile immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc &=
 						~(RTCSC_SIE | RTCSC_ALE);
+	/* Enable the RTC */
+	((volatile immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc |=
+						(RTCSC_RTF | RTCSC_RTE);
 
 	/* Enabling the decrementer also enables the timebase interrupts
 	 * (or from the other point of view, to get decrementer interrupts
@@ -260,15 +258,14 @@
 	return(0);
 }
 
-unsigned long
+static unsigned long
 m8xx_get_rtc_time(void)
 {
-	/* Get time from the RTC.
-	*/
+	/* Get time from the RTC. */
 	return((unsigned long)(((immap_t *)IMAP_ADDR)->im_sit.sit_rtc));
 }
 
-void
+static void
 m8xx_restart(char *cmd)
 {
 	__volatile__ unsigned char dummy;
@@ -288,20 +285,21 @@
 	while(1);
 }
 
-void
+static void
 m8xx_power_off(void)
 {
    m8xx_restart(NULL);
 }
 
-void
+static void
 m8xx_halt(void)
 {
    m8xx_restart(NULL);
 }
 
 
-int m8xx_setup_residual(char *buffer)
+static int
+m8xx_setup_residual(char *buffer)
 {
         int     len = 0;
 	bd_t	*bp;
@@ -322,7 +320,7 @@
  * External interrupts can be either edge or level triggered, and
  * need to be initialized by the appropriate driver.
  */
-void __init
+static void __init
 m8xx_init_IRQ(void)
 {
 	int i;
@@ -353,32 +351,12 @@
  * IDE stuff.
  */
 #ifdef CONFIG_BLK_DEV_MPC8xx_IDE
-void ide_interrupt_handler (void *dev)
+static void ide_interrupt_handler (void *dev)
 {
 }
 #endif
 
-void
-m8xx_ide_insw(ide_ioreg_t port, void *buf, int ns)
-{
-#ifdef CONFIG_BLK_DEV_MPC8xx_IDE
-	ide_insw(port, buf, ns);
-#else
-	_insw_ns((unsigned short *)(port+_IO_BASE), buf, ns);
-#endif
-}
-
-void
-m8xx_ide_outsw(ide_ioreg_t port, void *buf, int ns)
-{
-#ifdef CONFIG_BLK_DEV_MPC8xx_IDE
-	ide_outsw(port, buf, ns);
-#else
-	_outsw_ns((unsigned short *)(port+_IO_BASE), buf, ns);
-#endif
-}
-
-int
+static int
 m8xx_ide_default_irq(ide_ioreg_t base)
 {
 #ifdef CONFIG_BLK_DEV_MPC8xx_IDE
@@ -391,13 +369,13 @@
 #endif
 }
 
-ide_ioreg_t
+static ide_ioreg_t
 m8xx_ide_default_io_base(int index)
 {
         return index;
 }
 
-int
+static int
 m8xx_ide_request_irq(unsigned int irq,
 		       void (*handler)(int, void *, struct pt_regs *),
 		       unsigned long flags, 
@@ -412,8 +390,9 @@
  *
  * See include/linux/ide.h for definition of hw_regs_t (p, base)
  */
-void m8xx_ide_init_hwif_ports(hw_regs_t *hw,
-	ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq)
+static void
+m8xx_ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, 
+		ide_ioreg_t ctrl_port, int *irq)
 {
 	int i;
 #ifdef CONFIG_BLK_DEV_MPC8xx_IDE
@@ -479,7 +458,7 @@
 # endif	/* CONFIG_SPD823TS, CONFIG_IVMS8 */
 
 	for (i = 0; i < IDE_NR_PORTS; ++i) {
-	 	*p++ = base + ioport_dsc[data_port].reg_off[i];
+		*p++ = base + ioport_dsc[data_port].reg_off[i] - _IO_BASE;
 	}
 
 	if (irq) {
@@ -585,7 +564,8 @@
  * functions in the image just to get prom_init, all we really need right
  * now is the initialization of the physical memory region.
  */
-unsigned long __init m8xx_find_end_of_memory(void)
+static unsigned long __init
+m8xx_find_end_of_memory(void)
 {
 	bd_t	*binfo;
 	extern unsigned char __res[];
@@ -595,11 +575,47 @@
 	return binfo->bi_memsize;
 }
 
-void __init
-m8xx_init(unsigned long r3, unsigned long r4, unsigned long r5,
-	 unsigned long r6, unsigned long r7)
+/*
+ * Now map in some of the I/O space that is generically needed
+ * or shared with multiple devices.
+ * All of this fits into the same 4Mbyte region, so it only
+ * requires one page table page.  (or at least it used to  -- paulus)
+ */
+static void __init
+m8xx_map_io(void)
 {
+        io_block_mapping(IMAP_ADDR, IMAP_ADDR, IMAP_SIZE, _PAGE_IO);
+#ifdef CONFIG_MBX
+        io_block_mapping(NVRAM_ADDR, NVRAM_ADDR, NVRAM_SIZE, _PAGE_IO);
+        io_block_mapping(MBX_CSR_ADDR, MBX_CSR_ADDR, MBX_CSR_SIZE, _PAGE_IO);
+        io_block_mapping(PCI_CSR_ADDR, PCI_CSR_ADDR, PCI_CSR_SIZE, _PAGE_IO);
+
+	/* Map some of the PCI/ISA I/O space to get the IDE interface.
+	*/
+        io_block_mapping(PCI_ISA_IO_ADDR, PCI_ISA_IO_ADDR, 0x4000, _PAGE_IO);
+        io_block_mapping(PCI_IDE_ADDR, PCI_IDE_ADDR, 0x4000, _PAGE_IO);
+#endif
+#if defined(CONFIG_RPXLITE) || defined(CONFIG_RPXCLASSIC)
+	io_block_mapping(RPX_CSR_ADDR, RPX_CSR_ADDR, RPX_CSR_SIZE, _PAGE_IO);
+#if !defined(CONFIG_PCI)
+	io_block_mapping(_IO_BASE,_IO_BASE,_IO_BASE_SIZE, _PAGE_IO);
+#endif
+#endif
+#ifdef CONFIG_HTDMSOUND
+	io_block_mapping(HIOX_CSR_ADDR, HIOX_CSR_ADDR, HIOX_CSR_SIZE, _PAGE_IO);
+#endif
+#ifdef CONFIG_FADS
+	io_block_mapping(BCSR_ADDR, BCSR_ADDR, BCSR_SIZE, _PAGE_IO);
+#endif
+#ifdef CONFIG_PCI
+        io_block_mapping(PCI_CSR_ADDR, PCI_CSR_ADDR, PCI_CSR_SIZE, _PAGE_IO);
+#endif
+}
 
+void __init
+platform_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) );
 	
@@ -617,8 +633,7 @@
 #endif /* CONFIG_BLK_DEV_INITRD */
 	/* take care of cmd line */
 	if ( r6 )
-	{
-		
+	{	
 		*(char *)(r7+KERNELBASE) = 0;
 		strcpy(cmd_line, (char *)(r6+KERNELBASE));
 	}
@@ -641,6 +656,7 @@
 	ppc_md.calibrate_decr = m8xx_calibrate_decr;
 
 	ppc_md.find_end_of_memory = m8xx_find_end_of_memory;
+	ppc_md.setup_io_mappings = m8xx_map_io;
 
 	ppc_md.kbd_setkeycode    = NULL;
 	ppc_md.kbd_getkeycode    = NULL;
@@ -653,13 +669,8 @@
 #endif
 
 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
-        ppc_ide_md.insw = m8xx_ide_insw;
-        ppc_ide_md.outsw = m8xx_ide_outsw;
         ppc_ide_md.default_irq = m8xx_ide_default_irq;
         ppc_ide_md.default_io_base = m8xx_ide_default_io_base;
-        ppc_ide_md.fix_driveid = ppc_generic_ide_fix_driveid;
         ppc_ide_md.ide_init_hwif = m8xx_ide_init_hwif_ports;
-
-        ppc_ide_md.io_base = _IO_BASE;
 #endif		
 }
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/misc.S linux/arch/ppc/kernel/misc.S
--- v2.4.9/linux/arch/ppc/kernel/misc.S	Sun Aug 12 13:27:58 2001
+++ linux/arch/ppc/kernel/misc.S	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.misc.S 1.21 07/07/01 17:00:08 paulus
+ * BK Id: SCCS/s.misc.S 1.28 08/24/01 20:07:37 paulus
  */
 /*
  * This file contains miscellaneous low-level functions.
@@ -22,6 +22,7 @@
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/cache.h>
+#include <asm/cputable.h>
 #include "ppc_asm.h"
 
 	.text
@@ -49,6 +50,97 @@
 	mtlr	r0
 	blr
 
+/*
+ * identify_cpu,
+ * called with r3 = data offset and r4 = CPU number
+ * doesn't change r3
+ */
+_GLOBAL(identify_cpu)
+	addis	r8,r3,cpu_specs@ha
+	addi	r8,r8,cpu_specs@l
+	mfpvr	r7
+1:
+	lwz	r5,CPU_SPEC_PVR_MASK(r8)
+	and	r5,r5,r7
+	lwz	r6,CPU_SPEC_PVR_VALUE(r8)
+	cmplw	0,r6,r5
+	beq	1f
+	addi	r8,r8,CPU_SPEC_ENTRY_SIZE
+	b	1b
+1:
+	addis	r6,r3,cur_cpu_spec@ha
+	addi	r6,r6,cur_cpu_spec@l
+	slwi	r4,r4,2
+	sub	r8,r8,r3
+	stwx	r8,r4,r6
+	blr
+
+/*
+ * do_cpu_ftr_fixups - goes through the list of CPU feature fixups
+ * and writes nop's over sections of code that don't apply for this cpu.
+ * r3 = data offset (not changed)
+ */
+_GLOBAL(do_cpu_ftr_fixups)
+	/* Get CPU 0 features */
+	addis	r6,r3,cur_cpu_spec@ha
+	addi	r6,r6,cur_cpu_spec@l
+	lwz	r4,0(r6)
+	add	r4,r4,r3
+	lwz	r4,CPU_SPEC_FEATURES(r4)
+
+	/* Get the fixup table */
+	addis	r6,r3,__start___ftr_fixup@ha
+	addi	r6,r6,__start___ftr_fixup@l
+	addis	r7,r3,__stop___ftr_fixup@ha
+	addi	r7,r7,__stop___ftr_fixup@l
+
+	/* Do the fixup */
+1:	cmplw	0,r6,r7
+	bgelr
+	addi	r6,r6,16
+	lwz	r8,-16(r6)	/* mask */
+	and	r8,r8,r4
+	lwz	r9,-12(r6)	/* value */
+	cmplw	0,r8,r9
+	beq	1b
+	lwz	r8,-8(r6)	/* section begin */
+	lwz	r9,-4(r6)	/* section end */
+	subf.	r9,r8,r9
+	beq	1b
+	/* write nops over the section of code */
+	/* todo: if large section, add a branch at the start of it */
+	srwi	r9,r9,2
+	mtctr	r9
+	add	r8,r8,r3
+	lis	r0,0x60000000@h	/* nop */
+3:	stw	r0,0(r8)
+	andi.	r10,r4,CPU_FTR_SPLIT_ID_CACHE@l
+	beq	2f
+	dcbst	0,r8		/* suboptimal, but simpler */
+	sync
+	icbi	0,r8
+2:	addi	r8,r8,4
+	bdnz	3b
+	sync			/* additional sync needed on g4 */
+	isync
+	b	1b
+
+/*
+ * call_setup_cpu - call the setup_cpu function for this cpu
+ * r3 = data offset, r24 = cpu number
+ */
+_GLOBAL(call_setup_cpu)
+	addis	r5,r3,cur_cpu_spec@ha
+	addi	r5,r5,cur_cpu_spec@l
+	slwi	r4,r24,2
+	lwzx	r5,r4,r5
+	add	r5,r5,r3
+	lwz	r6,CPU_SPEC_SETUP(r5)
+	add	r6,r6,r3
+	mtctr	r6
+	mr	r3,r24
+	bctr
+
 /* void __save_flags_ptr(unsigned long *flags) */
 _GLOBAL(__save_flags_ptr)
 	mfmsr	r4
@@ -185,7 +277,7 @@
 _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) */
+	or	r0,r0,r4	/* Or on the bits in r4 (second parm) */
 	SYNC			/* Some chip revs have problems here... */
 	mtmsr	r0		/* Update machine state */
 	isync
@@ -216,8 +308,7 @@
 	tlbia
 	sync
 #ifdef CONFIG_SMP
-	tlbsync
-	sync
+	TLBSYNC
 	li	r0,0
 	stw	r0,0(r9)		/* clear hash_table_lock */
 	mtmsr	r10
@@ -249,8 +340,7 @@
 	tlbie	r3
 	sync
 #ifdef CONFIG_SMP
-	tlbsync
-	sync
+	TLBSYNC
 	li	r0,0
 	stw	r0,0(r9)		/* clear hash_table_lock */
 	mtmsr	r10
@@ -314,26 +404,70 @@
 	sync				/* additional sync needed on g4 */
 	isync
 	blr
+/*
+ * Write any modified data cache blocks out to memory.
+ * Does not invalidate the corresponding cache lines (especially for
+ * any corresponding instruction cache).
+ *
+ * clean_dcache_range(unsigned long start, unsigned long stop)
+ */
+_GLOBAL(clean_dcache_range)
+	li	r5,CACHE_LINE_SIZE-1
+	andc	r3,r3,r5
+	subf	r4,r3,r4
+	add	r4,r4,r5
+	srwi.	r4,r4,LG_CACHE_LINE_SIZE
+	beqlr
+	mtctr	r4
+
+1:	dcbst	0,r3
+	addi	r3,r3,CACHE_LINE_SIZE
+	bdnz	1b
+	sync				/* wait for dcbst's to get to ram */
+	blr
 
 /*
- * Like above, but only do the D-cache.
+ * Write any modified data cache blocks out to memory
+ * and invalidate the corresponding instruction cache blocks.
  *
  * flush_dcache_range(unsigned long start, unsigned long stop)
  */
 _GLOBAL(flush_dcache_range)
-       li      r5,CACHE_LINE_SIZE-1
-       andc    r3,r3,r5
-       subf    r4,r3,r4
-       add     r4,r4,r5
-       srwi.   r4,r4,LG_CACHE_LINE_SIZE
-       beqlr
-       mtctr   r4
-
-1:     dcbst   0,r3
-       addi    r3,r3,CACHE_LINE_SIZE
-       bdnz    1b
-       sync                            /* wait for dcbst's to get to ram */
-       blr
+	li	r5,CACHE_LINE_SIZE-1
+	andc	r3,r3,r5
+	subf	r4,r3,r4
+	add	r4,r4,r5
+	srwi.	r4,r4,LG_CACHE_LINE_SIZE
+	beqlr
+	mtctr	r4
+
+1:	dcbf	0,r3
+	addi	r3,r3,CACHE_LINE_SIZE
+	bdnz	1b
+	sync				/* wait for dcbst's to get to ram */
+	blr
+
+/*
+ * Like above, but invalidate the D-cache.  This is used by the 8xx
+ * to invalidate the cache so the PPC core doesn't get stale data
+ * from the CPM (no cache snooping here :-).
+ *
+ * invalidate_dcache_range(unsigned long start, unsigned long stop)
+ */
+_GLOBAL(invalidate_dcache_range)
+	li	r5,CACHE_LINE_SIZE-1
+	andc	r3,r3,r5
+	subf	r4,r3,r4
+	add	r4,r4,r5
+	srwi.	r4,r4,LG_CACHE_LINE_SIZE
+	beqlr
+	mtctr	r4
+
+1:	dcbi	0,r3
+	addi	r3,r3,CACHE_LINE_SIZE
+	bdnz	1b
+	sync				/* wait for dcbi's to get to ram */
+	blr
 
 /*
  * Flush a particular page from the data cache to RAM.
@@ -481,94 +615,9 @@
 	blr
 
 /*
- * Try to acquire a spinlock.
- * Only does the stwcx. if the load returned 0 - the Programming
- * Environments Manual suggests not doing unnecessary stcwx.'s
- * since they may inhibit forward progress by other CPUs in getting
- * a lock.
- */
-_GLOBAL(__spin_trylock)
-	mr	r4,r3
-	eieio			/* prevent reordering of stores */
-	li	r5,-1
-	lwarx	r3,0,r4		/* fetch old value, establish reservation */
-	cmpwi	0,r3,0		/* is it 0? */
-	bnelr-			/* return failure if not */
-	stwcx.	r5,0,r4		/* try to update with new value */
-	bne-	1f		/* if we failed */
-	eieio			/* prevent reordering of stores */
-	blr
-1:	li	r3,1		/* return non-zero for failure */
-	blr
-
-/*
- * Atomic add/sub/inc/dec operations
- *
- * void atomic_add(int c, int *v)
- * void atomic_sub(int c, int *v)
- * void atomic_inc(int *v)
- * void atomic_dec(int *v)
- * int atomic_dec_and_test(int *v)
- * int atomic_inc_return(int *v)
- * int atomic_dec_return(int *v)
  * void atomic_clear_mask(atomic_t mask, atomic_t *addr)
  * void atomic_set_mask(atomic_t mask, atomic_t *addr);
  */
-#if 0 /* now inline - paulus */
-_GLOBAL(atomic_add)
-10:	lwarx	r5,0,r4		/* Fetch old value & reserve */
-	add	r5,r5,r3	/* Perform 'add' operation */
-	stwcx.	r5,0,r4		/* Update with new value */
-	bne-	10b		/* Retry if "reservation" (i.e. lock) lost */
-	blr
-_GLOBAL(atomic_add_return)
-10:	lwarx	r5,0,r4		/* Fetch old value & reserve */
-	add	r5,r5,r3	/* Perform 'add' operation */
-	stwcx.	r5,0,r4		/* Update with new value */
-	bne-	10b		/* Retry if "reservation" (i.e. lock) lost */
-	mr	r3,r5
-	blr
-_GLOBAL(atomic_sub)
-10:	lwarx	r5,0,r4		/* Fetch old value & reserve */
-	sub	r5,r5,r3	/* Perform 'add' operation */
-	stwcx.	r5,0,r4		/* Update with new value */
-	bne-	10b		/* Retry if "reservation" (i.e. lock) lost */
-	blr
-_GLOBAL(atomic_inc)
-10:	lwarx	r5,0,r3		/* Fetch old value & reserve */
-	addi	r5,r5,1		/* Perform 'add' operation */
-	stwcx.	r5,0,r3		/* Update with new value */
-	bne-	10b		/* Retry if "reservation" (i.e. lock) lost */
-	blr
-_GLOBAL(atomic_inc_return)
-10:	lwarx	r5,0,r3		/* Fetch old value & reserve */
-	addi	r5,r5,1		/* Perform 'add' operation */
-	stwcx.	r5,0,r3		/* Update with new value */
-	bne-	10b		/* Retry if "reservation" (i.e. lock) lost */
-	mr	r3,r5		/* Return new value */
-	blr
-_GLOBAL(atomic_dec)
-10:	lwarx	r5,0,r3		/* Fetch old value & reserve */
-	subi	r5,r5,1		/* Perform 'add' operation */
-	stwcx.	r5,0,r3		/* Update with new value */
-	bne-	10b		/* Retry if "reservation" (i.e. lock) lost */
-	blr
-_GLOBAL(atomic_dec_return)
-10:	lwarx	r5,0,r3		/* Fetch old value & reserve */
-	subi	r5,r5,1		/* Perform 'add' operation */
-	stwcx.	r5,0,r3		/* Update with new value */
-	bne-	10b		/* Retry if "reservation" (i.e. lock) lost */
-	mr	r3,r5		/* Return new value */
-	blr
-_GLOBAL(atomic_dec_and_test)
-10:	lwarx	r5,0,r3		/* Fetch old value & reserve */
-	subi	r5,r5,1		/* Perform 'add' operation */
-	stwcx.	r5,0,r3		/* Update with new value */
-	bne-	10b		/* Retry if "reservation" (i.e. lock) lost */
-	cntlzw	r3,r5
-	srwi	r3,r3,5
-	blr
-#endif /* 0 */
 _GLOBAL(atomic_clear_mask)
 10:	lwarx	r5,0,r4
 	andc	r5,r5,r3
@@ -768,281 +817,7 @@
 _GLOBAL(_get_SP)
 	mr	r3,r1		/* Close enough */
 	blr
-
-#if 0
-/* isn't it just easier to use the mtspr/mfspr inline macros?? --Troy */
-_GLOBAL(_get_THRM1)
-	mfspr	r3,THRM1
-	blr
-
-_GLOBAL(_get_THRM2)
-	mfspr	r3,THRM2
-	blr
-
-_GLOBAL(_get_THRM3)
-	mfspr	r3,THRM3
-	blr
-		
-_GLOBAL(_set_THRM1)
-	mtspr	THRM1,r3
-	blr
-
-_GLOBAL(_set_THRM2)
-	mtspr	THRM2,r3
-	blr
-
-_GLOBAL(_set_THRM3)
-	mtspr	THRM3,r3
-	blr
-#endif
-	
-_GLOBAL(_get_PVR)
-	mfspr	r3,PVR
-	blr
-
-#ifdef CONFIG_8xx
-_GLOBAL(_get_IMMR)
-	mfspr	r3, 638
-	blr
-#endif
 	
-_GLOBAL(_get_HID0)
-	mfspr	r3,HID0
-	blr
-
-_GLOBAL(_set_HID0)
-	sync
-	mtspr	HID0, r3
-	SYNC		/* Handle errata in some cases */
-	blr
-
-_GLOBAL(_get_ICTC)
-	mfspr	r3,ICTC
-	blr
-
-_GLOBAL(_set_ICTC)
-	mtspr	ICTC,r3
-	blr
-
-/*
-	L2CR functions
-	Copyright © 1997-1998 by PowerLogix R & D, Inc.
-	
-	This program is free software; you can redistribute it and/or modify
-	it under the terms of the GNU General Public License as published by
-	the Free Software Foundation; either version 2 of the License, or
-	(at your option) any later version.
-	
-	This 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.
-*/
-/*
-	Thur, Dec. 12, 1998.
-	- First public release, contributed by PowerLogix.
-	***********
-	Sat, Aug. 7, 1999.
-	- Terry: Made sure code disabled interrupts before running. (Previously
-			it was assumed interrupts were already disabled).
-	- Terry: Updated for tentative G4 support.  4MB of memory is now flushed
-			instead of 2MB.  (Prob. only 3 is necessary).
-	- Terry: Updated for workaround to HID0[DPM] processor bug
-			during global invalidates.
-	***********
-	Thu, July 13, 2000.
-	- Terry: Added isync to correct for an errata.
-	
-	Author:	Terry Greeniaus (tgree@phys.ualberta.ca)
-	Please e-mail updates to this file to me, thanks!
-*/
-/* Usage:
-	
-	When setting the L2CR register, you must do a few special
-	things.  If you are enabling the cache, you must perform a
-	global invalidate.  If you are disabling the cache, you must
-	flush the cache contents first.  This routine takes care of
-	doing these things.  When first enabling the cache, make sure
-	you pass in the L2CR you want, as well as passing in the
-	global invalidate bit set.  A global invalidate will only be
-	performed if the L2I bit is set in applyThis.  When enabling
-	the cache, you should also set the L2E bit in applyThis.  If
-	you want to modify the L2CR contents after the cache has been
-	enabled, the recommended procedure is to first call
-	__setL2CR(0) to disable the cache and then call it again with
-	the new values for L2CR.  Examples:
-
-	_setL2CR(0)		- disables the cache
-	_setL2CR(0xB3A04000)	- enables my G3 upgrade card:
-				- L2E set to turn on the cache
-				- L2SIZ set to 1MB
-				- L2CLK set to 1:1
-				- L2RAM set to pipelined synchronous late-write
-				- L2I set to perform a global invalidation
-				- L2OH set to 0.5 nS
-				- L2DF set because this upgrade card
-				  requires it
-
-	A similar call should work for your card.  You need to know
-	the correct setting for your card and then place them in the
-	fields I have outlined above.  Other fields support optional
-	features, such as L2DO which caches only data, or L2TS which
-	causes cache pushes from the L1 cache to go to the L2 cache
-	instead of to main memory.
-*/
-/*
- * Summary: this procedure ignores the L2I bit in the value passed in,
- * flushes the cache if it was already enabled, always invalidates the
- * cache, then enables the cache if the L2E bit is set in the value
- * passed in.
- *   -- paulus.
- */
-_GLOBAL(_set_L2CR)
-	/* Make sure this is a 750 or 7400 chip */
-	mfspr	r4,PVR
-	rlwinm	r4,r4,16,16,31
-	cmpwi	r4,0x0008
-	cmpwi	cr1,r4,0x000c
-	cror	2,2,4*cr1+2
-	bne	99f
-
-	/* Turn off interrupts and data relocation. */
-	mfmsr	r7		/* Save MSR in r7 */
-	rlwinm	r4,r7,0,17,15
-	rlwinm	r4,r4,0,28,26	/* Turn off DR bit */
-	sync
-	mtmsr	r4
-	isync
-
-	/* Get the current enable bit of the L2CR into r4 */
-	mfspr	r4,L2CR
-	
-	/* Tweak some bits */
-	rlwinm	r5,r3,0,0,0		/* r5 contains the new enable bit */
-	rlwinm	r3,r3,0,11,9		/* Turn off the invalidate bit */
-	rlwinm	r3,r3,0,1,31		/* Turn off the enable bit */
-
-	/* Check to see if we need to flush */
-	rlwinm.	r4,r4,0,0,0
-	beq	2f
-
-	/* Flush the cache. First, read the first 4MB of memory (physical) to
-	 * put new data in the cache.  (Actually we only need
-	 * the size of the L2 cache plus the size of the L1 cache, but 4MB will
-	 * cover everything just to be safe).
-	 */
-		
-	 /**** Might be a good idea to set L2DO here - to prevent instructions
-	       from getting into the cache.  But since we invalidate
-	       the next time we enable the cache it doesn't really matter.
-	  ****/
-
-	lis	r4,0x0002
-	mtctr	r4
-	li	r4,0
-1:
-	lwzx	r0,r0,r4
-	addi	r4,r4,32		/* Go to start of next cache line */
-	bdnz	1b
-	
-	/* Now, flush the first 4MB of memory */
-	lis	r4,0x0002
-	mtctr	r4
-	li	r4,0
-	sync
-1:
-	dcbf	r0,r4
-	addi	r4,r4,32		/* Go to start of next cache line */
-	bdnz	1b
-
-2:
-	/* Set up the L2CR configuration bits (and switch L2 off) */
-	sync
-	mtspr	L2CR,r3
-	sync
-
-	/* Before we perform the global invalidation, we must disable dynamic
-	 * power management via HID0[DPM] to work around a processor bug where
-	 * DPM can possibly interfere with the state machine in the processor
-	 * that invalidates the L2 cache tags.
-	 */
-	mfspr	r8,HID0			/* Save HID0 in r8 */
-	rlwinm	r4,r8,0,12,10		/* Turn off HID0[DPM] */
-	sync
-	mtspr	HID0,r4			/* Disable DPM */
-	sync
-
-	/* Perform a global invalidation */
-	oris	r3,r3,0x0020
-	sync
-	mtspr	L2CR,r3
-	sync
-	isync				/* For errata */
-
-	/* Wait for the invalidation to complete */
-3:	mfspr	r3,L2CR
-	rlwinm.	r4,r3,0,31,31
-	bne	3b
-	
-	rlwinm	r3,r3,0,11,9		/* Turn off the L2I bit */
-	sync
-	mtspr	L2CR,r3
-	sync
-	
-	/* Restore HID0[DPM] to whatever it was before */
-	sync
-	mtspr	1008,r8
-	sync
-
-	/* See if we need to enable the cache */
-	cmplwi	r5,0
-	beq	4f
-
-	/* Enable the cache */
-	oris	r3,r3,0x8000
-	mtspr	L2CR,r3
-	sync
-
-	/* Restore MSR (restores EE and DR bits to original state) */
-4:	SYNC
-	mtmsr	r7
-	isync
-	blr
-
-99:	li	r3,-1
-	blr
-
-_GLOBAL(_get_L2CR)
-	/* Make sure this is a 750 chip */
-	mfspr	r3,PVR
-	srwi	r3,r3,16
-	cmpwi	r3,0x0008
-	cmpwi	cr1,r3,0x000c
-	li	r3,0
-	cror	2,2,4*cr1+2
-	bnelr
-	/* Return the L2CR contents */
-	mfspr	r3,L2CR
-	blr
-
-/* --- End of PowerLogix code ---
- */
-
-/*
-_GLOBAL(_get_L2CR)
-	mfspr	r3,L2CR
-	blr
-
-_GLOBAL(_set_L2CR)
-	mtspr	L2CR,r3
-	blr
-		
-*/
-
 /*
  * These are used in the alignment trap handler when emulating
  * single-precision loads and stores.
@@ -1099,7 +874,7 @@
 	mr	r3,r4	        /* load arg and call fn */
 	blrl
 	li	r0,__NR_exit	/* exit after child exits */
-        li	r3,0
+	li	r3,0
 	sc
 
 /*
@@ -1279,7 +1054,7 @@
 	.long sys_setfsuid
 	.long sys_setfsgid
 	.long sys_llseek	/* 140 */
-        .long sys_getdents
+	.long sys_getdents
 	.long ppc_select
 	.long sys_flock
 	.long sys_msync
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/mk_defs.c linux/arch/ppc/kernel/mk_defs.c
--- v2.4.9/linux/arch/ppc/kernel/mk_defs.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/ppc/kernel/mk_defs.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.mk_defs.c 1.8 06/28/01 15:50:16 paulus
+ * BK Id: SCCS/s.mk_defs.c 1.11 08/19/01 22:43:23 paulus
  */
 /*
  * This program is used to generate definitions needed by
@@ -26,6 +26,7 @@
 #include <asm/page.h>
 #include <asm/pgtable.h>
 #include <asm/processor.h>
+#include <asm/cputable.h>
 
 #define DEFINE(sym, val) \
 	asm volatile("\n#define\t" #sym "\t%0" : : "i" (val))
@@ -118,5 +119,14 @@
 	DEFINE(TRAP, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, trap));
 	DEFINE(CLONE_VM, CLONE_VM);
 	DEFINE(MM_PGD, offsetof(struct mm_struct, pgd));
+
+	/* About the CPU features table */
+	DEFINE(CPU_SPEC_ENTRY_SIZE, sizeof(struct cpu_spec));
+	DEFINE(CPU_SPEC_PVR_MASK, offsetof(struct cpu_spec, pvr_mask));
+	DEFINE(CPU_SPEC_PVR_VALUE, offsetof(struct cpu_spec, pvr_value));
+	DEFINE(CPU_SPEC_FEATURES, offsetof(struct cpu_spec, cpu_features));
+	DEFINE(CPU_SPEC_SETUP, offsetof(struct cpu_spec, cpu_setup));
+
+	DEFINE(NUM_USER_SEGMENTS, TASK_SIZE>>28);
 	return 0;
 }
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/oak_setup.c linux/arch/ppc/kernel/oak_setup.c
--- v2.4.9/linux/arch/ppc/kernel/oak_setup.c	Mon May 21 17:04:47 2001
+++ linux/arch/ppc/kernel/oak_setup.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.oak_setup.c 1.5 05/17/01 18:14:21 cort
+ * BK Id: SCCS/s.oak_setup.c 1.8 08/15/01 21:48:38 paulus
  */
 /*
  *
@@ -74,8 +74,8 @@
  *
  */
 void __init
-oak_init(unsigned long r3, unsigned long r4, unsigned long r5, 
-	 unsigned long r6, unsigned long r7)
+platform_init(unsigned long r3, unsigned long r4, unsigned long r5, 
+	      unsigned long r6, unsigned long r7)
 {
 	/*
 	 * If we were passed in a board information, copy it into the
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/open_pic.c linux/arch/ppc/kernel/open_pic.c
--- v2.4.9/linux/arch/ppc/kernel/open_pic.c	Mon May 21 17:04:47 2001
+++ linux/arch/ppc/kernel/open_pic.c	Sat Sep  8 12:38:41 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.open_pic.c 1.20 05/17/01 18:14:21 cort
+ * BK Id: SCCS/s.open_pic.c 1.28 09/08/01 15:47:42 paulus
  */
 /*
  *  arch/ppc/kernel/open_pic.c -- OpenPIC Interrupt Handling
@@ -17,11 +17,13 @@
 #include <linux/sched.h>
 #include <linux/init.h>
 #include <linux/irq.h>
+#include <linux/init.h>
 #include <asm/ptrace.h>
 #include <asm/signal.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/prom.h>
+#include <asm/sections.h>
 
 #include "local_irq.h"
 #include "open_pic.h"
@@ -47,8 +49,6 @@
 
 /* Global Operations */
 static void openpic_disable_8259_pass_through(void);
-static u_int openpic_irq(void);
-static void openpic_eoi(void);
 static void openpic_set_priority(u_int pri);
 static void openpic_set_spurious(u_int vector);
 
@@ -73,8 +73,8 @@
  * These functions are not used but the code is kept here
  * for completeness and future reference.
  */
-#ifdef notused
 static void openpic_reset(void);
+#ifdef notused
 static void openpic_enable_8259_pass_through(void);
 static u_int openpic_get_priority(void);
 static u_int openpic_get_spurious(void);
@@ -412,13 +412,16 @@
 #endif
 }
 
-#ifdef notused
 static void openpic_reset(void)
 {
 	openpic_setfield(&OpenPIC->Global.Global_Configuration0,
 			 OPENPIC_CONFIG_RESET);
+	while (openpic_readfield(&OpenPIC->Global.Global_Configuration0,
+				 OPENPIC_CONFIG_RESET))
+		mb();
 }
 
+#ifdef notused
 static void openpic_enable_8259_pass_through(void)
 {
 	openpic_clearfield(&OpenPIC->Global.Global_Configuration0,
@@ -435,7 +438,7 @@
 /*
  *  Find out the current interrupt
  */
-static u_int openpic_irq(void)
+u_int openpic_irq(void)
 {
 	u_int vec;
 	DECL_THIS_CPU;
@@ -446,7 +449,7 @@
 	return vec;
 }
 
-static void openpic_eoi(void)
+void openpic_eoi(void)
 {
 	DECL_THIS_CPU;
 
@@ -518,6 +521,8 @@
 		      physmask(cpumask));
 }
 
+static spinlock_t openpic_setup_lock = SPIN_LOCK_UNLOCKED;
+
 #ifdef CONFIG_SMP
 /*
  *  Initialize an interprocessor interrupt (and disable it)
@@ -583,7 +588,6 @@
  * Get IPI's working and start taking interrupts.
  *   -- Cort
  */
-static spinlock_t openpic_setup_lock __initdata = SPIN_LOCK_UNLOCKED;
 
 void __init do_openpic_setup_cpu(void)
 {
@@ -802,11 +806,87 @@
 #endif
 		openpic_eoi();
         }
-	if (irq == OPENPIC_VEC_SPURIOUS + open_pic_irq_offset) {
+	if (irq == OPENPIC_VEC_SPURIOUS + open_pic_irq_offset)
 		irq = -1;
-		/* That's not SMP safe ... but who cares ? */
-		ppc_spurious_interrupts++;
-	}
 	return irq;
 }
 
+#ifdef CONFIG_SMP
+void
+smp_openpic_message_pass(int target, int msg, unsigned long data, int wait)
+{
+	/* make sure we're sending something that translates to an IPI */
+	if (msg > 0x3) {
+		printk("SMP %d: smp_message_pass: unknown msg %d\n",
+		       smp_processor_id(), msg);
+		return;
+	}
+	switch (target) {
+	case MSG_ALL:
+		openpic_cause_IPI(msg, 0xffffffff);
+		break;
+	case MSG_ALL_BUT_SELF:
+		openpic_cause_IPI(msg,
+				  0xffffffff & ~(1 << smp_processor_id()));
+		break;
+	default:
+		openpic_cause_IPI(msg, 1<<target);
+		break;
+	}
+}
+#endif /* CONFIG_SMP */
+
+#ifdef CONFIG_PMAC_PBOOK
+static u32 save_ipi_vp[OPENPIC_NUM_IPI];
+static u32 save_irq_src_vp[OPENPIC_MAX_SOURCES];
+static u32 save_irq_src_dest[OPENPIC_MAX_SOURCES];
+static u32 save_cpu_task_pri[OPENPIC_MAX_PROCESSORS];
+
+void __pmac
+openpic_sleep_save_intrs(void)
+{
+	int	i;
+	unsigned long flags;
+	
+	spin_lock_irqsave(&openpic_setup_lock, flags);
+
+	for (i=0; i<NumProcessors; i++) {
+		save_cpu_task_pri[i] = openpic_read(&OpenPIC->Processor[i].Current_Task_Priority);
+		openpic_writefield(&OpenPIC->Processor[i].Current_Task_Priority,
+				   OPENPIC_CURRENT_TASK_PRIORITY_MASK, 0xf);
+	}
+
+	for (i=0; i<OPENPIC_NUM_IPI; i++)
+		save_ipi_vp[i] = openpic_read(&OpenPIC->Global.IPI_Vector_Priority(i));
+	for (i=0; i<NumSources; i++) {
+		save_irq_src_vp[i] = openpic_read(&OpenPIC->Source[i].Vector_Priority)
+			& ~OPENPIC_ACTIVITY;
+		save_irq_src_dest[i] = openpic_read(&OpenPIC->Source[i].Destination);
+	}
+	spin_unlock_irqrestore(&openpic_setup_lock, flags);
+}
+
+void __pmac
+openpic_sleep_restore_intrs(void)
+{
+	int		i;
+	unsigned long	flags;
+
+	spin_lock_irqsave(&openpic_setup_lock, flags);
+	
+	openpic_reset();
+
+	for (i=0; i<OPENPIC_NUM_IPI; i++)
+		openpic_write(&OpenPIC->Global.IPI_Vector_Priority(i), save_ipi_vp[i]);
+	for (i=0; i<NumSources; i++) {
+		openpic_write(&OpenPIC->Source[i].Vector_Priority, save_irq_src_vp[i]);
+		openpic_write(&OpenPIC->Source[i].Destination, save_irq_src_dest[i]);
+	}
+	openpic_set_spurious(OPENPIC_VEC_SPURIOUS+open_pic_irq_offset);
+	openpic_disable_8259_pass_through();
+	for (i=0; i<NumProcessors; i++)
+		openpic_write(&OpenPIC->Processor[i].Current_Task_Priority, save_cpu_task_pri[i]);
+
+	spin_unlock_irqrestore(&openpic_setup_lock, flags);
+}
+#endif /* CONFIG_PMAC_PBOOK */
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/open_pic.h linux/arch/ppc/kernel/open_pic.h
--- v2.4.9/linux/arch/ppc/kernel/open_pic.h	Mon May 21 17:04:47 2001
+++ linux/arch/ppc/kernel/open_pic.h	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.open_pic.h 1.8 05/17/01 18:14:21 cort
+ * BK Id: SCCS/s.open_pic.h 1.12 08/20/01 22:33:28 paulus
  */
 /*
  *  arch/ppc/kernel/open_pic.h -- OpenPIC Interrupt Handling
@@ -19,6 +19,14 @@
 
 #define OPENPIC_SIZE	0x40000
 
+/*
+ *  Non-offset'ed vector numbers
+ */
+
+#define OPENPIC_VEC_TIMER	64	/* and up */
+#define OPENPIC_VEC_IPI		72	/* and up */
+#define OPENPIC_VEC_SPURIOUS	127
+
 /* OpenPIC IRQ controller structure */
 extern struct hw_interrupt_type open_pic;
 
@@ -33,16 +41,28 @@
 
 /* Exported functions */
 extern void openpic_init(int, int, unsigned char *, int);
+extern u_int openpic_irq(void);
+extern void openpic_eoi(void);
 extern void openpic_request_IPIs(void);
 extern void do_openpic_setup_cpu(void);
 extern int openpic_get_irq(struct pt_regs *regs);
 extern void openpic_init_processor(u_int cpumask);
 extern void openpic_setup_ISU(int isu_num, unsigned long addr);
 extern void openpic_cause_IPI(u_int ipi, u_int cpumask);
+extern void smp_openpic_message_pass(int target, int msg, unsigned long data,
+				     int wait);
 
 extern inline int openpic_to_irq(int irq)
 {
-	return irq += NUM_8259_INTERRUPTS;
+	/* IRQ 0 usually means 'disabled'.. don't mess with it 
+	 * exceptions to this (sandpoint maybe?) 
+	 * shouldn't use openpic_to_irq 
+	 */
+	if (irq != 0){
+		return irq += NUM_8259_INTERRUPTS;
+	} else {
+		return 0;
+	}
 }
 /*extern int open_pic_irq_offset;*/
 #endif /* _PPC_KERNEL_OPEN_PIC_H */
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/open_pic_defs.h linux/arch/ppc/kernel/open_pic_defs.h
--- v2.4.9/linux/arch/ppc/kernel/open_pic_defs.h	Mon May 21 17:04:47 2001
+++ linux/arch/ppc/kernel/open_pic_defs.h	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.open_pic_defs.h 1.7 05/17/01 18:14:21 cort
+ * BK Id: SCCS/s.open_pic_defs.h 1.8 08/20/01 22:33:28 paulus
  */
 /*
  *  linux/openpic.h -- OpenPIC definitions
@@ -44,14 +44,6 @@
 #define OPENPIC_NUM_PRI		16
 #define OPENPIC_NUM_VECTORS	256
 
-
-    /*
-     *  Non-offset'ed vector numbers
-     */
-
-#define OPENPIC_VEC_TIMER       64    /* and up */
-#define OPENPIC_VEC_IPI         72    /* and up */
-#define OPENPIC_VEC_SPURIOUS    127
 
 
     /*
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/pmac_backlight.c linux/arch/ppc/kernel/pmac_backlight.c
--- v2.4.9/linux/arch/ppc/kernel/pmac_backlight.c	Mon May 21 17:04:47 2001
+++ linux/arch/ppc/kernel/pmac_backlight.c	Sat Sep  8 12:38:41 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.pmac_backlight.c 1.5 05/17/01 18:14:21 cort
+ * BK Id: SCCS/s.pmac_backlight.c 1.8 09/08/01 15:47:42 paulus
  */
 /*
  * Miscellaneous procedures for dealing with the PowerMac hardware.
@@ -14,7 +14,7 @@
 #include <linux/stddef.h>
 #include <linux/reboot.h>
 #include <linux/nvram.h>
-#include <asm/init.h>
+#include <asm/sections.h>
 #include <asm/ptrace.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/pmac_nvram.c linux/arch/ppc/kernel/pmac_nvram.c
--- v2.4.9/linux/arch/ppc/kernel/pmac_nvram.c	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/kernel/pmac_nvram.c	Sat Sep  8 12:38:41 2001
@@ -1,17 +1,18 @@
 /*
- * BK Id: SCCS/s.pmac_nvram.c 1.10 08/08/01 16:23:35 paulus
+ * BK Id: SCCS/s.pmac_nvram.c 1.15 09/08/01 15:47:42 paulus
  */
 /*
  * Miscellaneous procedures for dealing with the PowerMac hardware.
  */
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/stddef.h>
 #include <linux/nvram.h>
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
-#include <asm/init.h>
+#include <asm/sections.h>
 #include <asm/io.h>
 #include <asm/system.h>
 #include <asm/prom.h>
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/pmac_pci.c linux/arch/ppc/kernel/pmac_pci.c
--- v2.4.9/linux/arch/ppc/kernel/pmac_pci.c	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/kernel/pmac_pci.c	Sat Sep  8 12:38:41 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.pmac_pci.c 1.22 08/08/01 16:35:43 paulus
+ * BK Id: SCCS/s.pmac_pci.c 1.27 09/08/01 15:47:42 paulus
  */
 /*
  * Support for PCI bridges found on Power Macintoshes.
@@ -22,7 +22,7 @@
 #include <linux/init.h>
 #include <linux/bootmem.h>
 
-#include <asm/init.h>
+#include <asm/sections.h>
 #include <asm/io.h>
 #include <asm/prom.h>
 #include <asm/pci-bridge.h>
@@ -528,6 +528,7 @@
 pmac_pci_enable_device_hook(struct pci_dev *dev, int initial)
 {
 	struct device_node* node;
+	int updatecfg = 0;
 
 	node = pci_device_to_OF_node(dev);
 
@@ -538,14 +539,40 @@
 	    && dev->device == PCI_DEVICE_ID_APPLE_KL_USB && !node)
 		return -EINVAL;
 		
-	/* Firewire was disabled after PCI probe, the driver is claiming it,
-	 * so we must re-enable it now, at least until the driver can do it
-	 * itself.
+	/* Firewire & GMAC were disabled after PCI probe, the driver is
+	 * claiming them, we must re-enable them now.
 	 */
 	if (node && !strcmp(node->name, "firewire") && 
-	    device_is_compatible(node, "pci106b,18")) {
+	    (device_is_compatible(node, "pci106b,18") || 
+	     device_is_compatible(node, "pci106b,30"))) {
 		feature_set_firewire_cable_power(node, 1);
 		feature_set_firewire_power(node, 1);
+		updatecfg = 1;
+	}
+	if (node && !strcmp(node->name, "ethernet") && 
+	    device_is_compatible(node, "gmac")) {
+		feature_set_gmac_power(node, 1);
+		updatecfg = 1;
+	}
+
+	if (updatecfg) {
+		u16 cmd;
+		
+		/*
+		 * Make sure PCI is correctly configured
+		 *
+		 * We use old pci_bios versions of the function since, by
+		 * default, gmac is not powered up, and so will be absent
+		 * from the kernel initial PCI lookup. 
+		 * 
+		 * Should be replaced by 2.4 new PCI mecanisms and really
+		 * regiser the device.
+		 */
+		pci_read_config_word(dev, PCI_COMMAND, &cmd);
+		cmd |= PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE;
+    		pci_write_config_word(dev, PCI_COMMAND, cmd);
+    		pci_write_config_byte(dev, PCI_LATENCY_TIMER, 16);
+    		pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 8);
 	}
 	
 	return 0;
@@ -580,7 +607,8 @@
 
 	nd = find_devices("firewire");
 	while (nd) {
-		if (nd->parent && device_is_compatible(nd, "pci106b,18")
+		if (nd->parent && (device_is_compatible(nd, "pci106b,18") ||
+					device_is_compatible(nd, "pci106b,30"))
 		    && device_is_compatible(nd->parent, "uni-north")) {
 			feature_set_firewire_power(nd, 0);
 			feature_set_firewire_cable_power(nd, 0);
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/pmac_pic.c linux/arch/ppc/kernel/pmac_pic.c
--- v2.4.9/linux/arch/ppc/kernel/pmac_pic.c	Mon May 21 17:04:47 2001
+++ linux/arch/ppc/kernel/pmac_pic.c	Sat Sep  8 12:38:42 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.pmac_pic.c 1.14 05/17/01 18:14:21 cort
+ * BK Id: SCCS/s.pmac_pic.c 1.20 09/08/01 15:47:42 paulus
  */
 #include <linux/config.h>
 #include <linux/stddef.h>
@@ -8,7 +8,7 @@
 #include <linux/signal.h>
 #include <linux/pci.h>
 
-#include <asm/init.h>
+#include <asm/sections.h>
 #include <asm/io.h>
 #include <asm/smp.h>
 #include <asm/prom.h>
@@ -35,7 +35,6 @@
 
 static int max_irqs;
 static int max_real_irqs;
-static int pmac_has_openpic;
 
 spinlock_t pmac_pic_lock = SPIN_LOCK_UNLOCKED;
 
@@ -291,17 +290,16 @@
  * controller.  If we find this second ohare, set it up and fix the
  * interrupt value in the device tree for the ethernet chip.
  */
-static void __init enable_second_ohare(void)
+static int __init enable_second_ohare(void)
 {
 	unsigned char bus, devfn;
 	unsigned short cmd;
         unsigned long addr;
-	int second_irq;
 	struct device_node *irqctrler = find_devices("pci106b,7");
 	struct device_node *ether;
 
 	if (irqctrler == NULL || irqctrler->n_addrs <= 0)
-		return;
+		return -1;
 	addr = (unsigned long) ioremap(irqctrler->addrs[0].address, 0x40);
 	pmac_irq_hw[1] = (volatile struct pmac_irq_hw *)(addr + 0x20);
 	max_irqs = 64;
@@ -317,11 +315,6 @@
 		}
 	}
 
-	second_irq = irqctrler->intrs[0].line;
-	printk(KERN_INFO "irq: secondary controller on irq %d\n", second_irq);
-	request_irq(second_irq, gatwick_action, SA_INTERRUPT,
-		    "interrupt cascade", 0 );
-
 	/* Fix interrupt for the modem/ethernet combo controller. The number
 	   in the device tree (27) is bogus (correct for the ethernet-only
 	   board but not the combo ethernet/modem board).
@@ -333,6 +326,9 @@
 		printk(KERN_INFO "irq: Fixed ethernet IRQ to %d\n",
 		       ether->intrs[0].line);
 	}
+
+	/* Return the interrupt number of the cascade */
+	return irqctrler->intrs[0].line;
 }
 
 void __init
@@ -341,8 +337,8 @@
         int i;
         struct device_node *irqctrler;
         unsigned long addr;
-	int second_irq = -999;
-
+	int irq_cascade = -1;
+	
 	/* We first try to detect Apple's new Core99 chipset, since mac-io
 	 * is quite different on those machines and contains an IBM MPIC2.
 	 */
@@ -368,7 +364,6 @@
 			OpenPIC_Addr = ioremap(irqctrler->addrs[0].address,
 					       irqctrler->addrs[0].size);
 			openpic_init(1, 0, 0, nmi_irq);
-			pmac_has_openpic = 1;
 #ifdef CONFIG_XMON
 			if (nmi_irq >= 0)
 				request_irq(nmi_irq, xmon_irq, 0,
@@ -418,6 +413,9 @@
 			for (i = 2; i < 4; ++i)
 				pmac_irq_hw[i] = (volatile struct pmac_irq_hw*)
 					(addr + (4 - i) * 0x10);
+			irq_cascade = irqctrler->intrs[0].line;
+			if (device_is_compatible(irqctrler, "gatwick"))
+				pmac_fix_gatwick_interrupts(irqctrler, max_real_irqs);
 		}
 	} else {
 		/* older powermacs have a GC (grand central) or ohare at
@@ -430,23 +428,20 @@
 	   ohare chip, on the combo ethernet/modem card */
 	if (machine_is_compatible("AAPL,3400/2400")
 	     || machine_is_compatible("AAPL,3500"))
-		enable_second_ohare();
+		irq_cascade = enable_second_ohare();
 
 	/* 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;
+	if (irq_cascade >= 0) {
 		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);
+			(int)irq_cascade);
 		for ( i = max_real_irqs ; i < max_irqs ; i++ )
 			irq_desc[i].handler = &gatwick_pic;
-		request_irq( second_irq, gatwick_action, SA_INTERRUPT,
-			     "gatwick cascade", 0 );
+		request_irq( irq_cascade, gatwick_action, SA_INTERRUPT,
+			     "cascade", 0 );
 	}
 	printk("System has %d possible interrupts\n", max_irqs);
 	if (max_irqs != max_real_irqs)
@@ -467,14 +462,15 @@
  */
 unsigned int sleep_save_mask[2];
 
-void
-sleep_save_intrs(int viaint)
+void __pmac
+pmac_sleep_save_intrs(int viaint)
 {
 	sleep_save_mask[0] = ppc_cached_irq_mask[0];
 	sleep_save_mask[1] = ppc_cached_irq_mask[1];
 	ppc_cached_irq_mask[0] = 0;
 	ppc_cached_irq_mask[1] = 0;
-	set_bit(viaint, ppc_cached_irq_mask);
+	if (viaint > 0)
+		set_bit(viaint, ppc_cached_irq_mask);
 	out_le32(&pmac_irq_hw[0]->enable, ppc_cached_irq_mask[0]);
 	if (max_real_irqs > 32)
 		out_le32(&pmac_irq_hw[1]->enable, ppc_cached_irq_mask[1]);
@@ -484,8 +480,8 @@
         (void)in_le32(&pmac_irq_hw[0]->enable);
 }
 
-void
-sleep_restore_intrs(void)
+void __pmac
+pmac_sleep_restore_intrs(void)
 {
 	int i;
 
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/pmac_pic.h linux/arch/ppc/kernel/pmac_pic.h
--- v2.4.9/linux/arch/ppc/kernel/pmac_pic.h	Mon May 21 17:04:47 2001
+++ linux/arch/ppc/kernel/pmac_pic.h	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.pmac_pic.h 1.5 05/17/01 18:14:21 cort
+ * BK Id: SCCS/s.pmac_pic.h 1.9 08/19/01 22:23:04 paulus
  */
 #ifndef _PPC_KERNEL_PMAC_PIC_H
 #define _PPC_KERNEL_PMAC_PIC_H
@@ -10,6 +10,5 @@
 
 void pmac_pic_init(void);
 int pmac_get_irq(struct pt_regs *regs);
-void pmac_post_irq(int);
 
 #endif /* _PPC_KERNEL_PMAC_PIC_H */
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/pmac_setup.c linux/arch/ppc/kernel/pmac_setup.c
--- v2.4.9/linux/arch/ppc/kernel/pmac_setup.c	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/kernel/pmac_setup.c	Sat Sep  8 12:38:42 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.pmac_setup.c 1.24 07/06/01 14:49:51 trini
+ * BK Id: SCCS/s.pmac_setup.c 1.39 09/08/01 15:47:42 paulus
  */
 /*
  *  linux/arch/ppc/kernel/setup.c
@@ -51,7 +51,7 @@
 #include <linux/pmu.h>
 
 #include <asm/processor.h>
-#include <asm/init.h>
+#include <asm/sections.h>
 #include <asm/prom.h>
 #include <asm/system.h>
 #include <asm/pgtable.h>
@@ -65,6 +65,8 @@
 #include <asm/keyboard.h>
 #include <asm/dma.h>
 #include <asm/bootx.h>
+#include <asm/cputable.h>
+#include <asm/btext.h>
 
 #include <asm/time.h>
 #include "local_irq.h"
@@ -133,13 +135,16 @@
 sys_ctrler_t sys_ctrler = SYS_CTRLER_UNKNOWN;
 
 #ifdef CONFIG_SMP
+extern struct smp_ops_t psurge_smp_ops;
+extern struct smp_ops_t core99_smp_ops;
+
 volatile static long int core99_l2_cache;
-void __pmac
+void __init
 core99_init_l2(void)
 {
 	int cpu = smp_processor_id();
 
-	if ( (_get_PVR() >> 16) != 8 && (_get_PVR() >> 16) != 12 )
+	if (!(cur_cpu_spec[0]->cpu_features & CPU_FTR_L2CR))
 		return;
 
 	if (cpu == 0){
@@ -277,6 +282,9 @@
 {
 	struct device_node *cpu;
 	int *fp;
+	unsigned long pvr;
+	
+	pvr = PVR_VER(mfspr(PVR));
 
 	/* Set loops_per_jiffy to a half-way reasonable value,
 	   for use until calibrate_delay gets called. */
@@ -284,18 +292,12 @@
 	if (cpu != 0) {
 		fp = (int *) get_property(cpu, "clock-frequency", NULL);
 		if (fp != 0) {
-			switch (_get_PVR() >> 16) {
-			case 4:		/* 604 */
-			case 8:		/* G3 */
-			case 9:		/* 604e */
-			case 10:	/* mach V (604ev5) */
-			case 12:	/* G4 */
-			case 20:	/* 620 */
+			if (pvr == 4 || pvr >= 8)
+				/* 604, G3, G4 etc. */
 				loops_per_jiffy = *fp / HZ;
-				break;
-			default:	/* 601, 603, etc. */
+			else
+				/* 601, 603, etc. */
 				loops_per_jiffy = *fp / (2*HZ);
-			}
 		} else
 			loops_per_jiffy = 50000000 / HZ;
 	}
@@ -303,14 +305,13 @@
 	/* this area has the CPU identification register
 	   and some registers used by smp boards */
 	sysctrl_regs = (volatile u32 *) ioremap(0xf8000000, 0x1000);
-	__ioremap(0xffc00000, 0x400000, pgprot_val(PAGE_READONLY));
 	ohare_init();
 
 	/* Lookup PCI hosts */
 	pmac_find_bridges();
 	
 	/* Checks "l2cr-value" property in the registry */
-	if ( (_get_PVR() >> 16) == 8 || (_get_PVR() >> 16) == 12 ) {
+	if (cur_cpu_spec[0]->cpu_features & CPU_FTR_L2CR) {
 		struct device_node *np = find_devices("cpus");		
 		if (np == 0)
 			np = find_type_devices("cpu");		
@@ -342,9 +343,19 @@
 
 #ifdef CONFIG_ADB_CUDA
 	find_via_cuda();
+#else
+	if (find_devices("via-cuda")) {
+		printk("WARNING ! Your machine is Cuda based but your kernel\n");
+		printk("          wasn't compiled with CONFIG_ADB_CUDA option !\n");
+	}
 #endif	
 #ifdef CONFIG_ADB_PMU
 	find_via_pmu();
+#else
+	if (find_devices("via-pmu")) {
+		printk("WARNING ! Your machine is PMU based but your kernel\n");
+		printk("          wasn't compiled with CONFIG_ADB_PMU option !\n");
+	}
 #endif	
 #ifdef CONFIG_NVRAM
 	pmac_nvram_init();
@@ -361,6 +372,14 @@
 	else
 #endif
 		ROOT_DEV = to_kdev_t(DEFAULT_ROOT_DEVICE);
+
+#ifdef CONFIG_SMP
+	/* Check for Core99 */
+	if (find_devices("uni-n"))
+		ppc_md.smp_ops = &core99_smp_ops;
+	else
+		ppc_md.smp_ops = &psurge_smp_ops;
+#endif /* CONFIG_SMP */
 }
 
 static void __init ohare_init(void)
@@ -475,9 +494,11 @@
 	static int found_boot = 0;
 	char *p;
 
-	/* Do nothing if the root has been set already. */
+	/* Do nothing if the root has been mounted already. */
+	if (init_task.fs->rootmnt != NULL)
+		return;
 	if ((goodness <= current_root_goodness) &&
-		(ROOT_DEV != to_kdev_t(DEFAULT_ROOT_DEVICE)))
+	    (ROOT_DEV != to_kdev_t(DEFAULT_ROOT_DEVICE)))
 		return;
 	p = strstr(saved_command_line, "root=");
 	if (p != NULL && (p == saved_command_line || p[-1] == ' '))
@@ -563,41 +584,7 @@
 /*
  * IDE stuff.
  */
-void __pmac
-pmac_ide_insw(ide_ioreg_t port, void *buf, int ns)
-{
-	_insw_ns((unsigned short *)(port+_IO_BASE), buf, ns);
-}
-
-void __pmac
-pmac_ide_outsw(ide_ioreg_t port, void *buf, int ns)
-{
-	_outsw_ns((unsigned short *)(port+_IO_BASE), buf, ns);
-}
-
-int __pmac
-pmac_ide_default_irq(ide_ioreg_t base)
-{
-#if defined(CONFIG_BLK_DEV_IDE) && defined(CONFIG_BLK_DEV_IDE_PMAC)
-	extern int pmac_ide_get_irq(ide_ioreg_t base);
-        return pmac_ide_get_irq(base);
-#else
-	return 0;
-#endif
-}
-
-ide_ioreg_t __pmac
-pmac_ide_default_io_base(int index)
-{
-#if defined(CONFIG_BLK_DEV_IDE) && defined(CONFIG_BLK_DEV_IDE_PMAC)
-	extern ide_ioreg_t pmac_ide_get_base(int index);
-        return pmac_ide_get_base(index);
-#else
-	return 0;
-#endif
-}
-
-int __pmac
+static int __pmac
 pmac_ide_check_region(ide_ioreg_t from, unsigned int extent)
 {
 	/*
@@ -606,11 +593,11 @@
 	 * register, it should be OK.
 	 */
 	if (from < ~_IO_BASE)
-		return 0;
-	return check_region(from, extent);
+		return check_region(from, extent);
+	return 0;
 }
 
-void __pmac
+static void __pmac
 pmac_ide_request_region(ide_ioreg_t from,
 			unsigned int extent,
 			const char *name)
@@ -619,7 +606,7 @@
 		request_region(from, extent, name);
 }
 
-void __pmac
+static void __pmac
 pmac_ide_release_region(ide_ioreg_t from,
 			unsigned int extent)
 {
@@ -627,21 +614,24 @@
 		release_region(from, extent);
 }
 
-#if defined(CONFIG_BLK_DEV_IDE) && defined(CONFIG_BLK_DEV_IDE_PMAC)
-/* This is declared in drivers/block/ide-pmac.c */
-void __pmac
-pmac_ide_init_hwif_ports (hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq);
-#else
 /*
- * This registers the standard ports for this architecture with the IDE
- * driver.
+ * This is only used if we have a PCI IDE controller, not
+ * for the IDE controller in the ohare/paddington/heathrow/keylargo.
  */
-void __pmac
-pmac_ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq)
+static void __pmac
+pmac_ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port,
+		ide_ioreg_t ctrl_port, int *irq)
 {
+	ide_ioreg_t reg = data_port;
+	int i;
+
+	for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
+		hw->io_ports[i] = reg;
+		reg += 1;
+	}
+	hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
 }
 #endif
-#endif
 
 /*
  * Read in a property describing some pieces of memory.
@@ -728,39 +718,8 @@
 }
 
 void __init
-pmac_init(unsigned long r3, unsigned long r4, unsigned long r5,
-	  unsigned long r6, unsigned long r7)
+select_adb_keyboard(void)
 {
-	/* 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.get_irq        = pmac_get_irq; /* Changed later on ... */
-	ppc_md.init           = pmac_init2;
-	
-	ppc_md.pcibios_fixup  = pmac_pcibios_fixup;
-	ppc_md.pcibios_enable_device_hook = pmac_pci_enable_device_hook;
-	ppc_md.pcibios_after_init = pmac_pcibios_after_init;
-
-	ppc_md.restart        = pmac_restart;
-	ppc_md.power_off      = pmac_power_off;
-	ppc_md.halt           = pmac_halt;
-
-	ppc_md.time_init      = pmac_time_init;
-	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;
-
-	ppc_md.find_end_of_memory = pmac_find_end_of_memory;
-
 #ifdef CONFIG_VT
 #ifdef CONFIG_INPUT
 	ppc_md.kbd_init_hw       = mac_hid_init_hw;
@@ -768,6 +727,7 @@
 	ppc_md.kbd_unexpected_up = mac_hid_kbd_unexpected_up;
 	ppc_md.kbd_setkeycode    = 0;
 	ppc_md.kbd_getkeycode    = 0;
+	ppc_md.kbd_leds		 = 0;
 #ifdef CONFIG_MAGIC_SYSRQ
 #ifdef CONFIG_MAC_ADBKEYCODES
 	if (!keyboard_sends_linux_keycodes) {
@@ -793,21 +753,55 @@
 #endif /* CONFIG_MAGIC_SYSRQ */
 #endif /* CONFIG_INPUT_ADBHID/CONFIG_ADB_KEYBOARD */
 #endif /* CONFIG_VT */
+}
+
+void __init
+pmac_init(unsigned long r3, unsigned long r4, unsigned long r5,
+	  unsigned long r6, unsigned long r7)
+{
+	/* 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.get_irq        = pmac_get_irq; /* Changed later on ... */
+	ppc_md.init           = pmac_init2;
+	
+	ppc_md.pcibios_fixup  = pmac_pcibios_fixup;
+	ppc_md.pcibios_enable_device_hook = pmac_pci_enable_device_hook;
+	ppc_md.pcibios_after_init = pmac_pcibios_after_init;
+
+	ppc_md.restart        = pmac_restart;
+	ppc_md.power_off      = pmac_power_off;
+	ppc_md.halt           = pmac_halt;
+
+	ppc_md.time_init      = pmac_time_init;
+	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;
+
+	ppc_md.find_end_of_memory = pmac_find_end_of_memory;
+
+	select_adb_keyboard();
 
 #if defined(CONFIG_BLK_DEV_IDE) && 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.ide_check_region	= pmac_ide_check_region;
         ppc_ide_md.ide_request_region	= pmac_ide_request_region;
         ppc_ide_md.ide_release_region	= pmac_ide_release_region;
-        ppc_ide_md.fix_driveid		= ppc_generic_ide_fix_driveid;
         ppc_ide_md.ide_init_hwif	= pmac_ide_init_hwif_ports;
 #endif /* CONFIG_BLK_DEV_IDE && CONFIG_BLK_DEV_IDE_PMAC */
+
 #ifdef CONFIG_BOOTX_TEXT
 	ppc_md.progress = pmac_progress;
 #endif /* CONFIG_BOOTX_TEXT */
+
 	if (ppc_md.progress) ppc_md.progress("pmac_init(): exit", 0);
 	
 }
@@ -821,7 +815,7 @@
 {
 	if (disp_bi == 0)
 		return;
-	prom_drawstring(s);
-	prom_drawchar('\n');
+	btext_drawstring(s);
+	btext_drawchar('\n');
 }
 #endif /* CONFIG_BOOTX_TEXT */
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/pmac_smp.c linux/arch/ppc/kernel/pmac_smp.c
--- v2.4.9/linux/arch/ppc/kernel/pmac_smp.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/ppc/kernel/pmac_smp.c	Sat Sep  8 12:38:42 2001
@@ -0,0 +1,489 @@
+/*
+ * BK Id: %F% %I% %G% %U% %#%
+ */
+/*
+ * SMP support for power macintosh.
+ *
+ * We support both the old "powersurge" SMP architecture
+ * and the current Core99 (G4 PowerMac) machines.
+ *
+ * Support Macintosh G4 SMP by Troy Benjegerdes (hozer@drgw.net)
+ * and Ben Herrenschmidt <benh@kernel.crashing.org>.
+ *
+ * Support for DayStar quad CPU cards
+ * Copyright (C) XLR8, Inc. 1994-2000
+ *
+ *  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 <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/smp.h>
+#include <linux/smp_lock.h>
+#include <linux/interrupt.h>
+#include <linux/kernel_stat.h>
+#include <linux/delay.h>
+#define __KERNEL_SYSCALLS__
+#include <linux/unistd.h>
+#include <linux/init.h>
+#include <linux/spinlock.h>
+
+#include <asm/ptrace.h>
+#include <asm/atomic.h>
+#include <asm/irq.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+#include <asm/hardirq.h>
+#include <asm/softirq.h>
+#include <asm/sections.h>
+#include <asm/io.h>
+#include <asm/prom.h>
+#include <asm/smp.h>
+#include <asm/residual.h>
+#include <asm/feature.h>
+#include <asm/time.h>
+#include <asm/gemini.h>
+
+#include "open_pic.h"
+
+/*
+ * Powersurge (old powermac SMP) support.
+ */
+
+extern void __secondary_start_psurge(void);
+extern void __secondary_start_psurge2(void);	/* Temporary horrible hack */
+extern void __secondary_start_psurge3(void);	/* Temporary horrible hack */
+
+/* Addresses for powersurge registers */
+#define HAMMERHEAD_BASE		0xf8000000
+#define HHEAD_CONFIG		0x90
+#define HHEAD_SEC_INTR		0xc0
+
+/* register for interrupting the primary processor on the powersurge */
+/* N.B. this is actually the ethernet ROM! */
+#define PSURGE_PRI_INTR		0xf3019000
+
+/* register for storing the start address for the secondary processor */
+/* N.B. this is the PCI config space address register for the 1st bridge */
+#define PSURGE_START		0xf2800000
+
+/* Daystar/XLR8 4-CPU card */
+#define PSURGE_QUAD_REG_ADDR	0xf8800000
+
+#define PSURGE_QUAD_IRQ_SET	0
+#define PSURGE_QUAD_IRQ_CLR	1
+#define PSURGE_QUAD_IRQ_PRIMARY	2
+#define PSURGE_QUAD_CKSTOP_CTL	3
+#define PSURGE_QUAD_PRIMARY_ARB	4
+#define PSURGE_QUAD_BOARD_ID	6
+#define PSURGE_QUAD_WHICH_CPU	7
+#define PSURGE_QUAD_CKSTOP_RDBK	8
+#define PSURGE_QUAD_RESET_CTL	11
+
+#define PSURGE_QUAD_OUT(r, v)	(out_8(quad_base + ((r) << 4) + 4, (v)))
+#define PSURGE_QUAD_IN(r)	(in_8(quad_base + ((r) << 4) + 4) & 0x0f)
+#define PSURGE_QUAD_BIS(r, v)	(PSURGE_QUAD_OUT((r), PSURGE_QUAD_IN(r) | (v)))
+#define PSURGE_QUAD_BIC(r, v)	(PSURGE_QUAD_OUT((r), PSURGE_QUAD_IN(r) & ~(v)))
+
+/* virtual addresses for the above */
+static volatile u8 *hhead_base;
+static volatile u8 *quad_base;
+static volatile u32 *psurge_pri_intr;
+static volatile u8 *psurge_sec_intr;
+static volatile u32 *psurge_start;
+
+/* what sort of powersurge board we have */
+static int psurge_type;
+
+/* values for psurge_type */
+#define PSURGE_DUAL		0
+#define PSURGE_QUAD_OKEE	1
+#define PSURGE_QUAD_COTTON	2
+#define PSURGE_QUAD_ICEGRASS	3
+
+/* l2 cache stuff for dual G4 macs */
+extern void core99_init_l2(void);
+
+/*
+ * Set and clear IPIs for powersurge.
+ */
+static inline void psurge_set_ipi(int cpu)
+{
+	if (cpu == 0)
+		in_be32(psurge_pri_intr);
+	else if (psurge_type == PSURGE_DUAL)
+		out_8(psurge_sec_intr, 0);
+	else
+		PSURGE_QUAD_OUT(PSURGE_QUAD_IRQ_SET, 1 << cpu);
+}
+
+static inline void psurge_clr_ipi(int cpu)
+{
+	if (cpu > 0) {
+		if (psurge_type == PSURGE_DUAL)
+			out_8(psurge_sec_intr, ~0);
+		else
+			PSURGE_QUAD_OUT(PSURGE_QUAD_IRQ_CLR, 1 << cpu);
+	}
+}
+
+/*
+ * On powersurge (old SMP powermac architecture) we don't have
+ * separate IPIs for separate messages like openpic does.  Instead
+ * we have a bitmap for each processor, where a 1 bit means that
+ * the corresponding message is pending for that processor.
+ * Ideally each cpu's entry would be in a different cache line.
+ *  -- paulus.
+ */
+static unsigned long psurge_smp_message[NR_CPUS];
+
+void __pmac
+psurge_smp_message_recv(struct pt_regs *regs)
+{
+	int cpu = smp_processor_id();
+	int msg;
+
+	/* clear interrupt */
+	psurge_clr_ipi(cpu);
+
+	if (smp_num_cpus < 2)
+		return;
+
+	/* make sure there is a message there */
+	for (msg = 0; msg < 4; msg++)
+		if (test_and_clear_bit(msg, &psurge_smp_message[cpu]))
+			smp_message_recv(msg, regs);
+}
+
+void __pmac
+psurge_primary_intr(int irq, void *d, struct pt_regs *regs)
+{
+	psurge_smp_message_recv(regs);
+}
+
+static void __pmac
+smp_psurge_message_pass(int target, int msg, unsigned long data, int wait)
+{
+	int i;
+
+	if (smp_num_cpus < 2)
+		return;
+
+	for (i = 0; i < smp_num_cpus; i++) {
+		if (target == MSG_ALL
+		    || (target == MSG_ALL_BUT_SELF && i != smp_processor_id())
+		    || target == i) {
+			set_bit(msg, &psurge_smp_message[i]);
+			psurge_set_ipi(i);
+		}
+	}
+}
+
+/*
+ * Determine a quad card presence. We read the board ID register, we
+ * force the data bus to change to something else, and we read it again.
+ * It it's stable, then the register probably exist (ugh !)
+ */
+static int __init psurge_quad_probe(void)
+{
+	int type;
+	unsigned int i;
+
+	type = PSURGE_QUAD_IN(PSURGE_QUAD_BOARD_ID);
+	if (type < PSURGE_QUAD_OKEE || type > PSURGE_QUAD_ICEGRASS
+	    || type != PSURGE_QUAD_IN(PSURGE_QUAD_BOARD_ID))
+		return PSURGE_DUAL;
+
+	/* looks OK, try a slightly more rigorous test */
+	/* bogus is not necessarily cacheline-aligned,
+	   though I don't suppose that really matters.  -- paulus */
+	for (i = 0; i < 100; i++) {
+		volatile u32 bogus[8];
+		bogus[(0+i)%8] = 0x00000000;
+		bogus[(1+i)%8] = 0x55555555;
+		bogus[(2+i)%8] = 0xFFFFFFFF;
+		bogus[(3+i)%8] = 0xAAAAAAAA;
+		bogus[(4+i)%8] = 0x33333333;
+		bogus[(5+i)%8] = 0xCCCCCCCC;
+		bogus[(6+i)%8] = 0xCCCCCCCC;
+		bogus[(7+i)%8] = 0x33333333;
+		wmb();
+		asm volatile("dcbf 0,%0" : : "r" (bogus) : "memory");
+		mb();
+		if (type != PSURGE_QUAD_IN(PSURGE_QUAD_BOARD_ID))
+			return PSURGE_DUAL;
+	}
+	return type;
+}
+
+static void __init psurge_quad_init(void)
+{
+	int procbits;
+
+	if (ppc_md.progress) ppc_md.progress("psurge_quad_init", 0x351);
+	procbits = ~PSURGE_QUAD_IN(PSURGE_QUAD_WHICH_CPU);
+	if (psurge_type == PSURGE_QUAD_ICEGRASS)
+		PSURGE_QUAD_BIS(PSURGE_QUAD_RESET_CTL, procbits);
+	else
+		PSURGE_QUAD_BIC(PSURGE_QUAD_CKSTOP_CTL, procbits);
+	mdelay(33);
+	out_8(psurge_sec_intr, ~0);
+	PSURGE_QUAD_OUT(PSURGE_QUAD_IRQ_CLR, procbits);
+	PSURGE_QUAD_BIS(PSURGE_QUAD_RESET_CTL, procbits);
+	if (psurge_type != PSURGE_QUAD_ICEGRASS)
+		PSURGE_QUAD_BIS(PSURGE_QUAD_CKSTOP_CTL, procbits);
+	PSURGE_QUAD_BIC(PSURGE_QUAD_PRIMARY_ARB, procbits);
+	mdelay(33);
+	PSURGE_QUAD_BIC(PSURGE_QUAD_RESET_CTL, procbits);
+	mdelay(33);
+	PSURGE_QUAD_BIS(PSURGE_QUAD_PRIMARY_ARB, procbits);
+	mdelay(33);
+}
+
+static int __init smp_psurge_probe(void)
+{
+	int i, ncpus;
+
+	/* We don't do SMP on the PPC601 -- paulus */
+	if (PVR_VER(mfspr(PVR)) == 1)
+		return 1;
+
+	/*
+	 * The powersurge cpu board can be used in the generation
+	 * of powermacs that have a socket for an upgradeable cpu card,
+	 * including the 7500, 8500, 9500, 9600.
+	 * The device tree doesn't tell you if you have 2 cpus because
+	 * OF doesn't know anything about the 2nd processor.
+	 * Instead we look for magic bits in magic registers,
+	 * in the hammerhead memory controller in the case of the
+	 * dual-cpu powersurge board.  -- paulus.
+	 */
+	if (find_devices("hammerhead") == NULL)
+		return 1;
+
+	hhead_base = ioremap(HAMMERHEAD_BASE, 0x800);
+	quad_base = ioremap(PSURGE_QUAD_REG_ADDR, 1024);
+	psurge_sec_intr = hhead_base + HHEAD_SEC_INTR;
+
+	psurge_type = psurge_quad_probe();
+	if (psurge_type != PSURGE_DUAL) {
+		psurge_quad_init();
+		/* All released cards using this HW design have 4 CPUs */
+		ncpus = 4;
+	} else {
+		iounmap((void *) quad_base);
+		if ((in_8(hhead_base + HHEAD_CONFIG) & 0x02) == 0) {
+			/* not a dual-cpu card */
+			iounmap((void *) hhead_base);
+			return 1;
+		}
+		ncpus = 2;
+	}
+
+	psurge_start = ioremap(PSURGE_START, 4);
+	psurge_pri_intr = ioremap(PSURGE_PRI_INTR, 4);
+
+	/* this is not actually strictly necessary -- paulus. */
+	for (i = 1; i < ncpus; ++i)
+		smp_hw_index[i] = i;
+
+	if (ppc_md.progress) ppc_md.progress("smp_psurge_probe - done", 0x352);
+
+	return ncpus;
+}
+
+static void __init smp_psurge_kick_cpu(int nr)
+{
+	void (*start)(void) = __secondary_start_psurge;
+	unsigned long a;
+
+	/* may need to flush here if secondary bats aren't setup */
+	for (a = KERNELBASE; a < KERNELBASE + 0x800000; a += 32)
+		asm volatile("dcbf 0,%0" : : "r" (a) : "memory");
+	asm volatile("sync");
+
+	if (ppc_md.progress) ppc_md.progress("smp_psurge_kick_cpu", 0x353);
+
+	/* setup entry point of secondary processor */
+	switch (nr) {
+	case 2:
+		start = __secondary_start_psurge2;
+		break;
+	case 3:
+		start = __secondary_start_psurge3;
+		break;
+	}
+
+	out_be32(psurge_start, __pa(start));
+	mb();
+
+	psurge_set_ipi(nr);
+	udelay(10);
+	psurge_clr_ipi(nr);
+
+	if (ppc_md.progress) ppc_md.progress("smp_psurge_kick_cpu - done", 0x354);
+}
+
+/*
+ * With the dual-cpu powersurge board, the decrementers and timebases
+ * of both cpus are frozen after the secondary cpu is started up,
+ * until we give the secondary cpu another interrupt.  This routine
+ * uses this to get the timebases synchronized.
+ *  -- paulus.
+ */
+static void __init psurge_dual_sync_tb(int cpu_nr)
+{
+	static volatile int sec_tb_reset = 0;
+	int t;
+
+	set_dec(tb_ticks_per_jiffy);
+	set_tb(0, 0);
+	last_jiffy_stamp(cpu_nr) = 0;
+
+	if (cpu_nr > 0) {
+		mb();
+		sec_tb_reset = 1;
+		return;
+	}
+
+	/* wait for the secondary to have reset its TB before proceeding */
+	for (t = 10000000; t > 0 && !sec_tb_reset; --t)
+		;
+
+	/* now interrupt the secondary, starting both TBs */
+	psurge_set_ipi(1);
+
+	smp_tb_synchronized = 1;
+}
+
+static void __init
+smp_psurge_setup_cpu(int cpu_nr)
+{
+
+	if (cpu_nr == 0) {
+		if (smp_num_cpus < 2)
+			return;
+		/* reset the entry point so if we get another intr we won't
+		 * try to startup again */
+		out_be32(psurge_start, 0x100);
+		if (request_irq(30, psurge_primary_intr, 0, "primary IPI", 0))
+			printk(KERN_ERR "Couldn't get primary IPI interrupt");
+	}
+
+	if (psurge_type == PSURGE_DUAL)
+		psurge_dual_sync_tb(cpu_nr);
+}
+
+static int __init
+smp_core99_probe(void)
+{
+	struct device_node *cpus;
+	int i, ncpus = 1;
+
+	if (ppc_md.progress) ppc_md.progress("smp_core99_probe", 0x345);
+	cpus = find_type_devices("cpu");
+	if (cpus)
+		while ((cpus = cpus->next) != NULL)
+			++ncpus;
+	printk("smp_core99_probe: found %d cpus\n", ncpus);
+	if (ncpus > 1) {
+		openpic_request_IPIs();
+		for (i = 1; i < ncpus; ++i)
+			smp_hw_index[i] = i;
+	}
+
+	return ncpus;
+}
+
+static void __init
+smp_core99_kick_cpu(int nr)
+{
+	unsigned long save_vector, new_vector;
+	unsigned long flags;
+#if 1 /* New way... */
+	volatile unsigned long *vector
+		 = ((volatile unsigned long *)(KERNELBASE+0x100));
+	if (nr < 1 || nr > 3)
+		return;
+#else
+	volatile unsigned long *vector
+		 = ((volatile unsigned long *)(KERNELBASE+0x500));
+	if (nr != 1)
+		return;
+#endif
+	if (ppc_md.progress) ppc_md.progress("smp_core99_kick_cpu", 0x346);
+
+	local_irq_save(flags);
+	local_irq_disable();
+	
+	/* Save reset vector */
+	save_vector = *vector;
+	
+	/* Setup fake reset vector that does	  
+	 *   b __secondary_start_psurge - KERNELBASE
+	 */  
+	switch(nr) {
+		case 1:
+			new_vector = (unsigned long)__secondary_start_psurge;
+			break;
+		case 2:
+			new_vector = (unsigned long)__secondary_start_psurge2;
+			break;
+		case 3:
+			new_vector = (unsigned long)__secondary_start_psurge3;
+			break;
+	}
+	*vector = 0x48000002 + new_vector - KERNELBASE;
+	
+	/* flush data cache and inval instruction cache */
+	flush_icache_range((unsigned long) vector, (unsigned long) vector + 4);
+	
+	/* Put some life in our friend */
+	feature_core99_kick_cpu(nr);
+	
+	/* FIXME: We wait a bit for the CPU to take the exception, I should
+	 * instead wait for the entry code to set something for me. Well,
+	 * ideally, all that crap will be done in prom.c and the CPU left
+	 * in a RAM-based wait loop like CHRP.
+	 */
+	mdelay(1);
+	
+	/* Restore our exception vector */
+	*vector = save_vector;
+	flush_icache_range((unsigned long) vector, (unsigned long) vector + 4);
+	
+	local_irq_restore(flags);
+	if (ppc_md.progress) ppc_md.progress("smp_core99_kick_cpu done", 0x347);
+}
+
+static void __init
+smp_core99_setup_cpu(int cpu_nr)
+{
+	/* Setup openpic */
+	do_openpic_setup_cpu();
+
+	/* Setup L2 */
+	if (cpu_nr != 0)
+		core99_init_l2();
+	else
+		if (ppc_md.progress) ppc_md.progress("core99_setup_cpu 0 done", 0x349);
+}
+
+/* PowerSurge-style Macs */
+struct smp_ops_t psurge_smp_ops __pmacdata = {
+	smp_psurge_message_pass,
+	smp_psurge_probe,
+	smp_psurge_kick_cpu,
+	smp_psurge_setup_cpu,
+};
+
+/* Core99 Macs (dual G4s) */
+struct smp_ops_t core99_smp_ops __pmacdata = {
+	smp_openpic_message_pass,
+	smp_core99_probe,
+	smp_core99_kick_cpu,
+	smp_core99_setup_cpu,
+};
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/pmac_time.c linux/arch/ppc/kernel/pmac_time.c
--- v2.4.9/linux/arch/ppc/kernel/pmac_time.c	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/kernel/pmac_time.c	Sat Sep  8 12:38:42 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.pmac_time.c 1.11 07/06/01 15:46:39 trini
+ * BK Id: SCCS/s.pmac_time.c 1.16 09/08/01 15:47:42 paulus
  */
 /*
  * Support for periodic interrupts (100 per second) and for getting
@@ -22,7 +22,7 @@
 #include <linux/cuda.h>
 #include <linux/pmu.h>
 
-#include <asm/init.h>
+#include <asm/sections.h>
 #include <asm/prom.h>
 #include <asm/system.h>
 #include <asm/io.h>
@@ -260,8 +260,13 @@
 	pmu_register_sleep_notifier(&time_sleep_notifier);
 #endif /* CONFIG_PMAC_PBOOK */
 
-	if (via_calibrate_decr())
-		return;
+	/* We assume MacRISC2 machines have correct device-tree
+	 * calibration. That's better since the VIA itself seems
+	 * to be slightly off. --BenH
+	 */
+	if (!machine_is_compatible("MacRISC2"))
+		if (via_calibrate_decr())
+			return;
 
 	/*
 	 * The cpu node should have a timebase-frequency property
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/ppc_asm.h linux/arch/ppc/kernel/ppc_asm.h
--- v2.4.9/linux/arch/ppc/kernel/ppc_asm.h	Wed Jul 25 17:10:18 2001
+++ linux/arch/ppc/kernel/ppc_asm.h	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.ppc_asm.h 1.14 07/02/01 22:08:05 paulus
+ * BK Id: SCCS/s.ppc_asm.h 1.16 08/15/01 22:43:06 paulus
  */
 /*
  * arch/ppc/kernel/ppc_asm.h
@@ -70,20 +70,35 @@
 #define REST_32VR(n,b,base)	REST_16VR(n,b,base); REST_16VR(n+16,b,base)
 
 #ifdef CONFIG_PPC601_SYNC_FIX
-#define SYNC \
-	sync; \
-	isync
+#define SYNC				\
+BEGIN_FTR_SECTION			\
+	sync;				\
+	isync;				\
+END_FTR_SECTION_IFSET(CPU_FTR_601)
+#define SYNC_601			\
+BEGIN_FTR_SECTION			\
+	sync;				\
+END_FTR_SECTION_IFSET(CPU_FTR_601)
+#define ISYNC_601			\
+BEGIN_FTR_SECTION			\
+	isync;				\
+END_FTR_SECTION_IFSET(CPU_FTR_601)
 #else
 #define	SYNC
+#define SYNC_601
+#define ISYNC_601
 #endif
 
 #ifndef CONFIG_SMP
 #define TLBSYNC
 #else /* CONFIG_SMP */
+/* tlbsync is not implemented on 601 */
 #define TLBSYNC				\
+BEGIN_FTR_SECTION			\
 	tlbsync;			\
-	sync
-#endif /* CONFIG_SMP */
+	sync;				\
+END_FTR_SECTION_IFCLR(CPU_FTR_601)
+#endif
 
 /*
  * This instruction is not implemented on the PPC 603 or 601; however, on
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/ppc_htab.c linux/arch/ppc/kernel/ppc_htab.c
--- v2.4.9/linux/arch/ppc/kernel/ppc_htab.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/ppc/kernel/ppc_htab.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.ppc_htab.c 1.11 06/28/01 15:50:16 paulus
+ * BK Id: SCCS/s.ppc_htab.c 1.17 08/20/01 22:59:41 paulus
  */
 /*
  * PowerPC hash table management proc entry.  Will show information
@@ -20,6 +20,7 @@
 #include <linux/stat.h>
 #include <linux/sysctl.h>
 #include <linux/ctype.h>
+#include <linux/threads.h>
 
 #include <asm/uaccess.h>
 #include <asm/bitops.h>
@@ -28,6 +29,8 @@
 #include <asm/residual.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
+#include <asm/cputable.h>
+#include <asm/system.h>
 
 static ssize_t ppc_htab_read(struct file * file, char * buf,
 			     size_t count, loff_t *ppos);
@@ -67,7 +70,7 @@
         write:          ppc_htab_write,
 };
 
-char *pmc1_lookup(unsigned long mmcr0)
+static char *pmc1_lookup(unsigned long mmcr0)
 {
 	switch ( mmcr0 & (0x7f<<7) )
 	{
@@ -84,7 +87,7 @@
 	}
 }	
 
-char *pmc2_lookup(unsigned long mmcr0)
+static char *pmc2_lookup(unsigned long mmcr0)
 {
 	switch ( mmcr0 & 0x3f )
 	{
@@ -121,11 +124,7 @@
 	if (count < 0)
 		return -EINVAL;
 
-	switch ( _get_PVR()>>16 )
-	{
-	case 4:  /* 604 */
-	case 9:  /* 604e */
-	case 10: /* 604ev5 */
+	if (cur_cpu_spec[0]->cpu_features & CPU_FTR_604_PERF_MON) {
 		asm volatile ("mfspr %0,952 \n\t"
 		    "mfspr %1,953 \n\t"
 		    "mfspr %2,954 \n\t"
@@ -141,12 +140,9 @@
 			      "PMC2\t\t: %08lx (%s)\n",
 			      pmc1, pmc1_lookup(mmcr0),
 			      pmc2, pmc2_lookup(mmcr0));
-		break;
-	default:
-		break;
 	}
 
-	
+#ifdef CONFIG_PPC_STD_MMU
 	/* if we don't have a htab */
 	if ( Hash_size == 0 )
 	{
@@ -154,7 +150,6 @@
 		goto return_string;
 	}
 
-#if !defined(CONFIG_8xx) && !defined(CONFIG_4xx)
 	for ( ptr = Hash ; ptr < Hash_end ; ptr++)
 	{
 		unsigned int ctx, mctx, vsid;
@@ -211,7 +206,7 @@
 		      "Evicts\t\t: %lu\n",
 		      htab_reloads, htab_preloads, htab_hash_searches,
 		      primary_pteg_full, htab_evicts);
-#endif /* !8xx && !4xx */
+#endif /* CONFIG_PPC_STD_MMU */
 	
 return_string:
 	n += sprintf( buffer + n,
@@ -235,7 +230,7 @@
 static ssize_t ppc_htab_write(struct file * file, const char * buffer,
 			      size_t count, loff_t *ppos)
 {
-#ifndef CONFIG_8xx
+#ifdef CONFIG_PPC_STD_MMU
 	unsigned long tmp;
 	if ( current->uid != 0 )
 		return -EACCES;
@@ -246,37 +241,22 @@
 	/* turn off performance monitoring */
 	if ( !strncmp( buffer, "off", 3) )
 	{
-		switch ( _get_PVR()>>16 )
-		{
-		case 4:  /* 604 */
-		case 9:  /* 604e */
-		case 10: /* 604ev5 */
+		if (cur_cpu_spec[0]->cpu_features & CPU_FTR_604_PERF_MON) {
 			asm volatile ("mtspr %0, %3 \n\t"
 			    "mtspr %1, %3 \n\t"
 			    "mtspr %2, %3 \n\t"			    
 			    :: "i" (MMCR0), "i" (PMC1), "i" (PMC2), "r" (0));
-			break;
-		default:
-			break;
 		}
-			
 	}
 
 	if ( !strncmp( buffer, "reset", 5) )
 	{
-		switch ( _get_PVR()>>16 )
-		{
-		case 4:  /* 604 */
-		case 9:  /* 604e */
-		case 10: /* 604ev5 */
+		if (cur_cpu_spec[0]->cpu_features & CPU_FTR_604_PERF_MON) {
 			/* reset PMC1 and PMC2 */
 			asm volatile (
 				"mtspr 953, %0 \n\t"
 				"mtspr 954, %0 \n\t"
 				:: "r" (0));
-			break;
-		default:
-			break;
 		}
 		htab_reloads = 0;
 		htab_evicts = 0;
@@ -286,11 +266,7 @@
 
 	if ( !strncmp( buffer, "user", 4) )
 	{
-		switch ( _get_PVR()>>16 )
-		{
-		case 4:  /* 604 */
-		case 9:  /* 604e */
-		case 10: /* 604ev5 */
+		if (cur_cpu_spec[0]->cpu_features & CPU_FTR_604_PERF_MON) {
 			/* setup mmcr0 and clear the correct pmc */
 			asm("mfspr %0,%1\n\t"  : "=r" (tmp) : "i" (MMCR0));
 			tmp &= ~(0x60000000);
@@ -301,19 +277,12 @@
 				"mtspr %5,%4 \n\t"    /* reset the pmc2 */
 				:: "r" (tmp), "i" (MMCR0), "i" (0),
 				"i" (PMC1),  "r" (0), "i"(PMC2) );
-			break;
-		default:
-			break;
 		}
 	}
 
 	if ( !strncmp( buffer, "kernel", 6) )
 	{
-		switch ( _get_PVR()>>16 )
-		{
-		case 4:  /* 604 */
-		case 9:  /* 604e */
-		case 10: /* 604ev5 */
+		if (cur_cpu_spec[0]->cpu_features & CPU_FTR_604_PERF_MON) {
 			/* setup mmcr0 and clear the correct pmc */
 			asm("mfspr %0,%1\n\t"  : "=r" (tmp) : "i" (MMCR0));
 			tmp &= ~(0x60000000);
@@ -324,20 +293,13 @@
 				"mtspr %5,%4 \n\t"    /* reset the pmc2 */
 				:: "r" (tmp), "i" (MMCR0), "i" (0),
 				"i" (PMC1),  "r" (0), "i"(PMC2) );
-			break;
-		default:
-			break;
 		}
 	}
 	
 	/* PMC1 values */
 	if ( !strncmp( buffer, "dtlb", 4) )
 	{
-		switch ( _get_PVR()>>16 )
-		{
-		case 4:  /* 604 */
-		case 9:  /* 604e */
-		case 10: /* 604ev5 */
+		if (cur_cpu_spec[0]->cpu_features & CPU_FTR_604_PERF_MON) {
 			/* setup mmcr0 and clear the correct pmc */
 			asm("mfspr %0,%1\n\t"  : "=r" (tmp) : "i" (MMCR0));
 			tmp &= ~(0x7f<<7);
@@ -352,11 +314,7 @@
 
 	if ( !strncmp( buffer, "ic miss", 7) )
 	{
-		switch ( _get_PVR()>>16 )
-		{
-		case 4:  /* 604 */
-		case 9:  /* 604e */
-		case 10: /* 604ev5 */
+		if (cur_cpu_spec[0]->cpu_features & CPU_FTR_604_PERF_MON) {
 			/* setup mmcr0 and clear the correct pmc */
 			asm("mfspr %0,%1\n\t"  : "=r" (tmp) : "i" (MMCR0));
 			tmp &= ~(0x7f<<7);
@@ -372,11 +330,7 @@
 	/* PMC2 values */
 	if ( !strncmp( buffer, "load miss time", 14) )
 	{
-		switch ( _get_PVR()>>16 )
-		{
-		case 4:  /* 604 */
-		case 9:  /* 604e */
-		case 10: /* 604ev5 */
+		if (cur_cpu_spec[0]->cpu_features & CPU_FTR_604_PERF_MON) {
 			/* setup mmcr0 and clear the correct pmc */
 		       asm volatile(
 			       "mfspr %0,%1\n\t"     /* get current mccr0 */
@@ -392,11 +346,7 @@
 	
 	if ( !strncmp( buffer, "itlb", 4) )
 	{
-		switch ( _get_PVR()>>16 )
-		{
-		case 4:  /* 604 */
-		case 9:  /* 604e */
-		case 10: /* 604ev5 */
+		if (cur_cpu_spec[0]->cpu_features & CPU_FTR_604_PERF_MON) {
 			/* setup mmcr0 and clear the correct pmc */
 		       asm volatile(
 			       "mfspr %0,%1\n\t"     /* get current mccr0 */
@@ -412,11 +362,7 @@
 
 	if ( !strncmp( buffer, "dc miss", 7) )
 	{
-		switch ( _get_PVR()>>16 )
-		{
-		case 4:  /* 604 */
-		case 9:  /* 604e */
-		case 10: /* 604ev5 */
+		if (cur_cpu_spec[0]->cpu_features & CPU_FTR_604_PERF_MON) {
 			/* setup mmcr0 and clear the correct pmc */
 		       asm volatile(
 			       "mfspr %0,%1\n\t"     /* get current mccr0 */
@@ -472,9 +418,9 @@
 	reset_SDR1();
 #endif	
 	return count;
-#else /* CONFIG_8xx */
+#else /* CONFIG_PPC_STD_MMU */
 	return 0;
-#endif /* CONFIG_8xx */
+#endif /* CONFIG_PPC_STD_MMU */
 }
 
 
@@ -516,7 +462,7 @@
 		"0.5", "1.0", "(reserved2)", "(reserved3)"
 	};
 
-	if ( ((_get_PVR() >> 16) != 8) && ((_get_PVR() >> 16) != 12))
+	if (!(cur_cpu_spec[0]->cpu_features & CPU_FTR_L2CR))
 		return -EFAULT;
 	
 	if ( /*!table->maxlen ||*/ (filp->f_pos && !write)) {
@@ -526,7 +472,7 @@
 	
 	vleft = table->maxlen / sizeof(int);
 	left = *lenp;
-	
+
 	for (; left /*&& vleft--*/; first=0) {
 		if (write) {
 			while (left) {
@@ -556,7 +502,6 @@
 			buffer += len;
 			left -= len;
 			_set_L2CR(val);
-			  
 		} else {
 			p = buf;
 			if (!first)
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/ppc_ksyms.c linux/arch/ppc/kernel/ppc_ksyms.c
--- v2.4.9/linux/arch/ppc/kernel/ppc_ksyms.c	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/kernel/ppc_ksyms.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.ppc_ksyms.c 1.38 07/23/01 15:35:53 trini
+ * BK Id: SCCS/s.ppc_ksyms.c 1.51 08/24/01 17:05:47 paulus
  */
 #include <linux/config.h>
 #include <linux/module.h>
@@ -48,6 +48,8 @@
 #include <asm/smp.h>
 #endif /* CONFIG_SMP */
 #include <asm/time.h>
+#include <asm/cputable.h>
+#include <asm/btext.h>
 
 #ifdef  CONFIG_8xx
 #include "../8xx_io/commproc.h"
@@ -73,6 +75,8 @@
 int abs(int);
 extern unsigned long ret_to_user_hook;
 
+extern unsigned long mm_ptov (unsigned long paddr);
+
 EXPORT_SYMBOL(clear_page);
 EXPORT_SYMBOL(do_signal);
 EXPORT_SYMBOL(syscall_trace);
@@ -157,16 +161,10 @@
 EXPORT_SYMBOL(ioremap);
 EXPORT_SYMBOL(__ioremap);
 EXPORT_SYMBOL(iounmap);
+EXPORT_SYMBOL(iopa);
+EXPORT_SYMBOL(mm_ptov);
 
-EXPORT_SYMBOL(ide_insw);
-EXPORT_SYMBOL(ide_outsw);
 EXPORT_SYMBOL(ppc_ide_md);
-#ifdef CONFIG_BLK_DEV_IDE_MODULE
-EXPORT_SYMBOL(chrp_ide_irq);
-EXPORT_SYMBOL(chrp_ide_ports_known);
-EXPORT_SYMBOL(chrp_ide_regbase);
-EXPORT_SYMBOL(chrp_ide_probe);
-#endif
 
 #ifdef CONFIG_PCI
 EXPORT_SYMBOL_NOVERS(isa_io_base);
@@ -183,10 +181,10 @@
 /*EXPORT_SYMBOL(_disable_interrupts);
   EXPORT_SYMBOL(_enable_interrupts);*/
 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(flush_dcache_range);
 EXPORT_SYMBOL(xchg_u32);
 #ifdef CONFIG_ALTIVEC
 EXPORT_SYMBOL(last_task_used_altivec);
@@ -200,6 +198,7 @@
 EXPORT_SYMBOL(__global_sti);
 EXPORT_SYMBOL(__global_save_flags);
 EXPORT_SYMBOL(__global_restore_flags);
+#ifdef SPINLOCK_DEBUG
 EXPORT_SYMBOL(_spin_lock);
 EXPORT_SYMBOL(_spin_unlock);
 EXPORT_SYMBOL(spin_trylock);
@@ -207,6 +206,7 @@
 EXPORT_SYMBOL(_read_unlock);
 EXPORT_SYMBOL(_write_lock);
 EXPORT_SYMBOL(_write_unlock);
+#endif
 EXPORT_SYMBOL(smp_call_function);
 EXPORT_SYMBOL(smp_hw_index);
 EXPORT_SYMBOL(smp_num_cpus);
@@ -226,17 +226,6 @@
 EXPORT_SYMBOL(cuda_request);
 EXPORT_SYMBOL(cuda_poll);
 #endif /* CONFIG_ADB_CUDA */
-#ifdef CONFIG_ADB_PMU
-EXPORT_SYMBOL(pmu_request);
-EXPORT_SYMBOL(pmu_poll);
-EXPORT_SYMBOL(pmu_suspend);
-EXPORT_SYMBOL(pmu_resume);
-#endif /* CONFIG_ADB_PMU */
-#ifdef CONFIG_PMAC_PBOOK
-EXPORT_SYMBOL(pmu_register_sleep_notifier);
-EXPORT_SYMBOL(pmu_unregister_sleep_notifier);
-EXPORT_SYMBOL(pmu_enable_irled);
-#endif /* CONFIG_PMAC_PBOOK */
 #ifdef CONFIG_PMAC_BACKLIGHT
 EXPORT_SYMBOL(get_backlight_level);
 EXPORT_SYMBOL(set_backlight_level);
@@ -245,7 +234,6 @@
 #endif /* CONFIG_PMAC_BACKLIGHT */
 #if defined(CONFIG_ALL_PPC)
 EXPORT_SYMBOL(_machine);
-EXPORT_SYMBOL_NOVERS(have_of);
 EXPORT_SYMBOL_NOVERS(sys_ctrler);
 EXPORT_SYMBOL(find_devices);
 EXPORT_SYMBOL(find_type_devices);
@@ -273,10 +261,11 @@
 EXPORT_SYMBOL(feature_set_usb_power);
 EXPORT_SYMBOL(feature_set_firewire_power);
 EXPORT_SYMBOL(feature_set_firewire_cable_power);
+EXPORT_SYMBOL(feature_set_modem_power);
 EXPORT_SYMBOL(feature_set_airport_power);
 #endif /* defined(CONFIG_ALL_PPC) */
 #if defined(CONFIG_BOOTX_TEXT)
-EXPORT_SYMBOL(bootx_update_display);
+EXPORT_SYMBOL(btext_update_display);
 #endif
 #if defined(CONFIG_SCSI) && defined(CONFIG_ALL_PPC)
 EXPORT_SYMBOL(note_scsi_host);
@@ -303,7 +292,7 @@
 
 EXPORT_SYMBOL(abs);
 
-#ifdef CONFIG_VT
+#ifdef CONFIG_VGA_CONSOLE
 EXPORT_SYMBOL(screen_info);
 #endif
 
@@ -367,3 +356,4 @@
 #endif
 extern long *ret_from_intercept;
 EXPORT_SYMBOL(ret_from_intercept);
+EXPORT_SYMBOL(cur_cpu_spec);
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/prep_nvram.c linux/arch/ppc/kernel/prep_nvram.c
--- v2.4.9/linux/arch/ppc/kernel/prep_nvram.c	Mon May 21 17:04:47 2001
+++ linux/arch/ppc/kernel/prep_nvram.c	Sat Sep  8 12:38:42 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.prep_nvram.c 1.9 05/17/01 18:14:22 cort
+ * BK Id: SCCS/s.prep_nvram.c 1.12 09/08/01 15:47:42 paulus
  */
 /*
  *  linux/arch/ppc/kernel/prep_nvram.c
@@ -12,7 +12,7 @@
 #include <linux/slab.h>
 #include <linux/ioport.h>
 
-#include <asm/init.h>
+#include <asm/sections.h>
 #include <asm/segment.h>
 #include <asm/io.h>
 #include <asm/processor.h>
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/prep_pci.c linux/arch/ppc/kernel/prep_pci.c
--- v2.4.9/linux/arch/ppc/kernel/prep_pci.c	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/kernel/prep_pci.c	Sat Sep  8 12:38:42 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.prep_pci.c 1.22 08/05/01 16:18:54 trini
+ * BK Id: SCCS/s.prep_pci.c 1.26 09/08/01 15:47:42 paulus
  */
 /*
  * PReP pci functions.
@@ -15,7 +15,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 
-#include <asm/init.h>
+#include <asm/sections.h>
 #include <asm/byteorder.h>
 #include <asm/io.h>
 #include <asm/ptrace.h>
@@ -172,7 +172,7 @@
 	0,	/* Slot 7  - unused */
 	0,	/* Slot 8  - unused */
 	0,	/* Slot 9  - unused */
-	0,	/* Slot 10 - unxued */
+	0,	/* Slot 10 - unused */
 	0,	/* Slot 11 - unused */
 	0,	/* Slot 12 - unused */
 	0,	/* Slot 13 - unused */
@@ -200,7 +200,7 @@
 	0,      /* Slot 7  - unused */
 	0,      /* Slot 8  - unused */
 	0,      /* Slot 9  - unused */
-	0,      /* Slot 10 - unxued */
+	0,      /* Slot 10 - unused */
 	0,      /* Slot 11 - unused */
 	0,      /* Slot 12 - unused */
 	0,      /* Slot 13 - unused */
@@ -322,8 +322,8 @@
 	3,	/* Slot 12 - unused */
 	0,	/* Slot 13 - unused */
 	2,	/* Slot 14 - SCSI */
-	0,	/* Slot 15 - graphics on 3600 */
-	9,	/* Slot 16 - PMC */
+	0,	/* Slot 15 - unused */
+	9,	/* Slot 16 - PMC 1 */
 	12,	/* Slot 17 - pci */
 	11,	/* Slot 18 - pci */
 	10,	/* Slot 19 - pci */
@@ -511,6 +511,44 @@
         13      /* Line 4 */
 };
 
+/*
+ * IBM RS/6000 43p/140  -- paulus
+ * XXX we should get all this from the residual data
+ */
+static char ibm43p_pci_IRQ_map[23] __prepdata = {
+        0, /* Slot 0  - unused */
+        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 - FireCoral ISA bridge */
+        6, /* Slot 12 - Ethernet  */
+        0, /* Slot 13 - openpic */
+        0, /* Slot 14 - unused */
+        0, /* Slot 15 - unused */
+        7, /* Slot 16 - NCR58C825a onboard scsi */
+        0, /* Slot 17 - unused */
+        2, /* Slot 18 - PCI Slot 2 PCIINTx# (See below) */
+        0, /* Slot 19 - unused */
+        0, /* Slot 20 - unused */
+        0, /* Slot 21 - unused */
+        1, /* Slot 22 - PCI slot 1 PCIINTx# (See below) */
+};
+
+static char ibm43p_pci_IRQ_routes[] __prepdata = {
+        0,      /* Line 0 - unused */
+        15,     /* Line 1 */
+        15,     /* Line 2 */
+        15,     /* Line 3 */
+        15,     /* Line 4 */
+};
+
 /* Motorola PowerPlus architecture PCI IRQ tables */
 /* Interrupt line values for INTA-D on primary/secondary MPIC inputs */
 
@@ -767,7 +805,52 @@
 	{0x000, 0x00, 0x00, "",					NULL,			NULL, NULL, NULL, 0x00}
 };
 
-unsigned long __init prep_route_pci_interrupts(void)
+void ibm_prep_init(void)
+{
+	u32 addr;
+#ifdef CONFIG_PREP_RESIDUAL
+	PPC_DEVICE *mpic;
+#endif
+
+	if (inb(0x0852) == 0xd5) {
+		/* This is for the 43p-140 */
+		early_read_config_dword(0, 0, PCI_DEVFN(13, 0),
+					PCI_BASE_ADDRESS_0, &addr);
+		if (addr != 0xffffffff
+		    && !(addr & PCI_BASE_ADDRESS_SPACE_IO)
+		    && (addr &= PCI_BASE_ADDRESS_MEM_MASK) != 0) {
+			addr += PREP_ISA_MEM_BASE;
+			OpenPIC_Addr = ioremap(addr, 0x40000);
+			ppc_md.get_irq = openpic_get_irq;
+		}
+	}
+
+#ifdef CONFIG_PREP_RESIDUAL
+	mpic = residual_find_device(-1, NULL, SystemPeripheral,
+				    ProgrammableInterruptController, MPIC, 0);
+	if (mpic != NULL) {
+		printk("mpic = %p\n", mpic);
+	}
+#endif
+}
+
+void
+ibm43p_pci_map_non0(struct pci_dev *dev)
+{
+	unsigned char intpin;
+	static unsigned char bridge_intrs[4] = { 3, 4, 5, 8 };
+
+	if (dev == NULL)
+		return;
+	pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &intpin);
+	if (intpin < 1 || intpin > 4)
+		return;
+	intpin = (PCI_SLOT(dev->devfn) + intpin - 1) & 3;
+	dev->irq = openpic_to_irq(bridge_intrs[intpin]);
+	pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
+}
+
+void __init prep_route_pci_interrupts(void)
 {
 	unsigned char *ibc_pirq = (unsigned char *)0x80800860;
 	unsigned char *ibc_pcicon = (unsigned char *)0x80800840;
@@ -856,7 +939,13 @@
 			Motherboard_map_name = "IBM 6015";
 			Motherboard_map = ibm6015_pci_IRQ_map;
 			Motherboard_routes = ibm6015_pci_IRQ_routes;
-			break;			
+			break;
+		case 0xd5:
+			Motherboard_map_name = "IBM 43p/140";
+			Motherboard_map = ibm43p_pci_IRQ_map;
+			Motherboard_routes = ibm43p_pci_IRQ_routes;
+			Motherboard_non0 = ibm43p_pci_map_non0;
+			break;
 		default:
 			Motherboard_map_name = "IBM 8xx (Carolina)";
 			Motherboard_map = ibm8xx_pci_IRQ_map;
@@ -878,7 +967,7 @@
 	else
 	{
 		printk("No known machine pci routing!\n");
-		return -1;
+		return;
 	}
 	
 	/* Set up mapping from slots */
@@ -888,16 +977,15 @@
 	}
 	/* Enable PCI interrupts */
 	*ibc_pcicon |= 0x20;
-	return 0;
 }
 
 void __init
 prep_pib_init(void)
 {
-unsigned char   reg;
-unsigned short  short_reg;
+	unsigned char   reg;
+	unsigned short  short_reg;
 
-struct pci_dev *dev = NULL;
+	struct pci_dev *dev = NULL;
 
 	if (( _prep_type == _PREP_Motorola) && (OpenPIC_Addr)) {
 		/*
@@ -910,43 +998,47 @@
 			 * PPCBUG does not set the enable bits
 			 * for the IDE device. Force them on here.
 			 */
-			pcibios_read_config_byte(dev->bus->number, 
-					dev->devfn, 0x40, &reg);
+			pci_read_config_byte(dev, 0x40, &reg);
 
 			reg |= 0x03; /* IDE: Chip Enable Bits */
-			pcibios_write_config_byte(dev->bus->number, 
-					dev->devfn, 0x40, reg);
-
-			/* Force correct IDE function interrupt */
-			dev->irq = 14;
-			pcibios_write_config_byte(dev->bus->number,
-					dev->devfn,
+			pci_write_config_byte(dev, 0x40, reg);
+		}
+		if ((dev = pci_find_device(PCI_VENDOR_ID_VIA,
+						PCI_DEVICE_ID_VIA_82C586_2,
+						dev)) && (dev->devfn = 0x5a)) {
+			/* Force correct USB interrupt */
+			dev->irq = 11;
+			pci_write_config_byte(dev,
 					PCI_INTERRUPT_LINE,
 					dev->irq);
-
-		} else if ((dev = pci_find_device(PCI_VENDOR_ID_WINBOND, 
+		}
+		if ((dev = pci_find_device(PCI_VENDOR_ID_WINBOND,
 					PCI_DEVICE_ID_WINBOND_83C553, dev))) {
-			/*
-			 * Clear the PCI Interrupt Routing Control Register.
-			 */
+			 /* Clear PCI Interrupt Routing Control Register. */
 			short_reg = 0x0000;
 			pci_write_config_word(dev, 0x44, short_reg);
 			if (OpenPIC_Addr){
-				/*
-				 * Route both IDE interrupts to IRQ 14
-				 */
+				/* Route IDE interrupts to IRQ 14 */
 				reg = 0xEE;
-				pci_write_config_byte(dev, 0x44, reg);
+				pci_write_config_byte(dev, 0x43, reg);
 			}
 		}
 	}
+
 	if ((dev = pci_find_device(PCI_VENDOR_ID_WINBOND,
 				   PCI_DEVICE_ID_WINBOND_82C105, dev))){
 		if (OpenPIC_Addr){
-			/* Disable LEGIRQ mode so PCI INTs are routed to
-			   the 8259 */
-			printk("Set winbond IDE to native mode\n");
-			pci_write_config_dword(dev, 0x40, 0x10ff00a1);
+			/*
+			 * Disable LEGIRQ mode so PCI INTS are routed
+			 * directly to the 8259 and enable both channels
+			 */
+			pci_write_config_dword(dev, 0x40, 0x10ff0033);
+
+			/* Force correct IDE interrupt */
+			dev->irq = 14;
+			pci_write_config_byte(dev,
+					PCI_INTERRUPT_LINE,
+					dev->irq);
 		}else{
 			/* Enable LEGIRQ for PCI INT -> 8259 IRQ routing */
 			pci_write_config_dword(dev, 0x40, 0x10ff08a1);
@@ -1106,6 +1198,19 @@
 	}
 }
 
+static void __init
+prep_init_resource(struct resource *res, unsigned long start,
+		   unsigned long end, int flags)
+{
+	res->flags = flags;
+	res->start = start;
+	res->end = end;
+	res->name = "PCI host bridge";
+	res->parent = NULL;
+	res->sibling = NULL;
+	res->child = NULL;
+}
+
 void __init
 prep_find_bridges(void)
 {
@@ -1119,6 +1224,9 @@
 	hose->last_busno = 0xff;
 	hose->pci_mem_offset = PREP_ISA_MEM_BASE;
 	hose->io_base_virt = (void *)PREP_ISA_IO_BASE;
+	prep_init_resource(&hose->io_resource, 0, 0x0fffffff, IORESOURCE_IO);
+	prep_init_resource(&hose->mem_resources[0], 0xc0000000, 0xfeffffff,
+			   IORESOURCE_MEM);
 	
 	printk("PReP architecture\n");
 	{
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/prep_setup.c linux/arch/ppc/kernel/prep_setup.c
--- v2.4.9/linux/arch/ppc/kernel/prep_setup.c	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/kernel/prep_setup.c	Sat Sep  8 12:38:42 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.prep_setup.c 1.26 08/05/01 16:18:54 trini
+ * BK Id: SCCS/s.prep_setup.c 1.36 09/08/01 15:47:42 paulus
  */
 /*
  *  linux/arch/ppc/kernel/setup.c
@@ -7,6 +7,9 @@
  *  Copyright (C) 1995  Linus Torvalds
  *  Adapted from 'alpha' version by Gary Thomas
  *  Modified by Cort Dougan (cort@cs.nmt.edu)
+ *
+ * Support for PReP (Motorola MTX/MVME)
+ * by Troy Benjegerdes (hozer@drgw.net)
  */
 
 /*
@@ -38,7 +41,7 @@
 #include <linux/pci.h>
 #include <linux/ide.h>
 
-#include <asm/init.h>
+#include <asm/sections.h>
 #include <asm/mmu.h>
 #include <asm/processor.h>
 #include <asm/residual.h>
@@ -78,6 +81,7 @@
 extern unsigned char rs_nvram_read_val(int addr);
 extern void rs_nvram_write_val(int addr,
 				 unsigned char val);
+extern void ibm_prep_init(void);
 
 extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode);
 extern int pckbd_getkeycode(unsigned int scancode);
@@ -329,13 +333,20 @@
 
 	/*print_residual_device_info();*/
 
-	raven_init();
+	switch (_prep_type) {
+	case _PREP_Motorola:
+		raven_init();
+		break;
+	case _PREP_IBM:
+		ibm_prep_init();
+		break;
+	}
 
 #ifdef CONFIG_VGA_CONSOLE
 	/* remap the VGA memory */
 	vgacon_remap_base = 0xf0000000;
 	/*vgacon_remap_base = ioremap(0xc0000000, 0xba000);*/
-        conswitchp = &vga_con;
+	conswitchp = &vga_con;
 #elif defined(CONFIG_DUMMY_CONSOLE)
 	conswitchp = &dummy_con;
 #endif
@@ -662,23 +673,6 @@
 	}
 }
 
-#if 0
-void __prep
-prep_do_IRQ(struct pt_regs *regs, int cpu)
-{
-        int irq;
-
-	if ( (irq = i8259_irq(0)) < 0 )
-	{
-		printk(KERN_DEBUG "Bogus interrupt from PC = %lx\n",
-		       regs->nip);
-		ppc_spurious_interrupts++;
-		return;
-	}
-        ppc_irq_dispatch_handler( regs, irq );
-}
-#endif
-
 int __prep
 prep_get_irq(struct pt_regs *regs)
 {
@@ -701,18 +695,6 @@
 /*
  * IDE stuff.
  */
-void __prep
-prep_ide_insw(ide_ioreg_t port, void *buf, int ns)
-{
-	_insw((unsigned short *)((port)+_IO_BASE), buf, ns);
-}
-
-void __prep
-prep_ide_outsw(ide_ioreg_t port, void *buf, int ns)
-{
-	_outsw((unsigned short *)((port)+_IO_BASE), buf, ns);
-}
-
 int __prep
 prep_ide_default_irq(ide_ioreg_t base)
 {
@@ -721,8 +703,9 @@
 		case 0x170: return 13;
 		case 0x1e8: return 11;
 		case 0x168: return 10;
-		default:
-                        return 0;
+		case 0xfff0: return 14;		/* MCP(N)750 ide0 */
+		case 0xffe0: return 15;		/* MCP(N)750 ide1 */
+		default: return 0;
 	}
 }
 
@@ -780,6 +763,45 @@
 }
 #endif
 
+#ifdef CONFIG_SMP
+/* PReP (MTX) support */
+static int
+smp_prep_probe(void)
+{
+	extern int mot_multi;
+
+	if (mot_multi) {
+		openpic_request_IPIs();
+		smp_hw_index[1] = 1;
+		return 2;
+	}
+
+	return 1;
+}
+
+static void
+smp_prep_kick_cpu(int nr)
+{
+	*(unsigned long *)KERNELBASE = nr;
+	asm volatile("dcbf 0,%0"::"r"(KERNELBASE):"memory");
+	printk("CPU1 reset, waiting\n");
+}
+
+static void
+smp_prep_setup_cpu(int cpu_nr)
+{
+	if (OpenPIC_Addr)
+		do_openpic_setup_cpu();
+}
+
+static struct smp_ops_t prep_smp_ops = {
+	smp_openpic_message_pass,
+	smp_prep_probe,
+	smp_prep_kick_cpu,
+	smp_prep_setup_cpu,
+};
+#endif /* CONFIG_SMP */
+
 /*
  * This finds the amount of physical ram and does necessary
  * setup for prep.  This is pretty architecture specific so
@@ -788,29 +810,39 @@
  */
 unsigned long __init prep_find_end_of_memory(void)
 {
-	unsigned long total;
+	unsigned long total = 0;
+	extern unsigned int boot_mem_size;
+
 #ifdef CONFIG_PREP_RESIDUAL	
 	total = res->TotalMemory;
-#else
-	total = 0;
 #endif	
 
-	if (total == 0 )
-	{
+	if (total == 0 && boot_mem_size != 0)
+		total = boot_mem_size;
+
+	if (total == 0) {
 		/*
 		 * I need a way to probe the amount of memory if the residual
 		 * data doesn't contain it. -- Cort
 		 */
-		printk("Ramsize from residual data was 0 -- Probing for value\n");
 		total = 0x02000000;
-		printk("Ramsize default to be %ldM\n", total>>20);
+		printk(KERN_INFO "Ramsize from residual data was 0"
+		       " -- defaulting to %ldM\n", total>>20);
 	}
 
 	return (total);
 }
 
-unsigned long *MotSave_SmpIar;
-unsigned char *MotSave_CpusState[2];
+/*
+ * Setup the bat mappings we're going to load that cover
+ * the io areas.  RAM was mapped by mapin_ram().
+ * -- Cort
+ */
+void __init prep_map_io(void)
+{
+	io_block_mapping(0x80000000, 0x80000000, 0x10000000, _PAGE_IO);
+	io_block_mapping(0xf0000000, 0xc0000000, 0x08000000, _PAGE_IO);
+}
 
 void __init
 prep_init2(void)
@@ -838,13 +870,6 @@
 	{
 		memcpy((void *)res,(void *)(r3+KERNELBASE),
 		       sizeof(RESIDUAL));
-
-		/* These need to be saved for the Motorola Prep 
-		 * MVME4600 and Dual MTX boards.
-		 */
-		MotSave_SmpIar = &old_res->VitalProductData.SmpIar;
-		MotSave_CpusState[0] = &old_res->Cpus[0].CpuState;
-		MotSave_CpusState[1] = &old_res->Cpus[1].CpuState;
 	}
 #endif
 
@@ -912,19 +937,16 @@
 	}
 
 	ppc_md.find_end_of_memory = prep_find_end_of_memory;
+	ppc_md.setup_io_mappings = prep_map_io;
 
 #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.ide_check_region = prep_ide_check_region;
         ppc_ide_md.ide_request_region = prep_ide_request_region;
         ppc_ide_md.ide_release_region = prep_ide_release_region;
-        ppc_ide_md.fix_driveid = NULL;
         ppc_ide_md.ide_init_hwif = prep_ide_init_hwif_ports;
-#endif		
-        ppc_ide_md.io_base = _IO_BASE;
+#endif
 
 #ifdef CONFIG_VT
 	ppc_md.kbd_setkeycode    = pckbd_setkeycode;
@@ -938,4 +960,8 @@
 	SYSRQ_KEY = 0x54;
 #endif
 #endif
+
+#ifdef CONFIG_SMP
+	ppc_md.smp_ops		 = &prep_smp_ops;
+#endif /* CONFIG_SMP */
 }
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/prep_time.c linux/arch/ppc/kernel/prep_time.c
--- v2.4.9/linux/arch/ppc/kernel/prep_time.c	Mon May 21 17:04:47 2001
+++ linux/arch/ppc/kernel/prep_time.c	Sat Sep  8 12:38:42 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.prep_time.c 1.7 05/17/01 18:14:22 cort
+ * BK Id: SCCS/s.prep_time.c 1.10 09/08/01 15:47:42 paulus
  */
 /*
  *  linux/arch/i386/kernel/time.c
@@ -23,7 +23,7 @@
 #include <linux/kernel_stat.h>
 #include <linux/init.h>
 
-#include <asm/init.h>
+#include <asm/sections.h>
 #include <asm/segment.h>
 #include <asm/io.h>
 #include <asm/processor.h>
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/process.c linux/arch/ppc/kernel/process.c
--- v2.4.9/linux/arch/ppc/kernel/process.c	Wed Jul 25 17:10:18 2001
+++ linux/arch/ppc/kernel/process.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.process.c 1.23 07/19/01 23:02:48 paulus
+ * BK Id: SCCS/s.process.c 1.27 08/28/01 22:01:21 paulus
  */
 /*
  *  linux/arch/ppc/kernel/process.c
@@ -59,8 +59,6 @@
 };
 /* only used to get secondary processor up */
 struct task_struct *current_set[NR_CPUS] = {&init_task, };
-char *sysmap = NULL; 
-unsigned long sysmap_size = 0;
 
 #undef SHOW_TASK_SWITCHES
 #undef CHECK_STACK
@@ -324,7 +322,6 @@
 	    unsigned long unused,
 	    struct task_struct *p, struct pt_regs *regs)
 {
-	unsigned long msr;
 	struct pt_regs *childregs, *kregs;
 	extern void ret_from_fork(void);
 	unsigned long sp = (unsigned long)p + sizeof(union task_union);
@@ -362,11 +359,12 @@
 	 * copy fpu info - assume lazy fpu switch now always
 	 *  -- Cort
 	 */
-	if (regs->msr & MSR_FP)
+	if (regs->msr & MSR_FP) {
 		giveup_fpu(current);
+		childregs->msr &= ~(MSR_FP | MSR_FE0 | MSR_FE1);
+	}
 	memcpy(&p->thread.fpr, &current->thread.fpr, sizeof(p->thread.fpr));
 	p->thread.fpscr = current->thread.fpscr;
-	childregs->msr &= ~MSR_FP;
 
 #ifdef CONFIG_ALTIVEC
 	/*
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/prom.c linux/arch/ppc/kernel/prom.c
--- v2.4.9/linux/arch/ppc/kernel/prom.c	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/kernel/prom.c	Sat Sep  8 12:38:42 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.prom.c 1.35 07/25/01 14:11:37 trini
+ * BK Id: SCCS/s.prom.c 1.42 09/08/01 15:47:42 paulus
  */
 /*
  * Procedures for interfacing to the Open Firmware PROM on
@@ -20,7 +20,7 @@
 #include <linux/threads.h>
 #include <linux/spinlock.h>
 
-#include <asm/init.h>
+#include <asm/sections.h>
 #include <asm/prom.h>
 #include <asm/page.h>
 #include <asm/processor.h>
@@ -33,6 +33,7 @@
 #include <asm/pgtable.h>
 #include <asm/bitops.h>
 #include <asm/bootinfo.h>
+#include <asm/btext.h>
 #include "open_pic.h"
 
 #ifdef CONFIG_FB
@@ -99,6 +100,7 @@
 #define FB_MAX	8
 #endif
 char *prom_display_paths[FB_MAX] __initdata = { 0, };
+phandle prom_display_nodes[FB_MAX] __initdata;
 unsigned int prom_num_displays __initdata = 0;
 char *of_stdout_device __initdata = 0;
 ihandle prom_disp_node __initdata = 0;
@@ -125,40 +127,6 @@
 
 static struct device_node *allnodes;
 
-#ifdef CONFIG_BOOTX_TEXT
-
-#define NO_SCROLL
-
-static void clearscreen(void);
-static void flushscreen(void);
-
-#ifndef NO_SCROLL
-static void scrollscreen(void);
-#endif
-
-static void prepare_disp_BAT(void);
-
-static void draw_byte(unsigned char c, long locX, long locY);
-static void draw_byte_32(unsigned char *bits, unsigned long *base, int rb);
-static void draw_byte_16(unsigned char *bits, unsigned long *base, int rb);
-static void draw_byte_8(unsigned char *bits, unsigned long *base, int rb);
-
-static int g_loc_X;
-static int g_loc_Y;
-static int g_max_loc_X;
-static int g_max_loc_Y;
-
-unsigned long disp_BAT[2] __initdata = {0, 0};
-
-#define cmapsz	(16*256)
-
-static unsigned char vga_font[cmapsz];
-
-int bootx_text_mapped = 1;
-
-#endif /* CONFIG_BOOTX_TEXT */
-
-
 static void *call_prom(const char *service, int nargs, int nret, ...);
 static void prom_exit(void);
 static unsigned long copy_device_tree(unsigned long, unsigned long);
@@ -174,7 +142,6 @@
 
 #ifdef CONFIG_BOOTX_TEXT
 static void setup_disp_fake_bi(ihandle dp);
-static void prom_welcome(boot_infos_t* bi, unsigned long phys);
 #endif
 
 extern void enter_rtas(void *);
@@ -182,10 +149,6 @@
 
 extern char cmd_line[512];	/* XXX */
 boot_infos_t *boot_infos;
-#ifdef CONFIG_BOOTX_TEXT
-boot_infos_t *disp_bi;
-boot_infos_t fake_bi;
-#endif
 unsigned long dev_tree_size;
 
 #define ALIGN(x) (((x) + sizeof(unsigned long)-1) & -sizeof(unsigned long))
@@ -257,13 +220,7 @@
 	unsigned long offset = reloc_offset();
 
 	if (RELOC(prom_stdout) == 0)
-	{
-#ifdef CONFIG_BOOTX_TEXT
-		if (RELOC(disp_bi) != 0)
-			prom_drawstring(msg);
-#endif
 		return;
-	}
 
 	for (p = msg; *p != 0; p = q) {
 		for (q = p; *q != 0 && *q != '\n'; ++q)
@@ -399,26 +356,21 @@
 		bi->logicalDisplayBase = 0;
 
 #ifdef CONFIG_BOOTX_TEXT
-	RELOC(g_loc_X) = 0;
-	RELOC(g_loc_Y) = 0;
-	RELOC(g_max_loc_X) = (bi->dispDeviceRect[2] - bi->dispDeviceRect[0]) / 8;
-	RELOC(g_max_loc_Y) = (bi->dispDeviceRect[3] - bi->dispDeviceRect[1]) / 16;
-	RELOC(disp_bi) = PTRUNRELOC(bi);
-		
-	clearscreen();
+	btext_init(bi);
 
-	/* Test if boot-info is compatible. Done only in config CONFIG_BOOTX_TEXT since
-	   there is nothing much we can do with an incompatible version, except display
-	   a message and eventually hang the processor...
-		   
-	   I'll try to keep enough of boot-info compatible in the future to always allow
-	   display of this message;
-	*/
-	if (!BOOT_INFO_IS_COMPATIBLE(bi))
-		prom_print(RELOC(" !!! WARNING - Incompatible version of BootX !!!\n\n\n"));
-		
-	prom_welcome(bi, phys);
-	flushscreen();
+	/*
+	 * Test if boot-info is compatible.  Done only in config
+	 * CONFIG_BOOTX_TEXT since there is nothing much we can do
+	 * with an incompatible version, except display a message
+	 * and eventually hang the processor...
+	 *
+	 * I'll try to keep enough of boot-info compatible in the
+	 * future to always allow display of this message;
+	 */
+	if (!BOOT_INFO_IS_COMPATIBLE(bi)) {
+		btext_drawstring(RELOC(" !!! WARNING - Incompatible version of BootX !!!\n\n\n"));
+		btext_flushscreen();
+	}
 #endif	/* CONFIG_BOOTX_TEXT */	
 		
 	/* New BootX enters kernel with MMU off, i/os are not allowed
@@ -461,10 +413,13 @@
 	}
 		
 #ifdef CONFIG_BOOTX_TEXT
-	prepare_disp_BAT();
-	prom_drawstring(RELOC("booting...\n"));
-	flushscreen();
-	RELOC(bootx_text_mapped) = 1;
+	/*
+	 * Note that after we call prepare_disp_BAT, we can't do
+	 * prom_draw*, flushscreen or clearscreen until we turn the MMU
+	 * on, since prepare_disp_BAT sets disp_bi->logicalDisplayBase
+	 * to a virtual address.
+	 */
+	btext_prepare_BAT();
 #endif
 }
 
@@ -591,13 +546,11 @@
 unsigned long __init
 prom_init(int r3, int r4, prom_entry pp)
 {
-	int chrp = 0;
 	unsigned long mem;
-	ihandle prom_mmu, prom_op;
+	ihandle prom_mmu;
 	unsigned long offset = reloc_offset();
 	int l;
 	char *p, *d;
-	int prom_version = 0;
  	unsigned long phys;
 
  	/* Default */
@@ -622,31 +575,6 @@
 	RELOC(of_stdout_device) = PTRUNRELOC(p);
 	mem += strlen(p) + 1;
 
-	/* Find the OF version */
-	prom_op = call_prom(RELOC("finddevice"), 1, 1, RELOC("/openprom"));
-	prom_version = 0;
-	if (prom_op != (void*)-1) {
-		char model[64];
-		int sz;
-		sz = (int)call_prom(RELOC("getprop"), 4, 1, prom_op,
-				    RELOC("model"), model, 64);
-		if (sz > 0) {
-			char *c;
-			/* hack to skip the ibm chrp firmware # */
-			if ( strncmp(model,RELOC("IBM"),3) ) {
-				for (c = model; *c; c++)
-					if (*c >= '0' && *c <= '9') {
-						prom_version = *c - '0';
-						break;
-					}
-			}
-			else
-				chrp = 1;
-		}
-	}
-	if (prom_version >= 3)
-		prom_print(RELOC("OF Version 3 detected.\n"));
-
 	/* Get the boot device and translate it to a full OF pathname. */
 	p = (char *) mem;
 	l = (int) call_prom(RELOC("getprop"), 4, 1, RELOC(prom_chosen),
@@ -725,22 +653,14 @@
 	call_prom(RELOC("quiesce"), 0, 0);
 
 #ifdef CONFIG_BOOTX_TEXT
-	if (!chrp && RELOC(disp_bi)) {
-		RELOC(prom_stdout) = 0; /* stop OF output */
-		clearscreen();
-		prepare_disp_BAT();
-		prom_welcome(PTRRELOC(RELOC(disp_bi)), phys);
-		prom_drawstring(RELOC("booting...\n"));
-		RELOC(bootx_text_mapped) = 1;
-	} else {
-		RELOC(bootx_text_mapped) = 0;
-	}
+	btext_prepare_BAT();
 #endif
 
 	prom_print(RELOC("returning "));
 	prom_print_hex(phys);
 	prom_print(RELOC(" from prom_init\n"));
 	RELOC(prom_stdout) = 0;
+
 	return phys;
 }
 
@@ -767,82 +687,6 @@
 	rtas(&u, RELOC(rtas_data));
 }
 
-#ifdef CONFIG_BOOTX_TEXT
-static void __init
-prom_welcome(boot_infos_t* bi, unsigned long phys)
-{
-	unsigned long offset = reloc_offset();
-	unsigned long flags;
-	unsigned long pvr;
-	
-	prom_drawstring(RELOC("Welcome to Linux, kernel " UTS_RELEASE "\n"));
-	prom_drawstring(RELOC("\nstarted at       : 0x"));
-	prom_drawhex(phys);
-	prom_drawstring(RELOC("\nlinked at        : 0x"));
-	prom_drawhex(KERNELBASE);
-	prom_drawstring(RELOC("\nframe buffer at  : 0x"));
-	prom_drawhex((unsigned long)bi->dispDeviceBase);
-	prom_drawstring(RELOC(" (phys), 0x"));
-	prom_drawhex((unsigned long)bi->logicalDisplayBase);
-	prom_drawstring(RELOC(" (log)"));
-	prom_drawstring(RELOC("\nklimit           : 0x"));
-	prom_drawhex((unsigned long)RELOC(klimit));
-	prom_drawstring(RELOC("\nMSR              : 0x"));
-	__asm__ __volatile__ ("mfmsr %0" : "=r" (flags));
-	prom_drawhex(flags);
-	__asm__ __volatile__ ("mfspr %0, 287" : "=r" (pvr));
-	pvr >>= 16;
-	if (pvr > 1) {
-	    prom_drawstring(RELOC("\nHID0             : 0x"));
-	    __asm__ __volatile__ ("mfspr %0, 1008" : "=r" (flags));
-	    prom_drawhex(flags);
-	}
-	if (pvr == 8 || pvr == 12 || pvr == 0x800c) {
-	    prom_drawstring(RELOC("\nICTC             : 0x"));
-	    __asm__ __volatile__ ("mfspr %0, 1019" : "=r" (flags));
-	    prom_drawhex(flags);
-	}
-	prom_drawstring(RELOC("\n\n"));
-}
-
-/* Calc BAT values for mapping the display and store them
- * in disp_BAT.  Those values are then used from head.S to map
- * the display during identify_machine() and MMU_Init()
- * 
- * For now, the display is mapped in place (1:1). This should
- * be changed if the display physical address overlaps
- * KERNELBASE, which is fortunately not the case on any machine
- * I know of. This mapping is temporary and will disappear as
- * soon as the setup done by MMU_Init() is applied
- * 
- * For now, we align the BAT and then map 8Mb on 601 and 16Mb
- * on other PPCs. This may cause trouble if the framebuffer
- * is really badly aligned, but I didn't encounter this case
- * yet.
- */
-static void __init
-prepare_disp_BAT(void)
-{
-	unsigned long offset = reloc_offset();
-	boot_infos_t* bi = PTRRELOC(RELOC(disp_bi));
-	unsigned long addr = (unsigned long)bi->dispDeviceBase;
-	
-	if ((_get_PVR() >> 16) != 1) {
-		/* 603, 604, G3, G4, ... */
-		addr &= 0xFF000000UL;
-		RELOC(disp_BAT[0]) = addr | (BL_16M<<2) | 2;
-		RELOC(disp_BAT[1]) = addr | (_PAGE_NO_CACHE | _PAGE_GUARDED | BPP_RW);		
-	} else {
-		/* 601 */
-		addr &= 0xFF800000UL;
-		RELOC(disp_BAT[0]) = addr | (_PAGE_NO_CACHE | PP_RWXX) | 4;
-		RELOC(disp_BAT[1]) = addr | BL_8M | 0x40;
-	}
-	bi->logicalDisplayBase = bi->dispDeviceBase;
-}
-
-#endif
-
 static int __init
 prom_set_color(ihandle ih, int i, int r, int g, int b)
 {
@@ -920,17 +764,22 @@
 		i = RELOC(prom_num_displays)++;
 		if (RELOC(of_stdout_device) != 0 && i > 0
 		    && strcmp(PTRRELOC(RELOC(of_stdout_device)), path) == 0) {
-			for (; i > 0; --i)
+			for (; i > 0; --i) {
 				RELOC(prom_display_paths[i])
 					= RELOC(prom_display_paths[i-1]);
+				RELOC(prom_display_nodes[i])
+					= RELOC(prom_display_nodes[i-1]);
+			}
 		}
 		RELOC(prom_display_paths[i]) = PTRUNRELOC(path);
+		RELOC(prom_display_nodes[i]) = node;
 		if (i == 0)
 			RELOC(prom_disp_node) = node;
 		if (RELOC(prom_num_displays) >= FB_MAX)
 			break;
 	}
 
+try_again:
 	/*
 	 * Open the first display and set its colormap.
 	 */
@@ -941,6 +790,15 @@
 		ih = call_prom(RELOC("open"), 1, 1, path);
 		if (ih == 0 || ih == (ihandle) -1) {
 			prom_print(RELOC("... failed\n"));
+			for (i=1; i<RELOC(prom_num_displays); i++) {
+				RELOC(prom_display_paths[i-1]) = RELOC(prom_display_paths[i]);
+				RELOC(prom_display_nodes[i-1]) = RELOC(prom_display_nodes[i]);
+			}	
+			if (--RELOC(prom_num_displays) > 0)
+				RELOC(prom_disp_node) = RELOC(prom_display_nodes[0]);
+			else
+				RELOC(prom_disp_node) = NULL;
+			goto try_again;
 		} else {
 			prom_print(RELOC("... ok\n"));
 			/*
@@ -977,7 +835,6 @@
 {
 	int width = 640, height = 480, depth = 8, pitch;
 	unsigned address;
-	boot_infos_t* bi;
 	unsigned long offset = reloc_offset();
 	struct pci_reg_property addrs[8];
 	int i, naddrs;
@@ -1025,20 +882,8 @@
 	/* kludge for valkyrie */
 	if (strcmp(name, RELOC("valkyrie")) == 0) 
 		address += 0x1000;
- 
-	RELOC(disp_bi) = &fake_bi;
-	bi = PTRRELOC((&fake_bi));
-	RELOC(g_loc_X) = 0;
-	RELOC(g_loc_Y) = 0;
-	RELOC(g_max_loc_X) = width / 8;
-	RELOC(g_max_loc_Y) = height / 16;
-	bi->logicalDisplayBase = (unsigned char *)address;
-	bi->dispDeviceBase = (unsigned char *)address;
-	bi->dispDeviceRowBytes = pitch;
-	bi->dispDeviceDepth = depth;
-	bi->dispDeviceRect[0] = bi->dispDeviceRect[1] = 0;
-	bi->dispDeviceRect[2] = width;
-	bi->dispDeviceRect[3] = height;
+
+	btext_setup_display(width, height, depth, pitch, address);
 }
 #endif
 
@@ -1147,8 +992,7 @@
 		prev_propp = &pp->next;
 		namep = (char *) (pp + 1);
 		pp->name = PTRUNRELOC(namep);
-		/* Work around a GCC3 bug */
-		memcpy(namep, RELOC("linux,phandle"), sizeof("linux,phandle"));
+		strcpy(namep, RELOC("linux,phandle"));
 		mem_start = ALIGN((unsigned long)namep + strlen(namep) + 1);
 		pp->value = (unsigned char *) PTRUNRELOC(&np->node);
 		pp->length = sizeof(np->node);
@@ -1213,15 +1057,21 @@
 		 * np->name has not been set yet.  -- paulus
 		 */
 		int n = 0;
-		char *name;
+		char *name, *ic;
+		int iclen;
 
 		for (np = allnodes; np != NULL; np = np->allnext) {
-			if ((name = get_property(np, "name", NULL)) == NULL
-			    || strcmp(name, "interrupt-controller") != 0)
-				continue;
-			if (n == 0)
-				dflt_interrupt_controller = np;
-			++n;
+			ic = get_property(np, "interrupt-controller", &iclen);
+			name = get_property(np, "name", NULL);
+			/* checking iclen makes sure we don't get a false
+			   match on /chosen.interrupt_controller */
+			if ((name != NULL
+			     && strcmp(name, "interrupt-controller") == 0)
+			    || (ic != NULL && iclen == 0)) {
+				if (n == 0)
+					dflt_interrupt_controller = np;
+				++n;
+			}
 		}
 		num_interrupt_controllers = n;
 	}
@@ -1559,7 +1409,7 @@
 	}
 }
 
-int __init
+int
 prom_n_addr_cells(struct device_node* np)
 {
 	int* ip;
@@ -1574,7 +1424,7 @@
 	return 1;
 }
 
-int __init
+int
 prom_n_size_cells(struct device_node* np)
 {
 	int* ip;
@@ -1890,7 +1740,7 @@
 /*
  * Returns all nodes linked together
  */
-struct device_node __openfirmware *
+struct device_node * __openfirmware
 find_all_nodes(void)
 {
 	struct device_node *head, **prevp, *np;
@@ -1983,7 +1833,7 @@
 /*
  * Find the device_node with a given phandle.
  */
-static struct device_node __init *
+static struct device_node * __init
 find_phandle(phandle ph)
 {
 	struct device_node *np;
@@ -2111,6 +1961,12 @@
 		u.words[i+3] = va_arg(list, unsigned long);
 	va_end(list);
 
+	/* Shouldn't we enable kernel FP here ? enter_rtas will play
+	 * with MSR_FE0|MSR_FE1|MSR_FP so I assume rtas might use
+	 * floating points. If that's the case, then we need to make
+	 * sure any lazy FP context is backed up
+	 * --BenH
+	 */
 	spin_lock_irqsave(&rtas_lock, s);
 	enter_rtas((void *)__pa(&u));
 	spin_unlock_irqrestore(&rtas_lock, s);
@@ -2130,694 +1986,3 @@
 	for (;;)
 		prom_exit();
 }
-
-#ifdef CONFIG_BOOTX_TEXT
-
-/* Here's a small text engine to use during early boot or for debugging purposes
- * 
- * todo:
- * 
- *  - build some kind of vgacon with it to enable early printk
- *  - move to a separate file
- *  - add a few video driver hooks to keep in sync with display
- *    changes.
- */
-
-void
-map_bootx_text(void)
-{
-	unsigned long base, offset, size;
-	if (disp_bi == 0)
-		return;
-	base = ((unsigned long) disp_bi->dispDeviceBase) & 0xFFFFF000UL;
-	offset = ((unsigned long) disp_bi->dispDeviceBase) - base;
-	size = disp_bi->dispDeviceRowBytes * disp_bi->dispDeviceRect[3] + offset
-		+ disp_bi->dispDeviceRect[0];
-	disp_bi->logicalDisplayBase = ioremap(base, size);
-	if (disp_bi->logicalDisplayBase == 0)
-		return;
-	disp_bi->logicalDisplayBase += offset;
-	bootx_text_mapped = 1;
-}
-
-/* Calc the base address of a given point (x,y) */
-static unsigned char * __pmac
-calc_base(boot_infos_t *bi, int x, int y)
-{
-	unsigned char *base;
-
-	base = bi->logicalDisplayBase;
-	if (base == 0)
-		base = bi->dispDeviceBase;
-	base += (x + bi->dispDeviceRect[0]) * (bi->dispDeviceDepth >> 3);
-	base += (y + bi->dispDeviceRect[1]) * bi->dispDeviceRowBytes;
-	return base;
-}
-
-/* Adjust the display to a new resolution */
-void __openfirmware
-bootx_update_display(unsigned long phys, int width, int height,
-		     int depth, int pitch)
-{
-	if (disp_bi == 0)
-		return;
-	/* check it's the same frame buffer (within 64MB) */
-	if ((phys ^ (unsigned long)disp_bi->dispDeviceBase) & 0xfc000000) {
-		return;
-	}
-
-	disp_bi->dispDeviceBase = (__u8 *) phys;
-	disp_bi->dispDeviceRect[0] = 0;
-	disp_bi->dispDeviceRect[1] = 0;
-	disp_bi->dispDeviceRect[2] = width;
-	disp_bi->dispDeviceRect[3] = height;
-	disp_bi->dispDeviceDepth = depth;
-	disp_bi->dispDeviceRowBytes = pitch;
-	if (bootx_text_mapped) {
-		iounmap(disp_bi->logicalDisplayBase);
-		bootx_text_mapped = 0;
-	}
-	map_bootx_text();
-	g_loc_X = 0;
-	g_loc_Y = 0;
-	g_max_loc_X = width / 8;
-	g_max_loc_Y = height / 16;
-}
-
-static void __pmac
-clearscreen(void)
-{
-	unsigned long offset	= reloc_offset();
-	boot_infos_t* bi	= PTRRELOC(RELOC(disp_bi));
-	unsigned long *base	= (unsigned long *)calc_base(bi, 0, 0);
-	unsigned long width 	= ((bi->dispDeviceRect[2] - bi->dispDeviceRect[0]) *
-					(bi->dispDeviceDepth >> 3)) >> 2;
-	int i,j;
-	
-	for (i=0; i<(bi->dispDeviceRect[3] - bi->dispDeviceRect[1]); i++)
-	{
-		unsigned long *ptr = base;
-		for(j=width; j; --j)
-			*(ptr++) = 0;
-		base += (bi->dispDeviceRowBytes >> 2);
-	}
-}
-
-__inline__ void dcbst(const void* addr)
-{
-	__asm__ __volatile__ ("dcbst 0,%0" :: "r" (addr));
-}
-
-static void __pmac
-flushscreen(void)
-{
-	unsigned long offset	= reloc_offset();
-	boot_infos_t* bi	= PTRRELOC(RELOC(disp_bi));
-	unsigned long *base	= (unsigned long *)calc_base(bi, 0, 0);
-	unsigned long width 	= ((bi->dispDeviceRect[2] - bi->dispDeviceRect[0]) *
-					(bi->dispDeviceDepth >> 3)) >> 2;
-	int i,j;
-	
-	for (i=0; i<(bi->dispDeviceRect[3] - bi->dispDeviceRect[1]); i++)
-	{
-		unsigned long *ptr = base;
-		for(j=width; j>0; j-=8) {
-			dcbst(ptr);
-			ptr += 8;
-		}
-		base += (bi->dispDeviceRowBytes >> 2);
-	}
-}
-
-#ifndef NO_SCROLL
-static void __pmac
-scrollscreen(void)
-{
-	unsigned long offset		= reloc_offset();
-	boot_infos_t* bi		= PTRRELOC(RELOC(disp_bi));
-	unsigned long *src		= (unsigned long *)calc_base(bi,0,16);
-	unsigned long *dst		= (unsigned long *)calc_base(bi,0,0);
-	unsigned long width		= ((bi->dispDeviceRect[2] - bi->dispDeviceRect[0]) *
-						(bi->dispDeviceDepth >> 3)) >> 2;
-	int i,j;
-	
-#ifdef CONFIG_ADB_PMU
-	pmu_suspend();	/* PMU will not shut us down ! */
-#endif
-	for (i=0; i<(bi->dispDeviceRect[3] - bi->dispDeviceRect[1] - 16); i++)
-	{
-		unsigned long *src_ptr = src;
-		unsigned long *dst_ptr = dst;
-		for(j=width; j; --j)
-			*(dst_ptr++) = *(src_ptr++);
-		src += (bi->dispDeviceRowBytes >> 2);
-		dst += (bi->dispDeviceRowBytes >> 2);
-	}
-	for (i=0; i<16; i++)
-	{
-		unsigned long *dst_ptr = dst;
-		for(j=width; j; --j)
-			*(dst_ptr++) = 0;
-		dst += (bi->dispDeviceRowBytes >> 2);
-	}
-#ifdef CONFIG_ADB_PMU
-	pmu_resume();	/* PMU will not shut us down ! */
-#endif
-}
-#endif /* ndef NO_SCROLL */
-
-void __pmac
-prom_drawchar(char c)
-{
-	unsigned long offset = reloc_offset();
-	int cline = 0, x;
-
-	if (!RELOC(bootx_text_mapped))
-		return;
-
-	switch (c) {
-	case '\b':
-		if (RELOC(g_loc_X) > 0)
-			--RELOC(g_loc_X);
-		break;
-	case '\t':
-		RELOC(g_loc_X) = (RELOC(g_loc_X) & -8) + 8;
-		break;
-	case '\r':
-		RELOC(g_loc_X) = 0;
-		break;
-	case '\n':
-		RELOC(g_loc_X) = 0;
-		RELOC(g_loc_Y)++;
-		cline = 1;
-		break;
-	default:
-		draw_byte(c, RELOC(g_loc_X)++, RELOC(g_loc_Y));
-	}
-	if (RELOC(g_loc_X) >= RELOC(g_max_loc_X)) {
-		RELOC(g_loc_X) = 0;
-		RELOC(g_loc_Y)++;
-		cline = 1;
-	}
-#ifndef NO_SCROLL
-	while (RELOC(g_loc_Y) >= RELOC(g_max_loc_Y)) {
-		scrollscreen();
-		RELOC(g_loc_Y)--;
-	}
-#else
-	/* wrap around from bottom to top of screen so we don't
-	   waste time scrolling each line.  -- paulus. */
-	if (RELOC(g_loc_Y) >= RELOC(g_max_loc_Y))
-		RELOC(g_loc_Y) = 0;
-	if (cline) {
-		for (x = 0; x < RELOC(g_max_loc_X); ++x)
-			draw_byte(' ', x, RELOC(g_loc_Y));
-	}
-#endif
-}
-
-void __pmac
-prom_drawstring(const char *c)
-{
-	unsigned long offset	= reloc_offset();
-
-	if (!RELOC(bootx_text_mapped))
-		return;
-	while (*c)
-		prom_drawchar(*c++);
-}
-
-void __pmac
-prom_drawhex(unsigned long v)
-{
-	static char hex_table[] = "0123456789abcdef";
-	unsigned long offset	= reloc_offset();
-	
-	if (!RELOC(bootx_text_mapped))
-		return;
-	prom_drawchar(RELOC(hex_table)[(v >> 28) & 0x0000000FUL]);
-	prom_drawchar(RELOC(hex_table)[(v >> 24) & 0x0000000FUL]);
-	prom_drawchar(RELOC(hex_table)[(v >> 20) & 0x0000000FUL]);
-	prom_drawchar(RELOC(hex_table)[(v >> 16) & 0x0000000FUL]);
-	prom_drawchar(RELOC(hex_table)[(v >> 12) & 0x0000000FUL]);
-	prom_drawchar(RELOC(hex_table)[(v >>  8) & 0x0000000FUL]);
-	prom_drawchar(RELOC(hex_table)[(v >>  4) & 0x0000000FUL]);
-	prom_drawchar(RELOC(hex_table)[(v >>  0) & 0x0000000FUL]);
-}
-
-static void __pmac
-draw_byte(unsigned char c, long locX, long locY)
-{
-	unsigned long offset	= reloc_offset();
-	boot_infos_t* bi	= PTRRELOC(RELOC(disp_bi));
-	unsigned char *base	= calc_base(bi, locX << 3, locY << 4);
-	unsigned char *font	= &RELOC(vga_font)[((unsigned long)c) * 16];
-	int rb			= bi->dispDeviceRowBytes;
-	
-	switch(bi->dispDeviceDepth) {
-		case 32:
-			draw_byte_32(font, (unsigned long *)base, rb);
-			break;
-		case 16:
-			draw_byte_16(font, (unsigned long *)base, rb);
-			break;
-		case 8:
-			draw_byte_8(font, (unsigned long *)base, rb);
-			break;
-		default:
-			break;
-	}
-}
-
-static unsigned long expand_bits_8[16] __pmacdata  = {
-	0x00000000,
-	0x000000ff,
-	0x0000ff00,
-	0x0000ffff,
-	0x00ff0000,
-	0x00ff00ff,
-	0x00ffff00,
-	0x00ffffff,
-	0xff000000,
-	0xff0000ff,
-	0xff00ff00,
-	0xff00ffff,
-	0xffff0000,
-	0xffff00ff,
-	0xffffff00,
-	0xffffffff
-};
-
-static unsigned long expand_bits_16[4] __pmacdata = {
-	0x00000000,
-	0x0000ffff,
-	0xffff0000,
-	0xffffffff
-};
-
-static void __pmac
-draw_byte_32(unsigned char *font, unsigned long *base, int rb)
-{
-	int l, bits;	
-	int fg = 0xFFFFFFFFUL;
-	int bg = 0x00000000UL;
-	
-	for (l = 0; l < 16; ++l)
-	{
-		bits = *font++;
-		base[0] = (-(bits >> 7) & fg) ^ bg;
-		base[1] = (-((bits >> 6) & 1) & fg) ^ bg;
-		base[2] = (-((bits >> 5) & 1) & fg) ^ bg;
-		base[3] = (-((bits >> 4) & 1) & fg) ^ bg;
-		base[4] = (-((bits >> 3) & 1) & fg) ^ bg;
-		base[5] = (-((bits >> 2) & 1) & fg) ^ bg;
-		base[6] = (-((bits >> 1) & 1) & fg) ^ bg;
-		base[7] = (-(bits & 1) & fg) ^ bg;
-		base = (unsigned long *) ((char *)base + rb);
-	}
-}
-
-static void __pmac
-draw_byte_16(unsigned char *font, unsigned long *base, int rb)
-{
-	int l, bits;	
-	int fg = 0xFFFFFFFFUL;
-	int bg = 0x00000000UL;
-	unsigned long offset = reloc_offset();
-	unsigned long *eb = RELOC(expand_bits_16);
-
-	for (l = 0; l < 16; ++l)
-	{
-		bits = *font++;
-		base[0] = (eb[bits >> 6] & fg) ^ bg;
-		base[1] = (eb[(bits >> 4) & 3] & fg) ^ bg;
-		base[2] = (eb[(bits >> 2) & 3] & fg) ^ bg;
-		base[3] = (eb[bits & 3] & fg) ^ bg;
-		base = (unsigned long *) ((char *)base + rb);
-	}
-}
-
-static void __pmac
-draw_byte_8(unsigned char *font, unsigned long *base, int rb)
-{
-	int l, bits;	
-	int fg = 0x0F0F0F0FUL;
-	int bg = 0x00000000UL;
-	unsigned long offset = reloc_offset();
-	unsigned long *eb = RELOC(expand_bits_8);
-
-	for (l = 0; l < 16; ++l)
-	{
-		bits = *font++;
-		base[0] = (eb[bits >> 4] & fg) ^ bg;
-		base[1] = (eb[bits & 0xf] & fg) ^ bg;
-		base = (unsigned long *) ((char *)base + rb);
-	}
-}
-
-static unsigned char vga_font[cmapsz] __pmacdata = {
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 
-0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xff, 
-0xdb, 0xff, 0xff, 0xc3, 0xe7, 0xff, 0xff, 0x7e, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x6c, 0xfe, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x7c, 0xfe, 
-0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 
-0x3c, 0x3c, 0xe7, 0xe7, 0xe7, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x7e, 0x18, 0x18, 0x3c, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 
-0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0x99, 0xbd, 
-0xbd, 0x99, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x1e, 0x0e, 
-0x1a, 0x32, 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x18, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x30, 
-0x30, 0x70, 0xf0, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x63, 
-0x7f, 0x63, 0x63, 0x63, 0x63, 0x67, 0xe7, 0xe6, 0xc0, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x18, 0x18, 0xdb, 0x3c, 0xe7, 0x3c, 0xdb, 0x18, 0x18, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfe, 0xf8, 
-0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x0e, 
-0x1e, 0x3e, 0xfe, 0x3e, 0x1e, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 
-0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xdb, 
-0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x7c, 0xc6, 0x60, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x0c, 0xc6, 
-0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0xfe, 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 
-0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
-0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 
-0xc0, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x7c, 0x7c, 0xfe, 0xfe, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x7c, 0x7c, 
-0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 
-0x6c, 0xfe, 0x6c, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 
-0x18, 0x18, 0x7c, 0xc6, 0xc2, 0xc0, 0x7c, 0x06, 0x06, 0x86, 0xc6, 0x7c, 
-0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc2, 0xc6, 0x0c, 0x18, 
-0x30, 0x60, 0xc6, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 
-0x6c, 0x38, 0x76, 0xdc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x30, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 
-0x30, 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x18, 
-0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 
-0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x02, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xce, 0xde, 0xf6, 0xe6, 0xc6, 0xc6, 0x7c, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, 
-0x18, 0x18, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 
-0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x7c, 0xc6, 0x06, 0x06, 0x3c, 0x06, 0x06, 0x06, 0xc6, 0x7c, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 
-0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc0, 
-0xc0, 0xc0, 0xfc, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x38, 0x60, 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc6, 0x06, 0x06, 0x0c, 0x18, 
-0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 
-0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x06, 0x06, 0x0c, 0x78, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 
-0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x06, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 
-0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 
-0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x0c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xde, 0xde, 
-0xde, 0xdc, 0xc0, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 
-0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x66, 0x66, 0x66, 0x66, 0xfc, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 
-0xc0, 0xc2, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x6c, 
-0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xfe, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 
-0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 
-0xc2, 0xc0, 0xc0, 0xde, 0xc6, 0xc6, 0x66, 0x3a, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 
-0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x0c, 
-0x0c, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0xe6, 0x66, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0x66, 0xe6, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x60, 0x60, 0x60, 0x60, 0x60, 
-0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xe7, 
-0xff, 0xff, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0xc6, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 
-0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x66, 
-0x66, 0x66, 0x7c, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 
-0x0c, 0x0e, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x6c, 
-0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 
-0xc6, 0x60, 0x38, 0x0c, 0x06, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0xff, 0xdb, 0x99, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 
-0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xc3, 
-0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xdb, 0xdb, 0xff, 0x66, 0x66, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x18, 
-0x3c, 0x66, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xc3, 
-0xc3, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0xff, 0xc3, 0x86, 0x0c, 0x18, 0x30, 0x60, 0xc1, 0xc3, 0xff, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 
-0x30, 0x30, 0x30, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 
-0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 
-0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 
-0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 
-0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x60, 
-0x60, 0x78, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x0c, 0x0c, 0x3c, 0x6c, 0xcc, 
-0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xf0, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 
-0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xcc, 0x78, 0x00, 0x00, 0x00, 0xe0, 0x60, 
-0x60, 0x6c, 0x76, 0x66, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x18, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x0e, 0x06, 0x06, 
-0x06, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3c, 0x00, 0x00, 0x00, 0xe0, 0x60, 
-0x60, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0xff, 0xdb, 
-0xdb, 0xdb, 0xdb, 0xdb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 
-0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0x0c, 0x1e, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0x60, 0x60, 0xf0, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, 
-0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x30, 
-0x30, 0xfc, 0x30, 0x30, 0x30, 0x30, 0x36, 0x1c, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xc3, 0xc3, 
-0xc3, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0xc3, 0xc3, 0xc3, 0xdb, 0xdb, 0xff, 0x66, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0xc3, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 
-0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0xfe, 0xcc, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x0e, 0x18, 0x18, 0x18, 0x70, 0x18, 0x18, 0x18, 0x18, 0x0e, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 
-0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x18, 
-0x18, 0x18, 0x0e, 0x18, 0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 
-0xc6, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 
-0xc2, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x0c, 0x06, 0x7c, 0x00, 0x00, 
-0x00, 0x00, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x00, 0x7c, 0xc6, 0xfe, 
-0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 
-0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0xcc, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, 0x78, 0x0c, 0x7c, 
-0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x38, 
-0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x60, 0x60, 0x66, 0x3c, 0x0c, 0x06, 
-0x3c, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xfe, 
-0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 
-0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x38, 0x18, 0x18, 
-0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x66, 
-0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 
-0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x38, 0x00, 
-0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 
-0x18, 0x30, 0x60, 0x00, 0xfe, 0x66, 0x60, 0x7c, 0x60, 0x60, 0x66, 0xfe, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, 0x3b, 0x1b, 
-0x7e, 0xd8, 0xdc, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x6c, 
-0xcc, 0xcc, 0xfe, 0xcc, 0xcc, 0xcc, 0xcc, 0xce, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 
-0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 
-0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x30, 0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, 0xcc, 0xcc, 0xcc, 
-0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 
-0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0x78, 0x00, 
-0x00, 0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 
-0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 
-0xc3, 0xc0, 0xc0, 0xc0, 0xc3, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xe6, 0xfc, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18, 0xff, 0x18, 
-0xff, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x66, 0x66, 
-0x7c, 0x62, 0x66, 0x6f, 0x66, 0x66, 0x66, 0xf3, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x0e, 0x1b, 0x18, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 
-0xd8, 0x70, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, 0x00, 0x78, 0x0c, 0x7c, 
-0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 
-0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x18, 0x30, 0x60, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, 0x00, 0xcc, 0xcc, 0xcc, 
-0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 
-0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 
-0x76, 0xdc, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x6c, 
-0x38, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x60, 0xc0, 0xc6, 0xc6, 0x7c, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc0, 
-0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0xfe, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x60, 0xce, 0x9b, 0x06, 
-0x0c, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 
-0x66, 0xce, 0x96, 0x3e, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 
-0x00, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x6c, 0xd8, 0x6c, 0x36, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x6c, 0x36, 
-0x6c, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x44, 0x11, 0x44, 
-0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 
-0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 
-0x55, 0xaa, 0x55, 0xaa, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 
-0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0x18, 0x18, 0x18, 0x18, 
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, 
-0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36, 0x36, 
-0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0xf8, 
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, 
-0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 
-0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 
-0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0xf6, 
-0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 
-0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 
-0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 
-0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
-0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 
-0x18, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 
-0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 
-0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 
-0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xff, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 
-0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 
-0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, 
-0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 
-0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 
-0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3f, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 
-0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 
-0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 
-0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 
-0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 
-0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 
-0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 
-0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 
-0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x76, 0xdc, 0xd8, 0xd8, 0xd8, 0xdc, 0x76, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0xd8, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc6, 0xc6, 0xc0, 0xc0, 0xc0, 
-0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0xfe, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0xfe, 0xc6, 0x60, 0x30, 0x18, 0x30, 0x60, 0xc6, 0xfe, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xd8, 0xd8, 
-0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xc0, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x18, 0x3c, 0x66, 0x66, 
-0x66, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 
-0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x6c, 0x6c, 0x6c, 0xee, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x30, 0x18, 0x0c, 0x3e, 0x66, 
-0x66, 0x66, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x7e, 0xdb, 0xdb, 0xdb, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x03, 0x06, 0x7e, 0xdb, 0xdb, 0xf3, 0x7e, 0x60, 0xc0, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x30, 0x60, 0x60, 0x7c, 0x60, 
-0x60, 0x60, 0x30, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 
-0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 
-0x18, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 
-0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x00, 0x7e, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x1b, 0x1b, 0x1b, 0x18, 0x18, 
-0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 
-0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x18, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 
-0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x6c, 
-0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0c, 0x0c, 
-0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x6c, 0x3c, 0x1c, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0xd8, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xd8, 0x30, 0x60, 0xc8, 0xf8, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 
-};
-
-#endif /* CONFIG_BOOTX_TEXT */
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/residual.c linux/arch/ppc/kernel/residual.c
--- v2.4.9/linux/arch/ppc/kernel/residual.c	Mon May 21 17:04:47 2001
+++ linux/arch/ppc/kernel/residual.c	Sat Sep  8 12:38:42 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.residual.c 1.7 05/17/01 18:14:22 cort
+ * BK Id: SCCS/s.residual.c 1.11 09/08/01 15:47:42 paulus
  */
 /*
  * Code to deal with the PReP residual data.
@@ -44,7 +44,7 @@
 #include <linux/pci.h>
 #include <linux/ide.h>
 
-#include <asm/init.h>
+#include <asm/sections.h>
 #include <asm/mmu.h>
 #include <asm/processor.h>
 #include <asm/io.h>
@@ -55,7 +55,7 @@
 unsigned char __res[sizeof(RESIDUAL)] __prepdata = {0,};
 RESIDUAL *res = (RESIDUAL *)&__res;
 
-const char * PnP_BASE_TYPES[] __initdata = {
+char * PnP_BASE_TYPES[] __initdata = {
   "Reserved",
   "MassStorageDevice",
   "NetworkInterfaceController",
@@ -71,7 +71,7 @@
 
 /* Device Sub Type Codes */
 
-const unsigned char * PnP_SUB_TYPES[] __initdata = {
+unsigned char * PnP_SUB_TYPES[] __initdata = {
   "\001\000SCSIController",
   "\001\001IDEController",
   "\001\002FloppyController",
@@ -128,7 +128,7 @@
 
 /* Device Interface Type Codes */
 
-const  unsigned char * PnP_INTERFACES[] __initdata = {
+unsigned char * PnP_INTERFACES[] __initdata = {
   "\000\000\000General",
   "\001\000\000GeneralSCSI",
   "\001\001\000GeneralIDE",
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/setup.c linux/arch/ppc/kernel/setup.c
--- v2.4.9/linux/arch/ppc/kernel/setup.c	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/kernel/setup.c	Sat Sep  8 12:38:42 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.setup.c 1.46 07/26/01 14:18:18 trini
+ * BK Id: SCCS/s.setup.c 1.57 09/08/01 15:47:42 paulus
  */
 /*
  * Common prep/pmac/chrp boot and setup code.
@@ -17,7 +17,6 @@
 #include <linux/tty.h>
 #include <linux/bootmem.h>
 
-#include <asm/init.h>
 #include <asm/residual.h>
 #include <asm/io.h>
 #include <asm/prom.h>
@@ -28,6 +27,7 @@
 #include <asm/amigappc.h>
 #include <asm/smp.h>
 #include <asm/elf.h>
+#include <asm/cputable.h>
 #ifdef CONFIG_8xx
 #include <asm/mpc8xx.h>
 #include <asm/8xx_immap.h>
@@ -40,55 +40,18 @@
 #include <asm/ppc4xx.h>
 #endif
 #include <asm/bootx.h>
+#include <asm/btext.h>
 #include <asm/machdep.h>
 #include <asm/feature.h>
 #include <asm/uaccess.h>
+#include <asm/system.h>
 
-
-extern void apus_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 gemini_init(unsigned long r3,
-                      unsigned long r4,
-                      unsigned long r5,
-                      unsigned long r6,
-                      unsigned long r7);
-
-extern void m8xx_init(unsigned long r3,
-		     unsigned long r4,
-		     unsigned long r5,
-		     unsigned long r6,
-		     unsigned long r7);
-
-extern void m8260_init(unsigned long r3,
-		     unsigned long r4,
-		     unsigned long r5,
-		     unsigned long r6,
-		     unsigned long r7);
-
-extern void pmac_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 platform_init(unsigned long r3, unsigned long r4,
+		unsigned long r5, unsigned long r6, unsigned long r7);
 extern void bootx_init(unsigned long r4, unsigned long phys);
 extern unsigned long reloc_offset(void);
+extern void identify_cpu(unsigned long offset, unsigned long cpu);
+extern void do_cpu_ftr_fixups(unsigned long offset);
 
 #ifdef CONFIG_XMON
 extern void xmon_map_scc(void);
@@ -98,6 +61,13 @@
 char saved_command_line[256];
 unsigned char aux_device_present;
 struct ide_machdep_calls ppc_ide_md;
+char *sysmap;
+unsigned long sysmap_size;
+
+/* Used with the BI_MEMSIZE bootinfo parameter to store the memory
+   size value reported by the boot loader. */ 
+unsigned int boot_mem_size;
+
 int parse_bootinfo(void);
 
 unsigned long ISA_DMA_THRESHOLD;
@@ -105,7 +75,13 @@
 
 #ifdef CONFIG_ALL_PPC
 int _machine = 0;
-int have_of = 0;
+
+extern void prep_init(unsigned long r3, unsigned long r4,
+		unsigned long r5, unsigned long r6, unsigned long r7);
+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);
 #endif /* CONFIG_ALL_PPC */
 
 #ifdef CONFIG_MAGIC_SYSRQ
@@ -126,15 +102,7 @@
 int icache_bsize;
 int ucache_bsize;
 
-/*
- * Perhaps we can put the pmac screen_info[] here
- * on pmac as well so we don't need the ifdef's.
- * Until we get multiple-console support in here
- * that is.  -- Cort
- * Maybe tie it to serial consoles, since this is really what
- * these processors use on existing boards.  -- Dan
- */ 
-#if !defined(CONFIG_4xx) && !defined(CONFIG_8xx) && !defined(CONFIG_8260)
+#ifdef CONFIG_VGA_CONSOLE
 struct screen_info screen_info = {
 	0, 25,			/* orig-x, orig-y */
 	0,			/* unused */
@@ -146,35 +114,7 @@
 	1,			/* orig-video-isVGA */
 	16			/* orig-video-points */
 };
-
-/*
- * I really need to add multiple-console support... -- Cort
- */
-int __init pmac_display_supported(char *name)
-{
-	return 0;
-}
-void __init pmac_find_display(void)
-{
-}
-
-#else /* CONFIG_4xx || CONFIG_8xx */
-
-/* We need this to satisfy some external references until we can
- * strip the kernel down.
- */
-struct screen_info screen_info = {
-	0, 25,			/* orig-x, orig-y */
-	0,			/* unused */
-	0,			/* orig-video-page */
-	0,			/* orig-video-mode */
-	80,			/* orig-video-cols */
-	0,0,0,			/* ega_ax, ega_bx, ega_cx */
-	25,			/* orig-video-lines */
-	0,			/* orig-video-isVGA */
-	16			/* orig-video-points */
-};
-#endif /* !CONFIG_4xx && !CONFIG_8xx */
+#endif /* CONFIG_VGA_CONSOLE */
 
 void machine_restart(char *cmd)
 {
@@ -190,35 +130,11 @@
 {
 	ppc_md.halt();
 }
-  
-unsigned long cpu_temp(void)
-{
-	unsigned char thres = 0;
-	
-#if 0
-	/* disable thrm2 */
-	_set_THRM2( 0 );
-	/* threshold 0 C, tid: exceeding threshold, tie: don't generate interrupt */
-	_set_THRM1( THRM1_V );
-
-	/* we need 20us to do the compare - assume 300MHz processor clock */
-	_set_THRM3(0);
-	_set_THRM3(THRM3_E | (300*30)<<18 );
-
-	udelay(100);
-	/* wait for the compare to complete */
-	/*while ( !(_get_THRM1() & THRM1_TIV) ) ;*/
-	if ( !(_get_THRM1() & THRM1_TIV) )
-		printk("no tiv\n");
-	if ( _get_THRM1() & THRM1_TIN )
-		printk("crossed\n");
-	/* turn everything off */
-	_set_THRM3(0);
-	_set_THRM1(0);
-#endif
-		
-	return thres;
-}
+
+#ifdef CONFIG_TAU
+extern u32 cpu_temp(unsigned long cpu);
+extern u32 cpu_temp_both(unsigned long cpu);
+#endif /* CONFIG_TAU */
 
 int get_cpuinfo(char *buffer)
 {
@@ -227,7 +143,7 @@
 	unsigned long i;
 	unsigned int pvr;
 	unsigned short maj, min;
-	
+
 #ifdef CONFIG_SMP
 #define CPU_PRESENT(x) (cpu_callin_map[(x)])
 #define GET_PVR ((long int)(cpu_data[i].pvr))
@@ -235,7 +151,7 @@
 #else
 #define CPU_PRESENT(x) ((x)==0)
 #define smp_num_cpus 1
-#define GET_PVR ((long int)_get_PVR())
+#define GET_PVR (mfspr(PVR))
 #define CD(x) (x)
 #endif	
 
@@ -249,90 +165,31 @@
 		len += sprintf(len+buffer,"cpu\t\t: ");
 
 		pvr = GET_PVR;
-	
-		switch (PVR_VER(pvr))
-		{
-		case 0x0001:
-			len += sprintf(len+buffer, "601\n");
-			break;
-		case 0x0003:
-			len += sprintf(len+buffer, "603\n");
-			break;
-		case 0x0004:
-			len += sprintf(len+buffer, "604\n");
-			break;
-		case 0x0006:
-			len += sprintf(len+buffer, "603e\n");
-			break;
-		case 0x0007:
-			len += sprintf(len+buffer, "603");
-			if (((pvr >> 12) & 0xF) == 1) {
-				pvr ^= 0x00001000;	/* revision fix-up */
-				len += sprintf(len+buffer, "r\n");
-			} else {
-				len += sprintf(len+buffer, "ev\n");
-			}
-			break;
-		case 0x0008:		/* 740/750(P) */
-		case 0x1008:
-			len += sprintf(len+buffer, "750%s\n",
-				       PVR_VER(pvr) == 0x1008 ? "P" : "");
-			len += sprintf(len+buffer, "temperature \t: %lu C\n",
-				       cpu_temp());
-			break;
-		case 0x0009:		/* 604e/604r */
-		case 0x000A:
-			len += sprintf(len+buffer, "604");
-
-			if (PVR_VER(pvr) == 0x000A ||
-			    ((pvr >> 12) & 0xF) != 0) {
-				pvr &= ~0x00003000;	/* revision fix-up */
-				len += sprintf(len+buffer, "r\n");
-			} else {
-				len += sprintf(len+buffer, "e\n");
-			}
-			break;
-		case 0x000C:
-			len += sprintf(len+buffer, "7400 (G4");
+
+		if (cur_cpu_spec[i]->pvr_mask)
+			len += sprintf(len+buffer, "%s", cur_cpu_spec[i]->cpu_name);
+		else
+			len += sprintf(len+buffer, "unknown (%08x)", pvr);
 #ifdef CONFIG_ALTIVEC
+		if (cur_cpu_spec[i]->cpu_features & CPU_FTR_ALTIVEC)
 			len += sprintf(len+buffer, ", altivec supported");
-#endif /* CONFIG_ALTIVEC */
-			len += sprintf(len+buffer, ")\n");
-			break;
-		case 0x0020:
-			len += sprintf(len+buffer, "403G");
-			switch ((pvr >> 8) & 0xFF) {
-			case 0x02:
-				len += sprintf(len+buffer, "C\n");    
-				break;				      
-			case 0x14:
-				len += sprintf(len+buffer, "CX\n");
-				break;
-			}
-			break;
-		case 0x0035:
-			len += sprintf(len+buffer, "POWER4\n");
-			break;
-		case 0x0040:
-			len += sprintf(len+buffer, "POWER3 (630)\n");
-			break;
-		case 0x0041:
-			len += sprintf(len+buffer, "POWER3 (630+)\n");
-			break;
-		case 0x0050:
-			len += sprintf(len+buffer, "8xx\n");
-			break;
-		case 0x0081:
-			len += sprintf(len+buffer, "82xx\n");
-			break;
-		case 0x4011:
-			len += sprintf(len+buffer, "405GP\n");
-			break;
-		default:
-			len += sprintf(len+buffer, "unknown (%08x)\n", pvr);
-			break;
+#endif		
+		len += sprintf(len+buffer, "\n");
+#ifdef CONFIG_TAU
+		if (cur_cpu_spec[i]->cpu_features & CPU_FTR_TAU) {
+#ifdef CONFIG_TAU_AVERAGE	/* more straightforward, but potentially misleading */
+			len += sprintf(len+buffer, "temperature \t: %u C (uncalibrated)\n",
+				       cpu_temp(i));
+#else
+			/* show the actual temp sensor range */
+			u32 temp;
+			temp = cpu_temp_both(i);
+			len += sprintf(len+buffer, "temperature \t: %u-%u C (uncalibrated)\n",
+					temp & 0xff, temp >> 16);
+#endif
 		}
-		
+#endif
+
 		/*
 		 * Assume here that all clock rates are the same in a
 		 * smp system.  -- Cort
@@ -394,7 +251,7 @@
 	}
 
 #ifdef CONFIG_SMP
-	if ( i )
+	if ( i && smp_num_cpus > 1)
 		len += sprintf(buffer+len, "\n");
 	len += sprintf(buffer+len,"total bogomips\t: %lu.%02lu\n",
 		       bogosum/(500000/HZ),
@@ -423,31 +280,6 @@
 	return len;
 }
 
-#ifdef CONFIG_ALL_PPC
-void __init
-intuit_machine_type(void)
-{
-	char *model;
-	struct device_node *root;
-			
-	/* ask the OF info if we're a chrp or pmac */
-	root = find_path_device("/");
-	if (root != 0) {
-		/* assume pmac unless proven to be chrp -- Cort */
-		_machine = _MACH_Pmac;
-		model = get_property(root, "device_type", NULL);
-		if (model && !strncmp("chrp", model, 4))
-			_machine = _MACH_chrp;
-		else {
-			model = get_property(root, "model", NULL);
-			if (model && !strncmp(model, "IBM", 3))
-				_machine = _MACH_chrp;
-		}
-	}
-}
-#endif /* CONFIG_ALL_PPC */
-
-#if defined(CONFIG_6xx) || defined(CONFIG_PPC64BRIDGE)
 /*
  * We're called here very early in the boot.  We determine the machine
  * type and call the appropriate low-level setup functions.
@@ -472,6 +304,13 @@
 	 * caches on yet */
 	memset_io(PTRRELOC(&__bss_start), 0, &_end - &__bss_start);
 
+	/*
+	 * Identify the CPU type and fix up code sections
+	 * that depend on which cpu we have.
+	 */
+	identify_cpu(offset, 0);
+	do_cpu_ftr_fixups(offset);
+
 #if defined(CONFIG_ALL_PPC)
 	/* If we came here from BootX, clear the screen,
 	 * set up some pointers and return. */
@@ -493,78 +332,105 @@
 
 	return phys;
 }
-#endif /* CONFIG_6xx || CONFIG_PPC64BRIDGE */
+
+#ifdef CONFIG_ALL_PPC
+void __init
+intuit_machine_type(void)
+{
+	char *model;
+	struct device_node *root;
+			
+	/* ask the OF info if we're a chrp or pmac */
+	root = find_path_device("/");
+	if (root != 0) {
+		/* assume pmac unless proven to be chrp -- Cort */
+		_machine = _MACH_Pmac;
+		model = get_property(root, "device_type", NULL);
+		if (model && !strncmp("chrp", model, 4))
+			_machine = _MACH_chrp;
+		else {
+			model = get_property(root, "model", NULL);
+			if (model && !strncmp(model, "IBM", 3))
+				_machine = _MACH_chrp;
+		}
+	}
+}
 
 /*
- * Find out what kind of machine we're on and save any data we need
- * from the early boot process (devtree is copied on pmac by prom_init() )
+ * The ALL_PPC version of platform_init...
  */
-unsigned long __init
-identify_machine(unsigned long r3, unsigned long r4, unsigned long r5,
-		 unsigned long r6, unsigned long r7)
+void __init
+platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+	      unsigned long r6, unsigned long r7)
 {
-#ifdef CONFIG_CMDLINE
-	strcpy(cmd_line, CONFIG_CMDLINE);
-#endif /* CONFIG_CMDLINE */
+#ifdef CONFIG_BOOTX_TEXT
+	extern boot_infos_t *disp_bi;
 
-	parse_bootinfo();
+	if (disp_bi) {
+		btext_clearscreen();
+		btext_welcome(disp_bi);
+	}
+#endif	
 
-	if ( ppc_md.progress ) ppc_md.progress("id mach(): start", 0x100);
-	
-#ifdef CONFIG_ALL_PPC
 	/* if we didn't get any bootinfo telling us what we are... */
-	if ( _machine == 0 )
-	{
+	if (_machine == 0) {
 		/* prep boot loader tells us if we're prep or not */
 		if ( *(unsigned long *)(KERNELBASE) == (0xdeadc0de) )
-		{
 			_machine = _MACH_prep;
-		} else
-			have_of = 1;
 	}
 
-	if ( have_of )
-	{
-		/* prom_init has already been called from __start */
-		if (boot_infos)
-			relocate_nodes();
-		/* we need to set _machine before calling finish_device_tree */
-		if (_machine == 0)
-			intuit_machine_type();
-		finish_device_tree();
-		/*
-		 * If we were booted via quik, r3 points to the physical
-		 * address of the command-line parameters.
-		 * If we were booted from an xcoff image (i.e. netbooted or
-		 * booted from floppy), we get the command line from the
-		 * bootargs property of the /chosen node.
-		 * If an initial ramdisk is present, r3 and r4
-		 * are used for initrd_start and initrd_size,
-		 * otherwise they contain 0xdeadbeef.  
-		 */
-		if (r3 >= 0x4000 && r3 < 0x800000 && r4 == 0) {
-			strncpy(cmd_line, (char *)r3 + KERNELBASE,
+	/* not much more to do here, if prep */
+	if (_machine == _MACH_prep) {
+		prep_init(r3, r4, r5, r6, r7);
+		return;
+	}
+
+	/* prom_init has already been called from __start */
+	if (boot_infos)
+		relocate_nodes();
+
+	/* If we aren't PReP, we can find out if we're Pmac
+	 * or CHRP with this. */
+	if (_machine == 0)
+		intuit_machine_type();
+
+	/* finish_device_tree may need _machine defined. */
+	finish_device_tree();
+
+	/*
+	 * If we were booted via quik, r3 points to the physical
+	 * address of the command-line parameters.
+	 * If we were booted from an xcoff image (i.e. netbooted or
+	 * booted from floppy), we get the command line from the
+	 * bootargs property of the /chosen node.
+	 * If an initial ramdisk is present, r3 and r4
+	 * are used for initrd_start and initrd_size,
+	 * otherwise they contain 0xdeadbeef.  
+	 */
+	if (r3 >= 0x4000 && r3 < 0x800000 && r4 == 0) {
+		cmd_line[0] = 0;
+		strncpy(cmd_line, (char *)r3 + KERNELBASE,
+			sizeof(cmd_line));
+	} else if (boot_infos != 0) {
+		/* booted by BootX - check for ramdisk */
+		if (boot_infos->kernelParamsOffset != 0)
+			strncpy(cmd_line, (char *) boot_infos
+				+ boot_infos->kernelParamsOffset,
 				sizeof(cmd_line));
-		} else if (boot_infos != 0) {
-			/* booted by BootX - check for ramdisk */
- 			if (boot_infos->kernelParamsOffset != 0)
-				strncpy(cmd_line, (char *) boot_infos
-					+ boot_infos->kernelParamsOffset,
-					sizeof(cmd_line));
 #ifdef CONFIG_BLK_DEV_INITRD
-			if (boot_infos->ramDisk) {
-				initrd_start = (unsigned long) boot_infos
-					+ boot_infos->ramDisk;
-				initrd_end = initrd_start + boot_infos->ramDiskSize;
-				initrd_below_start_ok = 1;
-			}
+		if (boot_infos->ramDisk) {
+			initrd_start = (unsigned long) boot_infos
+				+ boot_infos->ramDisk;
+			initrd_end = initrd_start + boot_infos->ramDiskSize;
+			initrd_below_start_ok = 1;
+		}
 #endif
-		} else {
-			struct device_node *chosen;
-			char *p;
+	} else {
+		struct device_node *chosen;
+		char *p;
 			
 #ifdef CONFIG_BLK_DEV_INITRD
-			if (r3 && r4 && r4 != 0xdeadbeef)
+		if (r3 && r4 && r4 != 0xdeadbeef)
 			{
 				if (r3 < KERNELBASE)
 					r3 += KERNELBASE;
@@ -574,92 +440,32 @@
 				initrd_below_start_ok = 1;
 			}
 #endif
-			chosen = find_devices("chosen");
-			if (chosen != NULL) {
-				p = get_property(chosen, "bootargs", NULL);
-				if (p && *p) {
-					cmd_line[0] = 0;
-					strncpy(cmd_line, p, sizeof(cmd_line));
-				}
+		chosen = find_devices("chosen");
+		if (chosen != NULL) {
+			p = get_property(chosen, "bootargs", NULL);
+			if (p && *p) {
+				cmd_line[0] = 0;
+				strncpy(cmd_line, p, sizeof(cmd_line));
 			}
 		}
-		cmd_line[sizeof(cmd_line) - 1] = 0;
 	}
-#endif /* CONFIG_ALL_PPC */
+	cmd_line[sizeof(cmd_line) - 1] = 0;
 
-#if defined(CONFIG_ALL_PPC)
-	switch (_machine)
-	{
+	switch (_machine) {
 	case _MACH_Pmac:
-                pmac_init(r3, r4, r5, r6, r7);
-		break;
-	case _MACH_prep:
-                prep_init(r3, r4, r5, r6, r7);
+		pmac_init(r3, r4, r5, r6, r7);
 		break;
 	case _MACH_chrp:
-                chrp_init(r3, r4, r5, r6, r7);
+		chrp_init(r3, r4, r5, r6, r7);
 		break;
-	default:
-		printk("Unknown machine type in identify_machine!\n");
-	}
-#elif defined(CONFIG_APUS)
-	apus_init(r3, r4, r5, r6, r7);
-#elif defined(CONFIG_GEMINI)
-	gemini_init(r3, r4, r5, r6, r7);
-#elif defined(CONFIG_4xx)
-	oak_init(r3, r4, r5, r6, r7);
-#elif defined(CONFIG_8xx)
-        m8xx_init(r3, r4, r5, r6, r7);
-#elif defined(CONFIG_8260)
-        m8260_init(r3, r4, r5, r6, r7);
-#else
-#error "No board type has been defined for identify_machine()!"
-#endif
-
-#if !defined(CONFIG_4xx) && !defined(CONFIG_8xx) && !defined(CONFIG_8260)
-	/* Check for nobats option (used in mapin_ram). */
-	if (strstr(cmd_line, "nobats")) {
-		extern int __map_without_bats;
-		__map_without_bats = 1;
-	}
-#endif /* !CONFIG_4xx && !CONFIG_8xx && !CONFIG_8260 */
-
-	/* Look for mem= option on command line */
-	if (strstr(cmd_line, "mem=")) {
-		char *p, *q;
-		unsigned long maxmem = 0;
-		extern unsigned long __max_memory;
-
-		for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) {
-			q = p + 4;
-			if (p > cmd_line && p[-1] != ' ')
-				continue;
-			maxmem = simple_strtoul(q, &q, 0);
-			if (*q == 'k' || *q == 'K') {
-				maxmem <<= 10;
-				++q;
-			} else if (*q == 'm' || *q == 'M') {
-				maxmem <<= 20;
-				++q;
-			}
-		}
-		__max_memory = maxmem;
 	}
-
-	/* this is for modules since _machine can be a define -- Cort */
-	ppc_md.ppc_machine = _machine;
-
-	if ( ppc_md.progress ) ppc_md.progress("id mach(): done", 0x200);
-
-	return 0;
 }
+#endif /* CONFIG_ALL_PPC */
 
 int parse_bootinfo(void)
 {
 	struct bi_record *rec;
 	extern char __bss_start[];
-	extern char *sysmap;
-	extern unsigned long sysmap_size;
 
 	rec = (struct bi_record *)_ALIGN((ulong)__bss_start+(1<<20)-1,(1<<20));
 	if ( rec->tag != BI_FIRST )
@@ -696,20 +502,43 @@
 #ifdef CONFIG_ALL_PPC
 		case BI_MACHTYPE:
 			_machine = data[0];
-			have_of = data[1];
 			break;
 #endif /* CONFIG_ALL_PPC */
+		case BI_MEMSIZE:
+			boot_mem_size = data[0];
+			break;
 		}
 	}
 
 	return 0;
 }
 
+/*
+ * Find out what kind of machine we're on and save any data we need
+ * from the early boot process (devtree is copied on pmac by prom_init()).
+ * This is called very early on the boot process, after a minimal
+ * MMU environment has been set up but before MMU_init is called.
+ */
+void __init
+machine_init(unsigned long r3, unsigned long r4, unsigned long r5,
+	     unsigned long r6, unsigned long r7)
+{
+#ifdef CONFIG_CMDLINE
+	strcpy(cmd_line, CONFIG_CMDLINE);
+#endif /* CONFIG_CMDLINE */
+
+	parse_bootinfo();
+
+	platform_init(r3, r4, r5, r6, r7);
+
+	if (ppc_md.progress)
+		ppc_md.progress("id mach(): done", 0x200);
+}
+
 /* Checks "l2cr=xxxx" command-line option */
-int ppc_setup_l2cr(char *str)
+int __init ppc_setup_l2cr(char *str)
 {
-	if ( ((_get_PVR() >> 16) == 8) || ((_get_PVR() >> 16) == 12) )
-	{
+	if (cur_cpu_spec[0]->cpu_features & CPU_FTR_L2CR) {
 		unsigned long val = simple_strtoul(str, NULL, 0);
 		printk(KERN_INFO "l2cr set to %lx\n", val);
                 _set_L2CR(0);           /* force invalidate by disable cache */
@@ -761,18 +590,13 @@
 	 * Systems with OF can look in the properties on the cpu node(s)
 	 * for a possibly more accurate value.
 	 */
-	dcache_bsize = icache_bsize = 32;	/* most common value */
-	switch (_get_PVR() >> 16) {
-	case 1:		/* 601, with unified cache */
-		ucache_bsize = 32;
-		break;
-	/* XXX need definitions in here for 8xx etc. */
-	case 0x40:
-	case 0x41:
-	case 0x35:	/* 64-bit POWER3, POWER3+, POWER4 */
-		dcache_bsize = icache_bsize = 128;
-		break;
-	}
+	if (cur_cpu_spec[0]->cpu_features & CPU_FTR_SPLIT_ID_CACHE) {
+		dcache_bsize = cur_cpu_spec[0]->dcache_bsize;
+		icache_bsize = cur_cpu_spec[0]->icache_bsize;
+		ucache_bsize = 0;
+	} else
+		ucache_bsize = dcache_bsize = icache_bsize
+			= cur_cpu_spec[0]->dcache_bsize;
 
 	/* reboot on panic */
 	panic_timeout = 180;
@@ -813,6 +637,9 @@
 
 	paging_init();
 	sort_exception_table();
+
+	/* this is for modules since _machine can be a define -- Cort */
+	ppc_md.ppc_machine = _machine;
 }
 
 /* Convert the shorts/longs in hd_driveid from little to big endian;
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/sleep.S linux/arch/ppc/kernel/sleep.S
--- v2.4.9/linux/arch/ppc/kernel/sleep.S	Tue Jul  3 17:08:18 2001
+++ linux/arch/ppc/kernel/sleep.S	Tue Aug 28 06:58:33 2001
@@ -1,10 +1,10 @@
 /*
- * BK Id: SCCS/s.sleep.S 1.10 06/28/01 15:50:17 paulus
+ * BK Id: SCCS/s.sleep.S 1.13 08/19/01 22:23:04 paulus
  */
 /*
  * This file contains sleep low-level functions for PowerBook G3.
  *    Copyright (C) 1999 Benjamin Herrenschmidt (benh@kernel.crashing.org)
- *    and Paul Mackerras (paulus@cs.anu.edu.au).
+ *    and Paul Mackerras (paulus@samba.org).
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -45,7 +45,13 @@
 #define tovirt(rd,rs)	addis	rd,rs,KERNELBASE@h
 
 	.text
+	.align	5
 
+/* This gets called by via-pmu.c late during the sleep process.
+ * The PMU was already send the sleep command and will shut us down
+ * soon. We need to save all that is needed and setup the wakeup
+ * vector that will be called by the ROM on wakeup
+ */
 _GLOBAL(low_sleep_handler)
 	mflr	r0
 	stw	r0,4(r1)
@@ -53,13 +59,14 @@
 	stw	r2,SL_R2(r1)
 	stmw	r12,SL_R12(r1)
 
-	/* Save MSR, SDR1, TB  */
+	/* Save MSR & SDR1 */
 	mfmsr	r4
 	stw	r4,SL_MSR(r1)
 	mfsdr1	r4
 	stw	r4,SL_SDR1(r1)
-1:	
-	mftbu	r4
+
+	/* Get a stable timebase and save it */
+1:	mftbu	r4
 	stw	r4,SL_TB(r1)
 	mftb	r5
 	stw	r5,SL_TB+4(r1)
@@ -114,10 +121,19 @@
 	/* Save HID0 */
 	mfspr	r4,HID0
 	stw	r4,SL_HID0(r1)
-
-	/* Set up stuff at address 0 */
-	lis	r5,wake_up@ha
-	addi	r5,r5,wake_up@l
+	
+	/* The ROM can wake us up via 2 different vectors:
+	 *  - On wallstreet & lombard, we must write a magic
+	 *    value 'Lars' at address 4 and a pointer to a
+	 *    memory location containing the PC to resume from
+	 *    at address 0.
+	 *  - On Core99, we must store the wakeup vector at
+	 *    address 0x80 and eventually it's parameters
+	 *    at address 0x84. I've have some trouble with those
+	 *    parameters however and I no longer use them.
+	 */
+	lis	r5,grackle_wake_up@ha
+	addi	r5,r5,grackle_wake_up@l
 	tophys(r5,r5)
 	stw	r5,SL_PC(r1)
 	lis	r4,KERNELBASE@h
@@ -127,22 +143,35 @@
 	addi	r6,r6,MAGIC@l
 	stw	r5,0(r4)
 	stw	r6,4(r4)
+	/* Setup stuffs at 0x80-0x84 for Core99 */
+	lis	r3,core99_wake_up@ha
+	addi	r3,r3,core99_wake_up@l
+	tophys(r3,r3)
+	stw	r3,0x80(r4)
+	stw	r5,0x84(r4)
+	/* Store a pointer to our backup storage into
+	 * a kernel global
+	 */
+	lis r3,sleep_storage@ha
+	addi r3,r3,sleep_storage@l
+	stw r5,0(r3)
+
 
 /*
- * Flush the L1 data cache by reading the first 64kB of RAM
+ * Flush the L1 data cache by reading the first 128kB of RAM
  * and then flushing the same area with the dcbf instruction.
  * The L2 cache has already been disabled.
  */
-	li	r4,0x0800	/* 64kB / 32B */
+	li	r4,0x1000	/* 128kB / 32B */
 	mtctr	r4
 	lis	r4,KERNELBASE@h
 1:
 	lwz	r0,0(r4)
-	addi	r4,r4,0x0020		/* Go to start of next cache line */
+	addi	r4,r4,0x0020	/* Go to start of next cache line */
 	bdnz	1b
 	sync
 	
-	li	r4,0x0800	/* 64k */
+	li	r4,0x1000	/* 128kB / 32B */
 	mtctr	r4
 	lis	r4,KERNELBASE@h
 1:
@@ -160,7 +189,13 @@
 	sync
 	mtspr	HID0,r2
 	sync
-	
+
+/* This loop puts us back to sleep in case we have a spurrious
+ * wakeup so that the host bridge properly stays asleep. The
+ * CPU will be turned off, either after a known time (about 1
+ * second) on wallstreet & lombard, or as soon as the CPU enters
+ * SLEEP mode on core99
+ */
 	mfmsr	r2
 	oris	r2,r2,MSR_POW@h
 1:	sync
@@ -170,22 +205,66 @@
 
 /* 
  * Here is the resume code.
+ */
+
+
+/*
+ * Core99 machines resume here
+ * r4 has the physical address of SL_PC(sp) (unused)
+ */
+_GLOBAL(core99_wake_up)
+	/* Make sure HID0 no longer contains any sleep bit */
+	mfspr	r3,HID0
+	rlwinm	r3,r3,0,11,7		/* clear SLEEP, NAP, DOZE bits */
+	mtspr	HID0,r3
+	sync
+	isync
+
+	/* Won't that cause problems on CPU that doesn't support it ? */
+	lis	r3, 0
+	mtspr	SPRN_MMCR0, r3
+	
+	/* sanitize MSR */
+	mfmsr	r3
+	ori	r3,r3,MSR_EE|MSR_IP
+	xori	r3,r3,MSR_EE|MSR_IP
+	sync
+	isync
+	mtmsr	r3
+	sync
+	isync
+
+	/* Recover sleep storage */
+	lis	r3,sleep_storage@ha
+	addi	r3,r3,sleep_storage@l
+	tophys(r3,r3)
+	lwz	r1,0(r3)
+
+	/* Pass thru to older resume code ... */
+/* 
+ * Here is the resume code for older machines.
  * r1 has the physical address of SL_PC(sp).
  */
 	
-wake_up:
-	/* Flash inval the instruction cache */
+grackle_wake_up:
+	/* Enable and then Flash inval the instruction & data cache */
 	mfspr	r3,HID0
-	ori	r3,r3, HID0_ICFI
-	mtspr	HID0,r3
+	ori	r3,r3, HID0_ICE|HID0_ICFI|HID0_DCE|HID0_DCI
+	sync
 	isync
-	/* Restore the HID0 register.  This turns on the L1 caches. */
+	mtspr	HID0,r3
+	xori	r3,r3, HID0_ICFI|HID0_DCI
+	mtspr	HID0,r3
+	sync
+	
+	/* Restore the remaining bits of the HID0 register. */
 	subi	r1,r1,SL_PC
 	lwz	r3,SL_HID0(r1)
 	sync
 	isync
 	mtspr	HID0,r3
 	sync
+	isync
 
 	/* Restore the kernel's segment registers, the
 	   BATs, and SDR1.  Then we can turn on the MMU. */
@@ -242,6 +321,13 @@
 	lwz	r4,SL_IBAT3+4(r1)
 	mtibatl	3,r4
 
+	/* Flush all TLBs */
+	lis	r4,0x1000
+1:	addic.	r4,r4,-0x1000
+	tlbie	r4
+	blt	1b
+	sync
+
 	/* restore the MSR and turn on the MMU */
 	lwz	r3,SL_MSR(r1)
 	bl	turn_on_mmu	
@@ -250,6 +336,8 @@
 	tovirt(r1,r1)
 
 	/* Restore TB */
+	li	r3,0
+	mttbl	r3
 	lwz	r3,SL_TB(r1)
 	lwz	r4,SL_TB+4(r1)
 	mttbu	r3
@@ -269,4 +357,10 @@
 	mtsrr0	r4
 	mtsrr1	r3
 	sync
+	isync
 	rfi
+
+	.data
+	.globl sleep_storage
+sleep_storage:
+	.long 0
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/smp.c linux/arch/ppc/kernel/smp.c
--- v2.4.9/linux/arch/ppc/kernel/smp.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/ppc/kernel/smp.c	Sat Sep  8 12:38:42 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.smp.c 1.25 05/23/01 00:38:42 cort
+ * BK Id: SCCS/s.smp.c 1.31 09/08/01 15:47:42 paulus
  */
 /*
  * Smp support for ppc.
@@ -9,11 +9,6 @@
  *
  * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
  *
- * Support for PReP (Motorola MTX/MVME) and Macintosh G4 SMP 
- * by Troy Benjegerdes (hozer@drgw.net)
- *
- * Support for DayStar quad CPU cards
- * Copyright (C) XLR8, Inc. 1994-2000
  */
 
 #include <linux/config.h>
@@ -36,16 +31,15 @@
 #include <asm/pgtable.h>
 #include <asm/hardirq.h>
 #include <asm/softirq.h>
-#include <asm/init.h>
 #include <asm/io.h>
 #include <asm/prom.h>
 #include <asm/smp.h>
 #include <asm/residual.h>
 #include <asm/feature.h>
 #include <asm/time.h>
-#include <asm/gemini.h>
 
 #include "open_pic.h"
+
 int smp_threads_ready;
 volatile int smp_commenced;
 int smp_num_cpus = 1;
@@ -54,13 +48,14 @@
 struct klock_info_struct klock_info = { KLOCK_CLEAR, 0 };
 atomic_t ipi_recv;
 atomic_t ipi_sent;
-spinlock_t kernel_flag = SPIN_LOCK_UNLOCKED;
+spinlock_t kernel_flag __cacheline_aligned = SPIN_LOCK_UNLOCKED;
 unsigned int prof_multiplier[NR_CPUS];
 unsigned int prof_counter[NR_CPUS];
 cycles_t cacheflush_time;
 static int max_cpus __initdata = NR_CPUS;
 unsigned long cpu_online_map;
 int smp_hw_index[NR_CPUS];
+static struct smp_ops_t *smp_ops;
 
 /* all cpu mappings are 1-1 -- Cort */
 volatile unsigned long cpu_callin_map[NR_CPUS];
@@ -74,60 +69,6 @@
 void smp_call_function_interrupt(void);
 void smp_message_pass(int target, int msg, unsigned long data, int wait);
 
-extern void __secondary_start_psurge(void);
-extern void __secondary_start_psurge2(void);	/* Temporary horrible hack */
-extern void __secondary_start_psurge3(void);	/* Temporary horrible hack */
-
-/* Addresses for powersurge registers */
-#define HAMMERHEAD_BASE		0xf8000000
-#define HHEAD_CONFIG		0x90
-#define HHEAD_SEC_INTR		0xc0
-
-/* register for interrupting the primary processor on the powersurge */
-/* N.B. this is actually the ethernet ROM! */
-#define PSURGE_PRI_INTR		0xf3019000
-
-/* register for storing the start address for the secondary processor */
-/* N.B. this is the PCI config space address register for the 1st bridge */
-#define PSURGE_START		0xf2800000
-
-/* Daystar/XLR8 4-CPU card */
-#define PSURGE_QUAD_REG_ADDR	0xf8800000
-
-#define PSURGE_QUAD_IRQ_SET	0
-#define PSURGE_QUAD_IRQ_CLR	1
-#define PSURGE_QUAD_IRQ_PRIMARY	2
-#define PSURGE_QUAD_CKSTOP_CTL	3
-#define PSURGE_QUAD_PRIMARY_ARB	4
-#define PSURGE_QUAD_BOARD_ID	6
-#define PSURGE_QUAD_WHICH_CPU	7
-#define PSURGE_QUAD_CKSTOP_RDBK	8
-#define PSURGE_QUAD_RESET_CTL	11
-
-#define PSURGE_QUAD_OUT(r, v)	(out_8(quad_base + ((r) << 4) + 4, (v)))
-#define PSURGE_QUAD_IN(r)	(in_8(quad_base + ((r) << 4) + 4) & 0x0f)
-#define PSURGE_QUAD_BIS(r, v)	(PSURGE_QUAD_OUT((r), PSURGE_QUAD_IN(r) | (v)))
-#define PSURGE_QUAD_BIC(r, v)	(PSURGE_QUAD_OUT((r), PSURGE_QUAD_IN(r) & ~(v)))
-
-/* virtual addresses for the above */
-static volatile u8 *hhead_base;
-static volatile u8 *quad_base;
-static volatile u32 *psurge_pri_intr;
-static volatile u8 *psurge_sec_intr;
-static volatile u32 *psurge_start;
-
-/* what sort of powersurge board we have */
-static int psurge_type;
-
-/* values for psurge_type */
-#define PSURGE_DUAL		0
-#define PSURGE_QUAD_OKEE	1
-#define PSURGE_QUAD_COTTON	2
-#define PSURGE_QUAD_ICEGRASS	3
-
-/* l2 cache stuff for dual G4 macs */
-extern void core99_init_l2(void);
-
 /* Since OpenPIC has only 4 IPIs, we use slightly different message numbers.
  * 
  * Make sure this matches openpic_request_IPIs in open_pic.c, or what shows up
@@ -137,621 +78,12 @@
 #define PPC_MSG_INVALIDATE_TLB	2
 #define PPC_MSG_XMON_BREAK	3
 
-static inline void set_tb(unsigned int upper, unsigned int lower)
-{
-	mtspr(SPRN_TBWL, 0);
-	mtspr(SPRN_TBWU, upper);
-	mtspr(SPRN_TBWL, lower);
-}
-
-/*
- * Set and clear IPIs for powersurge.
- */
-static inline void psurge_set_ipi(int cpu)
-{
-	if (cpu == 0)
-		in_be32(psurge_pri_intr);
-	else if (psurge_type == PSURGE_DUAL)
-		out_8(psurge_sec_intr, 0);
-	else
-		PSURGE_QUAD_OUT(PSURGE_QUAD_IRQ_SET, 1 << cpu);
-}
-
-static inline void psurge_clr_ipi(int cpu)
-{
-	if (cpu > 0) {
-		if (psurge_type == PSURGE_DUAL)
-			out_8(psurge_sec_intr, ~0);
-		else
-			PSURGE_QUAD_OUT(PSURGE_QUAD_IRQ_CLR, 1 << cpu);
-	}
-}
-
-/*
- * On powersurge (old SMP powermac architecture) we don't have
- * separate IPIs for separate messages like openpic does.  Instead
- * we have a bitmap for each processor, where a 1 bit means that
- * the corresponding message is pending for that processor.
- * Ideally each cpu's entry would be in a different cache line.
- *  -- paulus.
- */
-static unsigned long psurge_smp_message[NR_CPUS];
-
-void psurge_smp_message_recv(struct pt_regs *regs)
-{
-	int cpu = smp_processor_id();
-	int msg;
-
-	/* clear interrupt */
-	psurge_clr_ipi(cpu);
-
-	if (smp_num_cpus < 2)
-		return;
-
-	/* make sure there is a message there */
-	for (msg = 0; msg < 4; msg++)
-		if (test_and_clear_bit(msg, &psurge_smp_message[cpu]))
-			smp_message_recv(msg, regs);
-}
-
-void
-psurge_primary_intr(int irq, void *d, struct pt_regs *regs)
-{
-	psurge_smp_message_recv(regs);
-}
-
-static void
-smp_psurge_message_pass(int target, int msg, unsigned long data, int wait)
-{
-	int i;
-
-	if (smp_num_cpus < 2)
-		return;
-
-	for (i = 0; i < smp_num_cpus; i++) {
-		if (target == MSG_ALL
-		    || (target == MSG_ALL_BUT_SELF && i != smp_processor_id())
-		    || target == i) {
-			set_bit(msg, &psurge_smp_message[i]);
-			psurge_set_ipi(i);
-		}
-	}
-}
-
-/*
- * Determine a quad card presence. We read the board ID register, we
- * force the data bus to change to something else, and we read it again.
- * It it's stable, then the register probably exist (ugh !)
- */
-static int __init psurge_quad_probe(void)
-{
-	int type;
-	unsigned int i;
-
-	type = PSURGE_QUAD_IN(PSURGE_QUAD_BOARD_ID);
-	if (type < PSURGE_QUAD_OKEE || type > PSURGE_QUAD_ICEGRASS
-	    || type != PSURGE_QUAD_IN(PSURGE_QUAD_BOARD_ID))
-		return PSURGE_DUAL;
-
-	/* looks OK, try a slightly more rigorous test */
-	/* bogus is not necessarily cacheline-aligned,
-	   though I don't suppose that really matters.  -- paulus */
-	for (i = 0; i < 100; i++) {
-		volatile u32 bogus[8];
-		bogus[(0+i)%8] = 0x00000000;
-		bogus[(1+i)%8] = 0x55555555;
-		bogus[(2+i)%8] = 0xFFFFFFFF;
-		bogus[(3+i)%8] = 0xAAAAAAAA;
-		bogus[(4+i)%8] = 0x33333333;
-		bogus[(5+i)%8] = 0xCCCCCCCC;
-		bogus[(6+i)%8] = 0xCCCCCCCC;
-		bogus[(7+i)%8] = 0x33333333;
-		wmb();
-		asm volatile("dcbf 0,%0" : : "r" (bogus) : "memory");
-		mb();
-		if (type != PSURGE_QUAD_IN(PSURGE_QUAD_BOARD_ID))
-			return PSURGE_DUAL;
-	}
-	return type;
-}
-
-static void __init psurge_quad_init(void)
-{
-	int procbits;
-
-	if (ppc_md.progress) ppc_md.progress("psurge_quad_init", 0x351);
-	procbits = ~PSURGE_QUAD_IN(PSURGE_QUAD_WHICH_CPU);
-	if (psurge_type == PSURGE_QUAD_ICEGRASS)
-		PSURGE_QUAD_BIS(PSURGE_QUAD_RESET_CTL, procbits);
-	else
-		PSURGE_QUAD_BIC(PSURGE_QUAD_CKSTOP_CTL, procbits);
-	mdelay(33);
-	out_8(psurge_sec_intr, ~0);
-	PSURGE_QUAD_OUT(PSURGE_QUAD_IRQ_CLR, procbits);
-	PSURGE_QUAD_BIS(PSURGE_QUAD_RESET_CTL, procbits);
-	if (psurge_type != PSURGE_QUAD_ICEGRASS)
-		PSURGE_QUAD_BIS(PSURGE_QUAD_CKSTOP_CTL, procbits);
-	PSURGE_QUAD_BIC(PSURGE_QUAD_PRIMARY_ARB, procbits);
-	mdelay(33);
-	PSURGE_QUAD_BIC(PSURGE_QUAD_RESET_CTL, procbits);
-	mdelay(33);
-	PSURGE_QUAD_BIS(PSURGE_QUAD_PRIMARY_ARB, procbits);
-	mdelay(33);
-}
-
-static int __init smp_psurge_probe(void)
-{
-	int i, ncpus;
-
-	/* We don't do SMP on the PPC601 -- paulus */
-	if ((_get_PVR() >> 16) == 1)
-		return 1;
-
-	/*
-	 * The powersurge cpu board can be used in the generation
-	 * of powermacs that have a socket for an upgradeable cpu card,
-	 * including the 7500, 8500, 9500, 9600.
-	 * The device tree doesn't tell you if you have 2 cpus because
-	 * OF doesn't know anything about the 2nd processor.
-	 * Instead we look for magic bits in magic registers,
-	 * in the hammerhead memory controller in the case of the
-	 * dual-cpu powersurge board.  -- paulus.
-	 */
-	if (find_devices("hammerhead") == NULL)
-		return 1;
-
-	hhead_base = ioremap(HAMMERHEAD_BASE, 0x800);
-	quad_base = ioremap(PSURGE_QUAD_REG_ADDR, 1024);
-	psurge_sec_intr = hhead_base + HHEAD_SEC_INTR;
-
-	psurge_type = psurge_quad_probe();
-	if (psurge_type != PSURGE_DUAL) {
-		psurge_quad_init();
-		/* All released cards using this HW design have 4 CPUs */
-		ncpus = 4;
-	} else {
-		iounmap((void *) quad_base);
-		if ((in_8(hhead_base + HHEAD_CONFIG) & 0x02) == 0) {
-			/* not a dual-cpu card */
-			iounmap((void *) hhead_base);
-			return 1;
-		}
-		ncpus = 2;
-	}
-
-	psurge_start = ioremap(PSURGE_START, 4);
-	psurge_pri_intr = ioremap(PSURGE_PRI_INTR, 4);
-
-	/* this is not actually strictly necessary -- paulus. */
-	for (i = 1; i < ncpus; ++i)
-		smp_hw_index[i] = i;
-
-	if (ppc_md.progress) ppc_md.progress("smp_psurge_probe - done", 0x352);
-
-	return ncpus;
-}
-
-static void __init smp_psurge_kick_cpu(int nr)
-{
-	void (*start)(void) = __secondary_start_psurge;
-
-	if (ppc_md.progress) ppc_md.progress("smp_psurge_kick_cpu", 0x353);
-
-	/* setup entry point of secondary processor */
-	switch (nr) {
-	case 2:
-		start = __secondary_start_psurge2;
-		break;
-	case 3:
-		start = __secondary_start_psurge3;
-		break;
-	}
-
-	out_be32(psurge_start, __pa(start));
-	mb();
-
-	psurge_set_ipi(nr);
-	udelay(10);
-	psurge_clr_ipi(nr);
-
-	if (ppc_md.progress) ppc_md.progress("smp_psurge_kick_cpu - done", 0x354);
-}
-
-/*
- * With the dual-cpu powersurge board, the decrementers and timebases
- * of both cpus are frozen after the secondary cpu is started up,
- * until we give the secondary cpu another interrupt.  This routine
- * uses this to get the timebases synchronized.
- *  -- paulus.
- */
-static void __init psurge_dual_sync_tb(int cpu_nr)
-{
-	static volatile int sec_tb_reset = 0;
-	int t;
-
-	set_dec(tb_ticks_per_jiffy);
-	set_tb(0, 0);
-	last_jiffy_stamp(cpu_nr) = 0;
-
-	if (cpu_nr > 0) {
-		mb();
-		sec_tb_reset = 1;
-		return;
-	}
-
-	/* wait for the secondary to have reset its TB before proceeding */
-	for (t = 10000000; t > 0 && !sec_tb_reset; --t)
-		;
-
-	/* now interrupt the secondary, starting both TBs */
-	psurge_set_ipi(1);
-
-	smp_tb_synchronized = 1;
-}
-
-static void
-smp_psurge_setup_cpu(int cpu_nr)
-{
-
-	if (cpu_nr == 0) {
-		if (smp_num_cpus < 2)
-			return;
-		/* reset the entry point so if we get another intr we won't
-		 * try to startup again */
-		out_be32(psurge_start, 0x100);
-		if (request_irq(30, psurge_primary_intr, 0, "primary IPI", 0))
-			printk(KERN_ERR "Couldn't get primary IPI interrupt");
-	}
-
-	if (psurge_type == PSURGE_DUAL)
-		psurge_dual_sync_tb(cpu_nr);
-}
-
-
-static void
-smp_openpic_message_pass(int target, int msg, unsigned long data, int wait)
-{
-	/* make sure we're sending something that translates to an IPI */
-	if ( msg > 0x3 ){
-		printk("SMP %d: smp_message_pass: unknown msg %d\n",
-		       smp_processor_id(), msg);
-		return;
-	}
-	switch ( target )
-	{
-	case MSG_ALL:
-		openpic_cause_IPI(msg, 0xffffffff);
-		break;
-	case MSG_ALL_BUT_SELF:
-		openpic_cause_IPI(msg,
-				  0xffffffff & ~(1 << smp_processor_id()));
-		break;
-	default:
-		openpic_cause_IPI(msg, 1<<target);
-		break;
-	}
-}
-
-static int
-smp_core99_probe(void)
-{
-	struct device_node *cpus;
-	int i, ncpus = 1;
-
-	if (ppc_md.progress) ppc_md.progress("smp_core99_probe", 0x345);
-	cpus = find_type_devices("cpu");
-	if (cpus)
-		while ((cpus = cpus->next) != NULL)
-			++ncpus;
-	printk("smp_core99_probe: found %d cpus\n", ncpus);
-	if (ncpus > 1) {
-		openpic_request_IPIs();
-		for (i = 1; i < ncpus; ++i)
-			smp_hw_index[i] = i;
-	}
-
-	return ncpus;
-}
-
-static void
-smp_core99_kick_cpu(int nr)
-{
-	unsigned long save_vector, new_vector;
-	unsigned long flags;
-#if 1 /* New way... */
-	volatile unsigned long *vector
-		 = ((volatile unsigned long *)(KERNELBASE+0x100));
-	if (nr < 1 || nr > 3)
-		return;
-#else
-	volatile unsigned long *vector
-		 = ((volatile unsigned long *)(KERNELBASE+0x500));
-	if (nr != 1)
-		return;
-#endif
-	if (ppc_md.progress) ppc_md.progress("smp_core99_kick_cpu", 0x346);
-
-	local_irq_save(flags);
-	local_irq_disable();
-	
-	/* Save reset vector */
-	save_vector = *vector;
-	
-	/* Setup fake reset vector that does	  
-	 *   b __secondary_start_psurge - KERNELBASE
-	 */  
-	switch(nr) {
-		case 1:
-			new_vector = (unsigned long)__secondary_start_psurge;
-			break;
-		case 2:
-			new_vector = (unsigned long)__secondary_start_psurge2;
-			break;
-		case 3:
-			new_vector = (unsigned long)__secondary_start_psurge3;
-			break;
-	}
-	*vector = 0x48000002 + new_vector - KERNELBASE;
-	
-	/* flush data cache and inval instruction cache */
-	flush_icache_range((unsigned long) vector, (unsigned long) vector + 4);
-	
-	/* Put some life in our friend */
-	feature_core99_kick_cpu(nr);
-	
-	/* FIXME: We wait a bit for the CPU to take the exception, I should
-	 * instead wait for the entry code to set something for me. Well,
-	 * ideally, all that crap will be done in prom.c and the CPU left
-	 * in a RAM-based wait loop like CHRP.
-	 */
-	mdelay(1);
-	
-	/* Restore our exception vector */
-	*vector = save_vector;
-	flush_icache_range((unsigned long) vector, (unsigned long) vector + 4);
-	
-	local_irq_restore(flags);
-	if (ppc_md.progress) ppc_md.progress("smp_core99_kick_cpu done", 0x347);
-}
-
-static void
-smp_core99_setup_cpu(int cpu_nr)
-{
-	/* Setup openpic */
-	do_openpic_setup_cpu();
-
-	/* Setup L2 */
-	if (cpu_nr != 0)
-		core99_init_l2();
-	else
-		if (ppc_md.progress) ppc_md.progress("core99_setup_cpu 0 done", 0x349);
-}
-
-static int
-smp_chrp_probe(void)
-{
-	extern unsigned long smp_chrp_cpu_nr;
-
-	if (smp_chrp_cpu_nr > 1)
-		openpic_request_IPIs();
-
-	return smp_chrp_cpu_nr;
-}
-
-static void
-smp_chrp_kick_cpu(int nr)
-{
-	*(unsigned long *)KERNELBASE = nr;
-	asm volatile("dcbf 0,%0"::"r"(KERNELBASE):"memory");
-}
-
-static void
-smp_chrp_setup_cpu(int cpu_nr)
-{
-	static atomic_t ready = ATOMIC_INIT(1);
-	static volatile int frozen = 0;
-
-	if (cpu_nr == 0) {
-		/* wait for all the others */
-		while (atomic_read(&ready) < smp_num_cpus)
-			barrier();
-		atomic_set(&ready, 1);
-		/* freeze the timebase */
-		call_rtas("freeze-time-base", 0, 1, NULL);
-		mb();
-		frozen = 1;
-		/* XXX assumes this is not a 601 */
-		set_tb(0, 0);
-		last_jiffy_stamp(0) = 0;
-		while (atomic_read(&ready) < smp_num_cpus)
-			barrier();
-		/* thaw the timebase again */
-		call_rtas("thaw-time-base", 0, 1, NULL);
-		mb();
-		frozen = 0;
-		smp_tb_synchronized = 1;
-	} else {
-		atomic_inc(&ready);
-		while (!frozen)
-			barrier();
-		set_tb(0, 0);
-		last_jiffy_stamp(0) = 0;
-		mb();
-		atomic_inc(&ready);
-		while (frozen)
-			barrier();
-	}
-
-	if (OpenPIC_Addr)
-		do_openpic_setup_cpu();
-}
-
-#ifdef CONFIG_POWER4
-static void
-smp_xics_message_pass(int target, int msg, unsigned long data, int wait)
-{
-	/* for now, only do reschedule messages
-	   since we only have one IPI */
-	if (msg != PPC_MSG_RESCHEDULE)
-		return;
-	for (i = 0; i < smp_num_cpus; ++i) {
-		if (target == MSG_ALL || target == i
-		    || (target == MSG_ALL_BUT_SELF
-			&& i != smp_processor_id()))
-			xics_cause_IPI(i);
-	}
-}
-
-static int
-smp_xics_probe(void)
-{
-	return smp_chrp_cpu_nr;
-}
-
-static void
-smp_xics_setup_cpu(int cpu_nr)
-{
-	if (cpu_nr > 0)
-		xics_setup_cpu();
-}
-#endif /* CONFIG_POWER4 */
-
-static int
-smp_prep_probe(void)
-{
-	extern int mot_multi;
-
-	if (mot_multi) {
-		openpic_request_IPIs();
-		smp_hw_index[1] = 1;
-		return 2;
-	}
-
-	return 1;
-}
-
-static void
-smp_prep_kick_cpu(int nr)
-{
-	extern unsigned long *MotSave_SmpIar;
-	extern unsigned char *MotSave_CpusState[2];
-
-	*MotSave_SmpIar = (unsigned long)__secondary_start_psurge - KERNELBASE;
-	*MotSave_CpusState[1] = CPU_GOOD;
-	printk("CPU1 reset, waiting\n");
-}
-
-static void
-smp_prep_setup_cpu(int cpu_nr)
-{
-	if (OpenPIC_Addr)
-		do_openpic_setup_cpu();
-}
-
-#ifdef CONFIG_GEMINI	
-static int
-smp_gemini_probe(void)
-{
-	int i, nr;
-
-        nr = (readb(GEMINI_CPUSTAT) & GEMINI_CPU_COUNT_MASK) >> 2;
-	if (nr == 0)
-		nr = 4;
-
-	if (nr > 1) {
-		openpic_request_IPIs();
-		for (i = 1; i < nr; ++i)
-			smp_hw_index[i] = i;
-	}
-
-	return nr;
-}
-
-static void
-smp_gemini_kick_cpu(int nr)
-{
-	openpic_init_processor( 1<<nr );
-	openpic_init_processor( 0 );
-}
-
-static void
-smp_gemini_setup_cpu(int cpu_nr)
-{
-	if (OpenPIC_Addr)
-		do_openpic_setup_cpu();
-	if (cpu_nr > 0)
-		gemini_init_l2();
-}
-#endif /* CONFIG_GEMINI */
-
-
-static struct smp_ops_t {
-	void  (*message_pass)(int target, int msg, unsigned long data, int wait);
-	int   (*probe)(void);
-	void  (*kick_cpu)(int nr);
-	void  (*setup_cpu)(int nr);
-
-} *smp_ops;
-
 #define smp_message_pass(t,m,d,w) \
     do { if (smp_ops) \
 	     atomic_inc(&ipi_sent); \
 	     smp_ops->message_pass((t),(m),(d),(w)); \
        } while(0)
 
-
-/* PowerSurge-style Macs */
-static struct smp_ops_t psurge_smp_ops = {
-	smp_psurge_message_pass,
-	smp_psurge_probe,
-	smp_psurge_kick_cpu,
-	smp_psurge_setup_cpu,
-};
-
-/* Core99 Macs (dual G4s) */
-static struct smp_ops_t core99_smp_ops = {
-	smp_openpic_message_pass,
-	smp_core99_probe,
-	smp_core99_kick_cpu,
-	smp_core99_setup_cpu,
-};
-
-/* CHRP with openpic */
-static struct smp_ops_t chrp_smp_ops = {
-	smp_openpic_message_pass,
-	smp_chrp_probe,
-	smp_chrp_kick_cpu,
-	smp_chrp_setup_cpu,
-};
-
-#ifdef CONFIG_POWER4
-/* CHRP with new XICS interrupt controller */
-static struct smp_ops_t xics_smp_ops = {
-	smp_xics_message_pass,
-	smp_xics_probe,
-	smp_chrp_kick_cpu,
-	smp_xics_setup_cpu,
-};
-#endif /* CONFIG_POWER4 */
-
-/* PReP (MTX) */
-static struct smp_ops_t prep_smp_ops = {
-	smp_openpic_message_pass,
-	smp_prep_probe,
-	smp_prep_kick_cpu,
-	smp_prep_setup_cpu,
-};
-
-#ifdef CONFIG_GEMINI	
-/* Gemini */
-static struct smp_ops_t gemini_smp_ops = {
-	smp_openpic_message_pass,
-	smp_gemini_probe,
-	smp_gemini_kick_cpu,
-	smp_gemini_setup_cpu,
-};
-#endif /* CONFIG_GEMINI	*/
-
 /* 
  * Common functions
  */
@@ -798,7 +130,7 @@
  */
 void smp_send_tlb_invalidate(int cpu)
 {
-	if ( (_get_PVR()>>16) == 8 )
+	if ( PVR_VER(mfspr(PVR)) == 8 )
 		smp_message_pass(MSG_ALL_BUT_SELF, PPC_MSG_INVALIDATE_TLB, 0, 0);
 }
 
@@ -947,7 +279,6 @@
 	extern struct task_struct *current_set[NR_CPUS];
 	int i, cpu_nr;
 	struct task_struct *p;
-	unsigned long a;
 
 	printk("Entering SMP Mode...\n");
 	smp_num_cpus = 1;
@@ -973,35 +304,12 @@
 	 */
 	cacheflush_time = 5 * 1024;
 
-	/* To be later replaced by some arch-specific routine */
-	switch(_machine) {
-	case _MACH_Pmac:
-		/* Check for Core99 */
-		if (find_devices("uni-n"))
-			smp_ops = &core99_smp_ops;
-		else
-			smp_ops = &psurge_smp_ops;
-		break;
-	case _MACH_chrp:
-#ifndef CONFIG_POWER4
-		smp_ops = &chrp_smp_ops;
-#else
-		smp_ops = &xics_smp_ops;
-#endif /* CONFIG_POWER4 */
-		break;
-	case _MACH_prep:
-		smp_ops = &prep_smp_ops;
-		break;
-#ifdef CONFIG_GEMINI		
-	case _MACH_gemini:
-		smp_ops = &gemini_smp_ops;
-		break;
-#endif /* CONFIG_GEMINI	*/
-	default:
+	smp_ops = ppc_md.smp_ops;
+	if (smp_ops == NULL) {
 		printk("SMP not supported on this machine.\n");
 		return;
 	}
-	
+
 	/* Probe arch for CPUs */
 	cpu_nr = smp_ops->probe();
 
@@ -1044,10 +352,12 @@
 		p->has_cpu = 1;
 		current_set[i] = p;
 
-		/* need to flush here since secondary bats aren't setup */
-		for (a = KERNELBASE; a < KERNELBASE + 0x800000; a += 32)
-			asm volatile("dcbf 0,%0" : : "r" (a) : "memory");
-		asm volatile("sync");
+		/*
+		 * There was a cache flush loop here to flush the cache
+		 * to memory for the first 8MB of RAM.  The cache flush
+		 * has been pushed into the kick_cpu function for those
+		 * platforms that need it.
+		 */
 
 		/* wake up cpus */
 		smp_ops->kick_cpu(i);
@@ -1155,7 +465,6 @@
 	/* so time.c doesn't get confused */
 	set_dec(tb_ticks_per_jiffy);
 	last_jiffy_stamp(cpu) = 0;
-	cpu_callin_map[cpu] = 1;
 }
 
 void __init smp_commence(void)
@@ -1247,7 +556,7 @@
 
 	/* assume bogomips are same for everything */
         c->loops_per_jiffy = loops_per_jiffy;
-        c->pvr = _get_PVR();
+        c->pvr = mfspr(PVR);
 }
 
 static int __init maxcpus(char *str)
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/temp.c linux/arch/ppc/kernel/temp.c
--- v2.4.9/linux/arch/ppc/kernel/temp.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/ppc/kernel/temp.c	Tue Aug 28 06:58:33 2001
@@ -0,0 +1,278 @@
+/*
+ * temp.c	Thermal management for cpu's with Thermal Assist Units
+ *
+ * Written by Troy Benjegerdes <hozer@drgw.net>
+ *
+ * TODO:
+ * dynamic power management to limit peak CPU temp (using ICTC)
+ * calibration???
+ * 
+ * Silly, crazy ideas: use cpu load (from scheduler) and ICTC to extend battery
+ * life in portables, and add a 'performance/watt' metric somewhere in /proc
+ */
+
+#include <linux/config.h>
+#include <linux/errno.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/param.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/interrupt.h>
+#include <linux/init.h>
+
+#include <asm/segment.h>
+#include <asm/io.h>
+#include <asm/processor.h>
+#include <asm/nvram.h>
+#include <asm/cache.h>
+#include <asm/8xx_immap.h>
+#include <asm/machdep.h>
+
+static struct tau_temp
+{
+	int interrupts;
+	unsigned char low;
+	unsigned char high;
+	unsigned char grew;
+} tau[NR_CPUS];
+
+struct timer_list tau_timer;
+
+#undef DEBUG
+
+/* TODO: put these in a /proc interface, with some sanity checks, and maybe
+ * dynamic adjustment to minimize # of interrupts */
+/* configurable values for step size and how much to expand the window when
+ * we get an interrupt. These are based on the limit that was out of range */
+#define step_size		2	/* step size when temp goes out of range */
+#define window_expand		1	/* expand the window by this much */
+/* configurable values for shrinking the window */
+#define shrink_timer	2*HZ	/* period between shrinking the window */
+#define min_window	2	/* minimum window size, degrees C */
+
+void set_thresholds(unsigned long cpu)
+{
+#ifdef CONFIG_TAU_INT
+	/*
+	 * setup THRM1,
+	 * threshold, valid bit, enable interrupts, interrupt when below threshold
+	 */
+	mtspr(SPRN_THRM1, THRM1_THRES(tau[cpu].low) | THRM1_V | THRM1_TIE | THRM1_TID);
+
+	/* setup THRM2,
+	 * threshold, valid bit, enable interrupts, interrupt when above threshhold
+	 */
+	mtspr (SPRN_THRM2, THRM1_THRES(tau[cpu].high) | THRM1_V | THRM1_TIE);
+#else
+	/* same thing but don't enable interrupts */
+	mtspr(SPRN_THRM1, THRM1_THRES(tau[cpu].low) | THRM1_V | THRM1_TID);
+	mtspr(SPRN_THRM2, THRM1_THRES(tau[cpu].high) | THRM1_V);
+#endif
+}
+
+void TAUupdate(int cpu)
+{
+	unsigned thrm;
+
+#ifdef DEBUG
+	printk("TAUupdate ");
+#endif
+
+	/* if both thresholds are crossed, the step_sizes cancel out
+	 * and the window winds up getting expanded twice. */
+	if((thrm = mfspr(SPRN_THRM1)) & THRM1_TIV){ /* is valid? */
+		if(thrm & THRM1_TIN){ /* crossed low threshold */
+			if (tau[cpu].low >= step_size){
+				tau[cpu].low -= step_size;
+				tau[cpu].high -= (step_size - window_expand);
+			}
+			tau[cpu].grew = 1;
+#ifdef DEBUG
+			printk("low threshold crossed ");
+#endif
+		}
+	}
+	if((thrm = mfspr(SPRN_THRM2)) & THRM1_TIV){ /* is valid? */
+		if(thrm & THRM1_TIN){ /* crossed high threshold */
+			if (tau[cpu].high <= 127-step_size){
+				tau[cpu].low += (step_size - window_expand);
+				tau[cpu].high += step_size;
+			}
+			tau[cpu].grew = 1;
+#ifdef DEBUG
+			printk("high threshold crossed ");
+#endif
+		}
+	}
+
+#ifdef DEBUG
+	printk("grew = %d\n", tau[cpu].grew);
+#endif
+
+#ifndef CONFIG_TAU_INT /* tau_timeout will do this if not using interrupts */
+	set_thresholds(cpu);	
+#endif
+
+}
+
+#ifdef CONFIG_TAU_INT
+/*
+ * TAU interrupts - called when we have a thermal assist unit interrupt
+ * with interrupts disabled
+ */
+
+void TAUException(struct pt_regs * regs)
+{
+	unsigned long cpu = smp_processor_id();
+
+	hardirq_enter(cpu);
+	tau[cpu].interrupts++;
+	
+	TAUupdate(cpu);
+
+	hardirq_exit(cpu);
+	return;
+}
+#endif /* CONFIG_TAU_INT */
+
+static void tau_timeout(void * info)
+{
+	unsigned long cpu = smp_processor_id();
+	unsigned long flags;
+	int size;
+	int shrink;
+ 
+	/* disabling interrupts *should* be okay */
+	save_flags(flags); cli();
+
+#ifndef CONFIG_TAU_INT
+	TAUupdate(cpu);
+#endif
+	
+	size = tau[cpu].high - tau[cpu].low;
+	if (size > min_window && ! tau[cpu].grew) {
+		/* do an exponential shrink of half the amount currently over size */
+		shrink = (2 + size - min_window) / 4;
+		if (shrink) {
+			tau[cpu].low += shrink;
+			tau[cpu].high -= shrink;
+		} else { /* size must have been min_window + 1 */
+			tau[cpu].low += 1;
+#if 1 /* debug */
+			if ((tau[cpu].high - tau[cpu].low) != min_window){
+				printk(KERN_ERR "temp.c: line %d, logic error\n", __LINE__);
+			}
+#endif
+		}
+	}
+
+	tau[cpu].grew = 0;
+	
+	set_thresholds(cpu);
+
+	/*
+	 * Do the enable every time, since otherwise a bunch of (relatively)
+	 * complex sleep code needs to be added. One mtspr every time
+	 * tau_timeout is called is probably not a big deal.
+	 * 
+	 * Enable thermal sensor and set up sample interval timer
+	 * need 20 us to do the compare.. until a nice 'cpu_speed' function
+	 * call is implemented, just assume a 500 mhz clock. It doesn't really
+	 * matter if we take too long for a compare since it's all interrupt 
+	 * driven anyway. 
+	 *
+	 * use a extra long time.. (60 us @ 500 mhz)
+	 */
+	mtspr(SPRN_THRM3, THRM3_SITV(500*60) | THRM3_E);
+
+	restore_flags(flags);
+}
+
+static void tau_timeout_smp(unsigned long unused)
+{
+
+	/* schedule ourselves to be run again */
+	mod_timer(&tau_timer, jiffies + shrink_timer) ;
+#ifdef CONFIG_SMP
+	smp_call_function(tau_timeout, NULL, 1, 0);
+#endif
+	tau_timeout(NULL);
+}
+
+/*
+ * setup the TAU
+ * 
+ * Set things up to use THRM1 as a temperature lower bound, and THRM2 as an upper bound.
+ * Start off at zero
+ */
+
+int tau_initialized = 0;
+
+void __init TAU_init_smp(void * info)
+{
+	unsigned long cpu = smp_processor_id();
+	
+	/* set these to a reasonable value and let the timer shrink the
+	 * window */
+	tau[cpu].low = 5;
+	tau[cpu].high = 120;
+
+	set_thresholds(cpu);
+}
+
+int __init TAU_init(void)
+{
+	/* We assume in SMP that if one CPU has TAU support, they
+	 * all have it --BenH
+	 */
+	if (!(cur_cpu_spec[0]->cpu_features & CPU_FTR_TAU)) {
+		printk("Thermal assist unit not available\n");
+		tau_initialized = 0;
+		return 1;
+	}
+
+
+	/* first, set up the window shrinking timer */
+	init_timer(&tau_timer);
+	tau_timer.function = tau_timeout_smp;
+	tau_timer.expires = jiffies + shrink_timer;
+	add_timer(&tau_timer);
+	
+#ifdef CONFIG_SMP
+	smp_call_function(TAU_init_smp, NULL, 1, 0);
+#endif
+	TAU_init_smp(NULL);
+	
+	printk("Thermal assist unit ");
+#ifdef CONFIG_TAU_INT
+	printk("using interrupts, ");
+#else
+	printk("using timers, ");
+#endif
+	printk("shrink_timer: %d jiffies\n", shrink_timer); 
+	tau_initialized = 1;
+
+	return 0;
+}
+
+__initcall(TAU_init);
+
+/*
+ * return current temp
+ */
+
+u32 cpu_temp_both(unsigned long cpu)
+{
+	return ((tau[cpu].high << 16) | tau[cpu].low);
+}
+
+int cpu_temp(unsigned long cpu)
+{
+	return ((tau[cpu].high + tau[cpu].low) / 2);
+}
+
+int tau_interrupts(unsigned long cpu)
+{
+	return (tau[cpu].interrupts);
+}
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/time.c linux/arch/ppc/kernel/time.c
--- v2.4.9/linux/arch/ppc/kernel/time.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/ppc/kernel/time.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.time.c 1.18 06/06/01 22:33:09 paulus
+ * BK Id: SCCS/s.time.c 1.21 08/20/01 22:08:08 paulus
  */
 /*
  * Common time routines among all ppc machines.
@@ -72,11 +72,6 @@
 
 unsigned long disarm_decr[NR_CPUS];
 
-#ifdef CONFIG_SMP
-extern void smp_local_timer_interrupt(struct pt_regs *);
-extern int smp_tb_synchronized;
-#endif /* CONFIG_SMP */
-
 extern int do_sys_settimeofday(struct timeval *tv, struct timezone *tz);
 
 /* keep track of when we need to update the rtc */
@@ -321,27 +316,30 @@
 	 * makes things more complex. Repeatedly read the RTC until the
 	 * next second boundary to try to achieve some precision...
 	 */
-	stamp = get_native_tbl();
-	sec = ppc_md.get_rtc_time();
-	elapsed = 0;
-	do {
-		old_stamp = stamp; 
-		old_sec = sec;
+	if (ppc_md.get_rtc_time) {
 		stamp = get_native_tbl();
-		if (__USE_RTC() && stamp < old_stamp) old_stamp -= 1000000000;
-		elapsed += stamp - old_stamp;
 		sec = ppc_md.get_rtc_time();
-	} while ( sec == old_sec && elapsed < 2*HZ*tb_ticks_per_jiffy);
-	if (sec==old_sec) {
-		printk("Warning: real time clock seems stuck!\n");
+		elapsed = 0;
+		do {
+			old_stamp = stamp; 
+			old_sec = sec;
+			stamp = get_native_tbl();
+			if (__USE_RTC() && stamp < old_stamp) old_stamp -= 1000000000;
+			elapsed += stamp - old_stamp;
+			sec = ppc_md.get_rtc_time();
+		} while ( sec == old_sec && elapsed < 2*HZ*tb_ticks_per_jiffy);
+		if (sec==old_sec) {
+			printk("Warning: real time clock seems stuck!\n");
+		}
+		write_lock_irqsave(&xtime_lock, flags);
+		xtime.tv_sec = sec;
+		last_jiffy_stamp(0) = tb_last_stamp = stamp;
+		xtime.tv_usec = 0;
+		/* No update now, we just read the time from the RTC ! */
+		last_rtc_update = xtime.tv_sec;
+		write_unlock_irqrestore(&xtime_lock, flags);
 	}
-	write_lock_irqsave(&xtime_lock, flags);
-	xtime.tv_sec = sec;
-	last_jiffy_stamp(0) = tb_last_stamp = stamp;
-	xtime.tv_usec = 0;
-	/* No update now, we just read the time from the RTC ! */
-	last_rtc_update = xtime.tv_sec;
-	write_unlock_irqrestore(&xtime_lock, flags);
+
 	/* Not exact, but the timer interrupt takes care of this */
 	set_dec(tb_ticks_per_jiffy);
 
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/kernel/traps.c linux/arch/ppc/kernel/traps.c
--- v2.4.9/linux/arch/ppc/kernel/traps.c	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/kernel/traps.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.traps.c 1.16 07/31/01 10:53:34 trini
+ * BK Id: SCCS/s.traps.c 1.19 08/24/01 20:07:37 paulus
  */
 /*
  *  linux/arch/ppc/kernel/traps.c
@@ -244,7 +244,7 @@
 	 */
 	if ((instword & INST_MFSPR_PVR_MASK) == INST_MFSPR_PVR) {
 		rd = (instword >> 21) & 0x1f;
-		regs->gpr[rd] = _get_PVR();
+		regs->gpr[rd] = mfspr(PVR);
 		retval = 0;
 	}
 	if (retval == 0)
@@ -372,12 +372,14 @@
 }
 #endif
 
+#if !defined(CONFIG_TAU_INT)
 void
 TAUException(struct pt_regs *regs)
 {
 	printk("TAU trap at PC: %lx, SR: %lx, vector=%lx\n",
 	       regs->nip, regs->msr, regs->trap);
 }
+#endif /* CONFIG_INT_TAU */
 
 void __init trap_init(void)
 {
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/lib/checksum.S linux/arch/ppc/lib/checksum.S
--- v2.4.9/linux/arch/ppc/lib/checksum.S	Mon May 21 17:04:47 2001
+++ linux/arch/ppc/lib/checksum.S	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.checksum.S 1.5 05/17/01 18:14:22 cort
+ * BK Id: SCCS/s.checksum.S 1.8 08/20/01 22:09:34 paulus
  */
 /*
  * This file contains assembly-language implementations
@@ -122,12 +122,30 @@
 	addc	r0,r0,r6
 	srwi.	r6,r5,2		/* # words to do */
 	beq	3f
-1:	mtctr	r6
-82:	lwzu	r6,4(r3)	/* the bdnz has zero overhead, so it should */
-92:	stwu	r6,4(r4)	/* be unnecessary to unroll this loop */
+1:	srwi.	r6,r5,4		/* # groups of 4 words to do */
+	beq	10f
+	mtctr	r6
+71:	lwz	r6,4(r3)
+72:	lwz	r9,8(r3)
+73:	lwz	r10,12(r3)
+74:	lwzu	r11,16(r3)
 	adde	r0,r0,r6
+75:	stw	r6,4(r4)
+	adde	r0,r0,r9
+76:	stw	r9,8(r4)
+	adde	r0,r0,r10
+77:	stw	r10,12(r4)
+	adde	r0,r0,r11
+78:	stwu	r11,16(r4)
+	bdnz	71b
+10:	rlwinm.	r6,r5,30,30,31	/* # words left to do */
+	beq	13f
+	mtctr	r6
+82:	lwzu	r9,4(r3)
+92:	stwu	r9,4(r4)
+	adde	r0,r0,r9
 	bdnz	82b
-	andi.	r5,r5,3
+13:	andi.	r5,r5,3
 3:	cmpi	0,r5,2
 	blt+	4f
 83:	lhz	r6,4(r3)
@@ -148,12 +166,16 @@
 /* These shouldn't go in the fixup section, since that would
    cause the ex_table addresses to get out of order. */
 
+src_error_4:
+	mfctr	r6		/* update # bytes remaining from ctr */
+	rlwimi	r5,r6,4,0,27
+	b	79f
 src_error_1:
 	li	r6,0
 	subi	r5,r5,2
 95:	sth	r6,4(r4)
 	addi	r4,r4,2
-	srwi.	r6,r5,2
+79:	srwi.	r6,r5,2
 	beq	3f
 	mtctr	r6
 src_error_2:
@@ -187,6 +209,14 @@
 .section __ex_table,"a"
 	.long	81b,src_error_1
 	.long	91b,dst_error
+	.long	71b,src_error_4
+	.long	72b,src_error_4
+	.long	73b,src_error_4
+	.long	74b,src_error_4
+	.long	75b,dst_error
+	.long	76b,dst_error
+	.long	77b,dst_error
+	.long	78b,dst_error
 	.long	82b,src_error_2
 	.long	92b,dst_error
 	.long	83b,src_error_3
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/lib/locks.c linux/arch/ppc/lib/locks.c
--- v2.4.9/linux/arch/ppc/lib/locks.c	Mon May 21 17:04:47 2001
+++ linux/arch/ppc/lib/locks.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.locks.c 1.8 05/17/01 18:14:22 cort
+ * BK Id: SCCS/s.locks.c 1.11 08/19/01 22:27:32 paulus
  */
 /*
  * Locks for smp ppc 
@@ -16,29 +16,53 @@
 #include <asm/system.h>
 #include <asm/io.h>
 
-#define DEBUG_LOCKS 1
+#ifdef SPINLOCK_DEBUG
 
 #undef INIT_STUCK
 #define INIT_STUCK 200000000 /*0xffffffff*/
 
+/*
+ * Try to acquire a spinlock.
+ * Only does the stwcx. if the load returned 0 - the Programming
+ * Environments Manual suggests not doing unnecessary stcwx.'s
+ * since they may inhibit forward progress by other CPUs in getting
+ * a lock.
+ */
+static unsigned long __spin_trylock(volatile unsigned long *lock)
+{
+	unsigned long ret;
+
+	__asm__ __volatile__ ("\n\
+1:	lwarx	%0,0,%1\n\
+	cmpwi	0,%0,0\n\
+	bne	2f\n\
+	stwcx.	%2,0,%1\n\
+	bne-	1b\n\
+	isync\n\
+2:"
+	: "=&r"(ret)
+	: "r"(lock), "r"(1)
+	: "cr0", "memory");
+
+	return ret;
+}
+
 void _spin_lock(spinlock_t *lock)
 {
 	int cpu = smp_processor_id();
-#ifdef DEBUG_LOCKS
 	unsigned int stuck = INIT_STUCK;
-#endif /* DEBUG_LOCKS */
 	while (__spin_trylock(&lock->lock)) {
-#ifdef DEBUG_LOCKS
-		if(!--stuck) {
-			printk("_spin_lock(%p) CPU#%d NIP %p"
-			       " holder: cpu %ld pc %08lX\n",
-			       lock, cpu, __builtin_return_address(0),
-			       lock->owner_cpu,lock->owner_pc);
-			stuck = INIT_STUCK;
-			/* steal the lock */
-			/*xchg_u32((void *)&lock->lock,0);*/
+		while ((unsigned volatile long)lock->lock != 0) {
+			if (!--stuck) {
+				printk("_spin_lock(%p) CPU#%d NIP %p"
+				       " holder: cpu %ld pc %08lX\n",
+				       lock, cpu, __builtin_return_address(0),
+				       lock->owner_cpu,lock->owner_pc);
+				stuck = INIT_STUCK;
+				/* steal the lock */
+				/*xchg_u32((void *)&lock->lock,0);*/
+			}
 		}
-#endif /* DEBUG_LOCKS */
 	}
 	lock->owner_pc = (unsigned long)__builtin_return_address(0);
 	lock->owner_cpu = cpu;
@@ -53,11 +77,8 @@
 	return 1;
 }
 
-
-
 void _spin_unlock(spinlock_t *lp)
 {
-#ifdef DEBUG_LOCKS
   	if ( !lp->lock )
 		printk("_spin_unlock(%p): no lock cpu %d curr PC %p %s/%d\n",
 		       lp, smp_processor_id(), __builtin_return_address(0),
@@ -66,13 +87,12 @@
 		printk("_spin_unlock(%p): cpu %d trying clear of cpu %d pc %lx val %lx\n",
 		      lp, smp_processor_id(), (int)lp->owner_cpu,
 		      lp->owner_pc,lp->lock);
-#endif /* DEBUG_LOCKS */
 	lp->owner_pc = lp->owner_cpu = 0;
 	wmb();
 	lp->lock = 0;
-	wmb();
 }
 
+
 /*
  * Just like x86, implement read-write locks as a 32-bit counter
  * with the high bit (sign) being the "write" bit.
@@ -80,14 +100,11 @@
  */
 void _read_lock(rwlock_t *rw)
 {
-#ifdef DEBUG_LOCKS
 	unsigned long stuck = INIT_STUCK;
 	int cpu = smp_processor_id();
-#endif /* DEBUG_LOCKS */		  
 
 again:	
 	/* get our read lock in there */
-	wmb();
 	atomic_inc((atomic_t *) &(rw)->lock);
 	if ( (signed long)((rw)->lock) < 0) /* someone has a write lock */
 	{
@@ -96,13 +113,11 @@
 		/* wait for the write lock to go away */
 		while ((signed long)((rw)->lock) < 0)
 		{
-#ifdef DEBUG_LOCKS
 			if(!--stuck)
 			{
 				printk("_read_lock(%p) CPU#%d\n", rw, cpu);
 				stuck = INIT_STUCK;
 			}
-#endif /* DEBUG_LOCKS */
 		}
 		/* try to get the read lock again */
 		goto again;
@@ -112,38 +127,30 @@
 
 void _read_unlock(rwlock_t *rw)
 {
-#ifdef DEBUG_LOCKS
 	if ( rw->lock == 0 )
 		printk("_read_unlock(): %s/%d (nip %08lX) lock %lx\n",
 		       current->comm,current->pid,current->thread.regs->nip,
 		      rw->lock);
-#endif /* DEBUG_LOCKS */
 	wmb();
 	atomic_dec((atomic_t *) &(rw)->lock);
-	wmb();
 }
 
 void _write_lock(rwlock_t *rw)
 {
-#ifdef DEBUG_LOCKS
 	unsigned long stuck = INIT_STUCK;
 	int cpu = smp_processor_id();
-#endif /* DEBUG_LOCKS */		  
 
 again:
-	wmb();
 	if ( test_and_set_bit(31,&(rw)->lock) ) /* someone has a write lock */
 	{
 		while ( (rw)->lock & (1<<31) ) /* wait for write lock */
 		{
-#ifdef DEBUG_LOCKS
 			if(!--stuck)
 			{
 				printk("write_lock(%p) CPU#%d lock %lx)\n",
 				       rw, cpu,rw->lock);
 				stuck = INIT_STUCK;
 			}
-#endif /* DEBUG_LOCKS */		  
 			barrier();
 		}
 		goto again;
@@ -155,14 +162,12 @@
 		clear_bit(31,&(rw)->lock);
 		while ( (rw)->lock & ~(1<<31) )
 		{
-#ifdef DEBUG_LOCKS
 			if(!--stuck)
 			{
 				printk("write_lock(%p) 2 CPU#%d lock %lx)\n",
 				       rw, cpu,rw->lock);
 				stuck = INIT_STUCK;
 			}
-#endif /* DEBUG_LOCKS */
 			barrier();
 		}
 		goto again;
@@ -172,79 +177,12 @@
 
 void _write_unlock(rwlock_t *rw)
 {
-#ifdef DEBUG_LOCKS
 	if ( !(rw->lock & (1<<31)) )
 		printk("_write_lock(): %s/%d (nip %08lX) lock %lx\n",
 		      current->comm,current->pid,current->thread.regs->nip,
 		      rw->lock);
-#endif /* DEBUG_LOCKS */
 	wmb();
 	clear_bit(31,&(rw)->lock);
-	wmb();
-}
-
-void __lock_kernel(struct task_struct *task)
-{
-#ifdef DEBUG_LOCKS
-	unsigned long stuck = INIT_STUCK;
-	
-	if ( (signed long)(task->lock_depth) < 0 )
-	{
-		printk("__lock_kernel(): %s/%d (nip %08lX) lock depth %x\n",
-		      task->comm,task->pid,task->thread.regs->nip,
-		      task->lock_depth);
-	}
-#endif /* DEBUG_LOCKS */
-
-	if (atomic_inc_return((atomic_t *) &task->lock_depth) != 1)
-		return;
-	/* mine! */
-	while (__spin_trylock(&klock_info.kernel_flag)) {
-#ifdef DEBUG_LOCKS
-		if(!--stuck) {
-			printk("_lock_kernel() CPU#%d NIP %p\n",
-			       smp_processor_id(),
-			       __builtin_return_address(0));
-			stuck = INIT_STUCK;
-		}
-#endif /* DEBUG_LOCKS */
-	}
-	
-	klock_info.akp = smp_processor_id();
-	/* my kernel mode! mine!!! */
 }
 
-void __unlock_kernel(struct task_struct *task)
-{
-#ifdef DEBUG_LOCKS
- 	if ((task->lock_depth == 0) || (klock_info.kernel_flag != KLOCK_HELD))
-	{
-		printk("__unlock_kernel(): %s/%d (nip %08lX) "
-		       "lock depth %x flags %lx\n",
-		       task->comm,task->pid,task->thread.regs->nip,
-		       task->lock_depth, klock_info.kernel_flag);
-		klock_info.akp = NO_PROC_ID;		
-		klock_info.kernel_flag = 0;
-		return;
-	}
-#endif /* DEBUG_LOCKS */
-	if (atomic_dec_and_test((atomic_t *) &task->lock_depth))
-	{
-		wmb();
-		klock_info.akp = NO_PROC_ID;
-		wmb();
-		klock_info.kernel_flag = KLOCK_CLEAR;
-		wmb();
-	}
-}	
-
-void reacquire_kernel_lock(struct task_struct *task, int cpu,int depth)
-{
-	if (depth)
-	{
-		__cli();
-		__lock_kernel(task);
-		task->lock_depth = depth;
-		__sti();
-	}
-}
+#endif
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/mm/4xx_mmu.c linux/arch/ppc/mm/4xx_mmu.c
--- v2.4.9/linux/arch/ppc/mm/4xx_mmu.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/ppc/mm/4xx_mmu.c	Tue Aug 28 06:58:33 2001
@@ -0,0 +1,98 @@
+/*
+ * BK Id: %F% %I% %G% %U% %#%
+ */
+/*
+ * This file contains the routines for initializing the MMU
+ * on the 4xx series of chips.
+ *  -- paulus
+ * 
+ *  Derived from arch/ppc/mm/init.c:
+ *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
+ *
+ *  Modifications by Paul Mackerras (PowerMac) (paulus@cs.anu.edu.au)
+ *  and Cort Dougan (PReP) (cort@cs.nmt.edu)
+ *    Copyright (C) 1996 Paul Mackerras
+ *  Amiga/APUS changes by Jesper Skov (jskov@cygnus.co.uk).
+ *
+ *  Derived from "arch/i386/mm/init.c"
+ *    Copyright (C) 1991, 1992, 1993, 1994  Linus Torvalds
+ *
+ *  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 <linux/config.h>
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/types.h>
+#include <linux/ptrace.h>
+#include <linux/mman.h>
+#include <linux/mm.h>
+#include <linux/swap.h>
+#include <linux/stddef.h>
+#include <linux/vmalloc.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/bootmem.h>
+#include <linux/highmem.h>
+
+#include <asm/pgalloc.h>
+#include <asm/prom.h>
+#include <asm/io.h>
+#include <asm/mmu_context.h>
+#include <asm/pgtable.h>
+#include <asm/mmu.h>
+#include <asm/uaccess.h>
+#include <asm/smp.h>
+#include <asm/bootx.h>
+#include <asm/machdep.h>
+#include <asm/setup.h>
+
+/* Used by the 4xx TLB replacement exception handler.
+ * Just needed it declared someplace (and initialized to zero).
+ */
+unsigned int tlb_4xx_index;
+
+/*
+ * MMU_init_hw does the chip-specific initialization of the MMU hardware.
+ */
+void __init MMU_init_hw(void)
+{
+	/*
+	 * The Zone Protection Register (ZPR) defines how protection will
+	 * be applied to every page which is a member of a given zone. At
+	 * present, we utilize only two of the 4xx's zones.
+	 * The zone index bits (of ZSEL) in the PTE are used for software
+	 * indicators, except the LSB.  For user access, zone 15 is used,
+	 * for kernel access, zone 14 is used.  We set all but zone 15
+	 * to zero, allowing only kernel access as indicated in the PTE.
+	 * For zone 15, we set a 01 binary (a value of 10 will not work)
+	 * to allow user access as indicated in the PTE.  This also allows
+	 * kernel access as indicated in the PTE.
+	 */
+
+        mtspr(SPRN_ZPR, 0x00000001);
+
+	flush_instruction_cache();
+
+	/*
+	 * Set up the real-mode cache parameters for the exception vector
+	 * handlers (which are run in real-mode).
+	 */
+
+        mtspr(SPRN_DCWR, 0x00000000);	/* All caching is write-back */
+
+        /*
+	 * Cache instruction and data space where the exception
+	 * vectors and the kernel live in real-mode.
+	 */
+
+        mtspr(SPRN_DCCR, 0x80000000);	/* 128 MB of data space at 0x0. */
+        mtspr(SPRN_ICCR, 0x80000000);	/* 128 MB of instr. space at 0x0. */
+}
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/mm/Makefile linux/arch/ppc/mm/Makefile
--- v2.4.9/linux/arch/ppc/mm/Makefile	Tue Jul  3 17:08:18 2001
+++ linux/arch/ppc/mm/Makefile	Tue Aug 28 06:58:33 2001
@@ -1,4 +1,4 @@
-# BK Id: SCCS/s.Makefile 1.6 06/28/01 15:50:17 paulus
+# BK Id: SCCS/s.Makefile 1.8 08/16/01 17:25:47 paulus
 #
 #
 # Makefile for the linux ppc-specific parts of the memory manager.
@@ -15,15 +15,13 @@
 EXTRA_AFLAGS		:= -Wa,-mppc64bridge
 endif
 
-O_TARGET		:= mm.o
-obj-y			:= fault.o init.o mem_pieces.o extable.o
+O_TARGET			:= mm.o
+obj-y				:= fault.o init.o mem_pieces.o extable.o \
+					mmu_context.o pgtable.o
 
-ifneq ($(CONFIG_8xx),y)
-ifneq ($(CONFIG_4xx),y)
-obj-y			+= hashtable.o
-endif
-endif
-
-obj-$(CONFIG_4xx)	+= 4xx_tlb.o
+obj-$(CONFIG_PPC_STD_MMU)	+= hashtable.o ppc_mmu.o tlb.o
+obj-$(CONFIG_PPC_ISERIES)	+= iSeries_hashtable.o iSeries_mmu.o tlb.o
+obj-$(CONFIG_4xx)		+= cachemap.o 4xx_mmu.o
+obj-$(CONFIG_8xx)		+= cachemap.o
 
 include $(TOPDIR)/Rules.make
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/mm/cachemap.c linux/arch/ppc/mm/cachemap.c
--- v2.4.9/linux/arch/ppc/mm/cachemap.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/ppc/mm/cachemap.c	Tue Aug 28 06:58:33 2001
@@ -0,0 +1,163 @@
+/*
+ * BK Id: %F% %I% %G% %U% %#%
+ *
+ *  PowerPC version derived from arch/arm/mm/consistent.c
+ *    Copyright (C) 2001 Dan Malek (dmalek@jlc.net)
+ *
+ *  linux/arch/arm/mm/consistent.c
+ *
+ *  Copyright (C) 2000 Russell King
+ *
+ * Consistent memory allocators.  Used for DMA devices that want to
+ * share uncached memory with the processor core.  The function return
+ * is the virtual address and 'dma_handle' is the physical address.
+ * Mostly stolen from the ARM port, with some changes for PowerPC.
+ *						-- Dan
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/types.h>
+#include <linux/ptrace.h>
+#include <linux/mman.h>
+#include <linux/mm.h>
+#include <linux/swap.h>
+#include <linux/stddef.h>
+#include <linux/vmalloc.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/bootmem.h>
+#include <linux/highmem.h>
+#include <linux/pci.h>
+
+#include <asm/pgalloc.h>
+#include <asm/prom.h>
+#include <asm/io.h>
+#include <asm/hardirq.h>
+#include <asm/mmu_context.h>
+#include <asm/pgtable.h>
+#include <asm/mmu.h>
+#include <asm/uaccess.h>
+#include <asm/smp.h>
+#include <asm/machdep.h>
+
+void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle)
+{
+	int order, rsize;
+	unsigned long page;
+	void *ret;
+	pte_t	*pte;
+
+	if (in_interrupt())
+		BUG();
+
+	/* Only allocate page size areas.
+	*/
+	size = PAGE_ALIGN(size);
+	order = get_order(size);
+
+	page = __get_free_pages(gfp, order);
+	if (!page) {
+		BUG();
+		return NULL;
+	}
+
+	/*
+	 * we need to ensure that there are no cachelines in use,
+	 * or worse dirty in this area.
+	 */
+	invalidate_dcache_range(page, page + size);
+
+	ret = (void *)page;
+	*dma_handle = virt_to_bus(ret);
+
+	/* Chase down all of the PTEs and mark them uncached.
+	*/
+	rsize = (int)size;
+	while (rsize > 0) {
+		if (get_pteptr(&init_mm, page, &pte)) {
+			pte_val(*pte) |= _PAGE_NO_CACHE | _PAGE_GUARDED;
+			flush_tlb_page(find_vma(&init_mm,page),page);
+		}
+		else {
+			BUG();
+			return NULL;
+		}
+		page += PAGE_SIZE;
+		rsize -= PAGE_SIZE;
+	}
+
+	return ret;
+}
+
+/*
+ * free page(s) as defined by the above mapping.
+ * The caller has to tell us the size so we can free the proper number
+ * of pages.  We can't vmalloc() a new space for these pages and simply
+ * call vfree() like some other architectures because we could end up
+ * with aliased cache lines (or at least a cache line with the wrong
+ * attributes).  This can happen when the PowerPC speculative loads
+ * across page boundaries.
+ */
+void consistent_free(void *vaddr, size_t size)
+{
+	int order, rsize;
+	unsigned long addr;
+	pte_t	*pte;
+
+	if (in_interrupt())
+		BUG();
+
+	size = PAGE_ALIGN(size);
+	order = get_order(size);
+
+	/* Chase down all of the PTEs and mark them cached again.
+	*/
+	addr = (unsigned long)vaddr;
+	rsize = (int)size;
+	while (rsize > 0) {
+		if (get_pteptr(&init_mm, addr, &pte)) {
+			pte_val(*pte) &= ~(_PAGE_NO_CACHE | _PAGE_GUARDED);
+			flush_tlb_page(find_vma(&init_mm,addr),addr);
+		}
+		else {
+			BUG();
+			return;
+		}
+		addr += PAGE_SIZE;
+		rsize -= PAGE_SIZE;
+	}
+	free_pages((unsigned long)vaddr, order);
+}
+
+/*
+ * make an area consistent.
+ */
+void consistent_sync(void *vaddr, size_t size, int direction)
+{
+	unsigned long start = (unsigned long)vaddr;
+	unsigned long end   = start + size;
+
+	switch (direction) {
+	case PCI_DMA_NONE:
+		BUG();
+	case PCI_DMA_FROMDEVICE:	/* invalidate only */
+		invalidate_dcache_range(start, end);
+		break;
+	case PCI_DMA_TODEVICE:		/* writeback only */
+		clean_dcache_range(start, end);
+		break;
+	case PCI_DMA_BIDIRECTIONAL:	/* writeback and invalidate */
+		flush_dcache_range(start, end);
+		break;
+	}
+}
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/mm/hashtable.S linux/arch/ppc/mm/hashtable.S
--- v2.4.9/linux/arch/ppc/mm/hashtable.S	Tue Jul  3 17:08:18 2001
+++ linux/arch/ppc/mm/hashtable.S	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.hashtable.S 1.16 06/29/01 08:51:52 paulus
+ * BK Id: SCCS/s.hashtable.S 1.18 08/15/01 22:43:07 paulus
  */
 /*
  *  arch/ppc/kernel/hashtable.S
@@ -31,6 +31,7 @@
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/pgtable.h>
+#include <asm/cputable.h>
 
 #ifdef CONFIG_SMP
 	.comm	hash_table_lock,4
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/mm/init.c linux/arch/ppc/mm/init.c
--- v2.4.9/linux/arch/ppc/mm/init.c	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/mm/init.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.init.c 1.30 07/06/01 09:19:29 trini
+ * BK Id: SCCS/s.init.c 1.34 08/20/01 22:12:43 paulus
  */
 /*
  *  PowerPC version 
@@ -21,20 +21,14 @@
  */
 
 #include <linux/config.h>
-#include <linux/signal.h>
 #include <linux/sched.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/types.h>
-#include <linux/ptrace.h>
-#include <linux/mman.h>
 #include <linux/mm.h>
-#include <linux/swap.h>
 #include <linux/stddef.h>
-#include <linux/vmalloc.h>
 #include <linux/init.h>
-#include <linux/delay.h>
 #include <linux/bootmem.h>
 #include <linux/highmem.h>
 #ifdef CONFIG_BLK_DEV_INITRD
@@ -47,138 +41,49 @@
 #include <asm/mmu_context.h>
 #include <asm/pgtable.h>
 #include <asm/mmu.h>
-#include <asm/uaccess.h>
-#ifdef CONFIG_8xx
-#include <asm/8xx_immap.h>
-#include <asm/mpc8xx.h>
-#endif
-#ifdef CONFIG_8260
-#include <asm/immap_8260.h>
-#include <asm/mpc8260.h>
-#endif
 #include <asm/smp.h>
-#include <asm/bootx.h>
 #include <asm/machdep.h>
-#include <asm/setup.h>
-#include <asm/amigahw.h>
-#include <asm/gemini.h>
+#include <asm/btext.h>
 
 #include "mem_pieces.h"
+#include "mmu_decl.h"
 
-#if defined(CONFIG_4xx)
-#include "4xx_tlb.h"
-#endif
-
-#define MAX_LOW_MEM	(512 << 20)
+#define MAX_LOW_MEM	(0xF0000000UL - KERNELBASE)
 
-#define	PGTOKB(pages)	(((pages) * PAGE_SIZE) >> 10)
-
-mm_context_t next_mmu_context;
-unsigned long context_map[(LAST_CONTEXT+1) / (8*sizeof(unsigned long))];
-#ifdef FEW_CONTEXTS
-atomic_t nr_free_contexts;
-struct mm_struct *context_mm[LAST_CONTEXT+1];
-void steal_context(void);
-#endif /* FEW_CONTEXTS */
-
-int prom_trashed;
-unsigned long *end_of_DRAM;
+void *end_of_DRAM;
 unsigned long total_memory;
 unsigned long total_lowmem;
-unsigned long ram_phys_base;
+
 int mem_init_done;
 int init_bootmem_done;
 int boot_mapsize;
 unsigned long totalram_pages;
 unsigned long totalhigh_pages;
-extern pgd_t swapper_pg_dir[];
-extern char _start[], _end[];
+
+extern char _end[];
 extern char etext[], _stext[];
 extern char __init_begin, __init_end;
 extern char __prep_begin, __prep_end;
 extern char __chrp_begin, __chrp_end;
 extern char __pmac_begin, __pmac_end;
 extern char __openfirmware_begin, __openfirmware_end;
-unsigned long ioremap_base;
-unsigned long ioremap_bot;
-unsigned long avail_start;
-extern int num_memory;
-extern struct mem_info memory[];
-extern boot_infos_t *boot_infos;
-extern unsigned int rtas_data, rtas_size;
-#ifndef CONFIG_SMP
-struct pgtable_cache_struct quicklists;
-#endif
+
 #ifdef CONFIG_HIGHMEM
 pte_t *kmap_pte;
 pgprot_t kmap_prot;
 #endif
 
 void MMU_init(void);
-void *early_get_page(void);
-static void mapin_ram(void);
-int map_page(unsigned long va, unsigned long pa, int flags);
 void set_phys_avail(unsigned long total_ram);
-extern void die_if_kernel(char *,struct pt_regs *,long);
 
-extern char _start[], _end[];
-extern char _stext[], etext[];
+/* XXX should be in current.h  -- paulus */
 extern struct task_struct *current_set[NR_CPUS];
 
 char *klimit = _end;
 struct mem_pieces phys_avail;
 
-PTE *Hash, *Hash_end;
-unsigned long Hash_size, Hash_mask;
-#if !defined(CONFIG_4xx) && !defined(CONFIG_8xx)
-unsigned long _SDR1;
-static void hash_init(void);
-
-union ubat {			/* BAT register values to be loaded */
-	BAT	bat;
-#ifdef CONFIG_PPC64BRIDGE
-	u64	word[2];
-#else
-	u32	word[2];
-#endif	
-} BATS[4][2];			/* 4 pairs of IBAT, DBAT */
-
-struct batrange {		/* stores address ranges mapped by BATs */
-	unsigned long start;
-	unsigned long limit;
-	unsigned long phys;
-} bat_addrs[4];
-
-/*
- * Return PA for this VA if it is mapped by a BAT, or 0
- */
-static inline unsigned long 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 bat_addrs[b].phys + (va - bat_addrs[b].start);
-	return 0;
-}
-
-/*
- * Return VA for a given PA or 0 if not mapped
- */
-static inline unsigned long 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;
-}
-
-#else /* CONFIG_4xx || CONFIG_8xx */
-#define v_mapped_by_bats(x)	(0UL)
-#define p_mapped_by_bats(x)	(0UL)
-#endif /* !CONFIG_4xx && !CONFIG_8xx */
+extern char *sysmap; 
+extern unsigned long sysmap_size;
 
 /*
  * this tells the system to map all of ram with the segregs
@@ -298,421 +203,7 @@
 	val->mem_unit = PAGE_SIZE;
 }
 
-void *
-ioremap(unsigned long addr, unsigned long size)
-{
-	return __ioremap(addr, size, _PAGE_NO_CACHE);
-}
-
-void *
-__ioremap(unsigned long addr, unsigned long size, unsigned long flags)
-{
-	unsigned long p, v, i;
-	int err;
-
-	/*
-	 * Choose an address to map it to.
-	 * Once the vmalloc system is running, we use it.
-	 * Before then, we map addresses >= ioremap_base
-	 * virt == phys; for addresses below this we use
-	 * space going down from ioremap_base (ioremap_bot
-	 * records where we're up to).
-	 */
-	p = addr & PAGE_MASK;
-	size = PAGE_ALIGN(addr + size) - p;
-
-	/*
-	 * If the address lies within the first 16 MB, assume it's in ISA
-	 * memory space
-	 */
-	if ( p < 16*1024*1024 )
-		p += _ISA_MEM_BASE;
-
-	/*
-	 * 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;
-
-	/*
-	 * 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(p)) /*&& p_mapped_by_bats(p+size-1)*/ )
-		goto out;
-	
-	if (mem_init_done) {
-		struct vm_struct *area;
-		area = get_vm_area(size, VM_IOREMAP);
-		if (area == 0)
-			return NULL;
-		v = VMALLOC_VMADDR(area->addr);
-	} else {
-#ifndef CONFIG_HIGHMEM
-		if (p >= ioremap_base)
-#else
-		if (p >= ioremap_base && p < PKMAP_BASE)
-#endif /* CONFIG_HIGHMEM */
-			v = p;
-		else
-			v = (ioremap_bot -= size);
-	}
-
-	if ((flags & _PAGE_PRESENT) == 0)
-		flags |= pgprot_val(PAGE_KERNEL);
-	if (flags & (_PAGE_NO_CACHE | _PAGE_WRITETHRU))
-		flags |= _PAGE_GUARDED;
-
-	/*
-	 * Should check if it is a candidate for a BAT mapping
-	 */
-
-	err = 0;
-	for (i = 0; i < size && err == 0; i += PAGE_SIZE)
-		err = map_page(v+i, p+i, flags);
-	if (err) {
-		if (mem_init_done)
-			vfree((void *)v);
-		return NULL;
-	}
-
-out:
-	return (void *) (v + (addr & ~PAGE_MASK));
-}
-
-void iounmap(void *addr)
-{
-	if (addr > high_memory && (unsigned long) addr < ioremap_bot)
-		vfree((void *) (PAGE_MASK & (unsigned long) addr));
-}
-
-unsigned long iopa(unsigned long addr)
-{
-	unsigned long pa;
-	pmd_t *pd;
-	pte_t *pg;
-
-	/* Check the BATs */
-	pa = v_mapped_by_bats(addr);
-	if (pa)
-		return pa;
-
-	/* Do we have a page table? */
-	if (init_mm.pgd == NULL)
-		return 0;
-
-	/* Use upper 10 bits of addr to index the first level map */
-	pd = (pmd_t *) (init_mm.pgd + (addr >> PGDIR_SHIFT));
-	if (pmd_none(*pd))
-		return 0;
-
-	/* Use middle 10 bits of addr to index the second-level map */
-	pg = pte_offset(pd, addr);
-	return (pte_val(*pg) & PAGE_MASK) | (addr & ~PAGE_MASK);
-}
-
-int
-map_page(unsigned long va, unsigned long pa, int flags)
-{
-	pmd_t *pd;
-	pte_t *pg;
-	int err = -ENOMEM;
-
-	spin_lock(&init_mm.page_table_lock);
-	/* Use upper 10 bits of VA to index the first level map */
-	pd = pmd_offset(pgd_offset_k(va), va);
-	/* Use middle 10 bits of VA to index the second-level map */
-	pg = pte_alloc(&init_mm, pd, va);
-	if (pg != 0) {
-		err = 0;
-		set_pte(pg, mk_pte_phys(pa & PAGE_MASK, __pgprot(flags)));
-#if !defined(CONFIG_4xx) && !defined(CONFIG_8xx)
-		if (mem_init_done && Hash != 0)
-			flush_hash_page(0, va, pg);
-#endif /* !4xx && !8xx */
-	}
-	spin_unlock(&init_mm.page_table_lock);
-	return err;
-}
-
-#if !defined(CONFIG_4xx) && !defined(CONFIG_8xx)
-/*
- * TLB flushing:
- *
- *  - flush_tlb_all() flushes all processes TLBs
- *  - flush_tlb_mm(mm) flushes the specified mm context TLB's
- *  - flush_tlb_page(vma, vmaddr) flushes one page
- *  - flush_tlb_range(mm, start, end) flushes a range of pages
- *
- * since the hardware hash table functions as an extension of the
- * tlb as far as the linux tables are concerned, flush it too.
- *    -- Cort
- */
-
-/*
- * Flush all tlb/hash table entries (except perhaps for those
- * mapping RAM starting at PAGE_OFFSET, since they never change).
- */
-void
-local_flush_tlb_all(void)
-{
-	/* aargh!!! */
-	/* just flush the kernel part of the address space, that's
-	   all that the current callers of this require.  -- paulus. */
-	local_flush_tlb_range(&init_mm, TASK_SIZE, ~0UL);
-
-#ifdef CONFIG_SMP
-	smp_send_tlb_invalidate(0);
-#endif /* CONFIG_SMP */
-}
-
-/*
- * Flush all the (user) entries for the address space described
- * by mm.  We can't rely on mm->mmap describing all the entries
- * that might be in the hash table.
- */
-void
-local_flush_tlb_mm(struct mm_struct *mm)
-{
-	if (Hash == 0) {
-		_tlbia();
-		return;
-	}
-
-	if (mm->map_count) {
-		struct vm_area_struct *mp;
-		for (mp = mm->mmap; mp != NULL; mp = mp->vm_next)
-			local_flush_tlb_range(mm, mp->vm_start, mp->vm_end);
-	} else
-		local_flush_tlb_range(mm, 0, TASK_SIZE);
-
-#ifdef CONFIG_SMP
-	smp_send_tlb_invalidate(0);
-#endif	
-}
-
-void
-local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr)
-{
-	struct mm_struct *mm;
-	pmd_t *pmd;
-	pte_t *pte;
-
-	if (Hash == 0) {
-		_tlbie(vmaddr);
-		return;
-	}
-	mm = (vmaddr < TASK_SIZE)? vma->vm_mm: &init_mm;
-	pmd = pmd_offset(pgd_offset(mm, vmaddr), vmaddr);
-	if (!pmd_none(*pmd)) {
-		pte = pte_offset(pmd, vmaddr);
-		if (pte_val(*pte) & _PAGE_HASHPTE)
-			flush_hash_page(mm->context, vmaddr, pte);
-	}
-#ifdef CONFIG_SMP
-	smp_send_tlb_invalidate(0);
-#endif	
-}
-
-
-/*
- * For each address in the range, find the pte for the address
- * and check _PAGE_HASHPTE bit; if it is set, find and destroy
- * the corresponding HPTE.
- */
-void
-local_flush_tlb_range(struct mm_struct *mm, unsigned long start, unsigned long end)
-{
-	pmd_t *pmd;
-	pte_t *pte;
-	unsigned long pmd_end;
-	unsigned int ctx = mm->context;
-
-	if (Hash == 0) {
-		_tlbia();
-		return;
-	}
-	start &= PAGE_MASK;
-	if (start >= end)
-		return;
-	pmd = pmd_offset(pgd_offset(mm, start), start);
-	do {
-		pmd_end = (start + PGDIR_SIZE) & PGDIR_MASK;
-		if (!pmd_none(*pmd)) {
-			if (!pmd_end || pmd_end > end)
-				pmd_end = end;
-			pte = pte_offset(pmd, start);
-			do {
-				if ((pte_val(*pte) & _PAGE_HASHPTE) != 0)
-					flush_hash_page(ctx, start, pte);
-				start += PAGE_SIZE;
-				++pte;
-			} while (start && start < pmd_end);
-		} else {
-			start = pmd_end;
-		}
-		++pmd;
-	} while (start && start < end);
-
-#ifdef CONFIG_SMP
-	smp_send_tlb_invalidate(0);
-#endif	
-}
-
-/*
- * Set up one of the I/D BAT (block address translation) register pairs.
- * The parameters are not checked; in particular size must be a power
- * of 2 between 128k and 256M.
- */
-void __init setbat(int index, unsigned long virt, unsigned long phys,
-       unsigned int size, int flags)
-{
-	unsigned int bl;
-	int wimgxpp;
-	union ubat *bat = BATS[index];
-
-	bl = (size >> 17) - 1;
-	if ((_get_PVR() >> 16) != 1) {
-		/* 603, 604, etc. */
-		/* Do DBAT first */
-		wimgxpp = flags & (_PAGE_WRITETHRU | _PAGE_NO_CACHE
-				   | _PAGE_COHERENT | _PAGE_GUARDED);
-		wimgxpp |= (flags & _PAGE_RW)? BPP_RW: BPP_RX;
-		bat[1].word[0] = virt | (bl << 2) | 2; /* Vs=1, Vp=0 */
-		bat[1].word[1] = phys | wimgxpp;
-#ifndef CONFIG_KGDB /* want user access for breakpoints */
-		if (flags & _PAGE_USER)
-#endif
-			bat[1].bat.batu.vp = 1;
-		if (flags & _PAGE_GUARDED) {
-			/* G bit must be zero in IBATs */
-			bat[0].word[0] = bat[0].word[1] = 0;
-		} else {
-			/* make IBAT same as DBAT */
-			bat[0] = bat[1];
-		}
-	} else {
-		/* 601 cpu */
-		if (bl > BL_8M)
-			bl = BL_8M;
-		wimgxpp = flags & (_PAGE_WRITETHRU | _PAGE_NO_CACHE
-				   | _PAGE_COHERENT);
-		wimgxpp |= (flags & _PAGE_RW)?
-			((flags & _PAGE_USER)? PP_RWRW: PP_RWXX): PP_RXRX;
-		bat->word[0] = virt | wimgxpp | 4;	/* Ks=0, Ku=1 */
-		bat->word[1] = phys | bl | 0x40;	/* V=1 */
-	}
-
-	bat_addrs[index].start = virt;
-	bat_addrs[index].limit = virt + ((bl + 1) << 17) - 1;
-	bat_addrs[index].phys = phys;
-}
-
-#define IO_PAGE	(_PAGE_NO_CACHE | _PAGE_GUARDED | _PAGE_RW)
-#ifdef CONFIG_SMP
-#define RAM_PAGE (_PAGE_RW|_PAGE_COHERENT)
-#else
-#define RAM_PAGE (_PAGE_RW)
-#endif
-#endif /* CONFIG_8xx */
-
-/*
- * Map in all of physical memory starting at KERNELBASE.
- */
-static void __init mapin_ram(void)
-{
-	unsigned long v, p, s, f;
-
-#if !defined(CONFIG_4xx) && !defined(CONFIG_8xx) && !defined(CONFIG_POWER4)
-	if (!__map_without_bats) {
-		unsigned long tot, bl, done;
-		unsigned long max_size = (256<<20);
-		unsigned long align;
-
-		/* Set up BAT2 and if necessary BAT3 to cover RAM. */
-
-		/* Make sure we don't map a block larger than the
-		   smallest alignment of the physical address. */
-		/* alignment of ram_phys_base */
-		align = ~(ram_phys_base-1) & ram_phys_base;
-		/* set BAT block size to MIN(max_size, align) */
-		if (align && align < max_size)
-			max_size = align;
-
-		tot = total_lowmem;
-		for (bl = 128<<10; bl < max_size; bl <<= 1) {
-			if (bl * 2 > tot)
-				break;
-		}
-
-		setbat(2, KERNELBASE, ram_phys_base, bl, RAM_PAGE);
-		done = (unsigned long)bat_addrs[2].limit - KERNELBASE + 1;
-		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)
-				if (bl * 2 > tot)
-					break;
-			setbat(3, KERNELBASE+done, ram_phys_base+done, bl, 
-			       RAM_PAGE);
-		}
-	}
-#endif /* !CONFIG_4xx && !CONFIG_8xx && !CONFIG_POWER4 */
-
-	v = KERNELBASE;
-	p = ram_phys_base;
-	for (s = 0; s < total_lowmem; s += PAGE_SIZE) {
-		/* On the MPC8xx, we want the page shared so we
-		 * don't get ASID compares on kernel space.
-		 */
-		f = _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_SHARED;
-#if defined(CONFIG_KGDB) || defined(CONFIG_XMON)
-		/* Allows stub to set breakpoints everywhere */
-		f |= _PAGE_RW | _PAGE_DIRTY;
-#else
-		if ((char *) v < _stext || (char *) v >= etext)
-			f |= _PAGE_RW | _PAGE_DIRTY;
-#ifndef CONFIG_8xx
-		else
-			/* On the powerpc (not 8xx), no user access
-			   forces R/W kernel access */
-			f |= _PAGE_USER;
-#endif /* CONFIG_8xx */
-#endif /* CONFIG_KGDB */
-		map_page(v, p, f);
-		v += PAGE_SIZE;
-		p += PAGE_SIZE;
-	}
-}
-
-/* This is only called until mem_init is done. */
-void __init *early_get_page(void)
-{
-	void *p;
-
-	if (init_bootmem_done) {
-		p = alloc_bootmem_pages(PAGE_SIZE);
-	} else {
-		p = mem_pieces_find(PAGE_SIZE, PAGE_SIZE);
-	}
-	return p;
-}
-
+/* Free up now-unused memory */
 static void free_sec(unsigned long start, unsigned long end, const char *name)
 {
 	unsigned long cnt = 0;
@@ -725,7 +216,7 @@
 		start += PAGE_SIZE;
  	}
 	if (cnt) {
-		printk(" %ldk %s", PGTOKB(cnt), name);
+		printk(" %ldk %s", cnt << (PAGE_SHIFT - 10), name);
 		totalram_pages += cnt;
 	}
 }
@@ -766,110 +257,54 @@
 #endif
 
 /*
- * Initialize the context management stuff.
+ * Check for command-line options that affect what MMU_init will do.
  */
-static void mmu_context_init(void)
+void MMU_setup(void)
 {
-	context_map[0] = 1;	/* init_mm uses context 0 */
-	next_mmu_context = 1;
-#ifdef FEW_CONTEXTS
-	atomic_set(&nr_free_contexts, LAST_CONTEXT);
-	context_mm[0] = &init_mm;
-#endif /* FEW_CONTEXTS */
-}
-
-#ifdef FEW_CONTEXTS
-/*
- * Steal a context from a task that has one at the moment.
- * This is only used on 8xx and 4xx and we presently assume that
- * they don't do SMP.  If they do then this will have to check
- * whether the MM we steal is in use.
- * We also assume that this is only used on systems that don't
- * use an MMU hash table - this is true for 8xx and 4xx.
- * This isn't an LRU system, it just frees up each context in
- * turn (sort-of pseudo-random replacement :).  This would be the
- * place to implement an LRU scheme if anyone was motivated to do it.
- *  -- paulus
- */
-void steal_context(void)
-{
-	struct mm_struct *mm;
-
-	/* free up context `next_mmu_context' */
-	/* if we shouldn't free context 0, don't... */
-#ifdef CONFIG_4xx
-	if (next_mmu_context == 0)
-		next_mmu_context = 1;
-#endif /* CONFIG_4xx */
-	mm = context_mm[next_mmu_context];
-	flush_tlb_mm(mm);
-	destroy_context(mm);
+	/* Check for nobats option (used in mapin_ram). */
+	if (strstr(cmd_line, "nobats")) {
+		__map_without_bats = 1;
+	}
+
+	/* Look for mem= option on command line */
+	if (strstr(cmd_line, "mem=")) {
+		char *p, *q;
+		unsigned long maxmem = 0;
+
+		for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) {
+			q = p + 4;
+			if (p > cmd_line && p[-1] != ' ')
+				continue;
+			maxmem = simple_strtoul(q, &q, 0);
+			if (*q == 'k' || *q == 'K') {
+				maxmem <<= 10;
+				++q;
+			} else if (*q == 'm' || *q == 'M') {
+				maxmem <<= 20;
+				++q;
+			}
+		}
+		__max_memory = maxmem;
+	}
 }
-#endif /* FEW_CONTEXTS */
-
-extern boot_infos_t *disp_bi;
 
 /*
- * Do very early mm setup such as finding the size of memory
- * and setting up the hash table.
- * A lot of this is prep/pmac specific but a lot of it could
- * still be merged.
- * -- Cort
+ * MMU_init sets up the basic memory mappings for the kernel,
+ * including both RAM and possibly some I/O regions,
+ * and sets up the page tables and the MMU hardware ready to go.
  */
-#if defined(CONFIG_4xx)
-void __init
-MMU_init(void)
+void __init MMU_init(void)
 {
-	/*
-	 * The Zone Protection Register (ZPR) defines how protection will
-	 * be applied to every page which is a member of a given zone. At
-	 * present, we utilize only two of the 4xx's zones.
-	 * The zone index bits (of ZSEL) in the PTE are used for software
-	 * indicators, except the LSB.  For user access, zone 15 is used,
-	 * for kernel access, zone 14 is used.  We set all but zone 15
-	 * to zero, allowing only kernel access as indicated in the PTE.
-	 * For zone 15, we set a 10 binary (I guess a 01 would work too)
-	 * to allow user access as indicated in the PTE.  This also allows
-	 * kernel access as indicated in the PTE.
-	 */
+	if (ppc_md.progress)
+		ppc_md.progress("MMU:enter", 0x111);
 
-        mtspr(SPRN_ZPR, 0x00000002);
-
-	flush_instruction_cache();
+	/* parse args from command line */
+	MMU_setup();
 
 	/*
-	 * Find the top of physical memory and map all of it in starting
-	 * at KERNELBASE.
+	 * Figure out how much memory we have, how much
+	 * is lowmem, and how much is highmem.
 	 */
-
-        total_memory = total_lowmem = ppc_md.find_end_of_memory();
-	end_of_DRAM = __va(total_lowmem);
-	set_phys_avail(total_lowmem);
-        mapin_ram();
-
-	/*
-	 * Set up the real-mode cache parameters for the exception vector
-	 * handlers (which are run in real-mode).
-	 */
-
-        mtspr(SPRN_DCWR, 0x00000000);	/* All caching is write-back */
-
-        /*
-	 * Cache instruction and data space where the exception
-	 * vectors and the kernel live in real-mode.
-	 */
-
-        mtspr(SPRN_DCCR, 0x80000000);	/* 128 MB of data space at 0x0. */
-        mtspr(SPRN_ICCR, 0x80000000);	/* 128 MB of instr. space at 0x0. */
-
-	mmu_context_init();
-}
-
-#else /* !CONFIG_4xx */
-void __init MMU_init(void)
-{
-	if ( ppc_md.progress ) ppc_md.progress("MMU:enter", 0x111);
-
 	total_memory = ppc_md.find_end_of_memory();
 
 	if (__max_memory && total_memory > __max_memory)
@@ -884,114 +319,54 @@
 	end_of_DRAM = __va(total_lowmem);
 	set_phys_avail(total_lowmem);
 
-#if !defined(CONFIG_8xx)
-	if ( ppc_md.progress ) ppc_md.progress("MMU:hash init", 0x300);
-        hash_init();
-#ifndef CONFIG_PPC64BRIDGE
-        _SDR1 = __pa(Hash) | (Hash_mask >> 10);
-#endif
-	
-	ioremap_base = 0xf8000000;
-#endif /* CONFIG_8xx */
+	/* Initialize the MMU hardware */
+	if (ppc_md.progress)
+		ppc_md.progress("MMU:hw init", 0x300);
+	MMU_init_hw();
 
-	if ( ppc_md.progress ) ppc_md.progress("MMU:mapin", 0x301);
 	/* Map in all of RAM starting at KERNELBASE */
+	if (ppc_md.progress)
+		ppc_md.progress("MMU:mapin", 0x301);
 	mapin_ram();
 
-#if defined(CONFIG_8xx)
-        /* Now map in some of the I/O space that is generically needed
-         * or shared with multiple devices.
-         * All of this fits into the same 4Mbyte region, so it only
-         * requires one page table page.
-         */
-        ioremap(IMAP_ADDR, IMAP_SIZE);
-#ifdef CONFIG_MBX
-        ioremap(NVRAM_ADDR, NVRAM_SIZE);
-        ioremap(MBX_CSR_ADDR, MBX_CSR_SIZE);
-        ioremap(PCI_CSR_ADDR, PCI_CSR_SIZE);
-
-	/* Map some of the PCI/ISA I/O space to get the IDE interface.
-	*/
-        ioremap(PCI_ISA_IO_ADDR, 0x4000);
-        ioremap(PCI_IDE_ADDR, 0x4000);
-#endif
-#if defined(CONFIG_RPXLITE) || defined(CONFIG_RPXCLASSIC)
-	ioremap(RPX_CSR_ADDR, RPX_CSR_SIZE);
-#if !defined(CONFIG_PCI)
-	ioremap(_IO_BASE,_IO_BASE_SIZE);
-#endif
-#endif
-#ifdef CONFIG_HTDMSOUND
-	ioremap(HIOX_CSR_ADDR, HIOX_CSR_SIZE);
-#endif
-#ifdef CONFIG_FADS
-	ioremap(BCSR_ADDR, BCSR_SIZE);
-#endif
-#ifdef CONFIG_PCI
-        ioremap(PCI_CSR_ADDR, PCI_CSR_SIZE);
-#endif
-#else /* !CONFIG_8xx */
-	/*
-	 * Setup the bat mappings we're going to load that cover
-	 * the io areas.  RAM was mapped by mapin_ram().
-	 * -- Cort
-	 */
-	if ( ppc_md.progress ) ppc_md.progress("MMU:setbat", 0x302);
-	switch (_machine) {
-	case _MACH_prep:
-		setbat(0, 0x80000000, 0x80000000, 0x10000000, IO_PAGE);
-		setbat(1, 0xf0000000, 0xc0000000, 0x08000000, IO_PAGE);
-		ioremap_base = 0xf0000000;
-		break;
-	case _MACH_chrp:
-		/*
-		 * The code below tends to get removed, please don't take it out.
-		 * The F50 needs this mapping and it you take it out I'll track you
-		 * down and slap your hands.  If it causes problems please email me.
-		 *  -- Cort <cort@fsmlabs.com>
-		 */
-#ifndef CONFIG_POWER3
-		setbat(0, 0x80000000, 0x80000000, 0x10000000, IO_PAGE);
-		setbat(1, 0x90000000, 0x90000000, 0x10000000, IO_PAGE);
-#endif
-		break;
-	case _MACH_Pmac:
-		ioremap_base = 0xfe000000;
-		break;
-	case _MACH_apus:
-		/* Map PPC exception vectors. */
-		setbat(0, 0xfff00000, 0xfff00000, 0x00020000, RAM_PAGE);
-		/* Map chip and ZorroII memory */
-		setbat(1, zTwoBase,   0x00000000, 0x01000000, IO_PAGE);
-		break;
-	case _MACH_gemini:
-		setbat(0, 0xf0000000, 0xf0000000, 0x10000000, IO_PAGE);
-		setbat(1, 0x80000000, 0x80000000, 0x10000000, IO_PAGE);
-		break;
-	case _MACH_8260:
-		/* Map the IMMR, plus anything else we can cover
-		 * in that upper space according to the memory controller
-		 * chip select mapping.  Grab another bunch of space
-		 * below that for stuff we can't cover in the upper.
-		 */
-		setbat(0, 0xf0000000, 0xf0000000, 0x10000000, IO_PAGE);
-		setbat(1, 0xe0000000, 0xe0000000, 0x10000000, IO_PAGE);
-		ioremap_base = 0xe0000000;
-		break;
-	}
+#ifdef CONFIG_HIGHMEM
+	ioremap_base = PKMAP_BASE;
+#else
+	ioremap_base = 0xfe000000UL;	/* for now, could be 0xfffff000 */
+#endif /* CONFIG_HIGHMEM */
 	ioremap_bot = ioremap_base;
-#endif /* CONFIG_8xx */
 
-	if ( ppc_md.progress ) ppc_md.progress("MMU:exit", 0x211);
+	/* Map in I/O resources */
+	if (ppc_md.progress)
+		ppc_md.progress("MMU:setio", 0x302);
+	if (ppc_md.setup_io_mappings)
+		ppc_md.setup_io_mappings();
+
+	/* Initialize the context management stuff */
+	mmu_context_init();
+
+	if (ppc_md.progress)
+		ppc_md.progress("MMU:exit", 0x211);
+
 #ifdef CONFIG_BOOTX_TEXT
 	/* Must be done last, or ppc_md.progress will die */
-	if (_machine == _MACH_Pmac || _machine == _MACH_chrp)
-		map_bootx_text();
+	if (have_of)
+		map_boot_text();
 #endif
+}
 
-	mmu_context_init();
+/* This is only called until mem_init is done. */
+void __init *early_get_page(void)
+{
+	void *p;
+
+	if (init_bootmem_done) {
+		p = alloc_bootmem_pages(PAGE_SIZE);
+	} else {
+		p = mem_pieces_find(PAGE_SIZE, PAGE_SIZE);
+	}
+	return p;
 }
-#endif /* CONFIG_4xx */
 
 /*
  * Initialize the bootmem system and give it all the memory we
@@ -1068,8 +443,6 @@
 
 void __init mem_init(void)
 {
-	extern char *sysmap; 
-	extern unsigned long sysmap_size;
 	unsigned long addr;
 	int codepages = 0;
 	int datapages = 0;
@@ -1094,7 +467,7 @@
 	   make sure the ramdisk pages aren't reserved. */
 	if (initrd_start) {
 		for (addr = initrd_start; addr < initrd_end; addr += PAGE_SIZE)
-			clear_bit(PG_reserved, &virt_to_page(addr)->flags);
+			ClearPageReserved(virt_to_page(addr));
 	}
 #endif /* CONFIG_BLK_DEV_INITRD */
 
@@ -1106,7 +479,7 @@
 		     addr += PAGE_SIZE)
 			SetPageReserved(virt_to_page(addr));
 #endif /* defined(CONFIG_ALL_PPC) */
-	if ( sysmap_size )
+	if ( sysmap )
 		for (addr = (unsigned long)sysmap;
 		     addr < PAGE_ALIGN((unsigned long)sysmap+sysmap_size) ;
 		     addr += PAGE_SIZE)
@@ -1147,133 +520,12 @@
 	       codepages<< (PAGE_SHIFT-10), datapages<< (PAGE_SHIFT-10),
 	       initpages<< (PAGE_SHIFT-10),
 	       (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10)));
+	if (sysmap)
+		printk("System.map loaded at 0x%08x for debugger, size: %ld bytes\n",
+			(unsigned int)sysmap, sysmap_size);
 	mem_init_done = 1;
 }
 
-#if !defined(CONFIG_4xx) && !defined(CONFIG_8xx)
-/*
- * Initialize the hash table and patch the instructions in hashtable.S.
- */
-static void __init hash_init(void)
-{
-	int Hash_bits, mb, mb2;
-	unsigned int hmask, h;
-
-	extern unsigned int hash_page_patch_A[];
-	extern unsigned int hash_page_patch_B[], hash_page_patch_C[];
-	extern unsigned int hash_page[];
-	extern unsigned int flush_hash_patch_A[], flush_hash_patch_B[];
-
-#ifdef CONFIG_PPC64BRIDGE
-	/* The hash table has already been allocated and initialized
-	   in prom.c */
-	Hash_mask = (Hash_size >> 7) - 1;
-	hmask = Hash_mask >> 9;
-	Hash_bits = __ilog2(Hash_size) - 7;
-	mb = 25 - Hash_bits;
-	if (Hash_bits > 16)
-		Hash_bits = 16;
-	mb2 = 25 - Hash_bits;
-
-#else /* CONFIG_PPC64BRIDGE */
-
-	if ( ppc_md.progress ) ppc_md.progress("hash:enter", 0x105);
-	/*
-	 * Allow 64k of hash table for every 16MB of memory,
-	 * up to a maximum of 2MB.
-	 */
-	for (h = 64<<10; h < total_memory / 256 && h < (2<<20); h *= 2)
-		;
-	Hash_size = h;
-	Hash_mask = (h >> 6) - 1;
-	hmask = Hash_mask >> 10;
-	Hash_bits = __ilog2(h) - 6;
-	mb = 26 - Hash_bits;
-	if (Hash_bits > 16)
-		Hash_bits = 16;
-	mb2 = 26 - Hash_bits;
-
-	/* shrink the htab since we don't use it on 603's -- Cort */
-	switch (_get_PVR()>>16) {
-	case 3: /* 603 */
-	case 6: /* 603e */
-	case 7: /* 603ev */
-	case 0x0081: /* 82xx */
-		Hash_size = 0;
-		Hash_mask = 0;
-		break;
-	default:
-	        /* on 601/4 let things be */
-		break;
- 	}
-	
-	if ( ppc_md.progress ) ppc_md.progress("hash:find piece", 0x322);
-	/* Find some memory for the hash table. */
-	if ( Hash_size ) {
-		Hash = mem_pieces_find(Hash_size, Hash_size);
-		cacheable_memzero(Hash, Hash_size);
-		_SDR1 = __pa(Hash) | (Hash_mask >> 10);
-	} else
-		Hash = 0;
-#endif /* CONFIG_PPC64BRIDGE */
-
-	printk("Total memory = %ldMB; using %ldkB for hash table (at %p)\n",
-	       total_memory >> 20, Hash_size >> 10, Hash);
-	if ( Hash_size )
-	{
-		if ( ppc_md.progress ) ppc_md.progress("hash:patch", 0x345);
-		Hash_end = (PTE *) ((unsigned long)Hash + Hash_size);
-
-		/*
-		 * Patch up the instructions in hashtable.S:create_hpte
-		 */
-		hash_page_patch_A[0] = (hash_page_patch_A[0] & ~0xffff)
-			| ((unsigned int)(Hash) >> 16);
-		hash_page_patch_A[1] = (hash_page_patch_A[1] & ~0x7c0)
-			| (mb << 6);
-		hash_page_patch_A[2] = (hash_page_patch_A[2] & ~0x7c0)
-			| (mb2 << 6);
-		hash_page_patch_B[0] = (hash_page_patch_B[0] & ~0xffff)
-			| hmask;
-		hash_page_patch_C[0] = (hash_page_patch_C[0] & ~0xffff)
-			| hmask;
-		/*
-		 * Ensure that the locations we've patched have been written
-		 * out from the data cache and invalidated in the instruction
-		 * cache, on those machines with split caches.
-		 */
-		flush_icache_range((unsigned long) &hash_page_patch_A[0],
-				   (unsigned long) &hash_page_patch_C[1]);
-		/*
-		 * Patch up the instructions in hashtable.S:flush_hash_page
-		 */
-		flush_hash_patch_A[0] = (flush_hash_patch_A[0] & ~0xffff)
-			| ((unsigned int)(Hash) >> 16);
-		flush_hash_patch_A[1] = (flush_hash_patch_A[1] & ~0x7c0)
-			| (mb << 6);
-		flush_hash_patch_A[2] = (flush_hash_patch_A[2] & ~0x7c0)
-			| (mb2 << 6);
-		flush_hash_patch_B[0] = (flush_hash_patch_B[0] & ~0xffff)
-			| hmask;
-		flush_icache_range((unsigned long) &flush_hash_patch_A[0],
-				   (unsigned long) &flush_hash_patch_B[1]);
-	}
-	else {
-		Hash_end = 0;
-		/*
-		 * Put a blr (procedure return) instruction at the
-		 * start of hash_page, since we can still get DSI
-		 * exceptions on a 603.
-		 */
-		hash_page[0] = 0x4e800020;
-		flush_icache_range((unsigned long) &hash_page[0],
-				   (unsigned long) &hash_page[1]);
-	}
-
-	if ( ppc_md.progress ) ppc_md.progress("hash:done", 0x205);
-}
-#endif /* !CONFIG_4xx && !CONFIG_8xx */
-
 /*
  * Set phys_avail to the amount of physical memory,
  * less the kernel text/data/bss.
@@ -1314,12 +566,16 @@
 	/* remove the RTAS pages from the available memory */
 	if (rtas_data)
 		mem_pieces_remove(&phys_avail, rtas_data, rtas_size, 1);
+	/* remove the sysmap pages from the available memory */
+	if (sysmap)
+		mem_pieces_remove(&phys_avail, __pa(sysmap), sysmap_size, 1);
 #endif /* CONFIG_ALL_PPC */
-#ifdef CONFIG_PPC64BRIDGE
-	/* Remove the hash table from the available memory */
-	if (Hash)
-		mem_pieces_remove(&phys_avail, __pa(Hash), Hash_size, 1);
-#endif /* CONFIG_PPC64BRIDGE */
+}
+
+/* Mark some memory as reserved by removing it from phys_avail. */
+void __init reserve_phys_mem(unsigned long start, unsigned long size)
+{
+	mem_pieces_remove(&phys_avail, start, size, 1);
 }
 
 void flush_page_to_ram(struct page *page)
@@ -1328,32 +584,6 @@
 	__flush_page_to_ram(vaddr);
 	kunmap(page);
 }
-
-#if !defined(CONFIG_4xx) && !defined(CONFIG_8xx)
-/*
- * This is called at the end of handling a user page fault, when the
- * fault has been handled by updating a PTE in the linux page tables.
- * We use it to preload an HPTE into the hash table corresponding to
- * the updated linux PTE.
- */
-void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
-		      pte_t pte)
-{
-	struct mm_struct *mm;
-	pmd_t *pmd;
-	pte_t *ptep;
-	static int nopreload;
-
-	if (Hash == 0 || nopreload)
-		return;
-	mm = (address < TASK_SIZE)? vma->vm_mm: &init_mm;
-	pmd = pmd_offset(pgd_offset(mm, address), address);
-	if (!pmd_none(*pmd)) {
-		ptep = pte_offset(pmd, address);
-		add_hash_page(mm->context, address, ptep);
-	}
-}
-#endif /* !4xx && !8xx */
 
 /*
  * set_pte stores a linux PTE into the linux page table.
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/mm/mmu_context.c linux/arch/ppc/mm/mmu_context.c
--- v2.4.9/linux/arch/ppc/mm/mmu_context.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/ppc/mm/mmu_context.c	Tue Aug 28 06:58:33 2001
@@ -0,0 +1,89 @@
+/*
+ * BK Id: %F% %I% %G% %U% %#%
+ */
+/*
+ * This file contains the routines for handling the MMU on those
+ * PowerPC implementations where the MMU substantially follows the
+ * architecture specification.  This includes the 6xx, 7xx, 7xxx,
+ * 8260, and POWER3 implementations but excludes the 8xx and 4xx.
+ * Although the iSeries hardware does comply with the architecture
+ * specification, the need to work through the hypervisor makes
+ * things sufficiently different that it is handled elsewhere.
+ *  -- paulus
+ * 
+ *  Derived from arch/ppc/mm/init.c:
+ *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
+ *
+ *  Modifications by Paul Mackerras (PowerMac) (paulus@cs.anu.edu.au)
+ *  and Cort Dougan (PReP) (cort@cs.nmt.edu)
+ *    Copyright (C) 1996 Paul Mackerras
+ *  Amiga/APUS changes by Jesper Skov (jskov@cygnus.co.uk).
+ *
+ *  Derived from "arch/i386/mm/init.c"
+ *    Copyright (C) 1991, 1992, 1993, 1994  Linus Torvalds
+ *
+ *  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 <linux/config.h>
+#include <linux/mm.h>
+#include <linux/init.h>
+
+#include <asm/mmu_context.h>
+
+mm_context_t next_mmu_context;
+unsigned long context_map[(LAST_CONTEXT+1) / (8*sizeof(unsigned long))];
+#ifdef FEW_CONTEXTS
+atomic_t nr_free_contexts;
+struct mm_struct *context_mm[LAST_CONTEXT+1];
+void steal_context(void);
+#endif /* FEW_CONTEXTS */
+
+/*
+ * Initialize the context management stuff.
+ */
+void __init mmu_context_init(void)
+{
+	/*
+	 * Some processors have too few contexts to reserve one for
+	 * init_mm, and require using context 0 for a normal task.
+	 * Other processors reserve the use of context zero for the kernel.
+	 * This code assumes FIRST_CONTEXT < 32.
+	 */
+	context_map[0] = (1 << FIRST_CONTEXT) - 1;
+	next_mmu_context = FIRST_CONTEXT;
+#ifdef FEW_CONTEXTS
+	atomic_set(&nr_free_contexts, LAST_CONTEXT);
+#endif /* FEW_CONTEXTS */
+}
+
+#ifdef FEW_CONTEXTS
+/*
+ * Steal a context from a task that has one at the moment.
+ * This is only used on 8xx and 4xx and we presently assume that
+ * they don't do SMP.  If they do then this will have to check
+ * whether the MM we steal is in use.
+ * We also assume that this is only used on systems that don't
+ * use an MMU hash table - this is true for 8xx and 4xx.
+ * This isn't an LRU system, it just frees up each context in
+ * turn (sort-of pseudo-random replacement :).  This would be the
+ * place to implement an LRU scheme if anyone was motivated to do it.
+ *  -- paulus
+ */
+void steal_context(void)
+{
+	struct mm_struct *mm;
+
+	/* free up context `next_mmu_context' */
+	/* if we shouldn't free context 0, don't... */
+	if (next_mmu_context < FIRST_CONTEXT)
+		next_mmu_context = FIRST_CONTEXT;
+	mm = context_mm[next_mmu_context];
+	flush_tlb_mm(mm);
+	destroy_context(mm);
+}
+#endif /* FEW_CONTEXTS */
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/mm/mmu_decl.h linux/arch/ppc/mm/mmu_decl.h
--- v2.4.9/linux/arch/ppc/mm/mmu_decl.h	Wed Dec 31 16:00:00 1969
+++ linux/arch/ppc/mm/mmu_decl.h	Tue Aug 28 06:58:33 2001
@@ -0,0 +1,73 @@
+/*
+ * BK Id: %F% %I% %G% %U% %#%
+ */
+/*
+ * Declarations of procedures and variables shared between files
+ * in arch/ppc/mm/.
+ * 
+ *  Derived from arch/ppc/mm/init.c:
+ *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
+ *
+ *  Modifications by Paul Mackerras (PowerMac) (paulus@cs.anu.edu.au)
+ *  and Cort Dougan (PReP) (cort@cs.nmt.edu)
+ *    Copyright (C) 1996 Paul Mackerras
+ *  Amiga/APUS changes by Jesper Skov (jskov@cygnus.co.uk).
+ *
+ *  Derived from "arch/i386/mm/init.c"
+ *    Copyright (C) 1991, 1992, 1993, 1994  Linus Torvalds
+ *
+ *  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.
+ *
+ */
+
+extern void mapin_ram(void);
+extern void bat_mapin_ram(void);
+extern int map_page(unsigned long va, unsigned long pa, int flags);
+extern void setbat(int index, unsigned long virt, unsigned long phys,
+		   unsigned int size, int flags);
+extern void reserve_phys_mem(unsigned long start, unsigned long size);
+
+extern int __map_without_bats;
+extern void *end_of_DRAM;
+extern unsigned long ioremap_base;
+extern unsigned long ioremap_bot;
+extern unsigned int rtas_data, rtas_size;
+
+extern unsigned long total_memory;
+extern unsigned long total_lowmem;
+extern unsigned long ram_phys_base;
+extern int mem_init_done;
+
+extern PTE *Hash, *Hash_end;
+extern unsigned long Hash_size, Hash_mask;
+
+/* ...and now those things that may be slightly different between processor
+ * architectures.  -- Dan
+ */
+#if defined(CONFIG_8xx)
+#define flush_HPTE(X, va, pg)	_tlbie(va)
+#define MMU_init_hw()		do { } while(0)
+
+#elif defined(CONFIG_4xx)
+#define flush_HPTE(X, va, pg)	_tlbie(va)
+
+#else
+/* anything except 4xx or 8xx */
+extern void MMU_init_hw(void);
+
+/* Be careful....this needs to be updated if we ever encounter 603 SMPs,
+ * which includes all new 82xx processors.  We need tlbie/tlbsync here
+ * in that case (I think). -- Dan.
+ */
+static inline void flush_HPTE(unsigned context, unsigned long va, pte_t *pg)
+{
+	if ((Hash != 0) &&
+	    (cur_cpu_spec[0]->cpu_features & CPU_FTR_HPTE_TABLE))
+		flush_hash_page(0, va, pg);
+	else
+		_tlbie(va);
+}
+#endif
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/mm/pgtable.c linux/arch/ppc/mm/pgtable.c
--- v2.4.9/linux/arch/ppc/mm/pgtable.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/ppc/mm/pgtable.c	Tue Aug 28 06:58:33 2001
@@ -0,0 +1,360 @@
+/*
+ * BK Id: %F% %I% %G% %U% %#%
+ */
+/*
+ * This file contains the routines setting up the linux page tables.
+ *  -- paulus
+ * 
+ *  Derived from arch/ppc/mm/init.c:
+ *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
+ *
+ *  Modifications by Paul Mackerras (PowerMac) (paulus@cs.anu.edu.au)
+ *  and Cort Dougan (PReP) (cort@cs.nmt.edu)
+ *    Copyright (C) 1996 Paul Mackerras
+ *  Amiga/APUS changes by Jesper Skov (jskov@cygnus.co.uk).
+ *
+ *  Derived from "arch/i386/mm/init.c"
+ *    Copyright (C) 1991, 1992, 1993, 1994  Linus Torvalds
+ *
+ *  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 <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/vmalloc.h>
+#include <linux/init.h>
+
+#include <asm/pgtable.h>
+#include <asm/pgalloc.h>
+#include <asm/io.h>
+
+#include "mmu_decl.h"
+
+unsigned long ram_phys_base;
+
+unsigned long ioremap_base;
+unsigned long ioremap_bot;
+int io_bat_index;
+
+#ifndef CONFIG_SMP
+struct pgtable_cache_struct quicklists;
+#endif
+
+#if defined(CONFIG_6xx) || defined(CONFIG_POWER3)
+#define HAVE_BATS	1
+#endif
+
+extern char etext[], _stext[];
+
+#ifdef HAVE_BATS
+extern unsigned long v_mapped_by_bats(unsigned long va);
+extern unsigned long p_mapped_by_bats(unsigned long pa);
+void setbat(int index, unsigned long virt, unsigned long phys,
+	    unsigned int size, int flags);
+
+#else /* !HAVE_BATS */
+#define v_mapped_by_bats(x)	(0UL)
+#define p_mapped_by_bats(x)	(0UL)
+#endif /* HAVE_BATS */
+
+#ifndef CONFIG_PPC_ISERIES
+void *
+ioremap(unsigned long addr, unsigned long size)
+{
+	return __ioremap(addr, size, _PAGE_NO_CACHE);
+}
+
+void *
+__ioremap(unsigned long addr, unsigned long size, unsigned long flags)
+{
+	unsigned long p, v, i;
+	int err;
+
+	/*
+	 * Choose an address to map it to.
+	 * Once the vmalloc system is running, we use it.
+	 * Before then, we use space going down from ioremap_base
+	 * (ioremap_bot records where we're up to).
+	 */
+	p = addr & PAGE_MASK;
+	size = PAGE_ALIGN(addr + size) - p;
+
+	/*
+	 * If the address lies within the first 16 MB, assume it's in ISA
+	 * memory space
+	 */
+	if (p < 16*1024*1024)
+		p += _ISA_MEM_BASE;
+
+	/*
+	 * 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;
+
+	/*
+	 * 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(p)) /*&& p_mapped_by_bats(p+size-1)*/ )
+		goto out;
+	
+	if (mem_init_done) {
+		struct vm_struct *area;
+		area = get_vm_area(size, VM_IOREMAP);
+		if (area == 0)
+			return NULL;
+		v = VMALLOC_VMADDR(area->addr);
+	} else {
+		v = (ioremap_bot -= size);
+	}
+
+	if ((flags & _PAGE_PRESENT) == 0)
+		flags |= _PAGE_KERNEL;
+	if (flags & _PAGE_NO_CACHE)
+		flags |= _PAGE_GUARDED;
+
+	/*
+	 * Should check if it is a candidate for a BAT mapping
+	 */
+
+	err = 0;
+	for (i = 0; i < size && err == 0; i += PAGE_SIZE)
+		err = map_page(v+i, p+i, flags);
+	if (err) {
+		if (mem_init_done)
+			vfree((void *)v);
+		return NULL;
+	}
+
+out:
+	return (void *) (v + (addr & ~PAGE_MASK));
+}
+
+void iounmap(void *addr)
+{
+	/*
+	 * If mapped by BATs then there is nothing to do.
+	 * Calling vfree() generates a benign warning.
+	 */
+	if (v_mapped_by_bats((unsigned long)addr)) return;
+
+	if (addr > high_memory && (unsigned long) addr < ioremap_bot)
+		vfree((void *) (PAGE_MASK & (unsigned long) addr));
+}
+#endif /* CONFIG_PPC_ISERIES */
+
+int
+map_page(unsigned long va, unsigned long pa, int flags)
+{
+	pmd_t *pd;
+	pte_t *pg;
+	int err = -ENOMEM;
+
+	spin_lock(&init_mm.page_table_lock);
+	/* Use upper 10 bits of VA to index the first level map */
+	pd = pmd_offset(pgd_offset_k(va), va);
+	/* Use middle 10 bits of VA to index the second-level map */
+	pg = pte_alloc(&init_mm, pd, va);
+	if (pg != 0) {
+		err = 0;
+		set_pte(pg, mk_pte_phys(pa & PAGE_MASK, __pgprot(flags)));
+		if (mem_init_done)
+			flush_HPTE(0, va, pg);
+	}
+	spin_unlock(&init_mm.page_table_lock);
+	return err;
+}
+
+/*
+ * Map in all of physical memory starting at KERNELBASE.
+ */
+void __init mapin_ram(void)
+{
+	unsigned long v, p, s, f;
+
+#ifdef HAVE_BATS
+	if (!__map_without_bats)
+		bat_mapin_ram();
+#endif /* HAVE_BATS */
+
+	v = KERNELBASE;
+	p = ram_phys_base;
+	for (s = 0; s < total_lowmem; s += PAGE_SIZE) {
+		/* On the MPC8xx, we want the page shared so we
+		 * don't get ASID compares on kernel space.
+		 */
+		f = _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_SHARED;
+#if defined(CONFIG_KGDB) || defined(CONFIG_XMON)
+		/* Allows stub to set breakpoints everywhere */
+		f |= _PAGE_RW | _PAGE_DIRTY;
+#else
+		if ((char *) v < _stext || (char *) v >= etext)
+			f |= _PAGE_RW | _PAGE_DIRTY;
+#ifndef CONFIG_8xx
+		else
+			/* On the powerpc (not 8xx), no user access
+			   forces R/W kernel access */
+			f |= _PAGE_USER;
+#endif /* CONFIG_8xx */
+#endif /* CONFIG_KGDB */
+		map_page(v, p, f);
+		v += PAGE_SIZE;
+		p += PAGE_SIZE;
+	}
+}
+
+/* is x a power of 2? */
+#define is_power_of_2(x)	((x) != 0 && (((x) & ((x) - 1)) == 0))
+
+/*
+ * Set up a mapping for a block of I/O.
+ * virt, phys, size must all be page-aligned.
+ * This should only be called before ioremap is called.
+ */
+void __init io_block_mapping(unsigned long virt, unsigned long phys,
+			     unsigned int size, int flags)
+{
+	int i;
+
+	if (virt > KERNELBASE && virt < ioremap_bot)
+		ioremap_bot = ioremap_base = virt;
+
+#ifdef HAVE_BATS
+	/*
+	 * Use a BAT for this if possible...
+	 */
+	if (io_bat_index < 2 && is_power_of_2(size)
+	    && (virt & (size - 1)) == 0 && (phys & (size - 1)) == 0) {
+		setbat(io_bat_index, virt, phys, size, flags);
+		++io_bat_index;
+		return;
+	}
+#endif /* HAVE_BATS */
+
+	/* No BATs available, put it in the page tables. */
+	for (i = 0; i < size; i += PAGE_SIZE)
+		map_page(virt + i, phys + i, flags);
+}
+
+/* Scan the real Linux page tables and return a PTE pointer for
+ * a virtual address in a context.
+ * Returns true (1) if PTE was found, zero otherwise.  The pointer to
+ * the PTE pointer is unmodified if PTE is not found.
+ */
+int
+get_pteptr(struct mm_struct *mm, unsigned long addr, pte_t **ptep)
+{
+        pgd_t	*pgd;
+        pmd_t	*pmd;
+        pte_t	*pte;
+        int     retval = 0;
+
+        pgd = pgd_offset(mm, addr & PAGE_MASK);
+        if (pgd) {
+                pmd = pmd_offset(pgd, addr & PAGE_MASK);
+                if (pmd_present(*pmd)) {
+                        pte = pte_offset(pmd, addr & PAGE_MASK);
+                        if (pte) {
+				retval = 1;
+				*ptep = pte;
+                        }
+                }
+        }
+        return(retval);
+}
+
+/* Find physical address for this virtual address.  Normally used by
+ * I/O functions, but anyone can call it.
+ */
+unsigned long iopa(unsigned long addr)
+{
+	unsigned long pa;
+
+	/* I don't know why this won't work on PMacs or CHRP.  It
+	 * appears there is some bug, or there is some implicit
+	 * mapping done not properly represented by BATs or in page
+	 * tables.......I am actively working on resolving this, but
+	 * can't hold up other stuff.  -- Dan
+	 */
+	pte_t *pte;
+	struct mm_struct *mm;
+
+	/* Check the BATs */
+	pa = v_mapped_by_bats(addr);
+	if (pa)
+		return pa;
+
+	/* Allow mapping of user addresses (within the thread)
+	 * for DMA if necessary.
+	 */
+	if (addr < TASK_SIZE)
+		mm = current->mm;
+	else
+		mm = &init_mm;
+	
+	pa = 0;
+	if (get_pteptr(mm, addr, &pte))
+		pa = (pte_val(*pte) & PAGE_MASK) | (addr & ~PAGE_MASK);
+
+	return(pa);
+}
+
+/* This is will find the virtual address for a physical one....
+ * Swiped from APUS, could be dangerous :-).
+ * This is only a placeholder until I really find a way to make this
+ * work.  -- Dan
+ */
+unsigned long
+mm_ptov (unsigned long paddr)
+{
+	unsigned long ret;
+#if 0
+	if (paddr < 16*1024*1024)
+		ret = ZTWO_VADDR(paddr);
+	else {
+		int i;
+
+		for (i = 0; i < kmap_chunk_count;){
+			unsigned long phys = kmap_chunks[i++];
+			unsigned long size = kmap_chunks[i++];
+			unsigned long virt = kmap_chunks[i++];
+			if (paddr >= phys
+			    && paddr < (phys + size)){
+				ret = virt + paddr - phys;
+				goto exit;
+			}
+		}
+		
+		ret = (unsigned long) __va(paddr);
+	}
+exit:
+#ifdef DEBUGPV
+	printk ("PTOV(%lx)=%lx\n", paddr, ret);
+#endif
+#else
+	ret = (unsigned long)paddr + KERNELBASE;
+#endif
+	return ret;
+}
+
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/mm/ppc_mmu.c linux/arch/ppc/mm/ppc_mmu.c
--- v2.4.9/linux/arch/ppc/mm/ppc_mmu.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/ppc/mm/ppc_mmu.c	Tue Aug 28 06:58:33 2001
@@ -0,0 +1,313 @@
+/*
+ * BK Id: %F% %I% %G% %U% %#%
+ */
+/*
+ * This file contains the routines for handling the MMU on those
+ * PowerPC implementations where the MMU substantially follows the
+ * architecture specification.  This includes the 6xx, 7xx, 7xxx,
+ * 8260, and POWER3 implementations but excludes the 8xx and 4xx.
+ * Although the iSeries hardware does comply with the architecture
+ * specification, the need to work through the hypervisor makes
+ * things sufficiently different that it is handled elsewhere.
+ *  -- paulus
+ * 
+ *  Derived from arch/ppc/mm/init.c:
+ *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
+ *
+ *  Modifications by Paul Mackerras (PowerMac) (paulus@cs.anu.edu.au)
+ *  and Cort Dougan (PReP) (cort@cs.nmt.edu)
+ *    Copyright (C) 1996 Paul Mackerras
+ *  Amiga/APUS changes by Jesper Skov (jskov@cygnus.co.uk).
+ *
+ *  Derived from "arch/i386/mm/init.c"
+ *    Copyright (C) 1991, 1992, 1993, 1994  Linus Torvalds
+ *
+ *  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 <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/init.h>
+
+#include <asm/prom.h>
+#include <asm/mmu.h>
+#include <asm/machdep.h>
+
+#include "mmu_decl.h"
+#include "mem_pieces.h"
+
+PTE *Hash, *Hash_end;
+unsigned long Hash_size, Hash_mask;
+unsigned long _SDR1;
+
+union ubat {			/* BAT register values to be loaded */
+	BAT	bat;
+#ifdef CONFIG_PPC64BRIDGE
+	u64	word[2];
+#else
+	u32	word[2];
+#endif	
+} BATS[4][2];			/* 4 pairs of IBAT, DBAT */
+
+struct batrange {		/* stores address ranges mapped by BATs */
+	unsigned long start;
+	unsigned long limit;
+	unsigned long phys;
+} bat_addrs[4];
+
+/*
+ * Return PA for this VA if it is mapped by a BAT, or 0
+ */
+unsigned long 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 bat_addrs[b].phys + (va - bat_addrs[b].start);
+	return 0;
+}
+
+/*
+ * Return VA for a given PA or 0 if not mapped
+ */
+unsigned long 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;
+}
+
+void __init bat_mapin_ram(void)
+{
+	unsigned long tot, bl, done;
+	unsigned long max_size = (256<<20);
+	unsigned long align;
+
+	/* Set up BAT2 and if necessary BAT3 to cover RAM. */
+
+	/* Make sure we don't map a block larger than the
+	   smallest alignment of the physical address. */
+	/* alignment of ram_phys_base */
+	align = ~(ram_phys_base-1) & ram_phys_base;
+	/* set BAT block size to MIN(max_size, align) */
+	if (align && align < max_size)
+		max_size = align;
+
+	tot = total_lowmem;
+	for (bl = 128<<10; bl < max_size; bl <<= 1) {
+		if (bl * 2 > tot)
+			break;
+	}
+
+	setbat(2, KERNELBASE, ram_phys_base, bl, _PAGE_KERNEL);
+	done = (unsigned long)bat_addrs[2].limit - KERNELBASE + 1;
+	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)
+			if (bl * 2 > tot)
+				break;
+		setbat(3, KERNELBASE+done, ram_phys_base+done, bl, 
+		       _PAGE_KERNEL);
+	}
+}
+
+/*
+ * Set up one of the I/D BAT (block address translation) register pairs.
+ * The parameters are not checked; in particular size must be a power
+ * of 2 between 128k and 256M.
+ */
+void __init setbat(int index, unsigned long virt, unsigned long phys,
+		   unsigned int size, int flags)
+{
+	unsigned int bl;
+	int wimgxpp;
+	union ubat *bat = BATS[index];
+
+#ifdef CONFIG_SMP
+	if ((flags & _PAGE_NO_CACHE) == 0)
+		flags |= _PAGE_COHERENT;
+#endif
+	bl = (size >> 17) - 1;
+	if (PVR_VER(mfspr(PVR)) != 1) {
+		/* 603, 604, etc. */
+		/* Do DBAT first */
+		wimgxpp = flags & (_PAGE_WRITETHRU | _PAGE_NO_CACHE
+				   | _PAGE_COHERENT | _PAGE_GUARDED);
+		wimgxpp |= (flags & _PAGE_RW)? BPP_RW: BPP_RX;
+		bat[1].word[0] = virt | (bl << 2) | 2; /* Vs=1, Vp=0 */
+		bat[1].word[1] = phys | wimgxpp;
+#ifndef CONFIG_KGDB /* want user access for breakpoints */
+		if (flags & _PAGE_USER)
+#endif
+			bat[1].bat.batu.vp = 1;
+		if (flags & _PAGE_GUARDED) {
+			/* G bit must be zero in IBATs */
+			bat[0].word[0] = bat[0].word[1] = 0;
+		} else {
+			/* make IBAT same as DBAT */
+			bat[0] = bat[1];
+		}
+	} else {
+		/* 601 cpu */
+		if (bl > BL_8M)
+			bl = BL_8M;
+		wimgxpp = flags & (_PAGE_WRITETHRU | _PAGE_NO_CACHE
+				   | _PAGE_COHERENT);
+		wimgxpp |= (flags & _PAGE_RW)?
+			((flags & _PAGE_USER)? PP_RWRW: PP_RWXX): PP_RXRX;
+		bat->word[0] = virt | wimgxpp | 4;	/* Ks=0, Ku=1 */
+		bat->word[1] = phys | bl | 0x40;	/* V=1 */
+	}
+
+	bat_addrs[index].start = virt;
+	bat_addrs[index].limit = virt + ((bl + 1) << 17) - 1;
+	bat_addrs[index].phys = phys;
+}
+
+/*
+ * Initialize the hash table and patch the instructions in hashtable.S.
+ */
+void __init MMU_init_hw(void)
+{
+	int Hash_bits, mb, mb2;
+	unsigned int hmask;
+
+	extern unsigned int hash_page_patch_A[];
+	extern unsigned int hash_page_patch_B[], hash_page_patch_C[];
+	extern unsigned int hash_page[];
+	extern unsigned int flush_hash_patch_A[], flush_hash_patch_B[];
+
+#ifdef CONFIG_PPC64BRIDGE
+	/* The hash table has already been allocated and initialized
+	   in prom.c */
+	Hash_mask = (Hash_size >> 7) - 1;
+	hmask = Hash_mask >> 9;
+	Hash_bits = __ilog2(Hash_size) - 7;
+	mb = 25 - Hash_bits;
+	if (Hash_bits > 16)
+		Hash_bits = 16;
+	mb2 = 25 - Hash_bits;
+
+	/* Remove the hash table from the available memory */
+	if (Hash)
+		reserve_phys_mem(__pa(Hash), Hash_size);
+
+#else /* CONFIG_PPC64BRIDGE */
+	unsigned int h;
+
+	if ((cur_cpu_spec[0]->cpu_features & CPU_FTR_HPTE_TABLE) == 0)
+		return;
+	if ( ppc_md.progress ) ppc_md.progress("hash:enter", 0x105);
+	/*
+	 * Allow 64k of hash table for every 16MB of memory,
+	 * up to a maximum of 2MB.
+	 */
+	for (h = 64<<10; h < total_memory / 256 && h < (2<<20); h *= 2)
+		;
+	Hash_size = h;
+	Hash_mask = (h >> 6) - 1;
+	hmask = Hash_mask >> 10;
+	Hash_bits = __ilog2(h) - 6;
+	mb = 26 - Hash_bits;
+	if (Hash_bits > 16)
+		Hash_bits = 16;
+	mb2 = 26 - Hash_bits;
+
+	if ( ppc_md.progress ) ppc_md.progress("hash:find piece", 0x322);
+	/* Find some memory for the hash table. */
+	if ( Hash_size ) {
+		Hash = mem_pieces_find(Hash_size, Hash_size);
+		cacheable_memzero(Hash, Hash_size);
+		_SDR1 = __pa(Hash) | (Hash_mask >> 10);
+	} else
+		Hash = 0;
+#endif /* CONFIG_PPC64BRIDGE */
+
+	printk("Total memory = %ldMB; using %ldkB for hash table (at %p)\n",
+	       total_memory >> 20, Hash_size >> 10, Hash);
+	if (Hash_size) {
+		if ( ppc_md.progress ) ppc_md.progress("hash:patch", 0x345);
+		Hash_end = (PTE *) ((unsigned long)Hash + Hash_size);
+
+		/*
+		 * Patch up the instructions in hashtable.S:create_hpte
+		 */
+		hash_page_patch_A[0] = (hash_page_patch_A[0] & ~0xffff)
+			| ((unsigned int)(Hash) >> 16);
+		hash_page_patch_A[1] = (hash_page_patch_A[1] & ~0x7c0)
+			| (mb << 6);
+		hash_page_patch_A[2] = (hash_page_patch_A[2] & ~0x7c0)
+			| (mb2 << 6);
+		hash_page_patch_B[0] = (hash_page_patch_B[0] & ~0xffff)
+			| hmask;
+		hash_page_patch_C[0] = (hash_page_patch_C[0] & ~0xffff)
+			| hmask;
+		/*
+		 * Ensure that the locations we've patched have been written
+		 * out from the data cache and invalidated in the instruction
+		 * cache, on those machines with split caches.
+		 */
+		flush_icache_range((unsigned long) &hash_page_patch_A[0],
+				   (unsigned long) &hash_page_patch_C[1]);
+		/*
+		 * Patch up the instructions in hashtable.S:flush_hash_page
+		 */
+		flush_hash_patch_A[0] = (flush_hash_patch_A[0] & ~0xffff)
+			| ((unsigned int)(Hash) >> 16);
+		flush_hash_patch_A[1] = (flush_hash_patch_A[1] & ~0x7c0)
+			| (mb << 6);
+		flush_hash_patch_A[2] = (flush_hash_patch_A[2] & ~0x7c0)
+			| (mb2 << 6);
+		flush_hash_patch_B[0] = (flush_hash_patch_B[0] & ~0xffff)
+			| hmask;
+		flush_icache_range((unsigned long) &flush_hash_patch_A[0],
+				   (unsigned long) &flush_hash_patch_B[1]);
+	}
+	else {
+		Hash_end = 0;
+		/*
+		 * Put a blr (procedure return) instruction at the
+		 * start of hash_page, since we can still get DSI
+		 * exceptions on a 603.
+		 */
+		hash_page[0] = 0x4e800020;
+		flush_icache_range((unsigned long) &hash_page[0],
+				   (unsigned long) &hash_page[1]);
+	}
+
+	if ( ppc_md.progress ) ppc_md.progress("hash:done", 0x205);
+}
+
+/*
+ * This is called at the end of handling a user page fault, when the
+ * fault has been handled by updating a PTE in the linux page tables.
+ * We use it to preload an HPTE into the hash table corresponding to
+ * the updated linux PTE.
+ */
+void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
+		      pte_t pte)
+{
+	struct mm_struct *mm;
+	pmd_t *pmd;
+	pte_t *ptep;
+	static int nopreload;
+
+	if (Hash == 0 || nopreload)
+		return;
+	mm = (address < TASK_SIZE)? vma->vm_mm: &init_mm;
+	pmd = pmd_offset(pgd_offset(mm, address), address);
+	if (!pmd_none(*pmd)) {
+		ptep = pte_offset(pmd, address);
+		add_hash_page(mm->context, address, ptep);
+	}
+}
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/mm/tlb.c linux/arch/ppc/mm/tlb.c
--- v2.4.9/linux/arch/ppc/mm/tlb.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/ppc/mm/tlb.c	Tue Aug 28 06:58:33 2001
@@ -0,0 +1,162 @@
+/*
+ * BK Id: %F% %I% %G% %U% %#%
+ */
+/*
+ * This file contains the routines for TLB flushing.
+ * On machines where the MMU uses a hash table to store virtual to
+ * physical translations, these routines flush entries from the the
+ * hash table also.
+ *  -- paulus
+ * 
+ *  Derived from arch/ppc/mm/init.c:
+ *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
+ *
+ *  Modifications by Paul Mackerras (PowerMac) (paulus@cs.anu.edu.au)
+ *  and Cort Dougan (PReP) (cort@cs.nmt.edu)
+ *    Copyright (C) 1996 Paul Mackerras
+ *  Amiga/APUS changes by Jesper Skov (jskov@cygnus.co.uk).
+ *
+ *  Derived from "arch/i386/mm/init.c"
+ *    Copyright (C) 1991, 1992, 1993, 1994  Linus Torvalds
+ *
+ *  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 <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/init.h>
+
+#include "mmu_decl.h"
+
+/*
+ * TLB flushing:
+ *
+ *  - flush_tlb_all() flushes all processes TLBs
+ *  - flush_tlb_mm(mm) flushes the specified mm context TLB's
+ *  - flush_tlb_page(vma, vmaddr) flushes one page
+ *  - flush_tlb_range(mm, start, end) flushes a range of pages
+ *
+ * since the hardware hash table functions as an extension of the
+ * tlb as far as the linux tables are concerned, flush it too.
+ *    -- Cort
+ */
+
+/*
+ * Flush all tlb/hash table entries (except perhaps for those
+ * mapping RAM starting at PAGE_OFFSET, since they never change).
+ */
+void
+local_flush_tlb_all(void)
+{
+	/* aargh!!! */
+	/*
+	 * Just flush the kernel part of the address space, that's
+	 * all that the current callers of this require.
+	 * Eventually I hope to persuade the powers that be that
+	 * we can and should dispense with flush_tlb_all().
+	 *  -- paulus.
+	 */
+	local_flush_tlb_range(&init_mm, TASK_SIZE, ~0UL);
+
+#ifdef CONFIG_SMP
+	smp_send_tlb_invalidate(0);
+#endif /* CONFIG_SMP */
+}
+
+/*
+ * Flush all the (user) entries for the address space described
+ * by mm.  We can't rely on mm->mmap describing all the entries
+ * that might be in the hash table.
+ */
+void
+local_flush_tlb_mm(struct mm_struct *mm)
+{
+	if (Hash == 0) {
+		_tlbia();
+		return;
+	}
+
+	if (mm->map_count) {
+		struct vm_area_struct *mp;
+		for (mp = mm->mmap; mp != NULL; mp = mp->vm_next)
+			local_flush_tlb_range(mm, mp->vm_start, mp->vm_end);
+	} else
+		local_flush_tlb_range(mm, 0, TASK_SIZE);
+
+#ifdef CONFIG_SMP
+	smp_send_tlb_invalidate(0);
+#endif	
+}
+
+void
+local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr)
+{
+	struct mm_struct *mm;
+	pmd_t *pmd;
+	pte_t *pte;
+
+	if (Hash == 0) {
+		_tlbie(vmaddr);
+		return;
+	}
+	mm = (vmaddr < TASK_SIZE)? vma->vm_mm: &init_mm;
+	pmd = pmd_offset(pgd_offset(mm, vmaddr), vmaddr);
+	if (!pmd_none(*pmd)) {
+		pte = pte_offset(pmd, vmaddr);
+		if (pte_val(*pte) & _PAGE_HASHPTE)
+			flush_hash_page(mm->context, vmaddr, pte);
+	}
+#ifdef CONFIG_SMP
+	smp_send_tlb_invalidate(0);
+#endif	
+}
+
+
+/*
+ * For each address in the range, find the pte for the address
+ * and check _PAGE_HASHPTE bit; if it is set, find and destroy
+ * the corresponding HPTE.
+ */
+void
+local_flush_tlb_range(struct mm_struct *mm, unsigned long start, unsigned long end)
+{
+	pmd_t *pmd;
+	pte_t *pte;
+	unsigned long pmd_end;
+	unsigned int ctx = mm->context;
+
+	if (Hash == 0) {
+		_tlbia();
+		return;
+	}
+	start &= PAGE_MASK;
+	if (start >= end)
+		return;
+	pmd = pmd_offset(pgd_offset(mm, start), start);
+	do {
+		pmd_end = (start + PGDIR_SIZE) & PGDIR_MASK;
+		if (!pmd_none(*pmd)) {
+			if (!pmd_end || pmd_end > end)
+				pmd_end = end;
+			pte = pte_offset(pmd, start);
+			do {
+				if ((pte_val(*pte) & _PAGE_HASHPTE) != 0)
+					flush_hash_page(ctx, start, pte);
+				start += PAGE_SIZE;
+				++pte;
+			} while (start && start < pmd_end);
+		} else {
+			start = pmd_end;
+		}
+		++pmd;
+	} while (start && start < end);
+
+#ifdef CONFIG_SMP
+	smp_send_tlb_invalidate(0);
+#endif	
+}
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/vmlinux.lds linux/arch/ppc/vmlinux.lds
--- v2.4.9/linux/arch/ppc/vmlinux.lds	Mon Aug 27 12:41:39 2001
+++ linux/arch/ppc/vmlinux.lds	Tue Aug 28 06:58:33 2001
@@ -70,6 +70,10 @@
   __ksymtab : { *(__ksymtab) }
   __stop___ksymtab = .;
 
+  __start___ftr_fixup = .;
+  __ftr_fixup : { *(__ftr_fixup) }
+  __stop___ftr_fixup = .;
+
   . = ALIGN(32);
   .data.cacheline_aligned : { *(.data.cacheline_aligned) }
 
diff -u --recursive --new-file v2.4.9/linux/arch/ppc/xmon/start.c linux/arch/ppc/xmon/start.c
--- v2.4.9/linux/arch/ppc/xmon/start.c	Mon May 21 17:04:47 2001
+++ linux/arch/ppc/xmon/start.c	Tue Aug 28 06:58:33 2001
@@ -1,5 +1,5 @@
 /*
- * BK Id: SCCS/s.start.c 1.12 05/21/01 21:39:13 paulus
+ * BK Id: SCCS/s.start.c 1.16 08/20/01 22:17:58 paulus
  */
 /*
  * Copyright (C) 1996 Paul Mackerras.
@@ -18,6 +18,7 @@
 #include <asm/feature.h>
 #include <asm/processor.h>
 #include <asm/delay.h>
+#include <asm/btext.h>
 #ifdef CONFIG_SMP
 #include <asm/bitops.h>
 #endif
@@ -25,8 +26,6 @@
 static volatile unsigned char *sccc, *sccd;
 unsigned long TXRDY, RXRDY;
 extern void xmon_printf(const char *fmt, ...);
-extern void prom_drawchar(char);
-extern void prom_drawstring(const char *str);
 static int xmon_expect(const char *str, unsigned int timeout);
 
 static int console;
@@ -56,6 +55,7 @@
 void
 xmon_map_scc(void)
 {
+#ifdef CONFIG_ALL_PPC
 	volatile unsigned char *base;
 
 	use_screen = 0;
@@ -85,14 +85,34 @@
 				use_screen = 1;
 #endif
 		}
-		prom_drawstring("xmon uses ");
+		if (!use_screen && (np = find_devices("escc")) != NULL) {
+			/*
+			 * look for the device node for the serial port
+			 * we're using and see if it says it has a modem
+			 */
+			char *name = xmon_use_sccb? "ch-b": "ch-a";
+			char *slots;
+			int l;
+
+			np = np->child;
+			while (np != NULL && strcmp(np->name, name) != 0)
+				np = np->sibling;
+			if (np != NULL) {
+				/* XXX should parse this properly */
+				slots = get_property(np, "slot-names", &l);
+				if (slots != NULL && l >= 10
+				    && strcmp(slots+4, "Modem") == 0)
+					via_modem = 1;
+			}
+		}
+		btext_drawstring("xmon uses ");
 		if (use_screen)
-			prom_drawstring("screen and keyboard\n");
+			btext_drawstring("screen and keyboard\n");
 		else {
 			if (via_modem)
-				prom_drawstring("modem on ");
-			prom_drawstring(xmon_use_sccb? "printer": "modem");
-			prom_drawstring(" port\n");
+				btext_drawstring("modem on ");
+			btext_drawstring(xmon_use_sccb? "printer": "modem");
+			btext_drawstring(" port\n");
 		}
 
 #endif /* CONFIG_BOOTX_TEXT */
@@ -114,15 +134,6 @@
 		sccc = base + (addr & ~PAGE_MASK);
 		sccd = sccc + 0x10;
 	}
-	else if ( _machine & _MACH_gemini )
-	{
-		/* should already be mapped by the kernel boot */
-		sccc = (volatile unsigned char *) 0xffeffb0d;
-		sccd = (volatile unsigned char *) 0xffeffb08;
-		TXRDY = 0x20;
-		RXRDY = 1;
-		console = 1;
-	}
 	else
 	{
 		/* should already be mapped by the kernel boot */
@@ -135,6 +146,14 @@
 		TXRDY = 0x20;
 		RXRDY = 1;
 	}
+#elif defined(CONFIG_GEMINI)
+	/* should already be mapped by the kernel boot */
+	sccc = (volatile unsigned char *) 0xffeffb0d;
+	sccd = (volatile unsigned char *) 0xffeffb08;
+	TXRDY = 0x20;
+	RXRDY = 1;
+	console = 1;
+#endif /* platform */
 }
 
 static int scc_initialized = 0;
@@ -175,7 +194,7 @@
 	if (use_screen) {
 		/* write it on the screen */
 		for (i = 0; i < nb; ++i)
-			prom_drawchar(*p++);
+			btext_drawchar(*p++);
 		goto out;
 	}
 #endif
@@ -216,7 +235,7 @@
 
 static unsigned char xmon_keytab[128] =
 	"asdfhgzxcv\000bqwer"				/* 0x00 - 0x0f */
-	"yt123465=97-80o]"				/* 0x10 - 0x1f */
+	"yt123465=97-80]o"				/* 0x10 - 0x1f */
 	"u[ip\rlj'k;\\,/nm."				/* 0x20 - 0x2f */
 	"\t `\177\0\033\0\0\0\0\0\0\0\0\0\0"		/* 0x30 - 0x3f */
 	"\0.\0*\0+\0\0\0\0\0/\r\0-\0"			/* 0x40 - 0x4f */
@@ -224,7 +243,7 @@
 
 static unsigned char xmon_shift_keytab[128] =
 	"ASDFHGZXCV\000BQWER"				/* 0x00 - 0x0f */
-	"YT!@#$^%+(&=*)}O"				/* 0x10 - 0x1f */
+	"YT!@#$^%+(&_*)}O"				/* 0x10 - 0x1f */
 	"U{IP\rLJ\"K:|<?NM>"				/* 0x20 - 0x2f */
 	"\t ~\177\0\033\0\0\0\0\0\0\0\0\0\0"		/* 0x30 - 0x3f */
 	"\0.\0*\0+\0\0\0\0\0/\r\0-\0"			/* 0x40 - 0x4f */
@@ -243,15 +262,15 @@
 		do {
 			if (--t < 0) {
 				on = 1 - on;
-				prom_drawchar(on? 0xdb: 0x20);
-				prom_drawchar('\b');
+				btext_drawchar(on? 0xdb: 0x20);
+				btext_drawchar('\b');
 				t = 200000;
 			}
 			do_poll_adb();
 		} while (xmon_adb_keycode == -1);
 		k = xmon_adb_keycode;
 		if (on)
-			prom_drawstring(" \b");
+			btext_drawstring(" \b");
 
 		/* test for shift keys */
 		if ((k & 0x7f) == 0x38 || (k & 0x7f) == 0x7b) {
@@ -544,7 +563,9 @@
 xmon_enter(void)
 {
 #ifdef CONFIG_ADB_PMU
-	pmu_suspend();
+	if (_machine == _MACH_Pmac) {
+		pmu_suspend();
+	}
 #endif
 }
 
@@ -552,6 +573,8 @@
 xmon_leave(void)
 {
 #ifdef CONFIG_ADB_PMU
-	pmu_resume();
+	if (_machine == _MACH_Pmac) {
+		pmu_resume();
+	}
 #endif
 }
diff -u --recursive --new-file v2.4.9/linux/arch/sh/Makefile linux/arch/sh/Makefile
--- v2.4.9/linux/arch/sh/Makefile	Fri Dec 29 14:07:20 2000
+++ linux/arch/sh/Makefile	Sat Sep  8 12:29:09 2001
@@ -75,6 +75,11 @@
 
 MAKEBOOT = $(MAKE) -C arch/$(ARCH)/boot
 
+ifneq ($(CONFIG_SH_GENERIC)$(CONFIG_SH_STB1_HARP)$(CONFIG_SH_STB1_OVERDRIVE),)
+SUBDIRS += arch/sh/stboards
+CORE_FILES += arch/sh/stboards/stboards.o
+endif
+
 vmlinux: arch/sh/vmlinux.lds
 
 arch/sh/vmlinux.lds: arch/sh/vmlinux.lds.S FORCE
@@ -93,6 +98,7 @@
 archclean:
 	@$(MAKEBOOT) clean
 	$(MAKE) -C arch/$(ARCH)/kernel clean
+	$(MAKE) -C arch/$(ARCH)/stboards clean
 #	$(MAKE) -C arch/$(ARCH)/tools clean
 
 archmrproper:
diff -u --recursive --new-file v2.4.9/linux/arch/sh/config.in linux/arch/sh/config.in
--- v2.4.9/linux/arch/sh/config.in	Tue Jul  3 17:08:18 2001
+++ linux/arch/sh/config.in	Sat Sep  8 12:29:09 2001
@@ -42,6 +42,7 @@
 	 CAT68701		CONFIG_SH_CAT68701		\
 	 BigSur			CONFIG_SH_BIGSUR		\
 	 SH2000			CONFIG_SH_SH2000		\
+	 ADX			CONFIG_SH_ADX			\
 	 BareCPU		CONFIG_SH_UNKNOWN" Generic
 
 # The SH7750 RTC module is disabled in the Dreamcast
@@ -88,24 +89,40 @@
    define_bool CONFIG_CPU_SH4 y
 fi
 bool 'Little Endian' CONFIG_CPU_LITTLE_ENDIAN
+# Platform-specific memory start and size definitions
 if [ "$CONFIG_SH_SOLUTION_ENGINE" = "y" -o "$CONFIG_SH_HP600" = "y" -o \
      "$CONFIG_SH_BIGSUR" = "y" -o "$CONFIG_SH_7751_SOLUTION_ENGINE" = "y" -o \
      "$CONFIG_SH_DREAMCAST" = "y" -o "$CONFIG_SH_SH2000" = "y" ]; then
-  define_hex CONFIG_MEMORY_START 0c000000
-else
-  if [ "$CONFIG_CPU_SUBTYPE_ST40STB1" = "y" ]; then
-    bool 'Memory on LMI' CONFIG_ST40_LMI_MEMORY
-    if [ "$CONFIG_ST40_LMI_MEMORY" = "y" ] ; then
+   define_hex CONFIG_MEMORY_START 0c000000
+   define_hex CONFIG_MEMORY_SIZE 00400000
+   define_bool CONFIG_MEMORY_SET y
+fi
+if [ "$CONFIG_CPU_SUBTYPE_ST40STB1" = "y" ]; then
+   bool 'Memory on LMI' CONFIG_ST40_LMI_MEMORY
+   if [ "$CONFIG_ST40_LMI_MEMORY" = "y" ] ; then
       define_hex CONFIG_MEMORY_START 08000000
-    else
-      hex 'EMI physical memory start address' CONFIG_MEMORY_START 08000000
-    fi
-  else
-    hex 'Physical memory start address' CONFIG_MEMORY_START 08000000
-  fi
+      define_hex CONFIG_MEMORY_SIZE 00400000
+      define_bool CONFIG_MEMORY_SET y
+   fi
+fi
+if [ "$CONFIG_SH_ADX" = "y" ]; then
+   define_hex CONFIG_MEMORY_START 08000000
+   define_hex CONFIG_MEMORY_SIZE 00400000
+   define_bool CONFIG_MEMORY_SET y
+fi
+# If none of the above have set memory start/size, ask the user.
+if [ "$CONFIG_MEMORY_SET" != "y" ]; then
+   hex 'Physical memory start address' CONFIG_MEMORY_START 08000000
+   hex 'Physical memory size' CONFIG_MEMORY_SIZE 00400000
 fi
 endmenu
 
+if [ "$CONFIG_SH_HP690" = "y" ]; then
+  define_bool CONFIG_DISCONTIGMEM y
+else
+  define_bool CONFIG_DISCONTIGMEM n
+fi
+
 mainmenu_option next_comment
 comment 'General setup'
 
@@ -120,10 +137,23 @@
 bool 'Networking support' CONFIG_NET
 
 if [ "$CONFIG_SH_GENERIC" = "y" -o "$CONFIG_SH_SOLUTION_ENGINE" = "y" -o \
-     "$CONFIG_SH_UNKNOWN" = "y" -o "$CONFIG_SH_CAT68701" = "y" ]; then
+     "$CONFIG_SH_UNKNOWN" = "y" -o "$CONFIG_SH_CAT68701" = "y" -o \
+     "$CONFIG_SH_ADX" = "y" ]; then
   bool 'Compact Flash Enabler support' CONFIG_CF_ENABLER
 fi
 
+if [ "$CONFIG_CF_ENABLER" = "y" ]; then
+   choice 'Compact Flash Connection Area' \
+	"Area5 CONFIG_CF_AREA5 \
+	 Area6 CONFIG_CF_AREA6" Area6
+   if [ "$CONFIG_CF_AREA5" = "y" ]; then
+      define_hex CONFIG_CF_BASE_ADDR b4000000
+   fi
+   if [ "$CONFIG_CF_AREA6" = "y" ]; then
+      define_hex CONFIG_CF_BASE_ADDR b8000000
+   fi
+fi
+
 bool 'Hitachi HD64461 companion chip support' CONFIG_HD64461
 if [ "$CONFIG_HD64461" = "y" ]; then
    int 'HD64461 IRQ' CONFIG_HD64461_IRQ 36
@@ -136,6 +166,8 @@
    int 'HD64465 IRQ' CONFIG_HD64465_IRQ 5
 fi
 
+bool 'DMA controller (DMAC) support' CONFIG_SH_DMA
+
 bool 'PCI support' CONFIG_PCI
 if [ "$CONFIG_PCI" = "y" ]; then
    choice '  PCI access mode' \
@@ -148,6 +180,7 @@
    if [ "$CONFIG_PCI_GODIRECT" = "y" -o "$CONFIG_PCI_GOANY" = "y" ]; then
       define_bool CONFIG_PCI_DIRECT y
    fi
+   define_bool CONFIG_SH_PCIDMA_NONCOHERENT n
 fi
 
 source drivers/pci/Config.in
@@ -224,13 +257,22 @@
    endmenu
 fi
 
+mainmenu_option next_comment
+comment 'Old CD-ROM drivers (not SCSI, not IDE)'
+
+bool 'Support non-SCSI/IDE/ATAPI CDROM drives' CONFIG_CD_NO_IDESCSI
+if [ "$CONFIG_CD_NO_IDESCSI" != "n" ]; then
+   source drivers/cdrom/Config.in
+fi
+endmenu
+
 #
 # input before char - char/joystick depends on it. As does USB.
 #
 source drivers/input/Config.in
 
 if [ "$CONFIG_SH_DREAMCAST" = "y" ]; then
-source drivers/maple/Config.in
+   source drivers/maple/Config.in
 fi
 
 mainmenu_option next_comment
@@ -259,7 +301,7 @@
      "$CONFIG_SH_BIGSUR" = "y" -o \
      "$CONFIG_SH_7751_SOLUTION_ENGINE" = "y" -o \
      "$CONFIG_SH_SOLUTION_ENGINE" = "y" ]; then
-  bool 'Heartbeat LED' CONFIG_HEARTBEAT
+   bool 'Heartbeat LED' CONFIG_HEARTBEAT
 fi
 
 if [ "$CONFIG_SH_DREAMCAST" = "y" -a "$CONFIG_MAPLE" != "n" ]; then
@@ -322,7 +364,6 @@
 bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ
 bool 'Use LinuxSH standard BIOS' CONFIG_SH_STANDARD_BIOS
 if [ "$CONFIG_SH_STANDARD_BIOS" = "y" ]; then
-   bool 'GDB Stub kernel debug' CONFIG_DEBUG_KERNEL_WITH_GDB_STUB
    bool 'Early printk support' CONFIG_SH_EARLY_PRINTK
 fi
 endmenu
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/Makefile linux/arch/sh/kernel/Makefile
--- v2.4.9/linux/arch/sh/kernel/Makefile	Tue Jul  3 17:08:18 2001
+++ linux/arch/sh/kernel/Makefile	Sat Sep  8 12:29:09 2001
@@ -21,13 +21,14 @@
 obj-$(CONFIG_CF_ENABLER)	+= cf-enabler.o
 obj-$(CONFIG_CPU_SH4)		+= fpu.o
 obj-$(CONFIG_SH_RTC)            += rtc.o
+obj-$(CONFIG_SH_DMA)		+= dma.o
 obj-$(CONFIG_SH_STANDARD_BIOS)	+= sh_bios.o
 
 ifeq ($(CONFIG_PCI),y)
 ifeq ($(CONFIG_SH_DREAMCAST),y)
-obj-y 				+= pci-dc.o
+obj-y 				+= pci-dc.o pcibios.o
 else
-obj-y                           += pci-dma.o 
+obj-y                           += pci-dma.o pcibios.o
 obj-$(CONFIG_CPU_SUBTYPE_ST40STB1)+= pci_st40.o
 obj-$(CONFIG_CPU_SUBTYPE_SH7751)+= pci-sh7751.o 
 obj-$(CONFIG_SH_BIGSUR)+= pci-bigsur.o
@@ -41,8 +42,10 @@
 obj-$(CONFIG_SH_SOLUTION_ENGINE)+= mach_se.o setup_se.o io_se.o led_se.o
 machine-specific-objs		+= mach_se.o setup_se.o io_se.o led_se.o
 
-obj-$(CONFIG_SH_7751_SOLUTION_ENGINE)+= mach_se.o setup_se.o io_se.o led_se.o pci-7751se.o
-machine-specific-objs           += mach_se.o setup_se.o io_se.o led_se.o pci-7751se.o
+obj-$(CONFIG_SH_7751_SOLUTION_ENGINE)+= mach_7751se.o setup_7751se.o \
+					io_7751se.o led_7751se.o
+machine-specific-objs           += mach_7751se.o 7751setup_se.o \
+				   io_7751se.o led_7751se.o pci-7751se.o
 
 obj-$(CONFIG_SH_BIGSUR)		+= mach_bigsur.o setup_bigsur.o io_bigsur.o led_bigsur.o
 machine-specific-objs		+= mach_bigsur.o setup_bigsur.o io_bigsur.o led_bigsur.o
@@ -64,11 +67,14 @@
 
 obj-$(CONFIG_CPU_SUBTYPE_ST40STB1) +=irq_intc2.o
 
+obj-$(CONFIG_SH_ADX)		+= mach_adx.o setup_adx.o io_adx.o irq_maskreg.o
+machine-specific-objs		+= mach_adx.o setup_adx.o io_adx.o irq_maskreg.o
+
 # Doesn't compile well, so don't include in machine-specific-objs
 obj-$(CONFIG_HD64465)		+= setup_hd64465.o io_hd64465.o hd64465_gpio.o
 obj-$(CONFIG_SH_DMIDA)		+= mach_dmida.o
 obj-$(CONFIG_SH_EC3104)         += setup_ec3104.o io_ec3104.o mach_ec3104.o
-obj-$(CONFIG_SH_DREAMCAST)	+= mach_dc.o setup_dc.o io_dc.o
+obj-$(CONFIG_SH_DREAMCAST)	+= mach_dc.o setup_dc.o io_dc.o rtc-aica.o
 
 ifeq ($(CONFIG_SH_GENERIC),y)
 obj-y		+= $(machine-specific-objs)
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/cf-enabler.c linux/arch/sh/kernel/cf-enabler.c
--- v2.4.9/linux/arch/sh/kernel/cf-enabler.c	Wed Apr 11 21:24:52 2001
+++ linux/arch/sh/kernel/cf-enabler.c	Sat Sep  8 12:29:09 2001
@@ -1,9 +1,10 @@
-/* $Id: cf-enabler.c,v 1.2 2000/06/08 05:50:10 gniibe Exp $
+/* $Id: cf-enabler.c,v 1.8 2001/07/18 12:32:21 gniibe Exp $
  *
  *  linux/drivers/block/cf-enabler.c
  *
  *  Copyright (C) 1999  Niibe Yutaka
  *  Copyright (C) 2000  Toshiharu Nozawa
+ *  Copyright (C) 2001  A&D Co., Ltd.
  *
  *  Enable the CF configuration.
  */
@@ -14,7 +15,6 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 
-#define CF_CIS_BASE	0xb8000000
 /*
  * You can connect Compact Flash directly to the bus of SuperH.
  * This is the enabler for that.
@@ -29,15 +29,61 @@
  * 0xB8001000 : Common Memory
  * 0xBA000000 : I/O
  */
+#if defined(CONFIG_IDE) && defined(__SH4__)
+/* SH4 can't access PCMCIA interface through P2 area.
+ * we must remap it with appropreate attribute bit of the page set.
+ * this part is based on Greg Banks' hd64465_ss.c implementation - Masahiro Abe */
+#include <linux/mm.h>
+#include <linux/vmalloc.h>
+
+#if defined(CONFIG_CF_AREA6)
+#define slot_no 0
+#else
+#define slot_no 1
+#endif
+
+/* defined in mm/ioremap.c */
+extern void * p3_ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags);
+
+/* use this pointer to access to directly connected compact flash io area*/
+void *cf_io_base;
+
+static int __init allocate_cf_area(void)
+{
+	pgprot_t prot;
+	unsigned long paddrbase, psize;
+
+	/* open I/O area window */
+	paddrbase = virt_to_phys((void*)CONFIG_CF_BASE_ADDR);
+	psize = PAGE_SIZE;
+	prot = PAGE_KERNEL_PCC(slot_no, _PAGE_PCC_IO16);
+	cf_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
+	if (!cf_io_base) {
+		printk("allocate_cf_area : can't open CF I/O window!\n");
+		return -ENOMEM;
+	}
+/*	printk("p3_ioremap(paddr=0x%08lx, psize=0x%08lx, prot=0x%08lx)=0x%08lx\n",
+	    	paddrbase, psize, prot.pgprot, cf_io_base);*/
+
+	/* XXX : do we need attribute and common-memory area also? */
+
+	return 0;
+}
+#endif
 
 static int __init cf_init_default(void)
 {
-#ifdef CONFIG_IDE
-	/* Enable the card, and set the level interrupt */
-	ctrl_outw(0x0042, CF_CIS_BASE+0x0200);
+/* You must have enabled the card, and set the level interrupt
+ * before reaching this point. Possibly in boot ROM or boot loader.
+ */
+#if defined(CONFIG_IDE) && defined(__SH4__)
+	allocate_cf_area();
 #endif
+#if defined(CONFIG_SH_UNKNOWN)
+	/* This should be done in each board's init_xxx_irq. */
 	make_imask_irq(14);
 	disable_irq(14);
+#endif
 	return 0;
 }
 
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/dma.c linux/arch/sh/kernel/dma.c
--- v2.4.9/linux/arch/sh/kernel/dma.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/sh/kernel/dma.c	Sat Sep  8 12:29:09 2001
@@ -0,0 +1,142 @@
+/*
+ * arch/sh/kernel/dma.c
+ *
+ * Copyright (C) 2000 Takashi YOSHII
+ *
+ * PC like DMA API for SuperH's DMAC.
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+
+#include <asm/signal.h>
+#include <asm/dma.h>
+
+static struct dma_info_t *dma_info[MAX_DMA_CHANNELS];
+static struct dma_info_t *autoinit_info[SH_MAX_DMA_CHANNELS] = {0};
+static spinlock_t  dma_spin_lock;
+
+static unsigned int calc_chcr(struct dma_info_t *info)
+{
+	unsigned int chcr;
+
+	chcr = ( info->mode & DMA_MODE_WRITE )? info->mode_write : info->mode_read;
+	if( info->mode & DMA_AUTOINIT )
+		chcr |= CHCR_IE;
+	return chcr;
+}
+
+static __inline__ int ts_shift(unsigned long chcr)
+{
+	return ((int[]){3,0,1,2,5,0,0,0})[(chcr>>4)&0x000007];
+}
+
+static void dma_tei(int irq, void *dev_id, struct pt_regs *regs)
+{
+	int chan = irq - DMTE_IRQ[0];
+	struct dma_info_t *info = autoinit_info[chan];
+
+	if( info->mode & DMA_MODE_WRITE )
+		ctrl_outl(info->mem_addr, SAR[info->chan]);
+	else
+		ctrl_outl(info->mem_addr, DAR[info->chan]);
+
+	ctrl_outl(info->count>>ts_shift(calc_chcr(info)), DMATCR[info->chan]);
+	ctrl_outl(ctrl_inl(CHCR[info->chan])&~CHCR_TE, CHCR[info->chan]);
+}
+
+static struct irqaction irq_tei = { dma_tei, SA_INTERRUPT, 0, "dma_tei", NULL, NULL};
+
+void setup_dma(unsigned int dmanr, struct dma_info_t *info)
+{
+	make_ipr_irq(DMTE_IRQ[info->chan], DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
+	setup_irq(DMTE_IRQ[info->chan], &irq_tei);
+	dma_info[dmanr] = info;
+}
+
+unsigned long claim_dma_lock(void)
+{
+	unsigned long flags;
+	spin_lock_irqsave(&dma_spin_lock, flags);
+	return flags;
+}
+
+void release_dma_lock(unsigned long flags)
+{
+	spin_unlock_irqrestore(&dma_spin_lock, flags);
+}
+
+void enable_dma(unsigned int dmanr)
+{
+	struct dma_info_t *info = dma_info[dmanr];
+	ctrl_outl(calc_chcr(info)|CHCR_DE, CHCR[info->chan]);
+}
+
+void disable_dma(unsigned int dmanr)
+{
+	struct dma_info_t *info = dma_info[dmanr];
+	ctrl_outl(calc_chcr(info)&~CHCR_DE, CHCR[info->chan]);
+}
+
+void set_dma_mode(unsigned int dmanr, char mode)
+{
+	struct dma_info_t *info = dma_info[dmanr];
+
+	info->mode = mode;
+	set_dma_addr(dmanr, info->mem_addr);
+	set_dma_count(dmanr, info->count);
+	autoinit_info[info->chan] = info;
+}
+
+void set_dma_addr(unsigned int dmanr, unsigned int a)
+{
+	struct dma_info_t *info = dma_info[dmanr];
+	unsigned long sar, dar;
+
+	info->mem_addr = a;
+	sar = (info->mode & DMA_MODE_WRITE)? info->mem_addr: info->dev_addr;
+	dar = (info->mode & DMA_MODE_WRITE)? info->dev_addr: info->mem_addr;
+	ctrl_outl(sar, SAR[info->chan]);
+	ctrl_outl(dar, DAR[info->chan]);
+}
+
+void set_dma_count(unsigned int dmanr, unsigned int count)
+{
+	struct dma_info_t *info = dma_info[dmanr];
+	info->count = count;
+	ctrl_outl(count>>ts_shift(calc_chcr(info)), DMATCR[info->chan]);
+}
+
+int get_dma_residue(unsigned int dmanr)
+{
+	struct dma_info_t *info = dma_info[dmanr];
+	return ctrl_inl(DMATCR[info->chan])<<ts_shift(calc_chcr(info));
+}
+
+#if defined(__SH4__)
+static void dma_err(int irq, void *dev_id, struct pt_regs *regs)
+{
+	printk(KERN_WARNING "DMAE: DMAOR=%lx\n",ctrl_inl(DMAOR));
+	ctrl_outl(ctrl_inl(DMAOR)&~DMAOR_NMIF, DMAOR);
+	ctrl_outl(ctrl_inl(DMAOR)&~DMAOR_AE, DMAOR);
+	ctrl_outl(ctrl_inl(DMAOR)|DMAOR_DME, DMAOR);
+}
+static struct irqaction irq_err = { dma_err, SA_INTERRUPT, 0, "dma_err", NULL, NULL};
+#endif
+
+int __init init_dma(void)
+{
+#if defined(__SH4__)
+	make_ipr_irq(DMAE_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
+	setup_irq(DMAE_IRQ, &irq_err);
+#endif
+
+	ctrl_outl(DMAOR_DME, DMAOR);
+	return 0;
+}
+
+module_init(init_dma);
+
+/**/
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/entry.S linux/arch/sh/kernel/entry.S
--- v2.4.9/linux/arch/sh/kernel/entry.S	Tue Jul  3 17:08:18 2001
+++ linux/arch/sh/kernel/entry.S	Sat Sep  8 12:29:09 2001
@@ -1,4 +1,4 @@
-/* $Id: entry.S,v 1.71 2000/03/22 13:29:33 gniibe Exp $
+/* $Id: entry.S,v 1.71 2001/07/27 11:47:50 gniibe Exp $
  *
  *  linux/arch/sh/entry.S
  *
@@ -220,7 +220,7 @@
 1:	.long	MMU_TEA
 2:	.long   SYMBOL_NAME(do_address_error)
 
-#if defined(CONFIG_DEBUG_KERNEL_WITH_GDB_STUB) || defined(CONFIG_SH_STANDARD_BIOS)
+#if defined(CONFIG_SH_STANDARD_BIOS)
 	.align	2
 	/* Unwind the stack and jmp to the debug entry */
 debug_kernel:
@@ -263,7 +263,7 @@
 
 	.align	2
 debug_trap:	
-#if defined(CONFIG_DEBUG_KERNEL_WITH_GDB_STUB) || defined(CONFIG_SH_STANDARD_BIOS)
+#if defined(CONFIG_SH_STANDARD_BIOS)
 	mov	#OFF_SR, r0
 	mov.l	@(r0,r15), r0		! get status register
 	shll	r0
@@ -293,8 +293,23 @@
 !
 !
 ENTRY(ret_from_fork)
-	bra	SYMBOL_NAME(ret_from_syscall)
-	 add	#4, r15	! pop down bogus r0 (see switch_to MACRO)
+	mov.l	@r15+,r0
+	! Call schedule_tail
+	mov.l	1f, r1
+	jsr @r1
+	 mov	r0, r4
+	! If we're being traced, return via syscall_ret_trace, otherwise
+	! return directly to ret_from_syscall
+	stc	k_current, r0
+	mov.l	@(tsk_ptrace,r0), r0	! Is current PTRACE_SYSCALL'd?
+	mov	#PT_TRACESYS, r1
+	tst	r1, r0
+	bt	ret_from_syscall
+	bra	syscall_ret_trace
+	 nop	 
+
+	.align	2
+1:	.long	SYMBOL_NAME(schedule_tail)
 
 /*
  * Old syscall interface:
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/io_7751se.c linux/arch/sh/kernel/io_7751se.c
--- v2.4.9/linux/arch/sh/kernel/io_7751se.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/sh/kernel/io_7751se.c	Sat Sep  8 12:29:09 2001
@@ -0,0 +1,304 @@
+/* 
+ * linux/arch/sh/kernel/io_7751se.c
+ *
+ * Copyright (C) 2001  Ian da Silva, Jeremy Siegel
+ * Based largely on io_se.c.
+ *
+ * I/O routine for Hitachi 7751 SolutionEngine.
+ *
+ * Initial version only to support LAN access; some
+ * placeholder code from io_se.c left in with the
+ * expectation of later SuperIO and PCMCIA access.
+ */
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <asm/io.h>
+#include <asm/hitachi_7751se.h>
+#include <asm/addrspace.h>
+
+#include <asm/pci.h>
+#include <asm/pci-sh7751.h>
+
+#if 0
+/******************************************************************
+ * Variables from io_se.c, related to PCMCIA (not PCI); we're not
+ * compiling them in, and have removed references from functions
+ * which follow.  [Many checked for IO ports in the range bounded
+ * by sh_pcic_io_start/stop, and used sh_pcic_io_wbase as offset.
+ * As start/stop are uninitialized, only port 0x0 would match?]
+ * When used, remember to adjust names to avoid clash with io_se?
+ *****************************************************************/
+/* SH pcmcia io window base, start and end.  */
+int sh_pcic_io_wbase = 0xb8400000;
+int sh_pcic_io_start;
+int sh_pcic_io_stop;
+int sh_pcic_io_type;
+int sh_pcic_io_dummy;
+/*************************************************************/
+#endif
+
+/*
+ * The 7751 Solution Engine uses the built-in PCI controller (PCIC)
+ * of the 7751 processor, and has a SuperIO accessible via the PCI.
+ * The board also includes a PCMCIA controller on its memory bus,
+ * like the other Solution Engine boards.
+ */ 
+
+#define PCIIOBR		(volatile long *)PCI_REG(SH7751_PCIIOBR)
+#define PCIMBR          (volatile long *)PCI_REG(SH7751_PCIMBR)
+#define PCI_IO_AREA	SH7751_PCI_IO_BASE
+#define PCI_MEM_AREA	SH7751_PCI_CONFIG_BASE
+
+#define PCI_IOMAP(adr)	(PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))
+
+#define maybebadio(name,port) \
+  printk("bad PC-like io %s for port 0x%lx at 0x%08x\n", \
+	 #name, (port), (__u32) __builtin_return_address(0))
+
+static inline void delay(void)
+{
+	ctrl_inw(0xa0000000);
+}
+
+static inline volatile __u16 *
+port2adr(unsigned int port)
+{
+	if (port >= 0x2000)
+		return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
+#if 0
+	else
+		return (volatile __u16 *) (PA_SUPERIO + (port << 1));
+#endif
+	maybebadio(name,port);
+	return (volatile __u16*)port;
+}
+
+#if 0
+/* The 7751 Solution Engine seems to have everything hooked */
+/* up pretty normally (nothing on high-bytes only...) so this */
+/* shouldn't be needed */
+static inline int
+shifted_port(unsigned long port)
+{
+	/* For IDE registers, value is not shifted */
+	if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
+		return 0;
+	else
+		return 1;
+}
+#endif
+
+/* In case someone configures the kernel w/o PCI support: in that */
+/* scenario, don't ever bother to check for PCI-window addresses */
+
+/* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */
+#if defined(CONFIG_PCI)
+#define CHECK_SH7751_PCIIO(port) \
+  ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
+#else
+#define CHECK_SH_7751_PCIIO(port) (0)
+#endif
+
+/*
+ * General outline: remap really low stuff [eventually] to SuperIO,
+ * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
+ * is mapped through the PCI IO window.  Stuff with high bits (PXSEG)
+ * should be way beyond the window, and is used  w/o translation for
+ * compatibility.
+ */
+unsigned char sh7751se_inb(unsigned long port)
+{
+	if (PXSEG(port))
+		return *(volatile unsigned char *)port;
+	else if (CHECK_SH7751_PCIIO(port))
+		return *(volatile unsigned char *)PCI_IOMAP(port);
+	else
+		return (*port2adr(port))&0xff; 
+}
+
+unsigned char sh7751se_inb_p(unsigned long port)
+{
+	unsigned char v;
+
+        if (PXSEG(port))
+                v = *(volatile unsigned char *)port;
+	else if (CHECK_SH7751_PCIIO(port))
+                v = *(volatile unsigned char *)PCI_IOMAP(port);
+	else
+		v = (*port2adr(port))&0xff; 
+	delay();
+	return v;
+}
+
+unsigned short sh7751se_inw(unsigned long port)
+{
+        if (PXSEG(port))
+                return *(volatile unsigned short *)port;
+	else if (CHECK_SH7751_PCIIO(port))
+                return *(volatile unsigned short *)PCI_IOMAP(port);
+	else if (port >= 0x2000)
+		return *port2adr(port);
+	else
+		maybebadio(inw, port);
+	return 0;
+}
+
+unsigned int sh7751se_inl(unsigned long port)
+{
+        if (PXSEG(port))
+                return *(volatile unsigned long *)port;
+	else if (CHECK_SH7751_PCIIO(port))
+                return *(volatile unsigned int *)PCI_IOMAP(port);
+	else if (port >= 0x2000)
+		return *port2adr(port);
+	else
+		maybebadio(inl, port);
+	return 0;
+}
+
+void sh7751se_outb(unsigned char value, unsigned long port)
+{
+
+        if (PXSEG(port))
+                *(volatile unsigned char *)port = value;
+	else if (CHECK_SH7751_PCIIO(port))
+        	*((unsigned char*)PCI_IOMAP(port)) = value;
+	else
+		*(port2adr(port)) = value;
+}
+
+void sh7751se_outb_p(unsigned char value, unsigned long port)
+{
+        if (PXSEG(port))
+                *(volatile unsigned char *)port = value;
+	else if (CHECK_SH7751_PCIIO(port))
+        	*((unsigned char*)PCI_IOMAP(port)) = value;
+	else
+		*(port2adr(port)) = value;
+	delay();
+}
+
+void sh7751se_outw(unsigned short value, unsigned long port)
+{
+        if (PXSEG(port))
+                *(volatile unsigned short *)port = value;
+	else if (CHECK_SH7751_PCIIO(port))
+        	*((unsigned short *)PCI_IOMAP(port)) = value;
+	else if (port >= 0x2000)
+		*port2adr(port) = value;
+	else
+		maybebadio(outw, port);
+}
+
+void sh7751se_outl(unsigned int value, unsigned long port)
+{
+        if (PXSEG(port))
+                *(volatile unsigned long *)port = value;
+	else if (CHECK_SH7751_PCIIO(port))
+        	*((unsigned long*)PCI_IOMAP(port)) = value;
+	else
+		maybebadio(outl, port);
+}
+
+void sh7751se_insb(unsigned long port, void *addr, unsigned long count)
+{
+	unsigned char *p = addr;
+	while (count--) *p++ = sh7751se_inb(port);
+}
+
+void sh7751se_insw(unsigned long port, void *addr, unsigned long count)
+{
+	unsigned short *p = addr;
+	while (count--) *p++ = sh7751se_inw(port);
+}
+
+void sh7751se_insl(unsigned long port, void *addr, unsigned long count)
+{
+	maybebadio(insl, port);
+}
+
+void sh7751se_outsb(unsigned long port, const void *addr, unsigned long count)
+{
+	unsigned char *p = (unsigned char*)addr;
+	while (count--) sh7751se_outb(*p++, port);
+}
+
+void sh7751se_outsw(unsigned long port, const void *addr, unsigned long count)
+{
+	unsigned short *p = (unsigned short*)addr;
+	while (count--) sh7751se_outw(*p++, port);
+}
+
+void sh7751se_outsl(unsigned long port, const void *addr, unsigned long count)
+{
+	maybebadio(outsw, port);
+}
+
+/* For read/write calls, just copy generic (pass-thru); PCIMBR is  */
+/* already set up.  For a larger memory space, these would need to */
+/* reset PCIMBR as needed on a per-call basis...                   */
+
+unsigned char sh7751se_readb(unsigned long addr)
+{
+	return *(volatile unsigned char*)addr;
+}
+
+unsigned short sh7751se_readw(unsigned long addr)
+{
+	return *(volatile unsigned short*)addr;
+}
+
+unsigned int sh7751se_readl(unsigned long addr)
+{
+	return *(volatile unsigned long*)addr;
+}
+
+void sh7751se_writeb(unsigned char b, unsigned long addr)
+{
+	*(volatile unsigned char*)addr = b;
+}
+
+void sh7751se_writew(unsigned short b, unsigned long addr)
+{
+	*(volatile unsigned short*)addr = b;
+}
+
+void sh7751se_writel(unsigned int b, unsigned long addr)
+{
+        *(volatile unsigned long*)addr = b;
+}
+
+
+
+/* Map ISA bus address to the real address. Only for PCMCIA.  */
+
+/* ISA page descriptor.  */
+static __u32 sh_isa_memmap[256];
+
+static int
+sh_isa_mmap(__u32 start, __u32 length, __u32 offset)
+{
+	int idx;
+
+	if (start >= 0x100000 || (start & 0xfff) || (length != 0x1000))
+		return -1;
+
+	idx = start >> 12;
+	sh_isa_memmap[idx] = 0xb8000000 + (offset &~ 0xfff);
+#if 0
+	printk("sh_isa_mmap: start %x len %x offset %x (idx %x paddr %x)\n",
+	       start, length, offset, idx, sh_isa_memmap[idx]);
+#endif
+	return 0;
+}
+
+unsigned long
+sh7751se_isa_port2addr(unsigned long offset)
+{
+	int idx;
+
+	idx = (offset >> 12) & 0xff;
+	offset &= 0xfff;
+	return sh_isa_memmap[idx] + offset;
+}
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/io_adx.c linux/arch/sh/kernel/io_adx.c
--- v2.4.9/linux/arch/sh/kernel/io_adx.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/sh/kernel/io_adx.c	Sat Sep  8 12:29:09 2001
@@ -0,0 +1,192 @@
+/* 
+ * linux/arch/sh/kernel/io_adx.c
+ *
+ * Copyright (C) 2001 A&D Co., Ltd.
+ *
+ * I/O routine and setup routines for A&D ADX Board
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ */
+
+#include <asm/io.h>
+#include <asm/machvec.h>
+#include <linux/module.h>
+
+#define PORT2ADDR(x) (adx_isa_port2addr(x))
+
+static inline void delay(void)
+{
+	ctrl_inw(0xa0000000);
+}
+
+unsigned char adx_inb(unsigned long port)
+{
+	return *(volatile unsigned char*)PORT2ADDR(port);
+}
+
+unsigned short adx_inw(unsigned long port)
+{
+	return *(volatile unsigned short*)PORT2ADDR(port);
+}
+
+unsigned int adx_inl(unsigned long port)
+{
+	return *(volatile unsigned long*)PORT2ADDR(port);
+}
+
+unsigned char adx_inb_p(unsigned long port)
+{
+	unsigned long v = *(volatile unsigned char*)PORT2ADDR(port);
+
+	delay();
+	return v;
+}
+
+unsigned short adx_inw_p(unsigned long port)
+{
+	unsigned long v = *(volatile unsigned short*)PORT2ADDR(port);
+
+	delay();
+	return v;
+}
+
+unsigned int adx_inl_p(unsigned long port)
+{
+	unsigned long v = *(volatile unsigned long*)PORT2ADDR(port);
+
+	delay();
+	return v;
+}
+
+void adx_insb(unsigned long port, void *buffer, unsigned long count)
+{
+	unsigned char *buf = buffer;
+	while(count--) *buf++ = inb(port);
+}
+
+void adx_insw(unsigned long port, void *buffer, unsigned long count)
+{
+	unsigned short *buf = buffer;
+	while(count--) *buf++ = inw(port);
+}
+
+void adx_insl(unsigned long port, void *buffer, unsigned long count)
+{
+	unsigned long *buf = buffer;
+	while(count--) *buf++ = inl(port);
+}
+
+void adx_outb(unsigned char b, unsigned long port)
+{
+	*(volatile unsigned char*)PORT2ADDR(port) = b;
+}
+
+void adx_outw(unsigned short b, unsigned long port)
+{
+	*(volatile unsigned short*)PORT2ADDR(port) = b;
+}
+
+void adx_outl(unsigned int b, unsigned long port)
+{
+	*(volatile unsigned long*)PORT2ADDR(port) = b;
+}
+
+void adx_outb_p(unsigned char b, unsigned long port)
+{
+	*(volatile unsigned char*)PORT2ADDR(port) = b;
+	delay();
+}
+
+void adx_outw_p(unsigned short b, unsigned long port)
+{
+	*(volatile unsigned short*)PORT2ADDR(port) = b;
+	delay();
+}
+
+void adx_outl_p(unsigned int b, unsigned long port)
+{
+	*(volatile unsigned long*)PORT2ADDR(port) = b;
+	delay();
+}
+
+void adx_outsb(unsigned long port, const void *buffer, unsigned long count)
+{
+	const unsigned char *buf = buffer;
+	while(count--) outb(*buf++, port);
+}
+
+void adx_outsw(unsigned long port, const void *buffer, unsigned long count)
+{
+	const unsigned short *buf = buffer;
+	while(count--) outw(*buf++, port);
+}
+
+void adx_outsl(unsigned long port, const void *buffer, unsigned long count)
+{
+	const unsigned long *buf = buffer;
+	while(count--) outl(*buf++, port);
+}
+
+unsigned char adx_readb(unsigned long addr)
+{
+	return *(volatile unsigned char*)addr;
+}
+
+unsigned short adx_readw(unsigned long addr)
+{
+	return *(volatile unsigned short*)addr;
+}
+
+unsigned int adx_readl(unsigned long addr)
+{
+	return *(volatile unsigned long*)addr;
+}
+
+void adx_writeb(unsigned char b, unsigned long addr)
+{
+	*(volatile unsigned char*)addr = b;
+}
+
+void adx_writew(unsigned short b, unsigned long addr)
+{
+	*(volatile unsigned short*)addr = b;
+}
+
+void adx_writel(unsigned int b, unsigned long addr)
+{
+	*(volatile unsigned long*)addr = b;
+}
+
+void *adx_ioremap(unsigned long offset, unsigned long size)
+{
+	return (void *)P2SEGADDR(offset);
+}
+
+EXPORT_SYMBOL (adx_ioremap);
+
+void adx_iounmap(void *addr)
+{
+}
+
+EXPORT_SYMBOL(adx_iounmap);
+
+#include <linux/vmalloc.h>
+extern void *cf_io_base;
+
+unsigned long adx_isa_port2addr(unsigned long offset)
+{
+  /* CompactFlash (IDE) */
+	if (((offset >= 0x1f0) && (offset <= 0x1f7)) || (offset == 0x3f6)) {
+		return (unsigned long)cf_io_base + offset;
+	}
+
+  /* eth0 */
+	if ((offset >= 0x300) && (offset <= 0x30f)) {
+		return 0xa5000000 + offset;	/* COMM BOARD (AREA1) */
+	}
+
+	return offset + 0xb0000000; /* IOBUS (AREA 4)*/
+}
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/irq.c linux/arch/sh/kernel/irq.c
--- v2.4.9/linux/arch/sh/kernel/irq.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/sh/kernel/irq.c	Sat Sep  8 12:29:09 2001
@@ -1,4 +1,4 @@
-/* $Id: irq.c,v 1.12 2000/03/06 14:07:50 gniibe Exp $
+/* $Id: irq.c,v 1.21 2001/07/17 02:26:53 gniibe Exp $
  *
  * linux/arch/sh/kernel/irq.c
  *
@@ -31,7 +31,6 @@
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/bitops.h>
-#include <asm/smp.h>
 #include <asm/pgalloc.h>
 #include <asm/delay.h>
 #include <asm/irq.h>
@@ -399,7 +398,7 @@
 
 		spin_lock_irq(&desc->lock);
 		if (!desc->action)
-		  desc->handler->startup(i);
+			desc->handler->startup(i);
 		spin_unlock_irq(&desc->lock);
 	}
 
@@ -452,7 +451,6 @@
 		}
 		spin_unlock_irq(&desc->lock);
 	}
-	spin_unlock_irq(&desc->lock);
 
 	return val;
 }
@@ -536,7 +534,7 @@
 
 	if (!shared) {
 		desc->depth = 0;
-		desc->status &= ~IRQ_DISABLED;
+		desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT | IRQ_WAITING);
 		desc->handler->startup(irq);
 	}
 	spin_unlock_irqrestore(&desc->lock,flags);
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/irq_imask.c linux/arch/sh/kernel/irq_imask.c
--- v2.4.9/linux/arch/sh/kernel/irq_imask.c	Sun Jan 28 18:56:00 2001
+++ linux/arch/sh/kernel/irq_imask.c	Sat Sep  8 12:29:09 2001
@@ -1,4 +1,4 @@
-/* $Id: irq_imask.c,v 1.6 2000/03/06 14:11:32 gniibe Exp $
+/* $Id: irq_imask.c,v 1.13 2001/07/12 08:13:56 gniibe Exp $
  *
  * linux/arch/sh/kernel/irq_imask.c
  *
@@ -99,7 +99,8 @@
 
 static void end_imask_irq(unsigned int irq)
 {
-	enable_imask_irq(irq);
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_imask_irq(irq);
 }
 
 static void shutdown_imask_irq(unsigned int irq)
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/irq_intc2.c linux/arch/sh/kernel/irq_intc2.c
--- v2.4.9/linux/arch/sh/kernel/irq_intc2.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/sh/kernel/irq_intc2.c	Sat Sep  8 12:29:09 2001
@@ -92,7 +92,8 @@
 
 static void end_intc2_irq(unsigned int irq)
 {
-	enable_intc2_irq(irq);
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_intc2_irq(irq);
 }
 
 void make_intc2_irq(unsigned int irq, unsigned int addr, 
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/irq_ipr.c linux/arch/sh/kernel/irq_ipr.c
--- v2.4.9/linux/arch/sh/kernel/irq_ipr.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/sh/kernel/irq_ipr.c	Sat Sep  8 12:29:09 2001
@@ -1,4 +1,4 @@
-/* $Id: irq_ipr.c,v 1.6 2000/05/14 08:41:25 gniibe Exp $
+/* $Id: irq_ipr.c,v 1.20 2001/07/15 23:26:56 gniibe Exp $
  *
  * linux/arch/sh/kernel/irq_ipr.c
  *
@@ -102,7 +102,8 @@
 
 static void end_ipr_irq(unsigned int irq)
 {
-	enable_ipr_irq(irq);
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_ipr_irq(irq);
 }
 
 void make_ipr_irq(unsigned int irq, unsigned int addr, int pos, int priority)
@@ -176,7 +177,8 @@
 
 static void end_pint_irq(unsigned int irq)
 {
-	enable_pint_irq(irq);
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_pint_irq(irq);
 }
 
 void make_pint_irq(unsigned int irq)
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/irq_maskreg.c linux/arch/sh/kernel/irq_maskreg.c
--- v2.4.9/linux/arch/sh/kernel/irq_maskreg.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/sh/kernel/irq_maskreg.c	Sat Sep  8 12:29:09 2001
@@ -0,0 +1,107 @@
+/*
+ * linux/arch/sh/kernel/irq_maskreg.c
+ *
+ * Copyright (C) 2001 A&D Co., Ltd. <http://www.aandd.co.jp>
+ *
+ * This file may be copied or modified under the terms of the GNU
+ * General Public License.  See linux/COPYING for more information.
+ *
+ * Interrupt handling for Simple external interrupt mask register
+ *
+ * This is for the machine which have single 16 bit register
+ * for masking external IRQ individually.
+ * Each bit of the register is for masking each interrupt.  
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+
+#include <asm/system.h>
+#include <asm/io.h>
+#include <asm/machvec.h>
+
+/* address of external interrupt mask register
+ * address must be set prior to use these (maybe in init_XXX_irq())
+ * XXX : is it better to use .config than specifying it in code? */
+unsigned short *irq_mask_register = 0;
+
+/* forward declaration */
+static unsigned int startup_maskreg_irq(unsigned int irq);
+static void shutdown_maskreg_irq(unsigned int irq);
+static void enable_maskreg_irq(unsigned int irq);
+static void disable_maskreg_irq(unsigned int irq);
+static void mask_and_ack_maskreg(unsigned int);
+static void end_maskreg_irq(unsigned int irq);
+
+/* hw_interrupt_type */
+static struct hw_interrupt_type maskreg_irq_type = {
+	" Mask Register",
+	startup_maskreg_irq,
+	shutdown_maskreg_irq,
+	enable_maskreg_irq,
+	disable_maskreg_irq,
+	mask_and_ack_maskreg,
+	end_maskreg_irq
+};
+
+/* actual implementatin */
+static unsigned int startup_maskreg_irq(unsigned int irq)
+{ 
+	enable_maskreg_irq(irq);
+	return 0; /* never anything pending */
+}
+
+static void shutdown_maskreg_irq(unsigned int irq)
+{
+	disable_maskreg_irq(irq);
+}
+
+static void disable_maskreg_irq(unsigned int irq)
+{
+	if (irq_mask_register) {
+		unsigned long flags;
+		unsigned short val, mask = 0x01 << irq;
+
+		/* Set "irq"th bit */
+		save_and_cli(flags);
+		val = ctrl_inw((unsigned long)irq_mask_register);
+		val |= mask;
+		ctrl_outw(val, (unsigned long)irq_mask_register);
+		restore_flags(flags);
+	}
+}
+
+static void enable_maskreg_irq(unsigned int irq)
+{
+	if (irq_mask_register) {
+		unsigned long flags;
+		unsigned short val, mask = ~(0x01 << irq);
+
+		/* Clear "irq"th bit */
+		save_and_cli(flags);
+		val = ctrl_inw((unsigned long)irq_mask_register);
+		val &= mask;
+		ctrl_outw(val, (unsigned long)irq_mask_register);
+		restore_flags(flags);
+	}
+}
+
+static void mask_and_ack_maskreg(unsigned int irq)
+{
+	disable_maskreg_irq(irq);
+}
+
+static void end_maskreg_irq(unsigned int irq)
+{
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_maskreg_irq(irq);
+}
+
+void make_maskreg_irq(unsigned int irq)
+{
+	disable_irq_nosync(irq);
+	irq_desc[irq].handler = &maskreg_irq_type;
+	disable_maskreg_irq(irq);
+}
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/led_7751se.c linux/arch/sh/kernel/led_7751se.c
--- v2.4.9/linux/arch/sh/kernel/led_7751se.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/sh/kernel/led_7751se.c	Sat Sep  8 12:29:09 2001
@@ -0,0 +1,68 @@
+/*
+ * linux/arch/sh/kernel/led_se.c
+ *
+ * Copyright (C) 2000 Stuart Menefy <stuart.menefy@st.com>
+ *
+ * May be copied or modified under the terms of the GNU General Public
+ * License.  See linux/COPYING for more information.
+ *
+ * This file contains Solution Engine specific LED code.
+ */
+
+#include <linux/config.h>
+#include <asm/hitachi_7751se.h>
+
+static void mach_led(int position, int value)
+{
+	volatile unsigned short* p = (volatile unsigned short*)PA_LED;
+
+	if (value) {
+		*p |= (1<<8);
+	} else {
+		*p &= ~(1<<8);
+	}
+}
+
+#ifdef CONFIG_HEARTBEAT
+
+#include <linux/sched.h>
+
+/* Cycle the LED's in the clasic Knightrider/Sun pattern */
+void heartbeat_7751se(void)
+{
+	static unsigned int cnt = 0, period = 0;
+	volatile unsigned short* p = (volatile unsigned short*)PA_LED;
+	static unsigned bit = 0, up = 1;
+
+	cnt += 1;
+	if (cnt < period) {
+		return;
+	}
+
+	cnt = 0;
+
+	/* Go through the points (roughly!):
+	 * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
+	 */
+	period = 110 - ( (300<<FSHIFT)/
+			 ((avenrun[0]/5) + (3<<FSHIFT)) );
+
+	if (up) {
+		if (bit == 7) {
+			bit--;
+			up=0;
+		} else {
+			bit ++;
+		}
+	} else {
+		if (bit == 0) {
+			bit++;
+			up=1;
+		} else {
+			bit--;
+		}
+	}
+	*p = 1<<(bit+8);
+
+}
+#endif /* CONFIG_HEARTBEAT */
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/led_se.c linux/arch/sh/kernel/led_se.c
--- v2.4.9/linux/arch/sh/kernel/led_se.c	Wed Aug  9 13:59:04 2000
+++ linux/arch/sh/kernel/led_se.c	Sat Sep  8 12:29:09 2001
@@ -10,10 +10,11 @@
  */
 
 #include <linux/config.h>
+#include <asm/hitachi_se.h>
 
 static void mach_led(int position, int value)
 {
-	volatile unsigned short* p = (volatile unsigned short*)0xb0c00000;
+	volatile unsigned short* p = (volatile unsigned short*)PA_LED;
 
 	if (value) {
 		*p |= (1<<8);
@@ -30,7 +31,7 @@
 void heartbeat_se(void)
 {
 	static unsigned int cnt = 0, period = 0;
-	volatile unsigned short* p = (volatile unsigned short*)0xb0c00000;
+	volatile unsigned short* p = (volatile unsigned short*)PA_LED;
 	static unsigned bit = 0, up = 1;
 
 	cnt += 1;
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/mach_7751se.c linux/arch/sh/kernel/mach_7751se.c
--- v2.4.9/linux/arch/sh/kernel/mach_7751se.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/sh/kernel/mach_7751se.c	Sat Sep  8 12:29:09 2001
@@ -0,0 +1,78 @@
+/*
+ * linux/arch/sh/kernel/mach_7751se.c
+ *
+ * Minor tweak of mach_se.c file to reference 7751se-specific items.
+ *
+ * May be copied or modified under the terms of the GNU General Public
+ * License.  See linux/COPYING for more information.
+ *
+ * Machine vector for the Hitachi 7751 SolutionEngine
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+
+#include <asm/machvec.h>
+#include <asm/rtc.h>
+#include <asm/machvec_init.h>
+
+#include <asm/io_7751se.h>
+
+void heartbeat_7751se(void);
+void setup_7751se(void);
+void init_7751se_IRQ(void);
+
+/*
+ * The Machine Vector
+ */
+
+struct sh_machine_vector mv_7751se __initmv = {
+	mv_name:		"7751 SolutionEngine",
+
+	mv_nr_irqs:		72,
+
+	mv_inb:			sh7751se_inb,
+	mv_inw:			sh7751se_inw,
+	mv_inl:			sh7751se_inl,
+	mv_outb:		sh7751se_outb,
+	mv_outw:		sh7751se_outw,
+	mv_outl:		sh7751se_outl,
+
+	mv_inb_p:		sh7751se_inb_p,
+	mv_inw_p:		sh7751se_inw,
+	mv_inl_p:		sh7751se_inl,
+	mv_outb_p:		sh7751se_outb_p,
+	mv_outw_p:		sh7751se_outw,
+	mv_outl_p:		sh7751se_outl,
+
+	mv_insb:		sh7751se_insb,
+	mv_insw:		sh7751se_insw,
+	mv_insl:		sh7751se_insl,
+	mv_outsb:		sh7751se_outsb,
+	mv_outsw:		sh7751se_outsw,
+	mv_outsl:		sh7751se_outsl,
+
+	mv_readb:		sh7751se_readb,
+	mv_readw:		sh7751se_readw,
+	mv_readl:		sh7751se_readl,
+	mv_writeb:		sh7751se_writeb,
+	mv_writew:		sh7751se_writew,
+	mv_writel:		sh7751se_writel,
+
+	mv_ioremap:		generic_ioremap,
+	mv_iounmap:		generic_iounmap,
+
+	mv_isa_port2addr:	sh7751se_isa_port2addr,
+
+	mv_init_arch:		setup_7751se,
+	mv_init_irq:		init_7751se_IRQ,
+#ifdef CONFIG_HEARTBEAT
+	mv_heartbeat:		heartbeat_7751se,
+#endif
+
+	mv_rtc_gettimeofday:	sh_rtc_gettimeofday,
+	mv_rtc_settimeofday:	sh_rtc_settimeofday,
+
+	mv_hw_7751se:		1,
+};
+ALIAS_MV(7751se)
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/mach_adx.c linux/arch/sh/kernel/mach_adx.c
--- v2.4.9/linux/arch/sh/kernel/mach_adx.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/sh/kernel/mach_adx.c	Sat Sep  8 12:29:09 2001
@@ -0,0 +1,73 @@
+/*
+ * linux/arch/sh/kernel/mach_adx.c
+ *
+ * Copyright (C) 2001 A&D Co., Ltd.
+ *
+ * This file may be copied or modified under the terms of the GNU
+ * General Public License.  See linux/COPYING for more information.
+ *
+ * Machine vector for the A&D ADX Board
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+
+#include <asm/machvec.h>
+#include <asm/rtc.h>
+#include <asm/machvec_init.h>
+#include <asm/io_adx.h>
+
+extern void setup_adx(void);
+extern void init_adx_IRQ(void);
+
+/*
+ * The Machine Vector
+ */
+
+struct sh_machine_vector mv_adx __initmv = {
+	mv_name:		"A&D_ADX",
+
+	mv_nr_irqs:		48,
+
+	mv_inb:			adx_inb,
+	mv_inw:			adx_inw,
+	mv_inl:			adx_inl,
+	mv_outb:		adx_outb,
+	mv_outw:		adx_outw,
+	mv_outl:		adx_outl,
+
+	mv_inb_p:		adx_inb_p,
+	mv_inw_p:		adx_inw,
+	mv_inl_p:		adx_inl,
+	mv_outb_p:		adx_outb_p,
+	mv_outw_p:		adx_outw,
+	mv_outl_p:		adx_outl,
+
+	mv_insb:		adx_insb,
+	mv_insw:		adx_insw,
+	mv_insl:		adx_insl,
+	mv_outsb:		adx_outsb,
+	mv_outsw:		adx_outsw,
+	mv_outsl:		adx_outsl,
+
+	mv_readb:		adx_readb,
+	mv_readw:		adx_readw,
+	mv_readl:		adx_readl,
+	mv_writeb:		adx_writeb,
+	mv_writew:		adx_writew,
+	mv_writel:		adx_writel,
+
+	mv_ioremap:		adx_ioremap,
+	mv_iounmap:		adx_iounmap,
+
+	mv_isa_port2addr:	adx_isa_port2addr,
+
+	mv_init_arch:		setup_adx,
+	mv_init_irq:		init_adx_IRQ,
+
+	mv_rtc_gettimeofday:	sh_rtc_gettimeofday,
+	mv_rtc_settimeofday:	sh_rtc_settimeofday,
+
+	mv_hw_adx:		1,
+};
+ALIAS_MV(adx)
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/mach_dc.c linux/arch/sh/kernel/mach_dc.c
--- v2.4.9/linux/arch/sh/kernel/mach_dc.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/sh/kernel/mach_dc.c	Sat Sep  8 12:29:09 2001
@@ -1,10 +1,11 @@
 /*
- *	$Id: mach_dc.c,v 1.4 2001/05/24 05:09:16 mrbrown Exp $
+ *	$Id: mach_dc.c,v 1.5 2001/09/01 14:34:31 mrbrown Exp $
  *	SEGA Dreamcast machine vector
  */
 
 #include <linux/config.h>
 #include <linux/init.h>
+#include <linux/time.h>
 
 #include <asm/machvec.h>
 #include <asm/machvec_init.h>
@@ -16,6 +17,10 @@
 void __init setup_dreamcast(void);
 void __init dreamcast_pcibios_init(void);
 
+/* Custom Dreamcast RTC routines */
+void aica_rtc_gettimeofday(struct timeval *tv);
+int aica_rtc_settimeofday(const struct timeval *tv);
+
 /*
  * The Machine Vector
  */
@@ -59,6 +64,9 @@
 	mv_init_arch:		setup_dreamcast,
 	mv_isa_port2addr:	dreamcast_isa_port2addr,
 	mv_irq_demux:		systemasic_irq_demux,
+
+	mv_rtc_gettimeofday:	aica_rtc_gettimeofday,
+	mv_rtc_settimeofday:	aica_rtc_settimeofday,
 
 	mv_hw_dreamcast:	1,
 };
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/mach_hp600.c linux/arch/sh/kernel/mach_hp600.c
--- v2.4.9/linux/arch/sh/kernel/mach_hp600.c	Wed Apr 11 21:24:52 2001
+++ linux/arch/sh/kernel/mach_hp600.c	Sat Sep  8 12:29:09 2001
@@ -15,8 +15,8 @@
 #include <asm/rtc.h>
 #include <asm/machvec_init.h>
 
-#include <asm/io_hd64461.h>
-#include <asm/io_generic.h>
+#include <asm/io.h>
+#include <asm/hd64461.h>
 #include <asm/irq.h>
 
 /*
@@ -26,7 +26,7 @@
 struct sh_machine_vector mv_hp620 __initmv = {
 	mv_name:		"hp620",
 
-	mv_nr_irqs:		80, /* HD64461_IRQBASE+16, see hd64461.h */
+	mv_nr_irqs:		HD64461_IRQBASE+HD64461_IRQ_NUM,
 
 	mv_inb:			hd64461_inb,
 	mv_inw:			hd64461_inw,
@@ -71,7 +71,7 @@
 struct sh_machine_vector mv_hp680 __initmv = {
 	mv_name:		"hp680",
 
-	mv_nr_irqs:		80, /* HD64461_IRQBASE+16, see hd64461.h */
+	mv_nr_irqs:		HD64461_IRQBASE+HD64461_IRQ_NUM,
 
 	mv_inb:			hd64461_inb,
 	mv_inw:			hd64461_inw,
@@ -116,7 +116,7 @@
 struct sh_machine_vector mv_hp690 __initmv = {
 	mv_name:		"hp690",
 
-	mv_nr_irqs:		80, /* HD64461_IRQBASE+16, see hd64461.h */
+	mv_nr_irqs:		HD64461_IRQBASE+HD64461_IRQ_NUM,
 
 	mv_inb:			hd64461_inb,
 	mv_inw:			hd64461_inw,
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/pci-7751se.c linux/arch/sh/kernel/pci-7751se.c
--- v2.4.9/linux/arch/sh/kernel/pci-7751se.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/sh/kernel/pci-7751se.c	Sat Sep  8 12:29:09 2001
@@ -41,13 +41,13 @@
    unsigned long bcr1, wcr1, wcr2, wcr3, mcr;
    unsigned short bcr2;
 
-   //
-   // Initialize the slave bus controller on the pcic.  The values used
-   // here should not be hardcoded, but they should be taken from the bsc
-   // on the processor, to make this function as generic as possible.
-   // (i.e. Another sbc may usr different SDRAM timing settings -- in order
-   // for the pcic to work, its settings need to be exactly the same.)
-   //
+   /*
+    * Initialize the slave bus controller on the pcic.  The values used
+    * here should not be hardcoded, but they should be taken from the bsc
+    * on the processor, to make this function as generic as possible.
+    * (i.e. Another sbc may usr different SDRAM timing settings -- in order
+    * for the pcic to work, its settings need to be exactly the same.)
+    */
    bcr1 = (*(volatile unsigned long*)(SH7751_BCR1));
    bcr2 = (*(volatile unsigned short*)(SH7751_BCR2));
    wcr1 = (*(volatile unsigned long*)(SH7751_WCR1));
@@ -67,21 +67,47 @@
    mcr = (mcr & PCIMCR_MRSET_OFF) & PCIMCR_RFSH_OFF;
    PCIC_WRITE(SH7751_PCIMCR, mcr);      /* PCIC MCR */
 
+
+   /* Enable all interrupts, so we know what to fix */
    PCIC_WRITE(SH7751_PCIINTM, 0x0000c3ff);
-   PCIC_WRITE(SH7751_PCIAINTM, 0x0000980f);
-   PCIC_WRITE(SH7751_PCICONF1, 0xF39000C7);  /* FB9000C7 */
-   PCIC_WRITE(SH7751_PCICONF2, 0x00000000);  /* PCI Class code & Revision ID */
-   PCIC_WRITE(SH7751_PCICONF4, 0xab000001);  /* PCI I/O */
-   PCIC_WRITE(SH7751_PCICONF5, 0x0c000000);  /* PCI MEM0 old val: 0xb0000000 */
-   PCIC_WRITE(SH7751_PCICONF6, 0xd0000000);  /* PCI MEM1 */
-   PCIC_WRITE(SH7751_PCICONF11, 0x35051054); /* PCI Sub system ID & Sub system vendor ID */
-   PCIC_WRITE(SH7751_PCILSR0, 0x03f00000);   /* PCI MEM0 */
-   PCIC_WRITE(SH7751_PCILSR1, 0x00000000);   /* PCI MEM1 */
-   PCIC_WRITE(SH7751_PCILAR0, 0x0c000000);   /* MEM0 */
-   PCIC_WRITE(SH7751_PCILAR1, 0x00000000);   /* MEM1 */
+   PCIC_WRITE(SH7751_PCIAINTM, 0x0000380f);
+
+   /* Set up standard PCI config registers */
+   PCIC_WRITE(SH7751_PCICONF1, 	0xF39000C7); /* Bus Master, Mem & I/O access */
+   PCIC_WRITE(SH7751_PCICONF2, 	0x00000000); /* PCI Class code & Revision ID */
+   PCIC_WRITE(SH7751_PCICONF4, 	0xab000001); /* PCI I/O address (local regs) */
+   PCIC_WRITE(SH7751_PCICONF5, 	0x0c000000); /* PCI MEM address (local RAM)  */
+   PCIC_WRITE(SH7751_PCICONF6, 	0xd0000000); /* PCI MEM address (unused)     */
+   PCIC_WRITE(SH7751_PCICONF11, 0x35051054); /* PCI Subsystem ID & Vendor ID */
+   PCIC_WRITE(SH7751_PCILSR0, 0x03f00000);   /* MEM (full 64M exposed)       */
+   PCIC_WRITE(SH7751_PCILSR1, 0x00000000);   /* MEM (unused)                 */
+   PCIC_WRITE(SH7751_PCILAR0, 0x0c000000);   /* MEM (direct map from PCI)    */
+   PCIC_WRITE(SH7751_PCILAR1, 0x00000000);   /* MEM (unused)                 */
 
+   /* Now turn it on... */
    PCIC_WRITE(SH7751_PCICR, 0xa5000001);
 
+   /*
+    * Set PCIMBR and PCIIOBR here, assuming a single window
+    * (16M MEM, 256K IO) is enough.  If a larger space is
+    * needed, the readx/writex and inx/outx functions will
+    * have to do more (e.g. setting registers for each call).
+    */
+
+   /*
+    * Set the MBR so PCI address is one-to-one with window,
+    * meaning all calls go straight through... use ifdef to
+    * catch erroneous assumption.
+    */
+#if PCIBIOS_MIN_MEM != SH7751_PCI_MEMORY_BASE
+#error One-to-one assumption for PCI memory mapping is wrong!?!?!?
+#endif   
+   PCIC_WRITE(SH7751_PCIMBR, PCIBIOS_MIN_MEM);
+
+   /* Set IOBR for window containing area specified in pci.h */
+   PCIC_WRITE(SH7751_PCIIOBR, (PCIBIOS_MIN_IO & SH7751_PCIIOBR_MASK));
+
+   /* All done, may as well say so... */
    printk("SH7751 PCI: Finished initialization of the PCI controller\n");
 
    return 1;
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/pci-dc.c linux/arch/sh/kernel/pci-dc.c
--- v2.4.9/linux/arch/sh/kernel/pci-dc.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/sh/kernel/pci-dc.c	Sat Sep  8 12:29:09 2001
@@ -1,5 +1,5 @@
 /*
- $	$Id: pci-dc.c,v 1.2 2001/05/24 05:09:16 mrbrown Exp $
+ $	$Id: pci-dc.c,v 1.5 2001/08/24 12:38:19 dwmw2 Exp $
  *	Dreamcast PCI: Supports SEGA Broadband Adaptor only.
  */
 
@@ -104,62 +104,6 @@
 };
 
 
-void pcibios_align_resource(void *data, struct resource *res,
-			    unsigned long size)
-{
-}
-
-
-void __init pcibios_update_irq(struct pci_dev *dev, int irq)
-{
-}
-
-
-void __init pcibios_update_resource(struct pci_dev *dev, struct resource *root,
-			     struct resource *res, int resource)
-{
-}
-
-
-void pcibios_set_master(struct pci_dev *dev)
-{
-	/* No special bus mastering setup handling */
-}
-
-
-int pcibios_enable_device(struct pci_dev *dev)
-{
-
-	u16 cmd, old_cmd;
-	int idx;
-	struct resource *r;
-
-	pci_read_config_word(dev, PCI_COMMAND, &cmd);
-	old_cmd = cmd;
-	for (idx = 0; idx < 6; idx++) {
-		r = dev->resource + idx;
-		if (!r->start && r->end) {
-			printk(KERN_ERR
-			       "PCI: Device %s not available because"
-			       " of resource collisions\n",
-			       dev->slot_name);
-			return -EINVAL;
-		}
-		if (r->flags & IORESOURCE_IO)
-			cmd |= PCI_COMMAND_IO;
-		if (r->flags & IORESOURCE_MEM)
-			cmd |= PCI_COMMAND_MEMORY;
-	}
-	if (cmd != old_cmd) {
-		printk("PCI: enabling device %s (%04x -> %04x)\n",
-		       dev->slot_name, old_cmd, cmd);
-		pci_write_config_word(dev, PCI_COMMAND, cmd);
-	}
-	return 0;
-
-}
-
-
 void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
 			   dma_addr_t * dma_handle)
 {
@@ -172,7 +116,7 @@
 
 	gapspci_dma_used = PAGE_ALIGN(gapspci_dma_used+size);
 	
-	printk("pci_alloc_consistent: %ld bytes at 0x%p\n", size, buf);
+	printk("pci_alloc_consistent: %ld bytes at 0x%lx\n", (long)size, buf);
 
 	*dma_handle = (dma_addr_t)buf;
 
@@ -184,6 +128,7 @@
 			 void *vaddr, dma_addr_t dma_handle)
 {
 	/* XXX */
+	gapspci_dma_used = 0;
 }
 
 
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/pci-dma.c linux/arch/sh/kernel/pci-dma.c
--- v2.4.9/linux/arch/sh/kernel/pci-dma.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/sh/kernel/pci-dma.c	Sat Sep  8 12:29:09 2001
@@ -29,7 +29,7 @@
 		*dma_handle = virt_to_bus(ret);
 	}
 	/* We must flush the cache before we pass it on to the device */
-	flush_cache_all();
+	dma_cache_wback_inv(ret, size);
 	return  P2SEGADDR(ret);
 }
 
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/pci-sh7751.c linux/arch/sh/kernel/pci-sh7751.c
--- v2.4.9/linux/arch/sh/kernel/pci-sh7751.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/sh/kernel/pci-sh7751.c	Sat Sep  8 12:29:09 2001
@@ -20,7 +20,6 @@
 #include <linux/errno.h>
 #include <linux/irq.h>
 
-#include <asm/segment.h>
 #include <asm/machvec.h>
 #include <asm/io.h>
 #include <asm/pci-sh7751.h>
@@ -57,10 +56,10 @@
     /* PCIPDR may only be accessed as 32 bit words, 
      * so we must do byte alignment by hand 
      */
-	__save_and_cli(flags);
+	save_and_cli(flags);
 	outl(CONFIG_CMD(dev,where), PCI_REG(SH7751_PCIPAR));
 	word = inl(PCI_REG(SH7751_PCIPDR));
-	__restore_flags(flags);
+	restore_flags(flags);
 	switch (where & 0x3) {
 	    case 3:
 		    *value = (u8)(word >> 24);
@@ -88,10 +87,10 @@
     /* PCIPDR may only be accessed as 32 bit words, 
      * so we must do word alignment by hand 
      */
-	__save_and_cli(flags);
+	save_and_cli(flags);
 	outl(CONFIG_CMD(dev,where), PCI_REG(SH7751_PCIPAR));
 	word = inl(PCI_REG(SH7751_PCIPDR));
-	__restore_flags(flags);
+	restore_flags(flags);
 	switch (where & 0x3) {
 	    case 3:
 		    // This should never happen...
@@ -116,10 +115,10 @@
 {
 	unsigned long flags;
 	
-	__save_and_cli(flags);
+	save_and_cli(flags);
 	outl(CONFIG_CMD(dev,where), PCI_REG(SH7751_PCIPAR));
 	*value = inl(PCI_REG(SH7751_PCIPDR));
-	__restore_flags(flags);
+	restore_flags(flags);
 	PCIDBG(4,"pci_conf1_read_config_dword@0x%08x=0x%x\n",
 	     CONFIG_CMD(dev,where),*value);
 	return PCIBIOS_SUCCESSFUL;    
@@ -135,14 +134,14 @@
     /* Since SH7751 only does 32bit access we'll have to do a
      * read,mask,write operation
      */ 
-	__save_and_cli(flags);
+	save_and_cli(flags);
 	outl(CONFIG_CMD(dev,where), PCI_REG(SH7751_PCIPAR));
 	word = inl(PCI_REG(SH7751_PCIPDR)) ;
 	word &= ~mask;
 	word |= value << shift;
  
 	outl(word, PCI_REG(SH7751_PCIPDR));
-	__restore_flags(flags);
+	restore_flags(flags);
 	PCIDBG(4,"pci_conf1_write_config_byte@0x%08x=0x%x\n",
 	     CONFIG_CMD(dev,where),word);
 	return PCIBIOS_SUCCESSFUL;
@@ -161,14 +160,14 @@
      */ 
 	if (shift == 24)
 	    return PCIBIOS_BAD_REGISTER_NUMBER;
-	__save_and_cli(flags);
+	save_and_cli(flags);
 	outl(CONFIG_CMD(dev,where), PCI_REG(SH7751_PCIPAR));
 	word = inl(PCI_REG(SH7751_PCIPDR)) ;
 	word &= ~mask;
 	word |= value << shift;
  
 	outl(value, PCI_REG(SH7751_PCIPDR));
-	__restore_flags(flags);
+	restore_flags(flags);
 	PCIDBG(4,"pci_conf1_write_config_word@0x%08x=0x%x\n",
 	     CONFIG_CMD(dev,where),word);
 	return PCIBIOS_SUCCESSFUL;
@@ -178,10 +177,10 @@
 {
 	unsigned long flags;
 
-	__save_and_cli(flags);
+	save_and_cli(flags);
 	outl(CONFIG_CMD(dev,where), PCI_REG(SH7751_PCIPAR));
 	outl(value, PCI_REG(SH7751_PCIPDR));
-	__restore_flags(flags);
+	restore_flags(flags);
 	PCIDBG(4,"pci_conf1_write_config_dword@0x%08x=0x%x\n",
 	     CONFIG_CMD(dev,where),value);
 	return PCIBIOS_SUCCESSFUL;
@@ -233,7 +232,7 @@
  * BIOS32 and PCI BIOS handling.
  * 
  * The BIOS version of the pci functions is not yet implemented but it is left
- * in for completeness.  Currently an error will be genereated at compile time. 
+ * in for completeness.  Currently an error will be generated at compile time. 
  */
  
 #ifdef CONFIG_PCI_BIOS
@@ -417,54 +416,6 @@
 	return str;
 }
 
-void
-pcibios_update_resource(struct pci_dev *dev, struct resource *root,
-			struct resource *res, int resource)
-{
-	u32 new, check;
-	int reg;
-
-	new = res->start | (res->flags & PCI_REGION_FLAG_MASK);
-	if (resource < 6) {
-		reg = PCI_BASE_ADDRESS_0 + 4*resource;
-	} else if (resource == PCI_ROM_RESOURCE) {
-		res->flags |= PCI_ROM_ADDRESS_ENABLE;
-		new |= PCI_ROM_ADDRESS_ENABLE;
-		reg = dev->rom_base_reg;
-	} else {
-		/* Somebody might have asked allocation of a non-standard resource */
-		return;
-	}
-	
-	pci_write_config_dword(dev, reg, new);
-	pci_read_config_dword(dev, reg, &check);
-	if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) {
-		printk(KERN_ERR "PCI: Error while updating region "
-		       "%s/%d (%08x != %08x)\n", dev->slot_name, resource,
-		       new, check);
-	}
-}
-
-/*
- * We need to avoid collisions with `mirrored' VGA ports
- * and other strange ISA hardware, so we always want the
- * addresses to be allocated in the 0x000-0x0ff region
- * modulo 0x400.
- */
-void
-pcibios_align_resource(void *data, struct resource *res, unsigned long size)
-{
-	if (res->flags & IORESOURCE_IO) {
-		unsigned long start = res->start;
-
-		if (start & 0x300) {
-			start = (start + 0x3ff) & ~0x3ff;
-			res->start = start;
-		}
-	}
-}
-
-
 /*
  *    Allocate the bridge and device resources
  */
@@ -593,53 +544,6 @@
 	pcibios_assign_resources();
 }
 
-int pcibios_enable_device(struct pci_dev *dev)
-{
-	u16 cmd, old_cmd;
-	int idx;
-	struct resource *r;
-
-	pci_read_config_word(dev, PCI_COMMAND, &cmd);
-	old_cmd = cmd;
-	for(idx=0; idx<6; idx++) {
-		r = &dev->resource[idx];
-		if (!r->start && r->end) {
-			printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", dev->slot_name);
-			return -EINVAL;
-		}
-		if (r->flags & IORESOURCE_IO)
-			cmd |= PCI_COMMAND_IO;
-		if (r->flags & IORESOURCE_MEM)
-			cmd |= PCI_COMMAND_MEMORY;
-	}
-	if (dev->resource[PCI_ROM_RESOURCE].start)
-		cmd |= PCI_COMMAND_MEMORY;
-	if (cmd != old_cmd) {
-		printk(KERN_INFO "PCI: Enabling device %s (%04x -> %04x)\n", dev->name, old_cmd, cmd);
-		pci_write_config_word(dev, PCI_COMMAND, cmd);
-	}
-	return 0;
-}
-
-/*
- *  If we set up a device for bus mastering, we need to check and set
- *  the latency timer as it may not be properly set.
- */
-unsigned int pcibios_max_latency = 255;
-
-void pcibios_set_master(struct pci_dev *dev)
-{
-	u8 lat;
-	pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
-	if (lat < 16)
-		lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
-	else if (lat > pcibios_max_latency)
-		lat = pcibios_max_latency;
-	else
-		return;
-	printk(KERN_INFO "PCI: Setting latency timer of device %s to %d\n", dev->name, lat);
-	pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
-}
 
 /***************************************************************************************/
 /* 
@@ -665,10 +569,4 @@
 	PCIDBG(2,"Setting IRQ for slot %s to %d\n", dev->slot_name, irq);
 
 	return irq;
-}
-
-void __init pcibios_update_irq(struct pci_dev *dev, int irq)
-{
-	PCIDBG(3,"PCI: Update IRQ for %s on irq %d\n", dev->name, irq);
-	pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
 }
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/pci_st40.c linux/arch/sh/kernel/pci_st40.c
--- v2.4.9/linux/arch/sh/kernel/pci_st40.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/sh/kernel/pci_st40.c	Sat Sep  8 12:29:09 2001
@@ -458,91 +458,6 @@
 
 }
 
-int pcibios_enable_device(struct pci_dev *dev)
-{
-
-	u16 cmd, old_cmd;
-	int idx;
-	struct resource *r;
-
-	pci_read_config_word(dev, PCI_COMMAND, &cmd);
-	old_cmd = cmd;
-	for (idx = 0; idx < 6; idx++) {
-		r = dev->resource + idx;
-		if (!r->start && r->end) {
-			printk(KERN_ERR
-			       "PCI: Device %s not available because"
-			       " of resource collisions\n",
-			       dev->slot_name);
-			return -EINVAL;
-		}
-		if (r->flags & IORESOURCE_IO)
-			cmd |= PCI_COMMAND_IO;
-		if (r->flags & IORESOURCE_MEM)
-			cmd |= PCI_COMMAND_MEMORY;
-	}
-	if (cmd != old_cmd) {
-		printk("PCI: enabling device %s (%04x -> %04x)\n",
-		       dev->slot_name, old_cmd, cmd);
-		pci_write_config_word(dev, PCI_COMMAND, cmd);
-	}
-	return 0;
-
-}
-
 void __init pcibios_fixup_bus(struct pci_bus *bus)
 {
-}
-
-void pcibios_align_resource(void *data, struct resource *res,
-			    unsigned long size)
-{
-}
-
-void __init pcibios_update_resource(struct pci_dev *dev,
-				    struct resource *root,
-				    struct resource *res, int resource)
-{
-
-	unsigned long where, size;
-	u32 reg;
-
-	printk("PCI: Assigning %3s %08lx to %s\n",
-	       res->flags & IORESOURCE_IO ? "IO" : "MEM",
-	       res->start, dev->name);
-
-	where = PCI_BASE_ADDRESS_0 + resource * 4;
-	size = res->end - res->start;
-
-	pci_read_config_dword(dev, where, &reg);
-	reg = (reg & size) | (((u32) (res->start - root->start)) & ~size);
-	pci_write_config_dword(dev, where, reg);
-
-}
-
-
-void __init pcibios_update_irq(struct pci_dev *dev, int irq)
-{
-	printk("PCI: Assigning IRQ %02d to %s\n", irq, dev->name);
-	pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
-}
-
-/*
- *  If we set up a device for bus mastering, we need to check the latency
- *  timer as certain crappy BIOSes forget to set it properly.
- */
-unsigned int pcibios_max_latency = 255;
-
-void pcibios_set_master(struct pci_dev *dev)
-{
-	u8 lat;
-	pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
-	if (lat < 16)
-		lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
-	else if (lat > pcibios_max_latency)
-		lat = pcibios_max_latency;
-	else
-		return;
-	printk("PCI: Setting latency timer of device %s to %d\n", dev->slot_name, lat);
-	pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
 }
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/pcibios.c linux/arch/sh/kernel/pcibios.c
--- v2.4.9/linux/arch/sh/kernel/pcibios.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/sh/kernel/pcibios.c	Sat Sep  8 12:29:09 2001
@@ -0,0 +1,126 @@
+/*
+ * $Id: pcibios.c,v 1.1 2001/08/24 12:38:19 dwmw2 Exp $
+ *
+ * arch/sh/kernel/pcibios.c
+ *
+ * This is GPL'd.
+ *
+ * Provided here are generic versions of:
+ *	pcibios_update_resource()
+ *	pcibios_align_resource()
+ *	pcibios_enable_device()
+ *	pcibios_set_master()
+ *	pcibios_update_irq()
+ *
+ * These functions are collected here to reduce duplication of common
+ * code amongst the many platform-specific PCI support code files.
+ *
+ * Platform-specific files are expected to provide:
+ *	pcibios_fixup_bus()
+ *	pcibios_init()
+ *	pcibios_setup()
+ *	pcibios_fixup_pbus_ranges()
+ */
+
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+
+void
+pcibios_update_resource(struct pci_dev *dev, struct resource *root,
+			struct resource *res, int resource)
+{
+	u32 new, check;
+	int reg;
+
+	new = res->start | (res->flags & PCI_REGION_FLAG_MASK);
+	if (resource < 6) {
+		reg = PCI_BASE_ADDRESS_0 + 4*resource;
+	} else if (resource == PCI_ROM_RESOURCE) {
+		res->flags |= PCI_ROM_ADDRESS_ENABLE;
+		new |= PCI_ROM_ADDRESS_ENABLE;
+		reg = dev->rom_base_reg;
+	} else {
+		/* Somebody might have asked allocation of a non-standard resource */
+		return;
+	}
+	
+	pci_write_config_dword(dev, reg, new);
+	pci_read_config_dword(dev, reg, &check);
+	if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) {
+		printk(KERN_ERR "PCI: Error while updating region "
+		       "%s/%d (%08x != %08x)\n", dev->slot_name, resource,
+		       new, check);
+	}
+}
+
+/*
+ * We need to avoid collisions with `mirrored' VGA ports
+ * and other strange ISA hardware, so we always want the
+ * addresses to be allocated in the 0x000-0x0ff region
+ * modulo 0x400.
+ */
+void pcibios_align_resource(void *data, struct resource *res, unsigned long size)
+{
+	if (res->flags & IORESOURCE_IO) {
+		unsigned long start = res->start;
+
+		if (start & 0x300) {
+			start = (start + 0x3ff) & ~0x3ff;
+			res->start = start;
+		}
+	}
+}
+
+int pcibios_enable_device(struct pci_dev *dev)
+{
+	u16 cmd, old_cmd;
+	int idx;
+	struct resource *r;
+
+	pci_read_config_word(dev, PCI_COMMAND, &cmd);
+	old_cmd = cmd;
+	for(idx=0; idx<6; idx++) {
+		r = &dev->resource[idx];
+		if (!r->start && r->end) {
+			printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", dev->slot_name);
+			return -EINVAL;
+		}
+		if (r->flags & IORESOURCE_IO)
+			cmd |= PCI_COMMAND_IO;
+		if (r->flags & IORESOURCE_MEM)
+			cmd |= PCI_COMMAND_MEMORY;
+	}
+	if (dev->resource[PCI_ROM_RESOURCE].start)
+		cmd |= PCI_COMMAND_MEMORY;
+	if (cmd != old_cmd) {
+		printk(KERN_INFO "PCI: Enabling device %s (%04x -> %04x)\n", dev->name, old_cmd, cmd);
+		pci_write_config_word(dev, PCI_COMMAND, cmd);
+	}
+	return 0;
+}
+
+/*
+ *  If we set up a device for bus mastering, we need to check and set
+ *  the latency timer as it may not be properly set.
+ */
+unsigned int pcibios_max_latency = 255;
+
+void pcibios_set_master(struct pci_dev *dev)
+{
+	u8 lat;
+	pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
+	if (lat < 16)
+		lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
+	else if (lat > pcibios_max_latency)
+		lat = pcibios_max_latency;
+	else
+		return;
+	printk(KERN_INFO "PCI: Setting latency timer of device %s to %d\n", dev->name, lat);
+	pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
+}
+
+void __init pcibios_update_irq(struct pci_dev *dev, int irq)
+{
+	pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
+}
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/process.c linux/arch/sh/kernel/process.c
--- v2.4.9/linux/arch/sh/kernel/process.c	Wed Apr 11 21:24:52 2001
+++ linux/arch/sh/kernel/process.c	Sat Sep  8 12:29:09 2001
@@ -1,4 +1,4 @@
-/* $Id: process.c,v 1.33 2000/03/25 00:06:15 gniibe Exp $
+/* $Id: process.c,v 1.34 2001/07/30 12:42:11 gniibe Exp $
  *
  *  linux/arch/sh/kernel/process.c
  *
@@ -11,40 +11,13 @@
  * This file handles the architecture-dependent parts of process handling..
  */
 
-#define __KERNEL_SYSCALLS__
-#include <stdarg.h>
-
-#include <linux/config.h>
-
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/smp.h>
-#include <linux/smp_lock.h>
-#include <linux/stddef.h>
-#include <linux/ptrace.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/user.h>
-#include <linux/a.out.h>
-#include <linux/interrupt.h>
 #include <linux/unistd.h>
-#include <linux/delay.h>
-#include <linux/reboot.h>
-#include <linux/init.h>
-#include <linux/irq.h>
+#include <linux/slab.h>
 
-#include <asm/uaccess.h>
-#include <asm/pgtable.h>
-#include <asm/system.h>
 #include <asm/io.h>
-#include <asm/processor.h>
+#include <asm/uaccess.h>
 #include <asm/mmu_context.h>
 #include <asm/elf.h>
-#ifdef CONFIG_SH_STANDARD_BIOS
-#include <asm/sh_bios.h>
-#endif
 
 static int hlt_counter=0;
 
@@ -71,11 +44,17 @@
 	current->counter = -100;
 
 	while (1) {
-		while (!current->need_resched) {
-			if (hlt_counter)
-				continue;
+		if (hlt_counter) {
+			if (current->need_resched)
+				break;
+		} else {
+			__cli();
+			while (!current->need_resched) {
+				__sti();
+				asm volatile("sleep" : : : "memory");
+				__cli();
+			}
 			__sti();
-			asm volatile("sleep" : : : "memory");
 		}
 		schedule();
 		check_pgt_cache();
@@ -84,16 +63,15 @@
 
 void machine_restart(char * __unused)
 {
-#ifdef CONFIG_SH_STANDARD_BIOS
-	sh_bios_shutdown(1);
-#endif
+	/* SR.BL=1 and invoke address error to let CPU reset (manual reset) */
+	asm volatile("ldc %0, sr\n\t"
+		     "mov.l @%1, %0" : : "r" (0x10000000), "r" (0x80000001));
 }
 
 void machine_halt(void)
 {
-#ifdef CONFIG_SH_STANDARD_BIOS
-	sh_bios_shutdown(0);
-#endif
+	while (1)
+		asm volatile("sleep" : : : "memory");
 }
 
 void machine_power_off(void)
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/ptrace.c linux/arch/sh/kernel/ptrace.c
--- v2.4.9/linux/arch/sh/kernel/ptrace.c	Wed Jul 25 17:10:19 2001
+++ linux/arch/sh/kernel/ptrace.c	Sat Sep  8 12:29:09 2001
@@ -1,4 +1,4 @@
-/* $Id: ptrace.c,v 1.6 2000/06/08 23:44:50 gniibe Exp $
+/* $Id: ptrace.c,v 1.12 2001/07/23 00:00:56 gniibe Exp $
  *
  * linux/arch/sh/kernel/ptrace.c
  *
@@ -122,24 +122,29 @@
 {
 	ctrl_outl(nextpc1, UBC_BARA);
 	ctrl_outb(asid, UBC_BASRA);
-#if defined(CONFIG_CPU_SUBTYPE_SH7709)
-	ctrl_outl(0x0fff, UBC_BAMRA);
-#else
-	ctrl_outb(BAMR_12, UBC_BAMRA);
-#endif
-	ctrl_outw(BBR_INST | BBR_READ, UBC_BBRA);
+	if(UBC_TYPE_SH7729){
+		ctrl_outl(0x0fff, UBC_BAMRA);
+		ctrl_outw(BBR_INST | BBR_READ | BBR_CPU, UBC_BBRA);
+	}else{
+		ctrl_outb(BAMR_12, UBC_BAMRA);
+		ctrl_outw(BBR_INST | BBR_READ, UBC_BBRA);
+	}
 
 	if (nextpc2 != (unsigned long) -1) {
 		ctrl_outl(nextpc2, UBC_BARB);
 		ctrl_outb(asid, UBC_BASRB);
-#if defined(CONFIG_CPU_SUBTYPE_SH7709)
-		ctrl_outl(0x0fff, UBC_BAMRA);
-#else
-		ctrl_outb(BAMR_12, UBC_BAMRB);
-#endif
-		ctrl_outw(BBR_INST | BBR_READ, UBC_BBRB);
-	}
-	ctrl_outw(BRCR_PCBA | BRCR_PCBB, UBC_BRCR);
+		if(UBC_TYPE_SH7729){
+			ctrl_outl(0x0fff, UBC_BAMRB);
+			ctrl_outw(BBR_INST | BBR_READ | BBR_CPU, UBC_BBRB);
+		}else{
+			ctrl_outb(BAMR_12, UBC_BAMRB);
+			ctrl_outw(BBR_INST | BBR_READ, UBC_BBRB);
+		}
+	}
+	if(UBC_TYPE_SH7729)
+		ctrl_outl(BRCR_PCBA | BRCR_PCBB | BRCR_PCTE, UBC_BRCR);
+	else
+		ctrl_outw(BRCR_PCBA | BRCR_PCBB, UBC_BRCR);
 }
 
 asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/rtc-aica.c linux/arch/sh/kernel/rtc-aica.c
--- v2.4.9/linux/arch/sh/kernel/rtc-aica.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/sh/kernel/rtc-aica.c	Sat Sep  8 12:29:09 2001
@@ -0,0 +1,70 @@
+/* arch/sh/kernel/rtc-aica.c
+ *
+ * Dreamcast AICA RTC routines.
+ *
+ * Copyright (c) 2001 M. R. Brown <mrbrown@0xd6.org>
+ *
+ * Released under the terms of the GNU GPL v2.0.
+ *
+ */
+
+#include <linux/time.h>
+
+#include <asm/io.h>
+
+/* The AICA RTC has an Epoch of 1/1/1950, so we must subtract 20 years (in
+   seconds to get the standard Unix Epoch when getting the time, and add 20
+   years when setting the time. */
+#define TWENTY_YEARS ((20 * 365LU + 5) * 86400)
+
+/* The AICA RTC is represented by a 32-bit seconds counter stored in 2 16-bit
+   registers.*/
+#define AICA_RTC_SECS_H		0xa0710000
+#define AICA_RTC_SECS_L		0xa0710004
+
+/**
+ * aica_rtc_gettimeofday - Get the time from the AICA RTC
+ * @tv: pointer to resulting timeval
+ *
+ * Grabs the current RTC seconds counter and adjusts it to the Unix Epoch.
+ */
+void aica_rtc_gettimeofday(struct timeval *tv) {
+	unsigned long val1, val2;
+
+	do {
+		val1 = ((ctrl_inl(AICA_RTC_SECS_H) & 0xffff) << 16) |
+			(ctrl_inl(AICA_RTC_SECS_L) & 0xffff);
+
+		val2 = ((ctrl_inl(AICA_RTC_SECS_H) & 0xffff) << 16) |
+			(ctrl_inl(AICA_RTC_SECS_L) & 0xffff);
+	} while (val1 != val2);
+
+	tv->tv_sec = val1 - TWENTY_YEARS;
+
+	/* Can't get microseconds with just a seconds counter. */
+	tv->tv_usec = 0;
+}
+
+/**
+ * aica_rtc_settimeofday - Set the AICA RTC to the current time
+ * @tv: contains the timeval to set
+ *
+ * Adjusts the given @tv to the AICA Epoch and sets the RTC seconds counter.
+ */
+int aica_rtc_settimeofday(const struct timeval *tv) {
+	unsigned long val1, val2;
+	unsigned long secs = tv->tv_sec + TWENTY_YEARS;
+
+	do {
+		ctrl_outl((secs & 0xffff0000) >> 16, AICA_RTC_SECS_H);
+		ctrl_outl((secs & 0xffff), AICA_RTC_SECS_L);
+
+		val1 = ((ctrl_inl(AICA_RTC_SECS_H) & 0xffff) << 16) |
+			(ctrl_inl(AICA_RTC_SECS_L) & 0xffff);
+
+		val2 = ((ctrl_inl(AICA_RTC_SECS_H) & 0xffff) << 16) |
+			(ctrl_inl(AICA_RTC_SECS_L) & 0xffff);
+	} while (val1 != val2);
+
+	return 0;
+}
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/setup.c linux/arch/sh/kernel/setup.c
--- v2.4.9/linux/arch/sh/kernel/setup.c	Tue Jul  3 17:08:18 2001
+++ linux/arch/sh/kernel/setup.c	Sat Sep  8 12:29:09 2001
@@ -1,4 +1,4 @@
-/* $Id: setup.c,v 1.20 2000/03/05 02:44:41 gniibe Exp $
+/* $Id: setup.c,v 1.31 2001/08/23 16:36:40 dwmw2 Exp $
  *
  *  linux/arch/sh/kernel/setup.c
  *
@@ -38,7 +38,6 @@
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/io_generic.h>
-#include <asm/smp.h>
 #include <asm/machvec.h>
 #ifdef CONFIG_SH_EARLY_PRINTK
 #include <asm/sh_bios.h>
@@ -48,7 +47,12 @@
  * Machine setup..
  */
 
-struct sh_cpuinfo boot_cpu_data = { CPU_SH_NONE, 0, 0, 0, };
+/*
+ * Initialize loops_per_jiffy as 10000000 (1000MIPS).
+ * This value will be used at the very early stage of serial setup.
+ * The bigger value means no problem.
+ */
+struct sh_cpuinfo boot_cpu_data = { CPU_SH_NONE, 0, 10000000, };
 struct screen_info screen_info;
 unsigned char aux_device_present = 0xaa;
 
@@ -209,8 +213,7 @@
 	saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
 
 	memory_start = (unsigned long)PAGE_OFFSET+__MEMORY_START;
-	/* Default is 4Mbyte. */
-	memory_end = (unsigned long)PAGE_OFFSET+0x00400000+__MEMORY_START;
+	memory_end = memory_start + __MEMORY_SIZE;
 
 	for (;;) {
 		/*
@@ -268,7 +271,9 @@
 
 void __init setup_arch(char **cmdline_p)
 {
+#if defined(CONFIG_SH_GENERIC) || defined(CONFIG_SH_UNKNOWN)
 	extern struct sh_machine_vector mv_unknown;
+#endif
 	struct sh_machine_vector *mv = NULL;
 	char mv_name[MV_NAME_SIZE] = "";
 	unsigned long mv_io_base = 0;
@@ -356,6 +361,18 @@
 #define PFN_DOWN(x)	((x) >> PAGE_SHIFT)
 #define PFN_PHYS(x)	((x) << PAGE_SHIFT)
 
+#ifdef CONFIG_DISCONTIGMEM
+	NODE_DATA(0)->bdata = &discontig_node_bdata[0];
+	NODE_DATA(1)->bdata = &discontig_node_bdata[1];
+
+	bootmap_size = init_bootmem_node(NODE_DATA(1), 
+					 PFN_UP(__MEMORY_START_2ND),
+					 PFN_UP(__MEMORY_START_2ND),
+					 PFN_DOWN(__MEMORY_START_2ND+__MEMORY_SIZE_2ND));
+	free_bootmem_node(NODE_DATA(1), __MEMORY_START_2ND, __MEMORY_SIZE_2ND);
+	reserve_bootmem_node(NODE_DATA(1), __MEMORY_START_2ND, bootmap_size);
+#endif
+
 	/*
 	 * Find the highest page frame number we have available
 	 */
@@ -377,7 +394,7 @@
 	 * is intact) must be done via bootmem_alloc().
 	 */
 	bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
-					 __MEMORY_START>>PAGE_SHIFT, 
+					 __MEMORY_START>>PAGE_SHIFT,
 					 max_low_pfn);
 
 	/*
@@ -399,7 +416,8 @@
 			last_pfn = max_low_pfn;
 
 		pages = last_pfn - curr_pfn;
-		free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(pages));
+		free_bootmem_node(NODE_DATA(0), PFN_PHYS(curr_pfn),
+				  PFN_PHYS(pages));
 	}
 
 	/*
@@ -409,19 +427,19 @@
 	 * case of us accidentally initializing the bootmem allocator with
 	 * an invalid RAM area.
 	 */
-	reserve_bootmem(__MEMORY_START+PAGE_SIZE, (PFN_PHYS(start_pfn) + 
-			bootmap_size + PAGE_SIZE-1) - __MEMORY_START);
+	reserve_bootmem_node(NODE_DATA(0), __MEMORY_START+PAGE_SIZE,
+		(PFN_PHYS(start_pfn)+bootmap_size+PAGE_SIZE-1)-__MEMORY_START);
 
 	/*
 	 * reserve physical page 0 - it's a special BIOS page on many boxes,
 	 * enabling clean reboots, SMP operation, laptop functions.
 	 */
-	reserve_bootmem(__MEMORY_START, PAGE_SIZE);
+	reserve_bootmem_node(NODE_DATA(0), __MEMORY_START, PAGE_SIZE);
 
 #ifdef CONFIG_BLK_DEV_INITRD
 	if (LOADER_TYPE && INITRD_START) {
 		if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
-			reserve_bootmem(INITRD_START+__MEMORY_START, INITRD_SIZE);
+			reserve_bootmem_node(NODE_DATA(0), INITRD_START+__MEMORY_START, INITRD_SIZE);
 			initrd_start =
 				INITRD_START ? INITRD_START + PAGE_OFFSET + __MEMORY_START : 0;
 			initrd_end = initrd_start + INITRD_SIZE;
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/setup_7751se.c linux/arch/sh/kernel/setup_7751se.c
--- v2.4.9/linux/arch/sh/kernel/setup_7751se.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/sh/kernel/setup_7751se.c	Sat Sep  8 12:29:09 2001
@@ -0,0 +1,136 @@
+/* 
+ * linux/arch/sh/kernel/setup_7751se.c
+ *
+ * Copyright (C) 2000  Kazumoto Kojima
+ *
+ * Hitachi SolutionEngine Support.
+ *
+ * Modified for 7751 Solution Engine by
+ * Ian da Silva and Jeremy Siegel, 2001.
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+
+#include <linux/hdreg.h>
+#include <linux/ide.h>
+#include <asm/io.h>
+#include <asm/hitachi_7751se.h>
+
+/*
+ * Configure the Super I/O chip
+ */
+#if 0
+/* Leftover code from regular Solution Engine, for reference. */
+/* The SH7751 Solution Engine has a different SuperIO. */
+static void __init smsc_config(int index, int data)
+{
+	outb_p(index, INDEX_PORT);
+	outb_p(data, DATA_PORT);
+}
+
+static void __init init_smsc(void)
+{
+	outb_p(CONFIG_ENTER, CONFIG_PORT);
+	outb_p(CONFIG_ENTER, CONFIG_PORT);
+
+	/* FDC */
+	smsc_config(CURRENT_LDN_INDEX, LDN_FDC);
+	smsc_config(ACTIVATE_INDEX, 0x01);
+	smsc_config(IRQ_SELECT_INDEX, 6); /* IRQ6 */
+
+	/* IDE1 */
+	smsc_config(CURRENT_LDN_INDEX, LDN_IDE1);
+	smsc_config(ACTIVATE_INDEX, 0x01);
+	smsc_config(IRQ_SELECT_INDEX, 14); /* IRQ14 */
+
+	/* AUXIO (GPIO): to use IDE1 */
+	smsc_config(CURRENT_LDN_INDEX, LDN_AUXIO);
+	smsc_config(GPIO46_INDEX, 0x00); /* nIOROP */
+	smsc_config(GPIO47_INDEX, 0x00); /* nIOWOP */
+
+	/* COM1 */
+	smsc_config(CURRENT_LDN_INDEX, LDN_COM1);
+	smsc_config(ACTIVATE_INDEX, 0x01);
+	smsc_config(IO_BASE_HI_INDEX, 0x03);
+	smsc_config(IO_BASE_LO_INDEX, 0xf8);
+	smsc_config(IRQ_SELECT_INDEX, 4); /* IRQ4 */
+
+	/* COM2 */
+	smsc_config(CURRENT_LDN_INDEX, LDN_COM2);
+	smsc_config(ACTIVATE_INDEX, 0x01);
+	smsc_config(IO_BASE_HI_INDEX, 0x02);
+	smsc_config(IO_BASE_LO_INDEX, 0xf8);
+	smsc_config(IRQ_SELECT_INDEX, 3); /* IRQ3 */
+
+	/* RTC */
+	smsc_config(CURRENT_LDN_INDEX, LDN_RTC);
+	smsc_config(ACTIVATE_INDEX, 0x01);
+	smsc_config(IRQ_SELECT_INDEX, 8); /* IRQ8 */
+
+	/* XXX: PARPORT, KBD, and MOUSE will come here... */
+	outb_p(CONFIG_EXIT, CONFIG_PORT);
+}
+#endif
+
+/*
+ * Initialize IRQ setting
+ */
+void __init init_7751se_IRQ(void)
+{
+
+  /* Leave old Solution Engine code in for reference. */
+#if defined(CONFIG_SH_SOLUTION_ENGINE)
+	/*
+	 * Super I/O (Just mimic PC):
+	 *  1: keyboard
+	 *  3: serial 0
+	 *  4: serial 1
+	 *  5: printer
+	 *  6: floppy
+	 *  8: rtc
+	 * 12: mouse
+	 * 14: ide0
+	 */
+	make_ipr_irq(14, BCR_ILCRA, 2, 0x0f-14);
+	make_ipr_irq(12, BCR_ILCRA, 1, 0x0f-12); 
+	make_ipr_irq( 8, BCR_ILCRB, 1, 0x0f- 8); 
+	make_ipr_irq( 6, BCR_ILCRC, 3, 0x0f- 6);
+	make_ipr_irq( 5, BCR_ILCRC, 2, 0x0f- 5);
+	make_ipr_irq( 4, BCR_ILCRC, 1, 0x0f- 4);
+	make_ipr_irq( 3, BCR_ILCRC, 0, 0x0f- 3);
+	make_ipr_irq( 1, BCR_ILCRD, 3, 0x0f- 1);
+
+	make_ipr_irq(10, BCR_ILCRD, 1, 0x0f-10); /* LAN */
+
+	make_ipr_irq( 0, BCR_ILCRE, 3, 0x0f- 0); /* PCIRQ3 */
+	make_ipr_irq(11, BCR_ILCRE, 2, 0x0f-11); /* PCIRQ2 */
+	make_ipr_irq( 9, BCR_ILCRE, 1, 0x0f- 9); /* PCIRQ1 */
+	make_ipr_irq( 7, BCR_ILCRE, 0, 0x0f- 7); /* PCIRQ0 */
+
+	/* #2, #13 are allocated for SLOT IRQ #1 and #2 (for now) */
+	/* NOTE: #2 and #13 are not used on PC */
+	make_ipr_irq(13, BCR_ILCRG, 1, 0x0f-13); /* SLOTIRQ2 */
+	make_ipr_irq( 2, BCR_ILCRG, 0, 0x0f- 2); /* SLOTIRQ1 */
+
+#elif defined(CONFIG_SH_7751_SOLUTION_ENGINE)
+
+	make_ipr_irq(13, BCR_ILCRD, 3, 2);
+
+	/* Add additional calls to make_ipr_irq() as drivers are added
+	 * and tested.
+	 */
+#endif
+
+}
+
+
+/*
+ * Initialize the board
+ */
+void __init setup_7751se(void)
+{
+	/* Call init_smsc() replacement to set up SuperIO. */
+	/* XXX: RTC setting comes here */
+}
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/setup_adx.c linux/arch/sh/kernel/setup_adx.c
--- v2.4.9/linux/arch/sh/kernel/setup_adx.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/sh/kernel/setup_adx.c	Sat Sep  8 12:29:09 2001
@@ -0,0 +1,40 @@
+/* 
+ * linux/arch/sh/kernel/setup_adx.c
+ *
+ * Copyright (C) 2001 A&D Co., Ltd.
+ *
+ * I/O routine and setup routines for A&D ADX Board
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ */
+
+#include <asm/io.h>
+#include <asm/machvec.h>
+#include <asm/irq.h>
+#include <linux/module.h>
+
+void setup_adx(void)
+{
+	/* nothing to do just yet */
+/*	printk("setup_adx()\n");*/
+}
+
+void init_adx_IRQ(void)
+{
+	int i;
+
+/*	printk("init_adx_IRQ()\n");*/
+	/* setup irq_mask_register */
+	irq_mask_register = (unsigned short *)0xa6000008;
+
+	/* cover all external interrupt area by maskreg_irq_type
+	 * (Actually, irq15 doesn't exist)
+	 */
+	for (i = 0; i < 16; i++) {
+		make_maskreg_irq(i);
+		disable_irq(i);
+	}
+}
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/setup_bigsur.c linux/arch/sh/kernel/setup_bigsur.c
--- v2.4.9/linux/arch/sh/kernel/setup_bigsur.c	Tue Jul  3 17:08:19 2001
+++ linux/arch/sh/kernel/setup_bigsur.c	Sat Sep  8 12:29:09 2001
@@ -181,10 +181,12 @@
 static void end_bigsur_irq(unsigned int irq)
 {
    	DPRINTK("end_bigsur_irq IRQ %d\n", irq);
-	if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH)	
-		enable_bigsur_l1irq(irq);
-	else
-		enable_bigsur_l2irq(irq);
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) {
+		if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH)	
+			enable_bigsur_l1irq(irq);
+		else
+			enable_bigsur_l2irq(irq);
+	}
 }
 
 static unsigned int startup_bigsur_irq(unsigned int irq)
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/setup_cqreek.c linux/arch/sh/kernel/setup_cqreek.c
--- v2.4.9/linux/arch/sh/kernel/setup_cqreek.c	Wed Apr 11 21:24:52 2001
+++ linux/arch/sh/kernel/setup_cqreek.c	Sat Sep  8 12:29:09 2001
@@ -1,4 +1,4 @@
-/* $Id: setup_cqreek.c,v 1.6 2001/02/14 09:36:42 gniibe Exp $
+/* $Id: setup_cqreek.c,v 1.9 2001/07/30 12:43:28 gniibe Exp $
  *
  * arch/sh/kernel/setup_cqreek.c
  *
@@ -85,15 +85,16 @@
 	unsigned short stat_port = cqreek_irq_data[irq].stat_port;
 	unsigned short bit = cqreek_irq_data[irq].bit;
 
-	inw(stat_port);
 	disable_cqreek_irq(irq);
 	/* Clear IRQ (it might be edge IRQ) */
+	inw(stat_port);
 	outw_p(bit, stat_port);
 }
 
 static void end_cqreek_irq(unsigned int irq)
 {
-	enable_cqreek_irq(irq);
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_cqreek_irq(irq);
 }
 
 static unsigned int startup_cqreek_irq(unsigned int irq)
@@ -156,16 +157,9 @@
  */
 void __init setup_cqreek(void)
 {
-	extern void disable_hlt(void);
 	int i;
 /* udelay is not available at setup time yet... */
 #define DELAY() do {for (i=0; i<10000; i++) ctrl_inw(0xa0000000);} while(0)
-
-	/*
-	 * XXX: I don't know the reason, but it becomes so fragile with
-	 * "sleep", so we need to stop sleeping.
-	 */
-	disable_hlt();
 
 	if ((inw (BRIDGE_FEATURE) & 1)) { /* We have IDE interface */
 		outw_p(0, BRIDGE_IDE_INTR_LVL);
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/setup_dc.c linux/arch/sh/kernel/setup_dc.c
--- v2.4.9/linux/arch/sh/kernel/setup_dc.c	Tue Jul  3 17:08:19 2001
+++ linux/arch/sh/kernel/setup_dc.c	Sat Sep  8 12:29:09 2001
@@ -8,8 +8,8 @@
  *
  * Released under the terms of the GNU GPL v2.0.
  * 
- * This file originally bore the message:
- *	$Id: setup_dc.c,v 1.5 2001/05/24 05:09:16 mrbrown Exp $
+ * This file originally bore the message (with enclosed-$):
+ *	Id: setup_dc.c,v 1.5 2001/05/24 05:09:16 mrbrown Exp
  *	SEGA Dreamcast support
  */
 
@@ -70,21 +70,29 @@
 /* Disable the hardware event by masking its bit in its EMR */
 static inline void disable_systemasic_irq(unsigned int irq)
 {
+	unsigned long flags;
 	__u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2);
 	__u32 mask;
+
+	save_and_cli(flags);
 	mask = inl(emr);
 	mask &= ~(1 << EVENT_BIT(irq));
 	outl(mask, emr);
+	restore_flags(flags);
 }
 
 /* Enable the hardware event by setting its bit in its EMR */
 static inline void enable_systemasic_irq(unsigned int irq)
 {
+	unsigned long flags;
 	__u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2);
 	__u32 mask;
+
+	save_and_cli(flags);
 	mask = inl(emr);
 	mask |= (1 << EVENT_BIT(irq));
 	outl(mask, emr);
+	restore_flags(flags);
 }
 
 /* Acknowledge a hardware event by writing its bit back to its ESR */
@@ -98,7 +106,8 @@
 /* After a IRQ has been ack'd and responded to, it needs to be renabled */
 static void end_systemasic_irq(unsigned int irq)
 {
-	enable_systemasic_irq(irq);
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_systemasic_irq(irq);
 }
 
 static unsigned int startup_systemasic_irq(unsigned int irq)
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/setup_ec3104.c linux/arch/sh/kernel/setup_ec3104.c
--- v2.4.9/linux/arch/sh/kernel/setup_ec3104.c	Sun May 20 12:11:38 2001
+++ linux/arch/sh/kernel/setup_ec3104.c	Sat Sep  8 12:29:09 2001
@@ -167,7 +167,8 @@
 
 static void end_ec3104_irq(unsigned int irq)
 {
-	unmask_ec3104_irq(irq);
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		unmask_ec3104_irq(irq);
 }
 
 static unsigned int startup_ec3104_irq(unsigned int irq)
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/setup_hd64461.c linux/arch/sh/kernel/setup_hd64461.c
--- v2.4.9/linux/arch/sh/kernel/setup_hd64461.c	Wed Apr 11 21:24:52 2001
+++ linux/arch/sh/kernel/setup_hd64461.c	Sat Sep  8 12:29:09 2001
@@ -1,5 +1,5 @@
 /*
- *	$Id: setup_hd64461.c,v 1.1 2000/06/10 21:45:18 yaegashi Exp $
+ *	$Id: setup_hd64461.c,v 1.9 2001/07/15 23:26:56 gniibe Exp $
  *	Copyright (C) 2000 YAEGASHI Takeshi
  *	Hitachi HD64461 companion chip support
  */
@@ -57,7 +57,8 @@
 
 static void end_hd64461_irq(unsigned int irq)
 {
-	enable_hd64461_irq(irq);
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_hd64461_irq(irq);
 }
 
 
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/setup_hd64465.c linux/arch/sh/kernel/setup_hd64465.c
--- v2.4.9/linux/arch/sh/kernel/setup_hd64465.c	Wed Apr 11 21:24:52 2001
+++ linux/arch/sh/kernel/setup_hd64465.c	Sat Sep  8 12:29:09 2001
@@ -1,5 +1,5 @@
 /*
- * $Id: setup_hd64465.c,v 1.3 2001/02/07 17:52:53 stuart_menefy Exp $
+ * $Id: setup_hd64465.c,v 1.4 2001/07/15 23:26:56 gniibe Exp $
  *
  * Setup and IRQ handling code for the HD64465 companion chip.
  * by Greg Banks <gbanks@pocketpenguins.com>
@@ -70,7 +70,8 @@
 
 static void end_hd64465_irq(unsigned int irq)
 {
-	enable_hd64465_irq(irq);
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_hd64465_irq(irq);
 }
 
 
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/sh_ksyms.c linux/arch/sh/kernel/sh_ksyms.c
--- v2.4.9/linux/arch/sh/kernel/sh_ksyms.c	Tue Jul  3 17:08:19 2001
+++ linux/arch/sh/kernel/sh_ksyms.c	Sat Sep  8 12:29:09 2001
@@ -9,6 +9,7 @@
 #include <linux/interrupt.h>
 #include <linux/smp_lock.h>
 #include <linux/vmalloc.h>
+#include <linux/pci.h>
 
 #include <asm/semaphore.h>
 #include <asm/processor.h>
@@ -18,7 +19,6 @@
 #include <asm/hardirq.h>
 #include <asm/delay.h>
 #include <asm/pgalloc.h>
-#include <asm/pci.h>
 #include <linux/irq.h>
 
 extern void dump_thread(struct pt_regs *, struct user *);
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/sys_sh.c linux/arch/sh/kernel/sys_sh.c
--- v2.4.9/linux/arch/sh/kernel/sys_sh.c	Mon Mar 19 12:35:10 2001
+++ linux/arch/sh/kernel/sys_sh.c	Sat Sep  8 12:29:09 2001
@@ -43,6 +43,45 @@
 	return error;
 }
 
+#if defined(__SH4__)
+/*
+ * To avoid cache alias, we map the shard page with same color.
+ */
+#define COLOUR_ALIGN(addr)	(((addr)+SHMLBA-1)&~(SHMLBA-1))
+
+unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
+	unsigned long len, unsigned long pgoff, unsigned long flags)
+{
+	struct vm_area_struct *vma;
+
+	if (flags & MAP_FIXED) {
+		/* We do not accept a shared mapping if it would violate
+		 * cache aliasing constraints.
+		 */
+		if ((flags & MAP_SHARED) && (addr & (SHMLBA - 1)))
+			return -EINVAL;
+		return addr;
+	}
+
+	if (len > TASK_SIZE)
+		return -ENOMEM;
+	if (!addr)
+		addr = TASK_UNMAPPED_BASE;
+
+	addr = COLOUR_ALIGN(addr);
+
+	for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) {
+		/* At this point:  (!vma || addr < vma->vm_end). */
+		if (TASK_SIZE - len < addr)
+			return -ENOMEM;
+		if (!vma || addr + len <= vma->vm_start)
+			return addr;
+		addr = vma->vm_end;
+		addr = COLOUR_ALIGN(addr);
+	}
+}
+#endif
+
 static inline long
 do_mmap2(unsigned long addr, unsigned long len, unsigned long prot, 
 	 unsigned long flags, int fd, unsigned long pgoff)
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/time.c linux/arch/sh/kernel/time.c
--- v2.4.9/linux/arch/sh/kernel/time.c	Tue Jul  3 17:08:19 2001
+++ linux/arch/sh/kernel/time.c	Sat Sep  8 12:29:09 2001
@@ -1,4 +1,4 @@
-/* $Id: time.c,v 1.20 2000/02/28 12:42:51 gniibe Exp $
+/* $Id: time.c,v 1.30 2001/09/01 14:34:31 mrbrown Exp $
  *
  *  linux/arch/sh/kernel/time.c
  *
@@ -183,10 +183,9 @@
 static inline void do_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	do_timer(regs);
-#if 0
+
 	if (!user_mode(regs))
 		sh_do_profile(regs->pc);
-#endif
 
 #ifdef CONFIG_HEARTBEAT
 	if (sh_mv.mv_heartbeat != NULL) 
@@ -360,17 +359,11 @@
 #endif
 #endif
 
-	if (MACH_DREAMCAST)
-		xtime.tv_sec = xtime.tv_usec = 0;
-	else
-		rtc_gettimeofday(&xtime);
+	rtc_gettimeofday(&xtime);
 
 	setup_irq(TIMER_IRQ, &irq0);
 
-	if (MACH_DREAMCAST)
-		timer_freq = 50*1000*1000/4;
-	else
-		timer_freq = get_timer_frequency();
+	timer_freq = get_timer_frequency();
 
 	module_clock = timer_freq * 4;
 
@@ -391,10 +384,9 @@
 	}
 #elif defined(__SH4__)
 	{
+#ifdef CONFIG_CPU_SUBTYPE_ST40STB1
 		unsigned long pvr;
-		frqcr = ctrl_inw(FRQCR);
 
-#ifdef CONFIG_CPU_SUBTYPE_ST40STB1
 		/* This should probably be moved into the SH3 probing code, and then use the processor
 		 * structure to determine which CPU we are running on.
 		 */
@@ -435,6 +427,8 @@
 		} else
 #endif
 		{
+			frqcr = ctrl_inw(FRQCR);
+
 			ifc  = ifc_table[(frqcr>> 6) & 0x0007];
 			bfc  = bfc_table[(frqcr>> 3) & 0x0007];
 			pfc = pfc_table[frqcr & 0x0007];
diff -u --recursive --new-file v2.4.9/linux/arch/sh/kernel/traps.c linux/arch/sh/kernel/traps.c
--- v2.4.9/linux/arch/sh/kernel/traps.c	Mon Jan 29 16:19:41 2001
+++ linux/arch/sh/kernel/traps.c	Sat Sep  8 12:29:09 2001
@@ -1,4 +1,4 @@
-/* $Id: traps.c,v 1.5 2000/02/27 08:27:55 gniibe Exp $
+/* $Id: traps.c,v 1.14 2001/07/24 08:07:10 gniibe Exp $
  *
  *  linux/arch/sh/traps.c
  *
@@ -314,10 +314,10 @@
 
 	/* shout about the first ten userspace fixups */
 	if (user_mode(regs) && handle_unaligned_notify_count>0) {
-	    handle_unaligned_notify_count--;
+		handle_unaligned_notify_count--;
 
-	    printk("Fixing up unaligned userspace access in \"%s\" pid=%d pc=0x%p ins=0x%04hx\n",
-		   current->comm,current->pid,(u16*)regs->pc,instruction);
+		printk("Fixing up unaligned userspace access in \"%s\" pid=%d pc=0x%p ins=0x%04hx\n",
+		       current->comm,current->pid,(u16*)regs->pc,instruction);
 	}
 
 	ret = -EFAULT;
@@ -502,7 +502,7 @@
 	die_if_kernel("exception", &regs, ex);
 }
 
-#if defined(CONFIG_DEBUG_KERNEL_WITH_GDB_STUB) || defined(CONFIG_SH_STANDARD_BIOS)
+#if defined(CONFIG_SH_STANDARD_BIOS)
 void *gdb_vbr_vector;
 #endif
 
@@ -514,7 +514,7 @@
 	exception_handling_table[12] = (void *)do_reserved_inst;
 	exception_handling_table[13] = (void *)do_illegal_slot_inst;
 
-#if defined(CONFIG_DEBUG_KERNEL_WITH_GDB_STUB) || defined(CONFIG_SH_STANDARD_BIOS)
+#if defined(CONFIG_SH_STANDARD_BIOS)
     	/*
 	 * Read the old value of the VBR register to initialise
 	 * the vector through which debug and BIOS traps are
diff -u --recursive --new-file v2.4.9/linux/arch/sh/lib/Makefile linux/arch/sh/lib/Makefile
--- v2.4.9/linux/arch/sh/lib/Makefile	Fri Dec 29 14:07:20 2000
+++ linux/arch/sh/lib/Makefile	Sat Sep  8 12:29:09 2001
@@ -4,7 +4,7 @@
 
 L_TARGET = lib.a
 obj-y  = delay.o memcpy.o memset.o memmove.o memchr.o old-checksum.o \
-	 checksum.o strcasecmp.o
+	 checksum.o strcasecmp.o strlen.o
 
 USE_STANDARD_AS_RULE := true
 
diff -u --recursive --new-file v2.4.9/linux/arch/sh/lib/checksum.S linux/arch/sh/lib/checksum.S
--- v2.4.9/linux/arch/sh/lib/checksum.S	Sun Jan 28 18:56:00 2001
+++ linux/arch/sh/lib/checksum.S	Sat Sep  8 12:29:09 2001
@@ -1,4 +1,4 @@
-/* $Id: checksum.S,v 1.4 2000/05/14 08:41:26 gniibe Exp $
+/* $Id: checksum.S,v 1.10 2001/07/06 13:11:32 gniibe Exp $
  *
  * INET		An implementation of the TCP/IP protocol suite for the LINUX
  *		operating system.  INET is implemented using the  BSD Socket
@@ -54,13 +54,14 @@
 	tst	#2, r0		! Check alignment.
 	bt	2f		! Jump if alignment is ok.
 	!
-	add	#-2, r5	! Alignment uses up two bytes.
+	add	#-2, r5		! Alignment uses up two bytes.
 	cmp/pz	r5		!
 	bt/s	1f		! Jump if we had at least two bytes.
 	 clrt
 	bra	6f
 	 add	#2, r5		! r5 was < 2.  Deal with it.
 1:
+	mov	r5, r1		! Save new len for later use.
 	mov.w	@r4+, r0
 	extu.w	r0, r0
 	addc	r0, r6
@@ -90,7 +91,7 @@
 	addc	r3, r6
 	addc	r0, r6
 	addc	r2, r6
-	movt	r0	
+	movt	r0
 	dt	r5
 	bf/s	3b
 	 cmp/eq	#1, r0
@@ -185,48 +186,48 @@
 	mov.l	r5,@-r15
 	mov.l	r6,@-r15
 
-	mov	#3, r0			! Check src and dest are equally aligned
-	mov	r4, r1
-	and	r0, r1
-	and	r5, r0
-	cmp/eq	r1, r0
-	bf	3f			! Different alignments, use slow version
-	tst	#1,r0			! Check dest word aligned
-	bf	3f			! If not, do it the slow way
+	mov	#3,r0		! Check src and dest are equally aligned
+	mov	r4,r1
+	and	r0,r1
+	and	r5,r0
+	cmp/eq	r1,r0
+	bf	3f		! Different alignments, use slow version
+	tst	#1,r0		! Check dest word aligned
+	bf	3f		! If not, do it the slow way
 
 	mov	#2,r0
-	tst	r0,r5			! Check dest alignment. 
-	bt	2f			! Jump if alignment is ok.
-	add	#-2,r6			! Alignment uses up two bytes.
-	cmp/pz	r6			! Jump if we had at least two bytes.
+	tst	r0,r5		! Check dest alignment. 
+	bt	2f		! Jump if alignment is ok.
+	add	#-2,r6		! Alignment uses up two bytes.
+	cmp/pz	r6		! Jump if we had at least two bytes.
 	bt/s	1f
 	 clrt
 	bra	4f
-	 add	#2,r6			! r6 was < 2.	Deal with it.
+	 add	#2,r6		! r6 was < 2.	Deal with it.
 
-3:	! Handle different src and dest alinments.
+3:	! Handle different src and dest alignments.
 	! This is not common, so simple byte by byte copy will do.
-	mov	r6, r2
+	mov	r6,r2
 	shlr	r6
-	tst	r6, r6
+	tst	r6,r6
 	bt	4f
 	clrt
-5:	
-SRC(	mov.b	@r4+,r0 )
-DST(	mov.b	r0,@r5	)
-	add	#1, r5
-SRC(	mov.b	@r4+,r1	)
-DST(	mov.b	r1,@r5	)
-	add	#1,r5
-
-	extu.b	r0,r0
+	.align	2
+5:
+SRC(	mov.b	@r4+,r1 	)
+SRC(	mov.b	@r4+,r0		)
 	extu.b	r1,r1
+DST(	mov.b	r1,@r5		)
+DST(	mov.b	r0,@(1,r5)	)
+	extu.b	r0,r0
+	add	#2,r5
+
 #ifdef	__LITTLE_ENDIAN__
-	shll8	r1
-#else
 	shll8	r0
+#else
+	shll8	r1
 #endif
-	or	r1,r0	
+	or	r1,r0
 
 	addc	r0,r7
 	movt	r0
@@ -238,16 +239,16 @@
 
 	mov	r2, r0
 	tst	#1, r0
-	bt	7f	
+	bt	7f
 	bra	5f
 	 clrt
 
 	! src and dest equally aligned, but to a two byte boundary.
 	! Handle first two bytes as a special case
-	.align	5
+	.align	2
 1:	
-SRC(	mov.w	@r4+,r0	)
-DST(	mov.w	r0,@r5	)
+SRC(	mov.w	@r4+,r0		)
+DST(	mov.w	r0,@r5		)
 	add	#2,r5
 	extu.w	r0,r0
 	addc	r0,r7
@@ -260,42 +261,36 @@
 	tst	r6,r6
 	bt/s	2f
 	 clrt
+	.align	2
 1:	
-SRC(	mov.l	@r4+,r0	)
-SRC(	mov.l	@r4+,r1	)
+SRC(	mov.l	@r4+,r0		)
+SRC(	mov.l	@r4+,r1		)
 	addc	r0,r7
-DST(	mov.l	r0,@r5	)
-	add	#4,r5
+DST(	mov.l	r0,@r5		)
+DST(	mov.l	r1,@(4,r5)	)
 	addc	r1,r7
-DST(	mov.l	r1,@r5	)
-	add	#4,r5
 
-SRC(	mov.l	@r4+,r0	)
-SRC(	mov.l	@r4+,r1	)
+SRC(	mov.l	@r4+,r0		)
+SRC(	mov.l	@r4+,r1		)
 	addc	r0,r7
-DST(	mov.l	r0,@r5	)
-	add	#4,r5
+DST(	mov.l	r0,@(8,r5)	)
+DST(	mov.l	r1,@(12,r5)	)
 	addc	r1,r7
-DST(	mov.l	r1,@r5	)
-	add	#4,r5
 
 SRC(	mov.l	@r4+,r0 	)
-SRC(	mov.l	@r4+,r1	)
+SRC(	mov.l	@r4+,r1		)
 	addc	r0,r7
-DST(	mov.l	r0,@r5	)
-	add	#4,r5
+DST(	mov.l	r0,@(16,r5)	)
+DST(	mov.l	r1,@(20,r5)	)
 	addc	r1,r7
-DST(	mov.l	r1,@r5	)
-	add	#4,r5
 
-SRC(	mov.l	@r4+,r0	)
-SRC(	mov.l	@r4+,r1	)
+SRC(	mov.l	@r4+,r0		)
+SRC(	mov.l	@r4+,r1		)
 	addc	r0,r7
-DST(	mov.l	r0,@r5	)
-	add	#4,r5
+DST(	mov.l	r0,@(24,r5)	)
+DST(	mov.l	r1,@(28,r5)	)
 	addc	r1,r7
-DST(	mov.l	r1,@r5	)
-	add	#4,r5
+	add	#32,r5
 	movt	r0
 	dt	r6
 	bf/s	1b
diff -u --recursive --new-file v2.4.9/linux/arch/sh/lib/strlen.S linux/arch/sh/lib/strlen.S
--- v2.4.9/linux/arch/sh/lib/strlen.S	Wed Dec 31 16:00:00 1969
+++ linux/arch/sh/lib/strlen.S	Sat Sep  8 12:29:09 2001
@@ -0,0 +1,70 @@
+/* $Id: strlen.S,v 1.2 2001/06/29 14:07:15 gniibe Exp $
+ *
+ * "strlen" implementation of SuperH
+ *
+ * Copyright (C) 1999  Kaz Kojima
+ *
+ */
+
+/* size_t strlen (const char *s)  */
+
+#include <linux/linkage.h>
+ENTRY(strlen)
+	mov	r4,r0
+	and	#3,r0
+	tst	r0,r0
+	bt/s	1f
+	 mov	#0,r2
+
+	add	#-1,r0
+	shll2	r0
+	shll	r0
+	braf	r0
+	 nop
+
+	mov.b	@r4+,r1
+	tst	r1,r1
+	bt	8f
+	add	#1,r2
+
+	mov.b	@r4+,r1
+	tst	r1,r1
+	bt	8f
+	add	#1,r2
+
+	mov.b	@r4+,r1
+	tst	r1,r1
+	bt	8f
+	add	#1,r2	
+
+1:
+	mov	#0,r3
+2:
+	mov.l	@r4+,r1
+	cmp/str	r3,r1
+	bf/s	2b
+	 add	#4,r2
+
+	add	#-4,r2
+#ifndef __LITTLE_ENDIAN__
+	swap.b	r1,r1
+	swap.w	r1,r1
+	swap.b	r1,r1
+#endif
+	extu.b	r1,r0
+	tst	r0,r0
+	bt/s	8f
+	 shlr8	r1
+	add	#1,r2
+	extu.b	r1,r0
+	tst	r0,r0
+	bt/s	8f
+	 shlr8	r1
+	add	#1,r2
+	extu.b	r1,r0
+	tst	r0,r0
+	bt	8f
+	add	#1,r2
+8:
+	rts
+	 mov	r2,r0
diff -u --recursive --new-file v2.4.9/linux/arch/sh/mm/Makefile linux/arch/sh/mm/Makefile
--- v2.4.9/linux/arch/sh/mm/Makefile	Fri Dec 29 14:07:20 2000
+++ linux/arch/sh/mm/Makefile	Sat Sep  8 12:29:09 2001
@@ -8,6 +8,11 @@
 # Note 2! The CFLAGS definition is now in the main makefile...
 
 O_TARGET := mm.o
-obj-y	 := init.o fault.o extable.o cache.o # ioremap.o 
+obj-y	 := init.o fault.o extable.o clear_page.o copy_page.o
+
+obj-$(CONFIG_CPU_SH3) += cache-sh3.o
+obj-$(CONFIG_CPU_SH4) += cache-sh4.o __clear_user_page-sh4.o __copy_user_page-sh4.o ioremap.o
+
+USE_STANDARD_AS_RULE := true
 
 include $(TOPDIR)/Rules.make
diff -u --recursive --new-file v2.4.9/linux/arch/sh/mm/__clear_user_page-sh4.S linux/arch/sh/mm/__clear_user_page-sh4.S
--- v2.4.9/linux/arch/sh/mm/__clear_user_page-sh4.S	Wed Dec 31 16:00:00 1969
+++ linux/arch/sh/mm/__clear_user_page-sh4.S	Sat Sep  8 12:29:09 2001
@@ -0,0 +1,49 @@
+/* $Id$
+ *
+ * __clear_user_page implementation of SuperH
+ *
+ * Copyright (C) 2001  Niibe Yutaka & Kaz Kojima
+ *
+ */
+
+/*
+ * __clear_user_page
+ * @to: P1 address (with same color)
+ * @orig_to: P1 address
+ *
+ * void __clear_user_page(void *to, void *orig_to)
+ */
+
+/*
+ * r0 --- scratch 
+ * r4 --- to
+ * r5 --- orig_to
+ * r6 --- to + 4096
+ */
+#include <linux/linkage.h>
+ENTRY(__clear_user_page)
+	mov	r4,r6
+	mov.w	.L4096,r0
+	add	r0,r6
+	mov	#0,r0
+	!
+1:	ocbi	@r5
+	add	#32,r5
+	movca.l	r0,@r4
+	mov	r4,r1
+	add	#32,r4
+	mov.l	r0,@-r4
+	mov.l	r0,@-r4
+	mov.l	r0,@-r4
+	mov.l	r0,@-r4
+	mov.l	r0,@-r4
+	mov.l	r0,@-r4
+	mov.l	r0,@-r4
+	add	#28,r4
+	cmp/eq	r6,r4
+	bf/s	1b
+	 ocbwb	@r1
+	!
+	rts
+	 nop
+.L4096:	.word	4096
diff -u --recursive --new-file v2.4.9/linux/arch/sh/mm/__copy_user_page-sh4.S linux/arch/sh/mm/__copy_user_page-sh4.S
--- v2.4.9/linux/arch/sh/mm/__copy_user_page-sh4.S	Wed Dec 31 16:00:00 1969
+++ linux/arch/sh/mm/__copy_user_page-sh4.S	Sat Sep  8 12:29:09 2001
@@ -0,0 +1,69 @@
+/* $Id: __copy_user_page-sh4.S,v 1.1 2001/07/23 09:02:17 gniibe Exp $
+ *
+ * __copy_user_page implementation of SuperH
+ *
+ * Copyright (C) 2001  Niibe Yutaka & Kaz Kojima
+ *
+ */
+
+/*
+ * __copy_user_page
+ * @to: P1 address (with same color)
+ * @from: P1 address
+ * @orig_to: P1 address
+ *
+ * void __copy_user_page(void *to, void *from, void *orig_to)
+ */
+
+/*
+ * r0, r1, r2, r3, r4, r5, r6, r7 --- scratch 
+ * r8 --- from + 4096
+ * r9 --- orig_to
+ * r10 --- to
+ * r11 --- from
+ */
+#include <linux/linkage.h>
+ENTRY(__copy_user_page)
+	mov.l	r8,@-r15
+	mov.l	r9,@-r15
+	mov.l	r10,@-r15
+	mov.l	r11,@-r15
+	mov	r4,r10
+	mov	r5,r11
+	mov	r6,r9
+	mov	r5,r8
+	mov.w	.L4096,r0
+	add	r0,r8
+	!
+1:	ocbi	@r9
+	add	#32,r9
+	mov.l	@r11+,r0
+	mov.l	@r11+,r1
+	mov.l	@r11+,r2
+	mov.l	@r11+,r3
+	mov.l	@r11+,r4
+	mov.l	@r11+,r5
+	mov.l	@r11+,r6
+	mov.l	@r11+,r7
+	movca.l	r0,@r10
+	mov	r10,r0
+	add	#32,r10
+	mov.l	r7,@-r10
+	mov.l	r6,@-r10
+	mov.l	r5,@-r10
+	mov.l	r4,@-r10
+	mov.l	r3,@-r10
+	mov.l	r2,@-r10
+	mov.l	r1,@-r10
+	ocbwb	@r0
+	cmp/eq	r11,r8
+	bf/s	1b
+	 add	#28,r10
+	!
+	mov.l	@r15+,r11
+	mov.l	@r15+,r10
+	mov.l	@r15+,r9
+	mov.l	@r15+,r8
+	rts
+	 nop
+.L4096:	.word	4096
diff -u --recursive --new-file v2.4.9/linux/arch/sh/mm/cache-sh3.c linux/arch/sh/mm/cache-sh3.c
--- v2.4.9/linux/arch/sh/mm/cache-sh3.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/sh/mm/cache-sh3.c	Sat Sep  8 12:29:09 2001
@@ -0,0 +1,219 @@
+/* $Id: cache-sh3.c,v 1.5 2001/08/24 15:31:41 dwmw2 Exp $
+ *
+ *  linux/arch/sh/mm/cache-sh3.c
+ *
+ * Copyright (C) 1999, 2000  Niibe Yutaka
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/mman.h>
+#include <linux/mm.h>
+#include <linux/threads.h>
+#include <asm/addrspace.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+#include <asm/processor.h>
+#include <asm/cache.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <asm/pgalloc.h>
+#include <asm/mmu_context.h>
+
+#define CCR		0xffffffec	/* Address of Cache Control Register */
+#define CCR_CACHE_VAL	0x00000005	/* 8k-byte cache, P1-wb, enable */
+#define CCR_CACHE_INIT	0x0000000d	/* 8k-byte cache, CF, P1-wb, enable */
+#define CCR_CACHE_ENABLE	 1
+
+#define CACHE_OC_ADDRESS_ARRAY 0xf0000000
+#define CACHE_VALID	  1
+#define CACHE_UPDATED	  2
+#define CACHE_PHYSADDR_MASK 0x1ffffc00
+
+/* 7709A/7729 has 16K cache (256-entry), while 7702 has only 2K(direct)
+   7702 is not supported (yet) */
+struct _cache_system_info {
+	int way_shift;
+	int entry_mask;
+	int num_entries;
+};
+
+/* Data at BSS is cleared after setting this variable.
+   So, we Should not placed this variable at BSS section.
+   Initialize this, it is placed at data section. */
+static struct _cache_system_info cache_system_info = {0,};
+
+#define CACHE_OC_WAY_SHIFT	(cache_system_info.way_shift)
+#define CACHE_OC_ENTRY_SHIFT    4
+#define CACHE_OC_ENTRY_MASK	(cache_system_info.entry_mask)
+#define CACHE_OC_NUM_ENTRIES	(cache_system_info.num_entries)
+#define CACHE_OC_NUM_WAYS	4
+#define CACHE_OC_ASSOC_BIT    (1<<3)
+
+
+/*
+ * Write back all the cache.
+ *
+ * For SH-4, we only need to flush (write back) Operand Cache,
+ * as Instruction Cache doesn't have "updated" data.
+ *
+ * Assumes that this is called in interrupt disabled context, and P2.
+ * Shuld be INLINE function.
+ */
+static inline void cache_wback_all(void)
+{
+	unsigned long addr, data, i, j;
+
+	for (i=0; i<CACHE_OC_NUM_ENTRIES; i++) {
+		for (j=0; j<CACHE_OC_NUM_WAYS; j++) {
+			addr = CACHE_OC_ADDRESS_ARRAY|(j<<CACHE_OC_WAY_SHIFT)|
+				(i<<CACHE_OC_ENTRY_SHIFT);
+			data = ctrl_inl(addr);
+			if ((data & (CACHE_UPDATED|CACHE_VALID))
+			    == (CACHE_UPDATED|CACHE_VALID))
+				ctrl_outl(data & ~CACHE_UPDATED, addr);
+		}
+	}
+}
+
+static void __init
+detect_cpu_and_cache_system(void)
+{
+	unsigned long addr0, addr1, data0, data1, data2, data3;
+
+	jump_to_P2();
+	/*
+	 * Check if the entry shadows or not.
+	 * When shadowed, it's 128-entry system.
+	 * Otherwise, it's 256-entry system.
+	 */
+	addr0 = CACHE_OC_ADDRESS_ARRAY + (3 << 12);
+	addr1 = CACHE_OC_ADDRESS_ARRAY + (1 << 12);
+
+	/* First, write back & invalidate */
+	data0  = ctrl_inl(addr0);
+	ctrl_outl(data0&~(CACHE_VALID|CACHE_UPDATED), addr0);
+	data1  = ctrl_inl(addr1);
+	ctrl_outl(data1&~(CACHE_VALID|CACHE_UPDATED), addr1);
+
+	/* Next, check if there's shadow or not */
+	data0 = ctrl_inl(addr0);
+	data0 ^= CACHE_VALID;
+	ctrl_outl(data0, addr0);
+	data1 = ctrl_inl(addr1);
+	data2 = data1 ^ CACHE_VALID;
+	ctrl_outl(data2, addr1);
+	data3 = ctrl_inl(addr0);
+
+	/* Lastly, invaliate them. */
+	ctrl_outl(data0&~CACHE_VALID, addr0);
+	ctrl_outl(data2&~CACHE_VALID, addr1);
+	back_to_P1();
+
+	if (data0 == data1 && data2 == data3) {	/* Shadow */
+		cache_system_info.way_shift = 11;
+		cache_system_info.entry_mask = 0x7f0;
+		cache_system_info.num_entries = 128;
+		cpu_data->type = CPU_SH7708;
+	} else {				/* 7709A or 7729  */
+		cache_system_info.way_shift = 12;
+		cache_system_info.entry_mask = 0xff0;
+		cache_system_info.num_entries = 256;
+		cpu_data->type = CPU_SH7729;
+	}
+}
+
+void __init cache_init(void)
+{
+	unsigned long ccr;
+
+	detect_cpu_and_cache_system();
+
+	jump_to_P2();
+	ccr = ctrl_inl(CCR);
+	if (ccr & CCR_CACHE_ENABLE)
+		/*
+		 * XXX: Should check RA here. 
+		 * If RA was 1, we only need to flush the half of the caches.
+		 */
+		cache_wback_all();
+
+	ctrl_outl(CCR_CACHE_INIT, CCR);
+	back_to_P1();
+}
+
+/*
+ * Write back the dirty D-caches, but not invalidate them.
+ *
+ * Is this really worth it, or should we just alias this routine
+ * to __flush_purge_region too?
+ *
+ * START: Virtual Address (U0, P1, or P3)
+ * SIZE: Size of the region.
+ */
+
+void __flush_wback_region(void *start, int size)
+{
+	unsigned long v, j;
+	unsigned long begin, end;
+	unsigned long flags;
+
+	begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
+	end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
+		& ~(L1_CACHE_BYTES-1);
+
+	for (v = begin; v < end; v+=L1_CACHE_BYTES) {
+		for (j=0; j<CACHE_OC_NUM_WAYS; j++) {
+			unsigned long data, addr, p;
+
+			p = __pa(v);
+			addr = CACHE_OC_ADDRESS_ARRAY|(j<<CACHE_OC_WAY_SHIFT)|
+				(v&CACHE_OC_ENTRY_MASK);
+			save_and_cli(flags);
+			data = ctrl_inl(addr);
+			
+			if ((data & CACHE_PHYSADDR_MASK) ==
+			    (p & CACHE_PHYSADDR_MASK)) {
+				data &= ~CACHE_UPDATED;
+				ctrl_outl(data, addr);
+				restore_flags(flags);
+				break;
+			}
+			restore_flags(flags);
+		}
+	}
+}
+
+/*
+ * Write back the dirty D-caches and invalidate them.
+ *
+ * START: Virtual Address (U0, P1, or P3)
+ * SIZE: Size of the region.
+ */
+void __flush_purge_region(void *start, int size)
+{
+	unsigned long v;
+	unsigned long begin, end;
+
+	begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
+	end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
+		& ~(L1_CACHE_BYTES-1);
+
+	for (v = begin; v < end; v+=L1_CACHE_BYTES) {
+		unsigned long data, addr;
+
+		data = (v & 0xfffffc00); /* _Virtual_ address, ~U, ~V */
+		addr = CACHE_OC_ADDRESS_ARRAY | (v&CACHE_OC_ENTRY_MASK) | 
+			CACHE_OC_ASSOC_BIT;
+		ctrl_outl(data, addr);
+	}
+}
+
+/*
+ * No write back please
+ *
+ * Except I don't think there's any way to avoid the writeback. So we
+ * just alias it to __flush_purge_region(). dwmw2.
+ */
+void __flush_invalidate_region(void *start, int size)
+	__attribute__((alias("__flush_purge_region")));
diff -u --recursive --new-file v2.4.9/linux/arch/sh/mm/cache-sh4.c linux/arch/sh/mm/cache-sh4.c
--- v2.4.9/linux/arch/sh/mm/cache-sh4.c	Wed Dec 31 16:00:00 1969
+++ linux/arch/sh/mm/cache-sh4.c	Sat Sep  8 12:29:09 2001
@@ -0,0 +1,439 @@
+/* $Id: cache-sh4.c,v 1.15 2001/08/10 14:13:13 gniibe Exp $
+ *
+ *  linux/arch/sh/mm/cache.c
+ *
+ * Copyright (C) 1999, 2000  Niibe Yutaka
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/mman.h>
+#include <linux/mm.h>
+#include <linux/threads.h>
+#include <asm/addrspace.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+#include <asm/processor.h>
+#include <asm/cache.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <asm/pgalloc.h>
+#include <asm/mmu_context.h>
+
+#define CCR		 0xff00001c	/* Address of Cache Control Register */
+#define CCR_CACHE_VAL	 0x00000105	/* 8k+16k-byte cache,P1-wb,enable */
+#define CCR_CACHE_INIT	 0x0000090d	/* ICI,ICE(8k), OCI,P1-wb,OCE(16k) */
+#define CCR_CACHE_ENABLE 0x00000101
+
+#define CACHE_IC_ADDRESS_ARRAY 0xf0000000
+#define CACHE_OC_ADDRESS_ARRAY 0xf4000000
+#define CACHE_VALID	  1
+#define CACHE_UPDATED	  2
+
+#define CACHE_OC_WAY_SHIFT       13
+#define CACHE_IC_WAY_SHIFT       13
+#define CACHE_OC_ENTRY_SHIFT      5
+#define CACHE_IC_ENTRY_SHIFT      5
+#define CACHE_OC_ENTRY_MASK		0x3fe0
+#define CACHE_OC_ENTRY_PHYS_MASK	0x0fe0
+#define CACHE_IC_ENTRY_MASK		0x1fe0
+#define CACHE_IC_NUM_ENTRIES	256
+#define CACHE_OC_NUM_ENTRIES	512
+
+static void __init
+detect_cpu_and_cache_system(void)
+{
+#ifdef CONFIG_CPU_SUBTYPE_ST40STB1
+	cpu_data->type = CPU_ST40STB1;
+#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751)
+	cpu_data->type = CPU_SH7750;
+#else
+#error Unknown SH4 CPU type
+#endif
+}
+
+void __init cache_init(void)
+{
+	unsigned long ccr;
+
+	detect_cpu_and_cache_system();
+
+	jump_to_P2();
+	ccr = ctrl_inl(CCR);
+	if (ccr & CCR_CACHE_ENABLE) {
+		/*
+		 * XXX: Should check RA here. 
+		 * If RA was 1, we only need to flush the half of the caches.
+		 */
+		unsigned long addr, data;
+
+		for (addr = CACHE_OC_ADDRESS_ARRAY;
+		     addr < (CACHE_OC_ADDRESS_ARRAY+
+			     (CACHE_OC_NUM_ENTRIES << CACHE_OC_ENTRY_SHIFT));
+		     addr += (1 << CACHE_OC_ENTRY_SHIFT)) {
+			data = ctrl_inl(addr);
+			if ((data & (CACHE_UPDATED|CACHE_VALID))
+			    == (CACHE_UPDATED|CACHE_VALID))
+				ctrl_outl(data & ~CACHE_UPDATED, addr);
+		}
+	}
+
+	ctrl_outl(CCR_CACHE_INIT, CCR);
+	back_to_P1();
+}
+
+/*
+ * SH-4 has virtually indexed and physically tagged cache.
+ */
+
+static struct semaphore p3map_sem[4];
+
+void __init p3_cache_init(void)
+{
+	/* In ioremap.c */
+	extern int remap_area_pages(unsigned long address,
+				    unsigned long phys_addr,
+				    unsigned long size, unsigned long flags);
+
+	if (remap_area_pages(P3SEG, 0, PAGE_SIZE*4, _PAGE_CACHABLE))
+		panic("p3_cachie_init failed.");
+	sema_init (&p3map_sem[0], 1);
+	sema_init (&p3map_sem[1], 1);
+	sema_init (&p3map_sem[2], 1);
+	sema_init (&p3map_sem[3], 1);
+}
+
+/*
+ * Write back the dirty D-caches, but not invalidate them.
+ *
+ * START: Virtual Address (U0, P1, or P3)
+ * SIZE: Size of the region.
+ */
+void __flush_wback_region(void *start, int size)
+{
+	unsigned long v;
+	unsigned long begin, end;
+
+	begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
+	end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
+		& ~(L1_CACHE_BYTES-1);
+	for (v = begin; v < end; v+=L1_CACHE_BYTES) {
+		asm volatile("ocbwb	%0"
+			     : /* no output */
+			     : "m" (__m(v)));
+	}
+}
+
+/*
+ * Write back the dirty D-caches and invalidate them.
+ *
+ * START: Virtual Address (U0, P1, or P3)
+ * SIZE: Size of the region.
+ */
+void __flush_purge_region(void *start, int size)
+{
+	unsigned long v;
+	unsigned long begin, end;
+
+	begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
+	end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
+		& ~(L1_CACHE_BYTES-1);
+	for (v = begin; v < end; v+=L1_CACHE_BYTES) {
+		asm volatile("ocbp	%0"
+			     : /* no output */
+			     : "m" (__m(v)));
+	}
+}
+
+
+/*
+ * No write back please
+ */
+void __flush_invalidate_region(void *start, int size)
+{
+	unsigned long v;
+	unsigned long begin, end;
+
+	begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
+	end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
+		& ~(L1_CACHE_BYTES-1);
+	for (v = begin; v < end; v+=L1_CACHE_BYTES) {
+		asm volatile("ocbi	%0"
+			     : /* no output */
+			     : "m" (__m(v)));
+	}
+}
+
+/*
+ * Write back the range of D-cache, and purge the I-cache.
+ *
+ * Called from kernel/module.c:sys_init_module and routine for a.out format.
+ */
+void flush_icache_range(unsigned long start, unsigned long end)
+{
+	flush_cache_all();
+}
+
+/*
+ * Write back the D-cache and purge the I-cache for signal trampoline. 
+ */
+void flush_cache_sigtramp(unsigned long addr)
+{
+	unsigned long v, index;
+	unsigned long flags; 
+
+	v = addr & ~(L1_CACHE_BYTES-1);
+	asm volatile("ocbwb	%0"
+		     : /* no output */
+		     : "m" (__m(v)));
+
+	index = CACHE_IC_ADDRESS_ARRAY| (v&CACHE_IC_ENTRY_MASK);
+	save_and_cli(flags);
+	jump_to_P2();
+	ctrl_outl(0, index);	/* Clear out Valid-bit */
+	back_to_P1();
+	restore_flags(flags);
+}
+
+/*
+ * Writeback&Invalidate the D-cache of the page
+ */
+static void __flush_dcache_page(unsigned long phys)
+{
+	unsigned long addr, data;
+	unsigned long flags;
+
+	phys |= CACHE_VALID;
+
+	save_and_cli(flags);
+	jump_to_P2();
+
+	/* Loop all the D-cache */
+	for (addr = CACHE_OC_ADDRESS_ARRAY;
+	     addr < (CACHE_OC_ADDRESS_ARRAY
+		     +(CACHE_OC_NUM_ENTRIES<< CACHE_OC_ENTRY_SHIFT));
+	     addr += (1<<CACHE_OC_ENTRY_SHIFT)) {
+		data = ctrl_inl(addr)&(0x1ffff000|CACHE_VALID);
+		if (data == phys)
+			ctrl_outl(0, addr);
+	}
+
+#if 0 /* DEBUG DEBUG */
+	/* Loop all the I-cache */
+	for (addr = CACHE_IC_ADDRESS_ARRAY;
+	     addr < (CACHE_IC_ADDRESS_ARRAY
+		     +(CACHE_IC_NUM_ENTRIES<< CACHE_IC_ENTRY_SHIFT));
+	     addr += (1<<CACHE_IC_ENTRY_SHIFT)) {
+		data = ctrl_inl(addr)&(0x1ffff000|CACHE_VALID);
+		if (data == phys) {
+			printk(KERN_INFO "__flush_cache_page: I-cache entry found\n");
+			ctrl_outl(0, addr);
+		}
+	}
+#endif
+	back_to_P1();
+	restore_flags(flags);
+}
+
+/*
+ * Write back & invalidate the D-cache of the page.
+ * (To avoid "alias" issues)
+ */
+void flush_dcache_page(struct page *page)
+{
+	if (test_bit(PG_mapped, &page->flags))
+		__flush_dcache_page(PHYSADDR(page_address(page)));
+}
+
+void flush_cache_all(void)
+{
+	extern unsigned long empty_zero_page[1024];
+	unsigned long flags;
+	unsigned long addr;
+
+	save_and_cli(flags);
+
+	/* Prefetch the data to write back D-cache */
+	for (addr = (unsigned long)empty_zero_page;
+	     addr < (unsigned long)empty_zero_page + 1024*16;
+	     addr += L1_CACHE_BYTES)
+		asm volatile("pref @%0"::"r" (addr));
+
+	jump_to_P2();
+	/* Flush D-cache/I-cache */
+	ctrl_outl(CCR_CACHE_INIT, CCR);
+	back_to_P1();
+	restore_flags(flags);
+}
+
+void flush_cache_mm(struct mm_struct *mm)
+{
+	/* Is there any good way? */
+	/* XXX: possibly call flush_cache_range for each vm area */
+	flush_cache_all();
+}
+
+/*
+ * Write back and invalidate D-caches.
+ *
+ * START, END: Virtual Address (U0 address)
+ *
+ * NOTE: We need to flush the _physical_ page entry.
+ * Flushing the cache lines for U0 only isn't enough.
+ * We need to flush for P1 too, which may contain aliases.
+ */
+void flush_cache_range(struct mm_struct *mm, unsigned long start,
+		       unsigned long end)
+{
+	/*
+	 * We could call flush_cache_page for the pages of these range,
+	 * but it's not efficient (scan the caches all the time...).
+	 *
+	 * We can't use A-bit magic, as there's the case we don't have
+	 * valid entry on TLB.
+	 */
+	flush_cache_all();
+}
+
+/*
+ * Write back and invalidate I/D-caches for the page.
+ *
+ * ADDR: Virtual Address (U0 address)
+ */
+void flush_cache_page(struct vm_area_struct *vma, unsigned long address)
+{
+	pgd_t *dir;
+	pmd_t *pmd;
+	pte_t *pte;
+	pte_t entry;
+	unsigned long phys, addr, data;
+	unsigned long flags;
+
+	dir = pgd_offset(vma->vm_mm, address);
+	pmd = pmd_offset(dir, address);
+	if (pmd_none(*pmd) || pmd_bad(*pmd))
+		return;
+	pte = pte_offset(pmd, address);
+	entry = *pte;
+	if (pte_none(entry) || !pte_present(entry))
+		return;
+
+	phys = pte_val(entry)&PTE_PHYS_MASK;
+
+	phys |= CACHE_VALID;
+	save_and_cli(flags);
+	jump_to_P2();
+
+	/* We only need to flush D-cache when we have alias */
+	if ((address^phys) & CACHE_ALIAS) {
+		/* Loop 4K of the D-cache */
+		for (addr = CACHE_OC_ADDRESS_ARRAY | (address & CACHE_ALIAS);
+		     addr < (CACHE_OC_ADDRESS_ARRAY + (address & CACHE_ALIAS) 
+			     +(CACHE_OC_NUM_ENTRIES/4<<CACHE_OC_ENTRY_SHIFT));
+		     addr += (1<<CACHE_OC_ENTRY_SHIFT)) {
+			data = ctrl_inl(addr)&(0x1ffff000|CACHE_VALID);
+			if (data == phys)
+				ctrl_outl(0, addr);
+		}
+		/* Loop another 4K of the D-cache */
+		for (addr = CACHE_OC_ADDRESS_ARRAY | (phys & CACHE_ALIAS);
+		     addr < (CACHE_OC_ADDRESS_ARRAY + (phys & CACHE_ALIAS) 
+			     +(CACHE_OC_NUM_ENTRIES/4<<CACHE_OC_ENTRY_SHIFT));
+		     addr += (1<<CACHE_OC_ENTRY_SHIFT)) {
+			data = ctrl_inl(addr)&(0x1ffff000|CACHE_VALID);
+			if (data == phys)
+				ctrl_outl(0, addr);
+		}
+	}
+
+	if (vma->vm_flags & VM_EXEC)
+		/* Loop 4K of the I-cache */
+		for (addr = CACHE_IC_ADDRESS_ARRAY|(address&0x1000);
+		     addr < ((CACHE_IC_ADDRESS_ARRAY|(address&0x1000))
+			     +(CACHE_IC_NUM_ENTRIES/2<<CACHE_IC_ENTRY_SHIFT));
+		     addr += (1<<CACHE_IC_ENTRY_SHIFT)) {
+			data = ctrl_inl(addr)&(0x1ffff000|CACHE_VALID);
+			if (data == phys)
+				ctrl_outl(0, addr);
+		}
+	back_to_P1();
+	restore_flags(flags);
+}
+
+/*
+ * clear_user_page
+ * @to: P1 address
+ * @address: U0 address to be mapped
+ */
+void clear_user_page(void *to, unsigned long address)
+{
+	struct page *page = virt_to_page(to);
+
+	__set_bit(PG_mapped, &page->flags);
+	if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0)
+		clear_page(to);
+	else {
+		pgprot_t pgprot = __pgprot(_PAGE_PRESENT | 
+					   _PAGE_RW | _PAGE_CACHABLE |
+					   _PAGE_DIRTY | _PAGE_ACCESSED | 
+					   _PAGE_HW_SHARED | _PAGE_FLAGS_HARD);
+		unsigned long phys_addr = PHYSADDR(to);
+		unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS);
+		pgd_t *dir = pgd_offset_k(p3_addr);
+		pmd_t *pmd = pmd_offset(dir, p3_addr);
+		pte_t *pte = pte_offset(pmd, p3_addr);
+		pte_t entry;
+		unsigned long flags;
+
+		entry = mk_pte_phys(phys_addr, pgprot);
+		down(&p3map_sem[(address & CACHE_ALIAS)>>12]);
+		set_pte(pte, entry);
+		save_and_cli(flags);
+		__flush_tlb_page(get_asid(), p3_addr);
+		restore_flags(flags);
+		update_mmu_cache(NULL, p3_addr, entry);
+		__clear_user_page((void *)p3_addr, to);
+		pte_clear(pte);
+		up(&p3map_sem[(address & CACHE_ALIAS)>>12]);
+	}
+}
+
+/*
+ * copy_user_page
+ * @to: P1 address
+ * @from: P1 address
+ * @address: U0 address to be mapped
+ */
+void copy_user_page(void *to, void *from, unsigned long address)
+{
+	struct page *page = virt_to_page(to);
+
+	__set_bit(PG_mapped, &page->flags);
+	if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0)
+		copy_page(to, from);
+	else {
+		pgprot_t pgprot = __pgprot(_PAGE_PRESENT | 
+					   _PAGE_RW | _PAGE_CACHABLE |
+					   _PAGE_DIRTY | _PAGE_ACCESSED | 
+					   _PAGE_HW_SHARED | _PAGE_FLAGS_HARD);
+		unsigned long phys_addr = PHYSADDR(to);
+		unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS);
+		pgd_t *dir = pgd_offset_k(p3_addr);
+		pmd_t *pmd = pmd_offset(dir, p3_addr);
+		pte_t *pte = pte_offset(pmd, p3_addr);
+		pte_t entry;
+		unsigned long flags;
+
+		entry = mk_pte_phys(phys_addr, pgprot);
+		down(&p3map_sem[(address & CACHE_ALIAS)>>12]);
+		set_pte(pte, entry);
+		save_and_cli(flags);
+		__flush_tlb_page(get_asid(), p3_addr);
+		restore_flags(flags);
+		update_mmu_cache(NULL, p3_addr, entry);
+		__copy_user_page((void *)p3_addr, from, to);
+		pte_clear(pte);
+		up(&p3map_sem[(address & CACHE_ALIAS)>>12]);
+	}
+}
diff -u --recursive --new-file v2.4.9/linux/arch/sh/mm/cache.c linux/arch/sh/mm/cache.c
--- v2.4.9/linux/arch/sh/mm/cache.c	Tue Jul  3 17:08:19 2001
+++ linux/arch/sh/mm/cache.c	Wed Dec 31 16:00:00 1969
@@ -1,524 +0,0 @@
-/* $Id: cache.c,v 1.10 2000/03/07 11:58:34 gniibe Exp $
- *
- *  linux/arch/sh/mm/cache.c
- *
- * Copyright (C) 1999, 2000  Niibe Yutaka
- *
- */
-
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/mman.h>
-#include <linux/mm.h>
-#include <linux/threads.h>
-#include <asm/page.h>
-#include <asm/pgtable.h>
-#include <asm/processor.h>
-#include <asm/cache.h>
-#include <asm/io.h>
-#include <asm/uaccess.h>
-
-#if defined(__sh3__)
-#define CCR		0xffffffec	/* Address of Cache Control Register */
-#define CCR_CACHE_VAL	0x00000005	/* 8k-byte cache, P1-wb, enable */
-#define CCR_CACHE_INIT	0x0000000d	/* 8k-byte cache, CF, P1-wb, enable */
-#define CCR_CACHE_ENABLE	 1
-
-#define CACHE_IC_ADDRESS_ARRAY 0xf0000000 /* SH-3 has unified cache system */
-#define CACHE_OC_ADDRESS_ARRAY 0xf0000000
-#define CACHE_VALID	  1
-#define CACHE_UPDATED	  2
-
-/* 7709A/7729 has 16K cache (256-entry), while 7702 has only 2K(direct)
-   7702 is not supported (yet) */
-struct _cache_system_info {
-	int way_shift;
-	int entry_mask;
-	int num_entries;
-};
-
-/* Data at BSS is cleared after setting this variable.
-   So, we Should not placed this variable at BSS section.
-   Initialize this, it is placed at data section. */
-static struct _cache_system_info cache_system_info = {0,};
-
-#define CACHE_OC_WAY_SHIFT	(cache_system_info.way_shift)
-#define CACHE_IC_WAY_SHIFT	(cache_system_info.way_shift)
-#define CACHE_OC_ENTRY_SHIFT    4
-#define CACHE_OC_ENTRY_MASK	(cache_system_info.entry_mask)
-#define CACHE_IC_ENTRY_MASK	(cache_system_info.entry_mask)
-#define CACHE_OC_NUM_ENTRIES	(cache_system_info.num_entries)
-#define CACHE_OC_NUM_WAYS	4
-#define CACHE_IC_NUM_WAYS	4
-#elif defined(__SH4__)
-#define CCR		 0xff00001c	/* Address of Cache Control Register */
-#define CCR_CACHE_VAL	 0x00000105	/* 8k+16k-byte cache,P1-wb,enable */
-#define CCR_CACHE_INIT	 0x0000090d	/* ICI,ICE(8k), OCI,P1-wb,OCE(16k) */
-#define CCR_CACHE_ENABLE 0x00000101
-
-#define CACHE_IC_ADDRESS_ARRAY 0xf0000000
-#define CACHE_OC_ADDRESS_ARRAY 0xf4000000
-#define CACHE_VALID	  1
-#define CACHE_UPDATED	  2
-
-#define CACHE_OC_WAY_SHIFT       13
-#define CACHE_IC_WAY_SHIFT       13
-#define CACHE_OC_ENTRY_SHIFT      5
-#define CACHE_IC_ENTRY_SHIFT      5
-#define CACHE_OC_ENTRY_MASK		0x3fe0
-#define CACHE_OC_ENTRY_PHYS_MASK	0x0fe0
-#define CACHE_IC_ENTRY_MASK		0x1fe0
-#define CACHE_IC_NUM_ENTRIES	256
-#define CACHE_OC_NUM_ENTRIES	512
-#define CACHE_OC_NUM_WAYS	  1
-#define CACHE_IC_NUM_WAYS	  1
-#endif
-
-
-/*
- * Write back all the cache.
- *
- * For SH-4, we only need to flush (write back) Operand Cache,
- * as Instruction Cache doesn't have "updated" data.
- *
- * Assumes that this is called in interrupt disabled context, and P2.
- * Shuld be INLINE function.
- */
-static inline void cache_wback_all(void)
-{
-	unsigned long addr, data, i, j;
-
-	for (i=0; i<CACHE_OC_NUM_ENTRIES; i++) {
-		for (j=0; j<CACHE_OC_NUM_WAYS; j++) {
-			addr = CACHE_OC_ADDRESS_ARRAY|(j<<CACHE_OC_WAY_SHIFT)|
-				(i<<CACHE_OC_ENTRY_SHIFT);
-			data = ctrl_inl(addr);
-			if ((data & (CACHE_UPDATED|CACHE_VALID))
-			    == (CACHE_UPDATED|CACHE_VALID)) {
-				data &= ~CACHE_UPDATED;
-				ctrl_outl(data, addr);
-			}
-		}
-	}
-}
-
-static void __init
-detect_cpu_and_cache_system(void)
-{
-#if defined(__sh3__)
-	unsigned long addr0, addr1, data0, data1, data2, data3;
-
-	jump_to_P2();
-	/*
-	 * Check if the entry shadows or not.
-	 * When shadowed, it's 128-entry system.
-	 * Otherwise, it's 256-entry system.
-	 */
-	addr0 = CACHE_OC_ADDRESS_ARRAY + (3 << 12);
-	addr1 = CACHE_OC_ADDRESS_ARRAY + (1 << 12);
-
-	/* First, write back & invalidate */
-	data0  = ctrl_inl(addr0);
-	ctrl_outl(data0&~(CACHE_VALID|CACHE_UPDATED), addr0);
-	data1  = ctrl_inl(addr1);
-	ctrl_outl(data1&~(CACHE_VALID|CACHE_UPDATED), addr1);
-
-	/* Next, check if there's shadow or not */
-	data0 = ctrl_inl(addr0);
-	data0 ^= CACHE_VALID;
-	ctrl_outl(data0, addr0);
-	data1 = ctrl_inl(addr1);
-	data2 = data1 ^ CACHE_VALID;
-	ctrl_outl(data2, addr1);
-	data3 = ctrl_inl(addr0);
-
-	/* Lastly, invaliate them. */
-	ctrl_outl(data0&~CACHE_VALID, addr0);
-	ctrl_outl(data2&~CACHE_VALID, addr1);
-	back_to_P1();
-
-	if (data0 == data1 && data2 == data3) {	/* Shadow */
-		cache_system_info.way_shift = 11;
-		cache_system_info.entry_mask = 0x7f0;
-		cache_system_info.num_entries = 128;
-		cpu_data->type = CPU_SH7708;
-	} else {				/* 7709A or 7729  */
-		cache_system_info.way_shift = 12;
-		cache_system_info.entry_mask = 0xff0;
-		cache_system_info.num_entries = 256;
-		cpu_data->type = CPU_SH7729;
-	}
-#elif defined(__SH4__)
-#ifdef CONFIG_CPU_SUBTYPE_ST40STB1
-	cpu_data->type = CPU_ST40STB1;
-#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || \
-      defined(CONFIG_CPU_SUBTYPE_SH7751)
-	cpu_data->type = CPU_SH7750;
-#else
-#error Unknown SH4 CPU type
-#endif
-#endif
-}
-
-void __init cache_init(void)
-{
-	unsigned long ccr;
-
-	detect_cpu_and_cache_system();
-
-	ccr = ctrl_inl(CCR);
-	jump_to_P2();
-	if (ccr & CCR_CACHE_ENABLE)
-		/*
-		 * XXX: Should check RA here. 
-		 * If RA was 1, we only need to flush the half of the caches.
-		 */
-		cache_wback_all();
-
-	ctrl_outl(CCR_CACHE_INIT, CCR);
-	back_to_P1();
-}
-
-#if defined(__SH4__)
-/*
- * SH-4 has virtually indexed and physically tagged cache.
- */
-
-/*
- * Write back the dirty D-caches, but not invalidate them.
- *
- * START, END: Virtual Address
- */
-static void dcache_wback_range(unsigned long start, unsigned long end)
-{
-	unsigned long v;
-
-	start &= ~(L1_CACHE_BYTES-1);
-	for (v = start; v < end; v+=L1_CACHE_BYTES) {
-		asm volatile("ocbwb	%0"
-			     : /* no output */
-			     : "m" (__m(v)));
-	}
-}
-
-/*
- * Invalidate I-caches.
- *
- * START, END: Virtual Address
- *
- */
-static void icache_purge_range(unsigned long start, unsigned long end)
-{
-	unsigned long addr, data, v;
-
-	start &= ~(L1_CACHE_BYTES-1);
-
-	jump_to_P2();
-	/*
-	 * To handle the cache-line, we calculate the entry with virtual
-	 * address: entry = vaddr & CACHE_IC_ENTRY_MASK.
-	 *
-	 * With A-bit "on", data written to is translated by MMU and
-	 * compared the tag of cache and if it's not matched, nothing
-	 * will be occurred.  (We can avoid flushing other caches.)
-	 * 
-	 * NOTE: We can use A-bit feature here, because we have valid
-	 * entriy in TLB (at least in UTLB), as dcache_wback_range is
-	 * called before this function is called.
-	 */
-	for (v = start; v < end; v+=L1_CACHE_BYTES) {
-		addr = CACHE_IC_ADDRESS_ARRAY |	(v&CACHE_IC_ENTRY_MASK)
-			| 0x8 /* A-bit */;
-		data = (v&0xfffffc00); /* Valid=0 */
-		ctrl_outl(data, addr);
-	}
-	back_to_P1();
-}
-
-/*
- * Write back the range of D-cache, and purge the I-cache.
- *
- * Called from sh/kernel/signal.c, after accessing the memory
- * through U0 area.  START and END is the address of U0.
- */
-void flush_icache_range(unsigned long start, unsigned long end)
-{
-	unsigned long flags;
-
-	save_and_cli(flags);
-	dcache_wback_range(start, end);
-	icache_purge_range(start, end);
-	restore_flags(flags);
-}
-
-/*
- * Write back the D-cache and purge the I-cache for signal trampoline. 
- */
-void flush_cache_sigtramp(unsigned long addr)
-{
-	unsigned long v, index;
-
-	v = addr & ~(L1_CACHE_BYTES-1);
-	asm volatile("ocbwb	%0"
-		     : /* no output */
-		     : "m" (__m(v)));
-
-	index = CACHE_IC_ADDRESS_ARRAY| (v&CACHE_IC_ENTRY_MASK);
-	ctrl_outl(0, index);	/* Clear out Valid-bit */
-}
-
-/*
- * Invalidate the I-cache of the page (don't need to write back D-cache).
- *
- * Called from kernel/ptrace.c, mm/memory.c after flush_page_to_ram is called.
- */
-void flush_icache_page(struct vm_area_struct *vma, struct page *pg)
-{
-	unsigned long phys, addr, data, i;
-
-	/* Physical address of this page */
-	phys = (pg - mem_map)*PAGE_SIZE + __MEMORY_START;
-
-	jump_to_P2();
-	/* Loop all the I-cache */
-	for (i=0; i<CACHE_IC_NUM_ENTRIES; i++) {
-		addr = CACHE_IC_ADDRESS_ARRAY| (i<<CACHE_IC_ENTRY_SHIFT);
-		data = ctrl_inl(addr);
-		if ((data & CACHE_VALID) && (data&PAGE_MASK) == phys) {
-			data &= ~CACHE_VALID;
-			ctrl_outl(data, addr);
-		}
-	}
-	back_to_P1();
-}
-
-/*
- * Write back & invalidate the D-cache of the page.
- * (To avoid "alias" issues)
- */
-void flush_dcache_page(struct page *pg)
-{
-	unsigned long phys, addr, data, i;
-
-	/* Physical address of this page */
-	phys = (pg - mem_map)*PAGE_SIZE + __MEMORY_START;
-
-	jump_to_P2();
-	/* Loop all the D-cache */
-	for (i=0; i<CACHE_OC_NUM_ENTRIES; i++) {
-		addr = CACHE_OC_ADDRESS_ARRAY| (i<<CACHE_OC_ENTRY_SHIFT);
-		data = ctrl_inl(addr);
-		if ((data & CACHE_VALID) && (data&PAGE_MASK) == phys) {
-			data &= ~(CACHE_VALID|CACHE_UPDATED);
-			ctrl_outl(data, addr);
-		}
-	}
-	back_to_P1();
-}
-
-void flush_cache_all(void)
-{
-	unsigned long addr, data, i;
-	unsigned long flags;
-
-	save_and_cli(flags);
-	jump_to_P2();
-
-	/* Loop all the D-cache */
-	for (i=0; i<CACHE_OC_NUM_ENTRIES; i++) {
-		addr = CACHE_OC_ADDRESS_ARRAY|(i<<CACHE_OC_ENTRY_SHIFT);
-		data = ctrl_inl(addr);
-		if (data & CACHE_VALID) {
-			data &= ~(CACHE_UPDATED|CACHE_VALID);
-			ctrl_outl(data, addr);
-		}
-	}
-
-	/* Loop all the I-cache */
-	for (i=0; i<CACHE_IC_NUM_ENTRIES; i++) {
-		addr = CACHE_IC_ADDRESS_ARRAY| (i<<CACHE_IC_ENTRY_SHIFT);
-		data = ctrl_inl(addr);
-		if (data & CACHE_VALID) {
-			data &= ~CACHE_VALID;
-			ctrl_outl(data, addr);
-		}
-	}
-
-	back_to_P1();
-	restore_flags(flags);
-}
-
-void flush_cache_mm(struct mm_struct *mm)
-{
-	/* Is there any good way? */
-	/* XXX: possibly call flush_cache_range for each vm area */
-	flush_cache_all();
-}
-
-/*
- * Write back and invalidate D-caches.
- *
- * START, END: Virtual Address (U0 address)
- *
- * NOTE: We need to flush the _physical_ page entry.
- * Flushing the cache lines for U0 only isn't enough.
- * We need to flush for P1 too, which may contain aliases.
- */
-void flush_cache_range(struct mm_struct *mm, unsigned long start,
-		       unsigned long end)
-{
-	/*
-	 * We could call flush_cache_page for the pages of these range,
-	 * but it's not efficient (scan the caches all the time...).
-	 *
-	 * We can't use A-bit magic, as there's the case we don't have
-	 * valid entry on TLB.
-	 */
-	flush_cache_all();
-}
-
-/*
- * Write back and invalidate D-caches for the page.
- *
- * ADDR: Virtual Address (U0 address)
- *
- * NOTE: We need to flush the _physical_ page entry.
- * Flushing the cache lines for U0 only isn't enough.
- * We need to flush for P1 too, which may contain aliases.
- */
-void flush_cache_page(struct vm_area_struct *vma, unsigned long addr)
-{
-	pgd_t *dir;
-	pmd_t *pmd;
-	pte_t *pte;
-	pte_t entry;
-	unsigned long phys;
-	struct page *pg;
-
-	dir = pgd_offset(vma->vm_mm, addr);
-	pmd = pmd_offset(dir, addr);
-	if (pmd_none(*pmd))
-		return;
-	if (pmd_bad(*pmd))
-		return;
-	pte = pte_offset(pmd, addr);
-	entry = *pte;
-	if (pte_none(entry) || !pte_present(entry))
-		return;
-	phys = pte_val(entry)&PAGE_MASK;
-	pg = virt_to_page(__va(phys));
-	flush_dcache_page(pg);
-}
-
-/*
- * Write-back & invalidate the cache.
- *
- * After accessing the memory from kernel space (P1-area), we need to 
- * write back the cache line.
- *
- * We search the D-cache to see if we have the entries corresponding to
- * the page, and if found, write back them.
- */
-void __flush_page_to_ram(void *kaddr)
-{
-	unsigned long phys, addr, data, i;
-
-	/* Physical address of this page */
-	phys = PHYSADDR(kaddr);
-
-	jump_to_P2();
-	/* Loop all the D-cache */
-	for (i=0; i<CACHE_OC_NUM_ENTRIES; i++) {
-		addr = CACHE_OC_ADDRESS_ARRAY| (i<<CACHE_OC_ENTRY_SHIFT);
-		data = ctrl_inl(addr);
-		if ((data & CACHE_VALID) && (data&PAGE_MASK) == phys) {
-			data &= ~(CACHE_UPDATED|CACHE_VALID);
-			ctrl_outl(data, addr);
-		}
-	}
-	back_to_P1();
-}
-
-void flush_page_to_ram(struct page *pg)
-{
-	unsigned long phys;
-
-	/* Physical address of this page */
-	phys = (pg - mem_map)*PAGE_SIZE + __MEMORY_START;
-	__flush_page_to_ram(phys_to_virt(phys));
-}
-
-/*
- * Check entries of the I-cache & D-cache of the page.
- * (To see "alias" issues)
- */
-void check_cache_page(struct page *pg)
-{
-	unsigned long phys, addr, data, i;
-	unsigned long kaddr;
-	unsigned long cache_line_index;
-	int bingo = 0;
-
-	/* Physical address of this page */
-	phys = (pg - mem_map)*PAGE_SIZE + __MEMORY_START;
-	kaddr = phys + PAGE_OFFSET;
-	cache_line_index = (kaddr&CACHE_OC_ENTRY_MASK)>>CACHE_OC_ENTRY_SHIFT;
-
-	jump_to_P2();
-	/* Loop all the D-cache */
-	for (i=0; i<CACHE_OC_NUM_ENTRIES; i++) {
-		addr = CACHE_OC_ADDRESS_ARRAY| (i<<CACHE_OC_ENTRY_SHIFT);
-		data = ctrl_inl(addr);
-		if ((data & (CACHE_UPDATED|CACHE_VALID))
-		    == (CACHE_UPDATED|CACHE_VALID)
-		    && (data&PAGE_MASK) == phys) {
-			data &= ~(CACHE_VALID|CACHE_UPDATED);
-			ctrl_outl(data, addr);
-			if ((i^cache_line_index)&0x180)
-				bingo = 1;
-		}
-	}
-
-	cache_line_index &= 0xff;
-	/* Loop all the I-cache */
-	for (i=0; i<CACHE_IC_NUM_ENTRIES; i++) {
-		addr = CACHE_IC_ADDRESS_ARRAY| (i<<CACHE_IC_ENTRY_SHIFT);
-		data = ctrl_inl(addr);
-		if ((data & CACHE_VALID) && (data&PAGE_MASK) == phys) {
-			data &= ~CACHE_VALID;
-			ctrl_outl(data, addr);
-			if (((i^cache_line_index)&0x80))
-				bingo = 2;
-		}
-	}
-	back_to_P1();
-
-	if (bingo) {
-		extern void dump_stack(void);
-
-		if (bingo ==1)
-			printk("BINGO!\n");
-		else
-			printk("Bingo!\n");
-		dump_stack();
-		printk("--------------------\n");
-	}
-}
-
-/* Page is 4K, OC size is 16K, there are four lines. */
-#define CACHE_ALIAS 0x00003000
-
-void clear_user_page(void *to, unsigned long address)
-{
-	clear_page(to);
-	if (((address ^ (unsigned long)to) & CACHE_ALIAS))
-		__flush_page_to_ram(to);
-}
-
-void copy_user_page(void *to, void *from, unsigned long address)
-{
-	copy_page(to, from);
-	if (((address ^ (unsigned long)to) & CACHE_ALIAS))
-		__flush_page_to_ram(to);
-}
-#endif
diff -u --recursive --new-file v2.4.9/linux/arch/sh/mm/clear_page.S linux/arch/sh/mm/clear_page.S
--- v2.4.9/linux/arch/sh/mm/clear_page.S	Wed Dec 31 16:00:00 1969
+++ linux/arch/sh/mm/clear_page.S	Sat Sep  8 12:29:09 2001
@@ -0,0 +1,52 @@
+/* $Id: clear_page.S,v 1.1 2001/07/23 10:08:50 gniibe Exp $
+ *
+ * clear_page implementation of SuperH
+ *
+ * Copyright (C) 2001  Niibe Yutaka & Kaz Kojima
+ *
+ */
+
+/*
+ * clear_page
+ * @to: P1 address
+ *
+ * void clear_page(void *to)
+ */
+
+/*
+ * r0 --- scratch
+ * r4 --- to
+ * r5 --- to + 4096
+ */
+#include <linux/linkage.h>
+ENTRY(clear_page)
+	mov	r4,r5
+	mov.w	.Llimit,r0
+	add	r0,r5
+	mov	#0,r0
+	!
+1:
+#if defined(__sh3__)
+	mov.l	r0,@r4
+#elif defined(__SH4__)
+	movca.l	r0,@r4
+	mov	r4,r1
+#endif
+	add	#32,r4
+	mov.l	r0,@-r4
+	mov.l	r0,@-r4
+	mov.l	r0,@-r4
+	mov.l	r0,@-r4
+	mov.l	r0,@-r4
+	mov.l	r0,@-r4
+	mov.l	r0,@-r4
+#if defined(__SH4__)
+	ocbwb	@r1
+#endif
+	cmp/eq	r5,r4
+	bf/s	1b
+	 add	#28,r4
+	!
+	rts
+	 nop
+.Llimit:	.word	(4096-28)
diff -u --recursive --new-file v2.4.9/linux/arch/sh/mm/copy_page.S linux/arch/sh/mm/copy_page.S
--- v2.4.9/linux/arch/sh/mm/copy_page.S	Wed Dec 31 16:00:00 1969
+++ linux/arch/sh/mm/copy_page.S	Sat Sep  8 12:29:09 2001
@@ -0,0 +1,69 @@
+/* $Id: copy_page.S,v 1.2 2001/07/23 10:27:25 gniibe Exp $
+ *
+ * copy_page implementation of SuperH
+ *
+ * Copyright (C) 2001  Niibe Yutaka & Kaz Kojima
+ *
+ */
+
+/*
+ * copy_page
+ * @to: P1 address
+ * @from: P1 address
+ *
+ * void copy_page(void *to, void *from)
+ */
+
+/*
+ * r0, r1, r2, r3, r4, r5, r6, r7 --- scratch 
+ * r8 --- from + 4096
+ * r9 --- not used
+ * r10 --- to
+ * r11 --- from
+ */
+#include <linux/linkage.h>
+ENTRY(copy_page)
+	mov.l	r8,@-r15
+	mov.l	r10,@-r15
+	mov.l	r11,@-r15
+	mov	r4,r10
+	mov	r5,r11
+	mov	r5,r8
+	mov.w	.L4096,r0
+	add	r0,r8
+	!
+1:	mov.l	@r11+,r0
+	mov.l	@r11+,r1
+	mov.l	@r11+,r2
+	mov.l	@r11+,r3
+	mov.l	@r11+,r4
+	mov.l	@r11+,r5
+	mov.l	@r11+,r6
+	mov.l	@r11+,r7
+#if defined(__sh3__)
+	mov.l	r0,@r10
+#elif defined(__SH4__)
+	movca.l	r0,@r10
+	mov	r10,r0
+#endif
+	add	#32,r10
+	mov.l	r7,@-r10
+	mov.l	r6,@-r10
+	mov.l	r5,@-r10
+	mov.l	r4,@-r10
+	mov.l	r3,@-r10
+	mov.l	r2,@-r10
+	mov.l	r1,@-r10
+#if defined(__SH4__)
+	ocbwb	@r0
+#endif
+	cmp/eq	r11,r8
+	bf/s	1b
+	 add	#28,r10
+	!
+	mov.l	@r15+,r11
+	mov.l	@r15+,r10
+	mov.l	@r15+,r8
+	rts
+	 nop
+.L4096:	.word	4096
diff -u --recursive --new-file v2.4.9/linux/arch/sh/mm/extable.c linux/arch/sh/mm/extable.c
--- v2.4.9/linux/arch/sh/mm/extable.c	Wed Apr 11 21:24:52 2001
+++ linux/arch/sh/mm/extable.c	Sat Sep  8 12:29:09 2001
@@ -1,4 +1,4 @@
-/* $Id: extable.c,v 1.1 1999/09/18 16:57:37 gniibe Exp $
+/* $Id: extable.c,v 1.2 2001/03/31 10:43:18 gniibe Exp $
  *
  * linux/arch/sh/mm/extable.c
  *  Taken from:
diff -u --recursive --new-file v2.4.9/linux/arch/sh/mm/fault.c linux/arch/sh/mm/fault.c
--- v2.4.9/linux/arch/sh/mm/fault.c	Tue Jul  3 17:08:19 2001
+++ linux/arch/sh/mm/fault.c	Sat Sep  8 12:29:09 2001
@@ -1,4 +1,4 @@
-/* $Id: fault.c,v 1.13 2000/03/07 12:05:24 gniibe Exp $
+/* $Id: fault.c,v 1.48 2001/08/09 00:27:04 gniibe Exp $
  *
  *  linux/arch/sh/mm/fault.c
  *  Copyright (C) 1999  Niibe Yutaka
@@ -28,10 +28,6 @@
 #include <asm/mmu_context.h>
 
 extern void die(const char *,struct pt_regs *,long);
-static void __flush_tlb_page(unsigned long asid, unsigned long page);
-#if defined(__SH4__)
-static void __flush_tlb_phys(unsigned long phys);
-#endif
 
 /*
  * Ugly, ugly, but the goto's result in better assembly..
@@ -242,8 +238,10 @@
 	pte_t *pte;
 	pte_t entry;
 
-	if (address >= VMALLOC_START && address < VMALLOC_END)
+	if (address >= P3SEG && address < P4SEG)
 		dir = pgd_offset_k(address);
+	else if (address >= TASK_SIZE)
+		return 1;
 	else
 		dir = pgd_offset(current->mm, address);
 
@@ -257,7 +255,7 @@
 	}
 	pte = pte_offset(pmd, address);
 	entry = *pte;
-	if (pte_none(entry) || !pte_present(entry)
+	if (pte_none(entry) || pte_not_present(entry)
 	    || (writeaccess && !pte_write(entry)))
 		return 1;
 
@@ -283,27 +281,24 @@
 	unsigned long pteval;
 	unsigned long vpn;
 #if defined(__SH4__)
+	struct page *page;
 	unsigned long ptea;
 #endif
 
-	save_and_cli(flags);
-#if defined(__SH4__)
-	if (pte_shared(pte)) {
-		struct page *pg;
+	/* Ptrace may call this routine. */
+	if (vma && current->active_mm != vma->vm_mm)
+		return;
 
-		pteval = pte_val(pte);
-		pteval &= PAGE_MASK; /* Physicall page address */
-		__flush_tlb_phys(pteval);
-		pg = virt_to_page(__va(pteval));
-		flush_dcache_page(pg);
+#if defined(__SH4__)
+	page = pte_page(pte);
+	if (VALID_PAGE(page) && !test_bit(PG_mapped, &page->flags)) {
+		unsigned long phys = pte_val(pte) & PTE_PHYS_MASK;
+		__flush_wback_region((void *)P1SEGADDR(phys), PAGE_SIZE);
+		__set_bit(PG_mapped, &page->flags);
 	}
 #endif
 
-	/* Ptrace may call this routine. */
-	if (vma && current->active_mm != vma->vm_mm) {
-		restore_flags(flags);
-		return;
-	}
+	save_and_cli(flags);
 
 	/* Set PTEH register */
 	vpn = (address & MMU_VPN_MASK) | get_asid();
@@ -327,7 +322,7 @@
 	restore_flags(flags);
 }
 
-static void __flush_tlb_page(unsigned long asid, unsigned long page)
+void __flush_tlb_page(unsigned long asid, unsigned long page)
 {
 	unsigned long addr, data;
 
@@ -349,40 +344,6 @@
 	back_to_P1();
 #endif
 }
-
-#if defined(__SH4__)
-static void __flush_tlb_phys(unsigned long phys)
-{
-	unsigned long addr, data, pte;
-
-	pte = phys | MMU_UTLB_VALID;
-	for (addr = MMU_UTLB_DATA_ARRAY;
-	     addr < MMU_UTLB_DATA_ARRAY+(MMU_UTLB_ENTRIES<<MMU_U_ENTRY_SHIFT);
-	     addr += (1<<MMU_U_ENTRY_SHIFT)) {
-		data = ctrl_inl(addr);
-		if ((data & (MMU_UTLB_VALID|PAGE_MASK)) == pte) {
-			data &= ~MMU_UTLB_VALID;
-			jump_to_P2();
-			ctrl_outl(data, addr);
-			back_to_P1();
-			break;
-		}
-	}
-	pte = phys | MMU_ITLB_VALID;
-	for (addr = MMU_ITLB_DATA_ARRAY;
-	     addr < MMU_ITLB_DATA_ARRAY+(MMU_ITLB_ENTRIES<<MMU_I_ENTRY_SHIFT);
-	     addr += (1<<MMU_I_ENTRY_SHIFT)) {
-		data = ctrl_inl(addr);
-		if ((data & (MMU_ITLB_VALID|PAGE_MASK)) == pte) {
-			data &= ~MMU_ITLB_VALID;
-			jump_to_P2();
-			ctrl_outl(data, addr);
-			back_to_P1();
-			break;
-		}
-	}
-}
-#endif
 
 void flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
 {
diff -u --recursive --new-file v2.4.9/linux/arch/sh/mm/init.c linux/arch/sh/mm/init.c
--- v2.4.9/linux/arch/sh/mm/init.c	Tue Jul  3 17:08:19 2001
+++ linux/arch/sh/mm/init.c	Sat Sep  8 12:29:09 2001
@@ -1,4 +1,4 @@
-/* $Id: init.c,v 1.17 2000-04-08 15:38:54+09 gniibe Exp $
+/* $Id: init.c,v 1.18 2001/08/03 11:22:06 gniibe Exp $
  *
  *  linux/arch/sh/mm/init.c
  *
@@ -40,35 +40,14 @@
  */
 unsigned long mmu_context_cache;
 
+#ifdef CONFIG_DISCONTIGMEM
+pg_data_t discontig_page_data[NR_NODES];
+bootmem_data_t discontig_node_bdata[NR_NODES];
+#endif
+
 static unsigned long totalram_pages;
 static unsigned long totalhigh_pages;
 
-extern unsigned long init_smp_mappings(unsigned long);
-
-extern unsigned long empty_zero_page[1024];
-
-int do_check_pgt_cache(int low, int high)
-{
-	int freed = 0;
-	if (pgtable_cache_size > high) {
-		do {
-			if (pgd_quicklist) {
-				free_pgd_slow(get_pgd_fast());
-				freed++;
-			}
-			if (pmd_quicklist) {
-				pmd_free_slow(pmd_alloc_one_fast(NULL, 0));
-				freed++;
-			}
-			if (pte_quicklist) {
-				pte_free_slow(pte_alloc_one_fast(NULL, 0));
-				freed++;
-			}
-		} while (pgtable_cache_size > low);
-	}
-	return freed;
-}
-
 void show_mem(void)
 {
 	int i, total = 0, reserved = 0;
@@ -91,7 +70,6 @@
 	printk("%d reserved pages\n",reserved);
 	printk("%d pages shared\n",shared);
 	printk("%d pages swap cached\n",cached);
-	printk("%ld pages in page table cache\n",pgtable_cache_size);
 	show_buffers();
 }
 
@@ -146,12 +124,18 @@
 			zones_size[ZONE_DMA] = max_dma - start_pfn;
 			zones_size[ZONE_NORMAL] = low - max_dma;
 		}
-		free_area_init_node(0, 0, 0, zones_size, __MEMORY_START, 0);
+		free_area_init_node(0, NODE_DATA(0), 0, zones_size, __MEMORY_START, 0);
+#ifdef CONFIG_DISCONTIGMEM
+		zones_size[ZONE_DMA] = __MEMORY_SIZE_2ND >> PAGE_SHIFT;
+		zones_size[ZONE_NORMAL] = 0;
+		free_area_init_node(1, NODE_DATA(1), 0, zones_size, __MEMORY_START_2ND, 0);
+#endif
  	}
 }
 
 void __init mem_init(void)
 {
+	extern unsigned long empty_zero_page[1024];
 	int codesize, reservedpages, datasize, initsize;
 	int tmp;
 
@@ -160,10 +144,13 @@
 
 	/* clear the zero-page */
 	memset(empty_zero_page, 0, PAGE_SIZE);
-	flush_page_to_ram(virt_to_page(empty_zero_page));
+	__flush_wback_region(empty_zero_page, PAGE_SIZE);
 
 	/* this will put all low memory onto the freelists */
-	totalram_pages += free_all_bootmem();
+	totalram_pages += free_all_bootmem_node(NODE_DATA(0));
+#ifdef CONFIG_DISCONTIGMEM
+	totalram_pages += free_all_bootmem_node(NODE_DATA(1));
+#endif
 	reservedpages = 0;
 	for (tmp = 0; tmp < num_physpages; tmp++)
 		/*
@@ -182,6 +169,8 @@
 		reservedpages << (PAGE_SHIFT-10),
 		datasize >> 10,
 		initsize >> 10);
+
+	p3_cache_init();
 }
 
 void free_initmem(void)
diff -u --recursive --new-file v2.4.9/linux/arch/sh/mm/ioremap.c linux/arch/sh/mm/ioremap.c
--- v2.4.9/linux/arch/sh/mm/ioremap.c	Wed Apr 11 21:24:52 2001
+++ linux/arch/sh/mm/ioremap.c	Sat Sep  8 12:29:09 2001
@@ -1,4 +1,4 @@
-/* $Id: ioremap.c,v 1.2 1999/11/25 14:00:28 gniibe Exp $
+/* $Id: ioremap.c,v 1.4 2001/06/30 09:18:39 gniibe Exp $
  *
  * arch/sh/mm/ioremap.c
  *
@@ -13,8 +13,8 @@
 #include <asm/io.h>
 #include <asm/pgalloc.h>
 
-static inline void remap_area_pte(pte_t * pte, unsigned long address, unsigned long size,
-	unsigned long phys_addr, unsigned long flags)
+static inline void remap_area_pte(pte_t * pte, unsigned long address,
+	unsigned long size, unsigned long phys_addr, unsigned long flags)
 {
 	unsigned long end;
 	pgprot_t pgprot = __pgprot(_PAGE_PRESENT | _PAGE_RW |
@@ -36,11 +36,11 @@
 		address += PAGE_SIZE;
 		phys_addr += PAGE_SIZE;
 		pte++;
-	} while (address && address < end);
+	} while (address && (address < end));
 }
 
-static inline int remap_area_pmd(pmd_t * pmd, unsigned long address, unsigned long size,
-	unsigned long phys_addr, unsigned long flags)
+static inline int remap_area_pmd(pmd_t * pmd, unsigned long address,
+	unsigned long size, unsigned long phys_addr, unsigned long flags)
 {
 	unsigned long end;
 
@@ -58,19 +58,19 @@
 		remap_area_pte(pte, address, end - address, address + phys_addr, flags);
 		address = (address + PMD_SIZE) & PMD_MASK;
 		pmd++;
-	} while (address && address < end);
+	} while (address && (address < end));
 	return 0;
 }
 
-static int remap_area_pages(unsigned long address, unsigned long phys_addr,
-			    unsigned long size, unsigned long flags)
+int remap_area_pages(unsigned long address, unsigned long phys_addr,
+		     unsigned long size, unsigned long flags)
 {
 	int error;
 	pgd_t * dir;
 	unsigned long end = address + size;
 
 	phys_addr -= address;
-	dir = pgd_offset(&init_mm, address);
+	dir = pgd_offset_k(address);
 	flush_cache_all();
 	if (address >= end)
 		BUG();
@@ -106,7 +106,7 @@
  * have to convert them into an offset in a page-aligned mapping, but the
  * caller shouldn't need to know that small detail.
  */
-void * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags)
+void * p3_ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags)
 {
 	void * addr;
 	struct vm_struct * area;
@@ -150,7 +150,7 @@
 	return (void *) (offset + (char *)addr);
 }
 
-void iounmap(void *addr)
+void p3_iounmap(void *addr)
 {
 	if (addr > high_memory)
 		return vfree((void *) (PAGE_MASK & (unsigned long) addr));
diff -u --recursive --new-file v2.4.9/linux/arch/sh/vmlinux.lds.S linux/arch/sh/vmlinux.lds.S
--- v2.4.9/linux/arch/sh/vmlinux.lds.S	Tue Jul  3 17:08:19 2001
+++ linux/arch/sh/vmlinux.lds.S	Sat Sep  8 12:29:09 2001
@@ -1,4 +1,4 @@
-/* $Id: vmlinux.lds.S,v 1.4 1999/12/23 11:37:45 gniibe Exp $
+/* $Id: vmlinux.lds.in,v 1.5 2001/07/27 11:45:55 gniibe Exp $
  * ld script to make SuperH Linux kernel
  * Written by Niibe Yutaka
  */
@@ -74,7 +74,11 @@
   . = ALIGN(4096);
   .data.page_aligned : { *(.data.idt) }
 
+#ifdef CONFIG_CPU_SH3	
+  . = ALIGN(16);
+#else
   . = ALIGN(32);
+#endif	
   .data.cacheline_aligned : { *(.data.cacheline_aligned) }
 
   . = ALIGN(4);
diff -u --recursive --new-file v2.4.9/linux/arch/sparc/boot/btfixupprep.c linux/arch/sparc/boot/btfixupprep.c
--- v2.4.9/linux/arch/sparc/boot/btfixupprep.c	Sun Oct  4 10:22:42 1998
+++ linux/arch/sparc/boot/btfixupprep.c	Tue Aug 28 07:09:44 2001
@@ -1,4 +1,4 @@
-/* $Id: btfixupprep.c,v 1.5 1998/09/16 12:24:55 jj Exp $
+/* $Id: btfixupprep.c,v 1.6 2001/08/22 15:27:47 davem Exp $
    Simple utility to prepare vmlinux image for sparc.
    Resolves all BTFIXUP uses and settings and creates
    a special .s object to link to the image.
@@ -88,6 +88,16 @@
 	return array + last - 1;
 }
 
+void set_mode (char *buffer)
+{
+  	for (mode = 0;; mode++)
+		if (buffer[mode] < '0' || buffer[mode] > '9')
+			break;
+	if (mode != 8 && mode != 16)
+		fatal();
+}
+
+
 int main(int argc,char **argv)
 {
 	char *p, *q;
@@ -106,14 +116,6 @@
 			goto main0;
 	fatal();
 main0:
-	if (fgets (buffer, 1024, stdin) == NULL || buffer[0] < '0' || buffer[0] > '9')
-		fatal();
-	for (mode = 0;; mode++)
-		if (buffer[mode] < '0' || buffer[mode] > '9')
-			break;
-	if (mode != 8 && mode != 16)
-		fatal();
-	
 	rellen = strlen(relrec);
 	while (fgets (buffer, 1024, stdin) != NULL)
 		if (!strncmp (buffer, relrec, rellen))
@@ -132,6 +134,8 @@
 		int nbase;
 		if (!strncmp (buffer, relrec, rellen))
 			goto main1;
+		if (mode == 0)
+			set_mode (buffer);
 		p = strchr (buffer, '\n');
 		if (p) *p = 0;
 		if (strlen (buffer) < 22+mode)
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/defconfig linux/arch/sparc64/defconfig
--- v2.4.9/linux/arch/sparc64/defconfig	Mon Aug 27 12:41:40 2001
+++ linux/arch/sparc64/defconfig	Fri Sep  7 11:01:20 2001
@@ -255,6 +255,7 @@
 CONFIG_BLK_DEV_IDEPCI=y
 # CONFIG_IDEPCI_SHARE_IRQ is not set
 CONFIG_BLK_DEV_IDEDMA_PCI=y
+CONFIG_BLK_DEV_ADMA=y
 # CONFIG_BLK_DEV_OFFBOARD is not set
 CONFIG_IDEDMA_PCI_AUTO=y
 CONFIG_BLK_DEV_IDEDMA=y
@@ -264,8 +265,8 @@
 # CONFIG_AEC62XX_TUNING is not set
 CONFIG_BLK_DEV_ALI15X3=y
 # CONFIG_WDC_ALI15X3 is not set
-# CONFIG_BLK_DEV_AMD7409 is not set
-# CONFIG_AMD7409_OVERRIDE is not set
+# CONFIG_BLK_DEV_AMD74XX is not set
+# CONFIG_AMD74XX_OVERRIDE is not set
 CONFIG_BLK_DEV_CMD64X=y
 # CONFIG_BLK_DEV_CY82C693 is not set
 # CONFIG_BLK_DEV_CS5530 is not set
@@ -276,7 +277,8 @@
 # CONFIG_BLK_DEV_OPTI621 is not set
 # CONFIG_BLK_DEV_PDC202XX is not set
 # CONFIG_PDC202XX_BURST is not set
-# CONFIG_BLK_DEV_OSB4 is not set
+# CONFIG_PDC202XX_FORCE is not set
+# CONFIG_BLK_DEV_SVWKS is not set
 # CONFIG_BLK_DEV_SIS5513 is not set
 # CONFIG_BLK_DEV_SLC90E66 is not set
 # CONFIG_BLK_DEV_TRM290 is not set
@@ -709,7 +711,10 @@
 CONFIG_USB_STORAGE=m
 # CONFIG_USB_STORAGE_DEBUG is not set
 CONFIG_USB_STORAGE_FREECOM=y
+CONFIG_USB_STORAGE_ISD200=y
 CONFIG_USB_STORAGE_DPCM=y
+CONFIG_USB_STORAGE_HP8200e=y
+CONFIG_USB_STORAGE_SDDR09=y
 CONFIG_USB_ACM=m
 CONFIG_USB_PRINTER=m
 
@@ -740,10 +745,10 @@
 #
 # USB Network adaptors
 #
-CONFIG_USB_PLUSB=m
 CONFIG_USB_PEGASUS=m
 CONFIG_USB_CATC=m
-CONFIG_USB_NET1080=m
+CONFIG_USB_KAWETH=m
+CONFIG_USB_USBNET=m
 
 #
 # USB port drivers
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/kernel/dtlb_backend.S linux/arch/sparc64/kernel/dtlb_backend.S
--- v2.4.9/linux/arch/sparc64/kernel/dtlb_backend.S	Mon Aug 27 12:41:40 2001
+++ linux/arch/sparc64/kernel/dtlb_backend.S	Tue Aug 28 07:09:44 2001
@@ -1,4 +1,4 @@
-/* $Id: dtlb_backend.S,v 1.12 2001/08/13 20:41:54 kanoj Exp $
+/* $Id: dtlb_backend.S,v 1.13 2001/08/17 04:55:09 kanoj Exp $
  * dtlb_backend.S: Back end to DTLB miss replacement strategy.
  *                 This is included directly into the trap table.
  *
@@ -6,11 +6,27 @@
  * Copyright (C) 1997,1998 Jakub Jelinek   (jj@ultra.linux.cz)
  */
 
-#define TAG_CONTEXT_BITS	0x3ff
+#include <asm/pgtable.h>
+
+#if PAGE_SHIFT == 13
+#define FILL_VALID_SZ_BITS1(r1) \
+	 sllx		%g2, 62, r1
+#define FILL_VALID_SZ_BITS2(r1)
+#define FILL_VALID_SZ_BITS_NOP nop
+#else /* PAGE_SHIFT */
+#define FILL_VALID_SZ_BITS1(r1) \
+	or		%g0, 5, r1
+#define FILL_VALID_SZ_BITS2(r1) \
+	sllx		r1, 61, r1
+#define FILL_VALID_SZ_BITS_NOP
+#endif /* PAGE_SHIFT */
+
+#define VPTE_BITS		(_PAGE_CP | _PAGE_CV | _PAGE_P )
 #define VPTE_SHIFT		(PAGE_SHIFT - 3)
-#define PMD_SHIFT		(23 - PAGE_SHIFT + 3)
-#define PGD_SHIFT		(34 - PAGE_SHIFT + 3)
-#define VPTE_BITS		(_PAGE_CP | _PAGE_CV | _PAGE_P)
+#define TLB_PMD_SHIFT		(PAGE_SHIFT - 3 + 3)
+#define TLB_PGD_SHIFT		(PAGE_SHIFT - 2 + PAGE_SHIFT - 3 + 3)
+#define TLB_PMD_MASK		(((1 << PMD_BITS) - 1) << 1)
+#define TLB_PGD_MASK		(((1 << (VA_BITS - PAGE_SHIFT - (PAGE_SHIFT - 3) - PMD_BITS)) - 1) << 2)
 
 /* Ways we can get here:
  *
@@ -31,13 +47,13 @@
 
 /* TLB1 ** ICACHE line 2: Quick VPTE miss	  	*/
 	ldxa		[%g1] ASI_DMMU, %g5		! Doing PGD caching?
-	srlx		%g6, (PMD_SHIFT - 1), %g1	! Position PMD offset
+	srlx		%g6, (TLB_PMD_SHIFT - 1), %g1	! Position PMD offset
 	be,pn		%xcc, sparc64_vpte_nucleus	! Is it from Nucleus?
-	 and		%g1, 0xffe, %g1			! Mask PMD offset bits
+	 and		%g1, TLB_PMD_MASK, %g1		! Mask PMD offset bits
 	brnz,pt		%g5, sparc64_vpte_continue	! Yep, go like smoke
 	 add		%g1, %g1, %g1			! Position PMD offset some more
-	srlx		%g6, (PGD_SHIFT - 2), %g5	! Position PGD offset
-	and		%g5, 0xffc, %g5			! Mask PGD offset
+	srlx		%g6, (TLB_PGD_SHIFT - 2), %g5	! Position PGD offset
+	and		%g5, TLB_PGD_MASK, %g5		! Mask PGD offset
 
 /* TLB1 ** ICACHE line 3: Quick VPTE miss	  	*/
 	lduwa		[%g7 + %g5] ASI_PHYS_USE_EC, %g5! Load PGD
@@ -48,7 +64,8 @@
 	lduwa		[%g5 + %g1] ASI_PHYS_USE_EC, %g5! Load PMD
 	sllx		%g5, 11, %g5			! Shift into place
 	brz,pn		%g5, vpte_noent			! Valid?
-	 sllx		%g2, 62, %g1			! Put _PAGE_VALID into %g1
+	 FILL_VALID_SZ_BITS1(%g1)			! Put _PAGE_VALID into %g1
+	FILL_VALID_SZ_BITS2(%g1)			! Put _PAGE_VALID into %g1
 	or		%g5, VPTE_BITS, %g5		! Prepare VPTE data
 
 /* TLB1 ** ICACHE line 4: Quick VPTE miss	  	*/
@@ -59,10 +76,15 @@
 	retry						! Load PTE once again
 	nop
 	nop
-	nop
+	FILL_VALID_SZ_BITS_NOP
 
-#undef TAG_CONTEXT_BITS
 #undef VPTE_SHIFT
-#undef PMD_SHIFT
-#undef PGD_SHIFT
+#undef TLB_PMD_SHIFT
+#undef TLB_PGD_SHIFT
 #undef VPTE_BITS
+#undef TLB_PMD_MASK
+#undef TLB_PGD_MASK
+#undef FILL_VALID_SZ_BITS1
+#undef FILL_VALID_SZ_BITS2
+#undef FILL_VALID_SZ_BITS_NOP
+
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/kernel/dtlb_base.S linux/arch/sparc64/kernel/dtlb_base.S
--- v2.4.9/linux/arch/sparc64/kernel/dtlb_base.S	Mon Aug 27 12:41:40 2001
+++ linux/arch/sparc64/kernel/dtlb_base.S	Tue Aug 28 07:09:44 2001
@@ -1,4 +1,4 @@
-/* $Id: dtlb_base.S,v 1.10 2001/08/13 20:41:54 kanoj Exp $
+/* $Id: dtlb_base.S,v 1.12 2001/08/17 04:55:09 kanoj Exp $
  * dtlb_base.S:	Front end to DTLB miss replacement strategy.
  *              This is included directly into the trap table.
  *
@@ -6,11 +6,6 @@
  * Copyright (C) 1997,1998 Jakub Jelinek   (jj@ultra.linux.cz)
  */
 
-#define TAG_CONTEXT_BITS	0x3ff
-#define VPTE_SHIFT		(PAGE_SHIFT - 3)
-#define KERN_HIGHBITS		((_PAGE_VALID | _PAGE_SZ4MB) ^ 0xfffff80000000000)
-#define KERN_LOWBITS		(_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_W)
-
 /* %g1	TLB_SFSR	(%g1 + %g1 == TLB_TAG_ACCESS)
  * %g2	(KERN_HIGHBITS | KERN_LOWBITS)
  * %g3  VPTE base	(0xfffffffe00000000)	Spitfire/Blackbird (44-bit VA space)
@@ -48,26 +43,47 @@
  * 4) User space accesses by nucleus at tl0
  */
 
+#if PAGE_SHIFT == 13
+/*
+ * To compute vpte offset, we need to do ((addr >> 13) << 3),
+ * which can be optimized to (addr >> 10) if bits 10/11/12 can
+ * be guaranteed to be 0 ... mmu_context.h does guarantee this
+ * by only using 10 bits in the hwcontext value.
+ */
+#define CREATE_VPTE_OFFSET1(r1, r2)
+#define CREATE_VPTE_OFFSET2(r1, r2) \
+				srax	r1, 10, r2
+#define CREATE_VPTE_NOP		nop
+#else
+#define CREATE_VPTE_OFFSET1(r1, r2) \
+				srax	r1, PAGE_SHIFT, r2
+#define CREATE_VPTE_OFFSET2(r1, r2) \
+				sllx	r2, 3, r2
+#define CREATE_VPTE_NOP
+#endif
+
 /* DTLB ** ICACHE line 1: Quick user TLB misses		*/
 	ldxa		[%g1 + %g1] ASI_DMMU, %g4	! Get TAG_ACCESS
 	andcc		%g4, TAG_CONTEXT_BITS, %g0	! From Nucleus?
 from_tl1_trap:
+	CREATE_VPTE_OFFSET1(%g4, %g6)			! Create VPTE offset
 	be,pn		%xcc, 3f			! Yep, special processing
-	 srax		%g4, VPTE_SHIFT, %g6		! Create VPTE offset
+	 CREATE_VPTE_OFFSET2(%g4, %g6)			! Create VPTE offset
 	ldxa		[%g3 + %g6] ASI_S, %g5		! Load VPTE
 1:	brlz,pt		%g5, 9f				! Valid, load into TLB
 	 nop						! Delay-slot
-	ba,a,pt		%xcc, 4f			! Invalid, branch out
+	ba,a,pt		%xcc, longpath			! Invalid, branch out
 
 /* DTLB ** ICACHE line 2: Quick kernel TLB misses	*/
 3:	brlz,pt		%g4, 9f				! Kernel virtual map?
 	 xor		%g2, %g4, %g5			! Finish bit twiddles
-	ldxa		[%g3 + %g6] ASI_N, %g5		! Yep, load k-vpte
-	ba,pt		%xcc, 1b			! Continue tlb reload
+	ba,pt		%xcc, kvmap			! Yep, go check for obp/vmalloc
 	 nop
+	nop
 9:	stxa		%g5, [%g0] ASI_DTLB_DATA_IN	! Reload TLB
 	retry						! Trap return
-4:	rdpr		%pstate, %g5			! Move into alternate globals
+longpath:
+	rdpr		%pstate, %g5			! Move into alternate globals
 
 /* DTLB ** ICACHE line 3: winfixups+real_faults		*/
 	wrpr		%g5, PSTATE_AG|PSTATE_MG, %pstate
@@ -87,9 +103,8 @@
 	nop
 	nop
 	nop
-	nop
+	CREATE_VPTE_NOP
 
-#undef TAG_CONTEXT_BITS
-#undef VPTE_SHIFT
-#undef KERN_HIGHBITS
-#undef KERN_LOWBITS
+#undef CREATE_VPTE_OFFSET1
+#undef CREATE_VPTE_OFFSET2
+#undef CREATE_VPTE_NOP
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/kernel/entry.S linux/arch/sparc64/kernel/entry.S
--- v2.4.9/linux/arch/sparc64/kernel/entry.S	Mon Aug 27 12:41:40 2001
+++ linux/arch/sparc64/kernel/entry.S	Tue Aug 28 07:09:44 2001
@@ -1,4 +1,4 @@
-/* $Id: entry.S,v 1.129 2001/08/13 20:41:54 kanoj Exp $
+/* $Id: entry.S,v 1.134 2001/08/27 18:42:07 kanoj Exp $
  * arch/sparc64/kernel/entry.S:  Sparc64 trap low-level entry points.
  *
  * Copyright (C) 1995,1997 David S. Miller (davem@caip.rutgers.edu)
@@ -21,7 +21,7 @@
 #include <asm/visasm.h>
 #include <asm/estate.h>
 
-/* #define SYSCALL_TRACING */
+/* #define SYSCALL_TRACING	1 */
 
 #define curptr      g6
 
@@ -32,7 +32,25 @@
 
 	.globl		sparc64_vpte_patchme1
 	.globl		sparc64_vpte_patchme2
+/*
+ * On a second level vpte miss, check whether the original fault is to the OBP 
+ * range (note that this is only possible for instruction miss, data misses to
+ * obp range do not use vpte). If so, go back directly to the faulting address.
+ * This is because we want to read the tpc, otherwise we have no way of knowing
+ * the 8k aligned faulting address if we are using >8k kernel pagesize. This also
+ * ensures no vpte range addresses are dropped into tlb while obp is executing
+ * (see inherit_locked_prom_mappings() rant).
+ */
 sparc64_vpte_nucleus:
+	mov		0xf, %g5
+	sllx		%g5, 28, %g5			! Load 0xf0000000
+	cmp		%g4, %g5			! Is addr >= LOW_OBP_ADDRESS?
+	blu,pn		%xcc, sparc64_vpte_patchme1
+	 mov		0x1, %g5
+	sllx		%g5, 32, %g5			! Load 0x100000000
+	cmp		%g4, %g5			! Is addr < HI_OBP_ADDRESS?
+	blu,pn		%xcc, obp_iaddr_patch
+	 nop
 sparc64_vpte_patchme1:
 	sethi		%hi(0), %g5			! This has to be patched
 sparc64_vpte_patchme2:
@@ -45,6 +63,74 @@
 	stxa		%g4, [%g1 + %g1] ASI_DMMU	! Restore previous TAG_ACCESS
 	done						! Slick trick
 
+	.globl		obp_iaddr_patch
+	.globl		obp_daddr_patch
+
+obp_iaddr_patch:
+	sethi		%hi(0), %g5			! This and following is patched
+	or		%g5, %lo(0), %g5		! g5 now holds obp pmd base physaddr
+	wrpr		%g0, 1, %tl			! Behave as if we are at TL0
+	rdpr		%tpc, %g4			! Find original faulting iaddr
+	srlx		%g4, 13, %g4			! Throw out context bits
+	sllx		%g4, 13, %g4			! g4 has vpn + ctx0 now
+	mov		TLB_SFSR, %g1			! Restore %g1 value
+	stxa		%g4, [%g1 + %g1] ASI_IMMU	! Restore previous TAG_ACCESS
+	srlx		%g4, 23, %g6			! Find pmd number
+	and		%g6, 0x7ff, %g6			! Find pmd number
+	sllx		%g6, 2, %g6			! Find pmd offset
+	lduwa		[%g5 + %g6] ASI_PHYS_USE_EC, %g5! Load pmd, ie pagetable physaddr
+	brz,pn		%g5, longpath			! Kill the PROM ? :-)
+	 sllx		%g5, 11, %g5			! Shift into place
+	srlx		%g4, 13, %g6			! find pte number in pagetable
+	and		%g6, 0x3ff, %g6			! find pte number in pagetable
+	sllx		%g6, 3, %g6			! find pte offset in pagetable
+	ldxa		[%g5 + %g6] ASI_PHYS_USE_EC, %g5! Load pte
+	brgez,pn	%g5, longpath			! Kill the PROM ? :-)
+	 nop
+	stxa		%g5, [%g0] ASI_ITLB_DATA_IN	! put into tlb
+	retry						! go back to original fault
+
+obp_daddr_patch:
+	sethi		%hi(0), %g5			! This and following is patched
+	or		%g5, %lo(0), %g5		! g5 now holds obp pmd base physaddr
+	srlx		%g4, 23, %g6			! Find pmd number
+	and		%g6, 0x7ff, %g6			! Find pmd number
+	sllx		%g6, 2, %g6			! Find pmd offset
+	lduwa		[%g5 + %g6] ASI_PHYS_USE_EC, %g5! Load pmd, ie pagetable physaddr
+	brz,pn		%g5, longpath
+	 sllx		%g5, 11, %g5			! Shift into place
+	srlx		%g4, 13, %g6			! find pte number in pagetable
+	and		%g6, 0x3ff, %g6			! find pte number in pagetable
+	sllx		%g6, 3, %g6			! find pte offset in pagetable
+	ldxa		[%g5 + %g6] ASI_PHYS_USE_EC, %g5! Load pte
+	brgez,pn	%g5, longpath
+	 nop
+	stxa		%g5, [%g0] ASI_DTLB_DATA_IN	! put into tlb
+	retry
+
+/*
+ * On a first level data miss, check whether this is to the OBP range (note that
+ * such accesses can be made by prom, as well as by kernel using prom_getproperty
+ * on "address"), and if so, do not use vpte access ... rather, use information
+ * saved during inherit_prom_mappings() using 8k pagesize.
+ */
+kvmap:
+	mov		0xf, %g5
+	sllx		%g5, 28, %g5			! Load 0xf0000000
+	cmp		%g4, %g5			! Is addr >= LOW_OBP_ADDRESS?
+	blu,pn		%xcc, vmalloc_addr
+	 mov		0x1, %g5
+	sllx		%g5, 32, %g5			! Load 0x100000000
+	cmp		%g4, %g5			! Is addr < HI_OBP_ADDRESS?
+	blu,pn		%xcc, obp_daddr_patch
+	 nop
+vmalloc_addr:						! vmalloc addr accessed
+	ldxa		[%g3 + %g6] ASI_N, %g5		! Yep, load k-vpte
+	brgez,pn	%g5, longpath			! Valid, load into TLB
+	 nop
+	stxa		%g5, [%g0] ASI_DTLB_DATA_IN	! Reload TLB
+	retry
+
 	/* This is trivial with the new code... */
 	.globl		do_fpdis
 do_fpdis:
@@ -1413,9 +1499,8 @@
 	 srl		%i0, 0, %o0				! IEU0
 	sll		%g1, 2, %l4				! IEU0	Group
 #ifdef SYSCALL_TRACING
-	add		%sp, STACK_BIAS + REGWIN_SZ, %o1
 	call		syscall_trace_entry
-	 mov		%g1, %o0
+	 add		%sp, STACK_BIAS + REGWIN_SZ, %o0
 	srl		%i0, 0, %o0
 #endif
 	mov		%i4, %o4				! IEU1
@@ -1442,9 +1527,8 @@
 	 mov		%i0, %o0				! IEU0
 	sll		%g1, 2, %l4				! IEU0	Group
 #ifdef SYSCALL_TRACING
-	add		%sp, STACK_BIAS + REGWIN_SZ, %o1
 	call		syscall_trace_entry
-	 mov		%g1, %o0
+	 add		%sp, STACK_BIAS + REGWIN_SZ, %o0
 	mov		%i0, %o0
 #endif
 	mov		%i1, %o1				! IEU1
@@ -1464,8 +1548,10 @@
 3:	stx		%o0, [%sp + STACK_BIAS + REGWIN_SZ + PT_V9_I0]
 ret_sys_call:
 #ifdef SYSCALL_TRACING
+	mov		%o0, %o1
 	call		syscall_trace_exit
-	 add		%sp, STACK_BIAS + REGWIN_SZ, %o1
+	 add		%sp, STACK_BIAS + REGWIN_SZ, %o0
+	mov		%o1, %o0
 #endif
 	ldx		[%sp + STACK_BIAS + REGWIN_SZ + PT_V9_TSTATE], %g3
 	ldx		[%sp + STACK_BIAS + REGWIN_SZ + PT_V9_TNPC], %l1 ! pc = npc
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/kernel/head.S linux/arch/sparc64/kernel/head.S
--- v2.4.9/linux/arch/sparc64/kernel/head.S	Thu Apr 12 12:10:25 2001
+++ linux/arch/sparc64/kernel/head.S	Fri Sep  7 11:01:20 2001
@@ -1,4 +1,4 @@
-/* $Id: head.S,v 1.77 2001/04/05 12:44:34 davem Exp $
+/* $Id: head.S,v 1.78 2001/08/30 03:22:00 kanoj Exp $
  * head.S: Initial boot code for the Sparc64 port of Linux.
  *
  * Copyright (C) 1996,1997 David S. Miller (davem@caip.rutgers.edu)
@@ -488,13 +488,6 @@
 	call	__bzero
 	 sub	%o1, %o0, %o1
 
-	/* Now clear empty_zero_page */
-	sethi	%hi(8192), %o1
-	or	%o1, %lo(8192), %o1
-	sethi	%hi(KERNBASE), %g3
-	call	__bzero
-	 or	%g3, %lo(KERNBASE), %o0
-
 	mov	%l6, %o1			! OpenPROM stack
 	call	prom_init
 	 mov	%l7, %o0			! OpenPROM cif handler
@@ -647,12 +640,13 @@
 	ret
 	 restore
 
+/*
+ * The following skips make sure the trap table in ttable.S is aligned
+ * on a 32K boundary as required by the v9 specs for TBA register.
+ */
 sparc64_boot_end:
 	.skip	0x2000 + _start - sparc64_boot_end
 bootup_user_stack_end:
-
-	.globl	empty_bad_page
-empty_bad_page:
 	.skip	0x2000
 
 #ifdef CONFIG_SBUS
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/kernel/ioctl32.c linux/arch/sparc64/kernel/ioctl32.c
--- v2.4.9/linux/arch/sparc64/kernel/ioctl32.c	Sun Aug 12 13:27:59 2001
+++ linux/arch/sparc64/kernel/ioctl32.c	Fri Sep  7 11:01:20 2001
@@ -1,4 +1,4 @@
-/* $Id: ioctl32.c,v 1.121 2001/08/03 14:27:21 davem Exp $
+/* $Id: ioctl32.c,v 1.123 2001/09/02 03:52:07 davem Exp $
  * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
  *
  * Copyright (C) 1997-2000  Jakub Jelinek  (jakub@redhat.com)
@@ -3691,6 +3691,8 @@
 COMPATIBLE_IOCTL(BLKFRASET)
 COMPATIBLE_IOCTL(BLKSECTSET)
 COMPATIBLE_IOCTL(BLKSSZGET)
+COMPATIBLE_IOCTL(BLKBSZGET)
+COMPATIBLE_IOCTL(BLKBSZSET)
 
 /* RAID */
 COMPATIBLE_IOCTL(RAID_VERSION)
@@ -3733,6 +3735,7 @@
 COMPATIBLE_IOCTL(KDGKBSENT)
 COMPATIBLE_IOCTL(KDSKBSENT)
 COMPATIBLE_IOCTL(KDGKBDIACR)
+COMPATIBLE_IOCTL(KDKBDREP)
 COMPATIBLE_IOCTL(KDSKBDIACR)
 COMPATIBLE_IOCTL(KDGKBLED)
 COMPATIBLE_IOCTL(KDSKBLED)
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/kernel/iommu_common.c linux/arch/sparc64/kernel/iommu_common.c
--- v2.4.9/linux/arch/sparc64/kernel/iommu_common.c	Mon Jun 19 17:59:38 2000
+++ linux/arch/sparc64/kernel/iommu_common.c	Tue Aug 28 07:09:44 2001
@@ -1,4 +1,4 @@
-/* $Id: iommu_common.c,v 1.4 2000/06/04 21:50:23 anton Exp $
+/* $Id: iommu_common.c,v 1.5 2001/08/24 17:57:51 kanoj Exp $
  * iommu_common.c: UltraSparc SBUS/PCI common iommu code.
  *
  * Copyright (C) 1999 David S. Miller (davem@redhat.com)
@@ -36,12 +36,12 @@
 		unsigned long start, end;
 
 		start = sg[i].dvma_address;
-		start = start & PAGE_MASK;
+		start = start & IO_PAGE_MASK;
 
 		end = sg[i].dvma_address + sg[i].dvma_length;
-		end = (end + (PAGE_SIZE - 1)) & PAGE_MASK;
+		end = (end + (IO_PAGE_SIZE - 1)) & IO_PAGE_MASK;
 
-		pgcount += ((end - start) >> PAGE_SHIFT);
+		pgcount += ((end - start) >> IO_PAGE_SHIFT);
 	}
 
 	if (pgcount != npages) {
@@ -70,7 +70,7 @@
 		unsigned long paddr;
 
 		/* SG and DMA_SG must begin at the same sub-page boundary. */
-		if ((sgaddr & ~PAGE_MASK) != (daddr & ~PAGE_MASK)) {
+		if ((sgaddr & ~IO_PAGE_MASK) != (daddr & ~IO_PAGE_MASK)) {
 			printk("verify_one_map: Wrong start offset "
 			       "sg[%08lx] dma[%08x]\n",
 			       sgaddr, daddr);
@@ -80,10 +80,10 @@
 
 		/* Verify the IOPTE points to the right page. */
 		paddr = iopte_val(*iopte) & IOPTE_PAGE;
-		if ((paddr + PAGE_OFFSET) != (sgaddr & PAGE_MASK)) {
+		if ((paddr + PAGE_OFFSET) != (sgaddr & IO_PAGE_MASK)) {
 			printk("verify_one_map: IOPTE[%08lx] maps the "
 			       "wrong page, should be [%08lx]\n",
-			       iopte_val(*iopte), (sgaddr & PAGE_MASK) - PAGE_OFFSET);
+			       iopte_val(*iopte), (sgaddr & IO_PAGE_MASK) - PAGE_OFFSET);
 			nents = -1;
 			goto out;
 		}
@@ -91,10 +91,10 @@
 		/* If this SG crosses a page, adjust to that next page
 		 * boundary and loop.
 		 */
-		if ((sgaddr & PAGE_MASK) ^ ((sgaddr + sglen - 1) & PAGE_MASK)) {
+		if ((sgaddr & IO_PAGE_MASK) ^ ((sgaddr + sglen - 1) & IO_PAGE_MASK)) {
 			unsigned long next_page, diff;
 
-			next_page = (sgaddr + PAGE_SIZE) & PAGE_MASK;
+			next_page = (sgaddr + IO_PAGE_SIZE) & IO_PAGE_MASK;
 			diff = next_page - sgaddr;
 			sgaddr += diff;
 			daddr += diff;
@@ -109,7 +109,7 @@
 		daddr += sglen;
 		dlen -= sglen;
 
-		if (dlen > 0 && ((daddr & ~PAGE_MASK) == 0))
+		if (dlen > 0 && ((daddr & ~IO_PAGE_MASK) == 0))
 			iopte++;
 
 		sg++;
@@ -175,7 +175,7 @@
 		int i;
 
 		printk("verify_sglist: Crap, messed up mappings, dumping, iodma at %08x.\n",
-		       (u32) (sg->dvma_address & PAGE_MASK));
+		       (u32) (sg->dvma_address & IO_PAGE_MASK));
 		for (i = 0; i < nents; i++) {
 			printk("sg(%d): address(%p) length(%x) "
 			       "dma_address[%08x] dma_length[%08x]\n",
@@ -189,13 +189,6 @@
 }
 #endif
 
-/* Two addresses are "virtually contiguous" if and only if:
- * 1) They are equal, or...
- * 2) They are both on a page boundry
- */
-#define VCONTIG(__X, __Y)	(((__X) == (__Y)) || \
-				 (((__X) | (__Y)) << (64UL - PAGE_SHIFT)) == 0UL)
-
 unsigned long prepare_sg(struct scatterlist *sg, int nents)
 {
 	struct scatterlist *dma_sg = sg;
@@ -204,7 +197,7 @@
 
 	prev  = (unsigned long) sg->address;
 	prev += (unsigned long) (dent_len = sg->length);
-	dent_addr = (u32) ((unsigned long)sg->address & (PAGE_SIZE - 1UL));
+	dent_addr = (u32) ((unsigned long)sg->address & (IO_PAGE_SIZE - 1UL));
 	while (--nents) {
 		unsigned long addr;
 
@@ -217,9 +210,9 @@
 
 			dent_addr = ((dent_addr +
 				      dent_len +
-				      (PAGE_SIZE - 1UL)) >> PAGE_SHIFT);
-			dent_addr <<= PAGE_SHIFT;
-			dent_addr += addr & (PAGE_SIZE - 1UL);
+				      (IO_PAGE_SIZE - 1UL)) >> IO_PAGE_SHIFT);
+			dent_addr <<= IO_PAGE_SHIFT;
+			dent_addr += addr & (IO_PAGE_SIZE - 1UL);
 			dent_len = 0;
 		}
 		dent_len += sg->length;
@@ -230,5 +223,5 @@
 
 	return ((unsigned long) dent_addr +
 		(unsigned long) dent_len +
-		(PAGE_SIZE - 1UL)) >> PAGE_SHIFT;
+		(IO_PAGE_SIZE - 1UL)) >> IO_PAGE_SHIFT;
 }
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/kernel/iommu_common.h linux/arch/sparc64/kernel/iommu_common.h
--- v2.4.9/linux/arch/sparc64/kernel/iommu_common.h	Mon Dec 20 22:05:52 1999
+++ linux/arch/sparc64/kernel/iommu_common.h	Tue Aug 28 07:09:44 2001
@@ -1,4 +1,4 @@
-/* $Id: iommu_common.h,v 1.1 1999/12/17 12:31:54 jj Exp $
+/* $Id: iommu_common.h,v 1.3 2001/08/24 19:36:58 kanoj Exp $
  * iommu_common.h: UltraSparc SBUS/PCI common iommu declarations.
  *
  * Copyright (C) 1999 David S. Miller (davem@redhat.com)
@@ -10,6 +10,22 @@
 #include <asm/page.h>
 #include <asm/iommu.h>
 #include <asm/scatterlist.h>
+
+/*
+ * These give mapping size of each iommu pte/tlb.
+ */
+#define IO_PAGE_SHIFT			13
+#define IO_PAGE_SIZE			(1UL << IO_PAGE_SHIFT)
+#define IO_PAGE_MASK			(~(IO_PAGE_SIZE-1))
+#define IO_PAGE_ALIGN(addr)		(((addr)+IO_PAGE_SIZE-1)&IO_PAGE_MASK)
+
+#define IO_TSB_ENTRIES			(128*1024)
+#define IO_TSB_SIZE			(IO_TSB_ENTRIES * 8)
+
+/*
+ * This is the hardwired shift in the iotlb tag/data parts.
+ */
+#define IOMMU_PAGE_SHIFT		13
 
 /* You are _strongly_ advised to enable the following debugging code
  * any time you make changes to the sg code below, run it for a while
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/kernel/itlb_base.S linux/arch/sparc64/kernel/itlb_base.S
--- v2.4.9/linux/arch/sparc64/kernel/itlb_base.S	Sun Nov 12 20:37:16 2000
+++ linux/arch/sparc64/kernel/itlb_base.S	Tue Aug 28 07:09:44 2001
@@ -1,4 +1,4 @@
-/* $Id: itlb_base.S,v 1.10 2000/11/10 08:28:45 davem Exp $
+/* $Id: itlb_base.S,v 1.11 2001/08/17 04:55:09 kanoj Exp $
  * itlb_base.S:	Front end to ITLB miss replacement strategy.
  *              This is included directly into the trap table.
  *
@@ -6,8 +6,25 @@
  * Copyright (C) 1997,1998 Jakub Jelinek   (jj@ultra.linux.cz)
  */
 
-#define TAG_CONTEXT_BITS	0x3ff
-#define VPTE_SHIFT		(PAGE_SHIFT - 3)
+#if PAGE_SHIFT == 13
+/*
+ * To compute vpte offset, we need to do ((addr >> 13) << 3),
+ * which can be optimized to (addr >> 10) if bits 10/11/12 can
+ * be guaranteed to be 0 ... mmu_context.h does guarantee this
+ * by only using 10 bits in the hwcontext value.
+ */
+#define CREATE_VPTE_OFFSET1(r1, r2) \
+				srax	r1, 10, r2
+#define CREATE_VPTE_OFFSET2(r1, r2)
+#define CREATE_VPTE_NOP		nop
+#else /* PAGE_SHIFT */
+#define CREATE_VPTE_OFFSET1(r1, r2) \
+				srax	r1, PAGE_SHIFT, r2
+#define CREATE_VPTE_OFFSET2(r1, r2) \
+				sllx	r2, 3, r2
+#define CREATE_VPTE_NOP
+#endif /* PAGE_SHIFT */
+
 
 /* Ways we can get here:
  *
@@ -20,7 +37,8 @@
 
 /* ITLB ** ICACHE line 1: Quick user TLB misses		*/
 	ldxa		[%g1 + %g1] ASI_IMMU, %g4	! Get TAG_ACCESS
-	srax		%g4, VPTE_SHIFT, %g6		! Create VPTE offset
+	CREATE_VPTE_OFFSET1(%g4, %g6)			! Create VPTE offset
+	CREATE_VPTE_OFFSET2(%g4, %g6)			! Create VPTE offset
 	ldxa		[%g3 + %g6] ASI_P, %g5		! Load VPTE
 1:	brgez,pn	%g5, 3f				! Not valid, branch out
 	 nop						! Delay-slot
@@ -58,7 +76,8 @@
 	nop
 	nop
 	nop
-	nop
+	CREATE_VPTE_NOP
 
-#undef TAG_CONTEXT_BITS
-#undef VPTE_SHIFT
+#undef CREATE_VPTE_OFFSET1
+#undef CREATE_VPTE_OFFSET2
+#undef CREATE_VPTE_NOP
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/kernel/pci_iommu.c linux/arch/sparc64/kernel/pci_iommu.c
--- v2.4.9/linux/arch/sparc64/kernel/pci_iommu.c	Thu May 24 15:00:58 2001
+++ linux/arch/sparc64/kernel/pci_iommu.c	Tue Aug 28 07:09:44 2001
@@ -1,4 +1,4 @@
-/* $Id: pci_iommu.c,v 1.14 2001/05/23 03:06:51 davem Exp $
+/* $Id: pci_iommu.c,v 1.15 2001/08/24 19:36:58 kanoj Exp $
  * pci_iommu.c: UltraSparc PCI controller IOM/STC support.
  *
  * Copyright (C) 1999 David S. Miller (davem@redhat.com)
@@ -121,7 +121,7 @@
 	while ((1UL << cnum) < npages)
 		cnum++;
 
-	ent = (base << (32 - PAGE_SHIFT + PBM_LOGCLUSTERS - iommu->page_table_sz_bits))
+	ent = (base << (32 - IO_PAGE_SHIFT + PBM_LOGCLUSTERS - iommu->page_table_sz_bits))
 		>> (32 + PBM_LOGCLUSTERS + cnum - iommu->page_table_sz_bits);
 
 	/* If the global flush might not have caught this entry,
@@ -184,7 +184,7 @@
 	void *ret;
 	int npages;
 
-	size = PAGE_ALIGN(size);
+	size = IO_PAGE_ALIGN(size);
 	order = get_order(size);
 	if (order >= 10)
 		return NULL;
@@ -198,7 +198,7 @@
 	iommu = pcp->pbm->iommu;
 
 	spin_lock_irqsave(&iommu->lock, flags);
-	iopte = alloc_consistent_cluster(iommu, size >> PAGE_SHIFT);
+	iopte = alloc_consistent_cluster(iommu, size >> IO_PAGE_SHIFT);
 	if (iopte == NULL) {
 		spin_unlock_irqrestore(&iommu->lock, flags);
 		free_pages(first_page, order);
@@ -206,9 +206,9 @@
 	}
 
 	*dma_addrp = (iommu->page_table_map_base +
-		      ((iopte - iommu->page_table) << PAGE_SHIFT));
+		      ((iopte - iommu->page_table) << IO_PAGE_SHIFT));
 	ret = (void *) first_page;
-	npages = size >> PAGE_SHIFT;
+	npages = size >> IO_PAGE_SHIFT;
 	ctx = 0;
 	if (iommu->iommu_ctxflush)
 		ctx = iommu->iommu_cur_ctx++;
@@ -218,17 +218,17 @@
 				     IOPTE_WRITE |
 				     (first_page & IOPTE_PAGE));
 		iopte++;
-		first_page += PAGE_SIZE;
+		first_page += IO_PAGE_SIZE;
 	}
 
 	{
 		int i;
 		u32 daddr = *dma_addrp;
 
-		npages = size >> PAGE_SHIFT;
+		npages = size >> IO_PAGE_SHIFT;
 		for (i = 0; i < npages; i++) {
 			pci_iommu_write(iommu->iommu_flush, daddr);
-			daddr += PAGE_SIZE;
+			daddr += IO_PAGE_SIZE;
 		}
 	}
 
@@ -245,11 +245,11 @@
 	iopte_t *iopte;
 	unsigned long flags, order, npages, i, ctx;
 
-	npages = PAGE_ALIGN(size) >> PAGE_SHIFT;
+	npages = IO_PAGE_ALIGN(size) >> IO_PAGE_SHIFT;
 	pcp = pdev->sysdata;
 	iommu = pcp->pbm->iommu;
 	iopte = iommu->page_table +
-		((dvma - iommu->page_table_map_base) >> PAGE_SHIFT);
+		((dvma - iommu->page_table_map_base) >> IO_PAGE_SHIFT);
 
 	spin_lock_irqsave(&iommu->lock, flags);
 
@@ -286,7 +286,7 @@
 		pci_iommu_write(iommu->iommu_ctxflush, ctx);
 	} else {
 		for (i = 0; i < npages; i++) {
-			u32 daddr = dvma + (i << PAGE_SHIFT);
+			u32 daddr = dvma + (i << IO_PAGE_SHIFT);
 
 			pci_iommu_write(iommu->iommu_flush, daddr);
 		}
@@ -321,8 +321,8 @@
 		BUG();
 
 	oaddr = (unsigned long)ptr;
-	npages = PAGE_ALIGN(oaddr + sz) - (oaddr & PAGE_MASK);
-	npages >>= PAGE_SHIFT;
+	npages = IO_PAGE_ALIGN(oaddr + sz) - (oaddr & IO_PAGE_MASK);
+	npages >>= IO_PAGE_SHIFT;
 
 	spin_lock_irqsave(&iommu->lock, flags);
 
@@ -330,9 +330,9 @@
 	if (base == NULL)
 		goto bad;
 	bus_addr = (iommu->page_table_map_base +
-		    ((base - iommu->page_table) << PAGE_SHIFT));
-	ret = bus_addr | (oaddr & ~PAGE_MASK);
-	base_paddr = __pa(oaddr & PAGE_MASK);
+		    ((base - iommu->page_table) << IO_PAGE_SHIFT));
+	ret = bus_addr | (oaddr & ~IO_PAGE_MASK);
+	base_paddr = __pa(oaddr & IO_PAGE_MASK);
 	ctx = 0;
 	if (iommu->iommu_ctxflush)
 		ctx = iommu->iommu_cur_ctx++;
@@ -343,7 +343,7 @@
 	if (direction != PCI_DMA_TODEVICE)
 		iopte_protection |= IOPTE_WRITE;
 
-	for (i = 0; i < npages; i++, base++, base_paddr += PAGE_SIZE)
+	for (i = 0; i < npages; i++, base++, base_paddr += IO_PAGE_SIZE)
 		iopte_val(*base) = iopte_protection | base_paddr;
 
 	spin_unlock_irqrestore(&iommu->lock, flags);
@@ -372,15 +372,15 @@
 	iommu = pcp->pbm->iommu;
 	strbuf = &pcp->pbm->stc;
 
-	npages = PAGE_ALIGN(bus_addr + sz) - (bus_addr & PAGE_MASK);
-	npages >>= PAGE_SHIFT;
+	npages = IO_PAGE_ALIGN(bus_addr + sz) - (bus_addr & IO_PAGE_MASK);
+	npages >>= IO_PAGE_SHIFT;
 	base = iommu->page_table +
-		((bus_addr - iommu->page_table_map_base) >> PAGE_SHIFT);
+		((bus_addr - iommu->page_table_map_base) >> IO_PAGE_SHIFT);
 #ifdef DEBUG_PCI_IOMMU
 	if (iopte_val(*base) == IOPTE_INVALID)
 		printk("pci_unmap_single called on non-mapped region %08x,%08x from %016lx\n", bus_addr, sz, __builtin_return_address(0));
 #endif
-	bus_addr &= PAGE_MASK;
+	bus_addr &= IO_PAGE_MASK;
 
 	spin_lock_irqsave(&iommu->lock, flags);
 
@@ -404,7 +404,7 @@
 				pci_iommu_write(flushreg, ctx);
 			} while(((long)pci_iommu_read(matchreg)) < 0L);
 		} else {
-			for (i = 0; i < npages; i++, vaddr += PAGE_SIZE)
+			for (i = 0; i < npages; i++, vaddr += IO_PAGE_SIZE)
 				pci_iommu_write(strbuf->strbuf_pflush, vaddr);
 		}
 
@@ -432,9 +432,9 @@
 		unsigned long pteval = ~0UL;
 		u32 dma_npages;
 
-		dma_npages = ((dma_sg->dvma_address & (PAGE_SIZE - 1UL)) +
+		dma_npages = ((dma_sg->dvma_address & (IO_PAGE_SIZE - 1UL)) +
 			      dma_sg->dvma_length +
-			      ((u32)(PAGE_SIZE - 1UL))) >> PAGE_SHIFT;
+			      ((u32)(IO_PAGE_SIZE - 1UL))) >> IO_PAGE_SHIFT;
 		do {
 			unsigned long offset;
 			signed int len;
@@ -449,15 +449,15 @@
 
 				tmp = (unsigned long) __pa(sg->address);
 				len = sg->length;
-				if (((tmp ^ pteval) >> PAGE_SHIFT) != 0UL) {
-					pteval = tmp & PAGE_MASK;
-					offset = tmp & (PAGE_SIZE - 1UL);
+				if (((tmp ^ pteval) >> IO_PAGE_SHIFT) != 0UL) {
+					pteval = tmp & IO_PAGE_MASK;
+					offset = tmp & (IO_PAGE_SIZE - 1UL);
 					break;
 				}
-				if (((tmp ^ (tmp + len - 1UL)) >> PAGE_SHIFT) != 0UL) {
-					pteval = (tmp + PAGE_SIZE) & PAGE_MASK;
+				if (((tmp ^ (tmp + len - 1UL)) >> IO_PAGE_SHIFT) != 0UL) {
+					pteval = (tmp + IO_PAGE_SIZE) & IO_PAGE_MASK;
 					offset = 0UL;
-					len -= (PAGE_SIZE - (tmp & (PAGE_SIZE - 1UL)));
+					len -= (IO_PAGE_SIZE - (tmp & (IO_PAGE_SIZE - 1UL)));
 					break;
 				}
 				sg++;
@@ -466,8 +466,8 @@
 			pteval = iopte_protection | (pteval & IOPTE_PAGE);
 			while (len > 0) {
 				*iopte++ = __iopte(pteval);
-				pteval += PAGE_SIZE;
-				len -= (PAGE_SIZE - offset);
+				pteval += IO_PAGE_SIZE;
+				len -= (IO_PAGE_SIZE - offset);
 				offset = 0;
 				dma_npages--;
 			}
@@ -479,14 +479,14 @@
 			 * adjusting pteval along the way.  Stop when we
 			 * detect a page crossing event.
 			 */
-			while ((pteval << (64 - PAGE_SHIFT)) != 0UL &&
+			while ((pteval << (64 - IO_PAGE_SHIFT)) != 0UL &&
 			       pteval == __pa(sg->address) &&
 			       ((pteval ^
-				 (__pa(sg->address) + sg->length - 1UL)) >> PAGE_SHIFT) == 0UL) {
+				 (__pa(sg->address) + sg->length - 1UL)) >> IO_PAGE_SHIFT) == 0UL) {
 				pteval += sg->length;
 				sg++;
 			}
-			if ((pteval << (64 - PAGE_SHIFT)) == 0UL)
+			if ((pteval << (64 - IO_PAGE_SHIFT)) == 0UL)
 				pteval = ~0UL;
 		} while (dma_npages != 0);
 		dma_sg++;
@@ -534,7 +534,7 @@
 	base = alloc_streaming_cluster(iommu, npages);
 	if (base == NULL)
 		goto bad;
-	dma_base = iommu->page_table_map_base + ((base - iommu->page_table) << PAGE_SHIFT);
+	dma_base = iommu->page_table_map_base + ((base - iommu->page_table) << IO_PAGE_SHIFT);
 
 	/* Step 3: Normalize DMA addresses. */
 	used = nelems;
@@ -591,16 +591,16 @@
 	iommu = pcp->pbm->iommu;
 	strbuf = &pcp->pbm->stc;
 	
-	bus_addr = sglist->dvma_address & PAGE_MASK;
+	bus_addr = sglist->dvma_address & IO_PAGE_MASK;
 
 	for (i = 1; i < nelems; i++)
 		if (sglist[i].dvma_length == 0)
 			break;
 	i--;
-	npages = (PAGE_ALIGN(sglist[i].dvma_address + sglist[i].dvma_length) - bus_addr) >> PAGE_SHIFT;
+	npages = (IO_PAGE_ALIGN(sglist[i].dvma_address + sglist[i].dvma_length) - bus_addr) >> IO_PAGE_SHIFT;
 
 	base = iommu->page_table +
-		((bus_addr - iommu->page_table_map_base) >> PAGE_SHIFT);
+		((bus_addr - iommu->page_table_map_base) >> IO_PAGE_SHIFT);
 
 #ifdef DEBUG_PCI_IOMMU
 	if (iopte_val(*base) == IOPTE_INVALID)
@@ -629,7 +629,7 @@
 				pci_iommu_write(flushreg, ctx);
 			} while(((long)pci_iommu_read(matchreg)) < 0L);
 		} else {
-			for (i = 0; i < npages; i++, vaddr += PAGE_SIZE)
+			for (i = 0; i < npages; i++, vaddr += IO_PAGE_SIZE)
 				pci_iommu_write(strbuf->strbuf_pflush, vaddr);
 		}
 
@@ -667,9 +667,9 @@
 
 	spin_lock_irqsave(&iommu->lock, flags);
 
-	npages = PAGE_ALIGN(bus_addr + sz) - (bus_addr & PAGE_MASK);
-	npages >>= PAGE_SHIFT;
-	bus_addr &= PAGE_MASK;
+	npages = IO_PAGE_ALIGN(bus_addr + sz) - (bus_addr & IO_PAGE_MASK);
+	npages >>= IO_PAGE_SHIFT;
+	bus_addr &= IO_PAGE_MASK;
 
 	/* Step 1: Record the context, if any. */
 	ctx = 0;
@@ -678,7 +678,7 @@
 		iopte_t *iopte;
 
 		iopte = iommu->page_table +
-			((bus_addr - iommu->page_table_map_base)>>PAGE_SHIFT);
+			((bus_addr - iommu->page_table_map_base)>>IO_PAGE_SHIFT);
 		ctx = (iopte_val(*iopte) & IOPTE_CONTEXT) >> 47UL;
 	}
 
@@ -696,7 +696,7 @@
 	} else {
 		unsigned long i;
 
-		for (i = 0; i < npages; i++, bus_addr += PAGE_SIZE)
+		for (i = 0; i < npages; i++, bus_addr += IO_PAGE_SIZE)
 			pci_iommu_write(strbuf->strbuf_pflush, bus_addr);
 	}
 
@@ -735,7 +735,7 @@
 		iopte_t *iopte;
 
 		iopte = iommu->page_table +
-			((sglist[0].dvma_address - iommu->page_table_map_base) >> PAGE_SHIFT);
+			((sglist[0].dvma_address - iommu->page_table_map_base) >> IO_PAGE_SHIFT);
 		ctx = (iopte_val(*iopte) & IOPTE_CONTEXT) >> 47UL;
 	}
 
@@ -754,14 +754,14 @@
 		unsigned long i, npages;
 		u32 bus_addr;
 
-		bus_addr = sglist[0].dvma_address & PAGE_MASK;
+		bus_addr = sglist[0].dvma_address & IO_PAGE_MASK;
 
 		for(i = 1; i < nelems; i++)
 			if (!sglist[i].dvma_length)
 				break;
 		i--;
-		npages = (PAGE_ALIGN(sglist[i].dvma_address + sglist[i].dvma_length) - bus_addr) >> PAGE_SHIFT;
-		for (i = 0; i < npages; i++, bus_addr += PAGE_SIZE)
+		npages = (IO_PAGE_ALIGN(sglist[i].dvma_address + sglist[i].dvma_length) - bus_addr) >> IO_PAGE_SHIFT;
+		for (i = 0; i < npages; i++, bus_addr += IO_PAGE_SIZE)
 			pci_iommu_write(strbuf->strbuf_pflush, bus_addr);
 	}
 
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/kernel/pci_psycho.c linux/arch/sparc64/kernel/pci_psycho.c
--- v2.4.9/linux/arch/sparc64/kernel/pci_psycho.c	Mon Aug 27 12:41:40 2001
+++ linux/arch/sparc64/kernel/pci_psycho.c	Tue Aug 28 07:09:44 2001
@@ -1,4 +1,4 @@
-/* $Id: pci_psycho.c,v 1.27 2001/08/12 13:18:23 davem Exp $
+/* $Id: pci_psycho.c,v 1.28 2001/08/24 19:36:58 kanoj Exp $
  * pci_psycho.c: PSYCHO/U2P specific PCI controller support.
  *
  * Copyright (C) 1997, 1998, 1999 David S. Miller (davem@caipfs.rutgers.edu)
@@ -18,6 +18,7 @@
 #include <asm/starfire.h>
 
 #include "pci_impl.h"
+#include "iommu_common.h"
 
 /* All PSYCHO registers are 64-bits.  The following accessor
  * routines are how they are accessed.  The REG parameter
@@ -715,12 +716,12 @@
 			       ((tag & PSYCHO_IOMMU_TAG_WRITE) ? 1 : 0),
 			       ((tag & PSYCHO_IOMMU_TAG_STREAM) ? 1 : 0),
 			       ((tag & PSYCHO_IOMMU_TAG_SIZE) ? 64 : 8),
-			       (tag & PSYCHO_IOMMU_TAG_VPAGE) << PAGE_SHIFT);
+			       (tag & PSYCHO_IOMMU_TAG_VPAGE) << IOMMU_PAGE_SHIFT);
 			printk("PSYCHO%d: IOMMU DATA(%d)[valid(%d) cache(%d) ppg(%016lx)]\n",
 			       p->index, i,
 			       ((data & PSYCHO_IOMMU_DATA_VALID) ? 1 : 0),
 			       ((data & PSYCHO_IOMMU_DATA_CACHE) ? 1 : 0),
-			       (data & PSYCHO_IOMMU_DATA_PPAGE) << PAGE_SHIFT);
+			       (data & PSYCHO_IOMMU_DATA_PPAGE) << IOMMU_PAGE_SHIFT);
 		}
 	}
 	__psycho_check_stc_error(p, afsr, afar, type);
@@ -1322,7 +1323,7 @@
 	 * table (128K ioptes * 8 bytes per iopte).  This is
 	 * page order 7 on UltraSparc.
 	 */
-	tsbbase = __get_free_pages(GFP_KERNEL, 7);
+	tsbbase = __get_free_pages(GFP_KERNEL, get_order(IO_TSB_SIZE));
 	if (!tsbbase) {
 		prom_printf("PSYCHO_IOMMU: Error, gfp(tsb) failed.\n");
 		prom_halt();
@@ -1331,7 +1332,7 @@
 	iommu->page_table_sz_bits = 17;
 	iommu->page_table_map_base = 0xc0000000;
 	iommu->dma_addr_mask = 0xffffffff;
-	memset((char *)tsbbase, 0, PAGE_SIZE << 7);
+	memset((char *)tsbbase, 0, IO_TSB_SIZE);
 
 	/* We start with no consistent mappings. */
 	iommu->lowest_consistent_map =
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/kernel/pci_sabre.c linux/arch/sparc64/kernel/pci_sabre.c
--- v2.4.9/linux/arch/sparc64/kernel/pci_sabre.c	Mon Aug 27 12:41:40 2001
+++ linux/arch/sparc64/kernel/pci_sabre.c	Tue Aug 28 07:09:44 2001
@@ -1,4 +1,4 @@
-/* $Id: pci_sabre.c,v 1.38 2001/08/12 13:18:23 davem Exp $
+/* $Id: pci_sabre.c,v 1.39 2001/08/24 19:36:58 kanoj Exp $
  * pci_sabre.c: Sabre specific PCI controller support.
  *
  * Copyright (C) 1997, 1998, 1999 David S. Miller (davem@caipfs.rutgers.edu)
@@ -19,6 +19,7 @@
 #include <asm/smp.h>
 
 #include "pci_impl.h"
+#include "iommu_common.h"
 
 /* All SABRE registers are 64-bits.  The following accessor
  * routines are how they are accessed.  The REG parameter
@@ -759,13 +760,13 @@
 			       p->index, i, tag, type_string,
 			       ((tag & SABRE_IOMMUTAG_WRITE) ? 1 : 0),
 			       ((tag & SABRE_IOMMUTAG_SIZE) ? 64 : 8),
-			       ((tag & SABRE_IOMMUTAG_VPN) << PAGE_SHIFT));
+			       ((tag & SABRE_IOMMUTAG_VPN) << IOMMU_PAGE_SHIFT));
 			printk("SABRE%d: IOMMU DATA(%d)[RAW(%016lx)valid(%d)used(%d)cache(%d)ppg(%016lx)\n",
 			       p->index, i, data,
 			       ((data & SABRE_IOMMUDATA_VALID) ? 1 : 0),
 			       ((data & SABRE_IOMMUDATA_USED) ? 1 : 0),
 			       ((data & SABRE_IOMMUDATA_CACHE) ? 1 : 0),
-			       ((data & SABRE_IOMMUDATA_PPN) << PAGE_SHIFT));
+			       ((data & SABRE_IOMMUDATA_PPN) << IOMMU_PAGE_SHIFT));
 		}
 	}
 	spin_unlock_irqrestore(&iommu->lock, flags);
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/kernel/pci_schizo.c linux/arch/sparc64/kernel/pci_schizo.c
--- v2.4.9/linux/arch/sparc64/kernel/pci_schizo.c	Mon Aug 27 12:41:40 2001
+++ linux/arch/sparc64/kernel/pci_schizo.c	Tue Aug 28 07:09:44 2001
@@ -1,4 +1,4 @@
-/* $Id: pci_schizo.c,v 1.20 2001/08/12 13:18:23 davem Exp $
+/* $Id: pci_schizo.c,v 1.21 2001/08/24 19:36:58 kanoj Exp $
  * pci_schizo.c: SCHIZO specific PCI controller support.
  *
  * Copyright (C) 2001 David S. Miller (davem@redhat.com)
@@ -16,6 +16,7 @@
 #include <asm/upa.h>
 
 #include "pci_impl.h"
+#include "iommu_common.h"
 
 /* All SCHIZO registers are 64-bits.  The following accessor
  * routines are how they are accessed.  The REG parameter
@@ -659,12 +660,12 @@
 			       ((tag & SCHIZO_IOMMU_TAG_WRITE) ? 1 : 0),
 			       ((tag & SCHIZO_IOMMU_TAG_STREAM) ? 1 : 0),
 			       ((tag & SCHIZO_IOMMU_TAG_SIZE) ? 64 : 8),
-			       (tag & SCHIZO_IOMMU_TAG_VPAGE) << PAGE_SHIFT);
+			       (tag & SCHIZO_IOMMU_TAG_VPAGE) << IOMMU_PAGE_SHIFT);
 			printk("SCHIZO%d: PBM-%c IOMMU DATA(%d)[valid(%d) cache(%d) ppg(%016lx)]\n",
 			       p->index, pbm_name, i,
 			       ((data & SCHIZO_IOMMU_DATA_VALID) ? 1 : 0),
 			       ((data & SCHIZO_IOMMU_DATA_CACHE) ? 1 : 0),
-			       (data & SCHIZO_IOMMU_DATA_PPAGE) << PAGE_SHIFT);
+			       (data & SCHIZO_IOMMU_DATA_PPAGE) << IOMMU_PAGE_SHIFT);
 		}
 	}
 	__schizo_check_stc_error_pbm(pbm, type);
@@ -1639,7 +1640,7 @@
 	 * table (128K ioptes * 8 bytes per iopte).  This is
 	 * page order 7 on UltraSparc.
 	 */
-	tsbbase = __get_free_pages(GFP_KERNEL, 7);
+	tsbbase = __get_free_pages(GFP_KERNEL, get_order(IO_TSB_SIZE));
 	if (!tsbbase) {
 		prom_printf("SCHIZO_IOMMU: Error, gfp(tsb) failed.\n");
 		prom_halt();
@@ -1648,7 +1649,7 @@
 	iommu->page_table_sz_bits = 17;
 	iommu->page_table_map_base = 0xc0000000;
 	iommu->dma_addr_mask = 0xffffffff;
-	memset((char *)tsbbase, 0, PAGE_SIZE << 7);
+	memset((char *)tsbbase, 0, IO_TSB_SIZE);
 
 	/* We start with no consistent mappings. */
 	iommu->lowest_consistent_map =
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/kernel/sbus.c linux/arch/sparc64/kernel/sbus.c
--- v2.4.9/linux/arch/sparc64/kernel/sbus.c	Thu May 24 15:00:58 2001
+++ linux/arch/sparc64/kernel/sbus.c	Tue Aug 28 07:09:44 2001
@@ -1,4 +1,4 @@
-/* $Id: sbus.c,v 1.14 2001/05/23 03:06:51 davem Exp $
+/* $Id: sbus.c,v 1.16 2001/08/24 19:36:58 kanoj Exp $
  * sbus.c: UltraSparc SBUS controller support.
  *
  * Copyright (C) 1999 David S. Miller (davem@redhat.com)
@@ -37,7 +37,7 @@
 #define ONE_GIG		(1UL * 1024UL * 1024UL * 1024UL)
 #define CLUSTER_SIZE	(ONE_GIG / NCLUSTERS)
 #define CLUSTER_MASK	(CLUSTER_SIZE - 1)
-#define CLUSTER_NPAGES	(CLUSTER_SIZE >> PAGE_SHIFT)
+#define CLUSTER_NPAGES	(CLUSTER_SIZE >> IO_PAGE_SHIFT)
 #define MAP_BASE	((u32)0xc0000000)
 
 struct sbus_iommu {
@@ -99,7 +99,7 @@
 static void iommu_flush(struct sbus_iommu *iommu, u32 base, unsigned long npages)
 {
 	while (npages--)
-		upa_writeq(base + (npages << PAGE_SHIFT),
+		upa_writeq(base + (npages << IO_PAGE_SHIFT),
 			   iommu->iommu_regs + IOMMU_FLUSH);
 	upa_readq(iommu->sbus_control_reg);
 }
@@ -120,7 +120,7 @@
 {
 	iommu->strbuf_flushflag = 0UL;
 	while (npages--)
-		upa_writeq(base + (npages << PAGE_SHIFT),
+		upa_writeq(base + (npages << IO_PAGE_SHIFT),
 			   iommu->strbuf_regs + STRBUF_PFLUSH);
 
 	/* Whoopee cushion! */
@@ -191,8 +191,8 @@
 	cnum = 0;
 	while ((1UL << cnum) < npages)
 		cnum++;
-	ent = (base & CLUSTER_MASK) >> (PAGE_SHIFT + cnum);
-	iopte = iommu->page_table + ((base - MAP_BASE) >> PAGE_SHIFT);
+	ent = (base & CLUSTER_MASK) >> (IO_PAGE_SHIFT + cnum);
+	iopte = iommu->page_table + ((base - MAP_BASE) >> IO_PAGE_SHIFT);
 	iopte_val(*iopte) = 0UL;
 
 	/* If the global flush might not have caught this entry,
@@ -235,7 +235,7 @@
 
 static void free_consistent_cluster(struct sbus_iommu *iommu, u32 base, unsigned long npages)
 {
-	iopte_t *iopte = iommu->page_table + ((base - MAP_BASE) >> PAGE_SHIFT);
+	iopte_t *iopte = iommu->page_table + ((base - MAP_BASE) >> IO_PAGE_SHIFT);
 
 	if ((iopte - iommu->page_table) == iommu->lowest_consistent_map) {
 		iopte_t *walk = iopte + npages;
@@ -266,7 +266,7 @@
 	if (size <= 0 || sdev == NULL || dvma_addr == NULL)
 		return NULL;
 
-	size = PAGE_ALIGN(size);
+	size = IO_PAGE_ALIGN(size);
 	order = get_order(size);
 	if (order >= 10)
 		return NULL;
@@ -278,7 +278,7 @@
 	iommu = sdev->bus->iommu;
 
 	spin_lock_irqsave(&iommu->lock, flags);
-	iopte = alloc_consistent_cluster(iommu, size >> PAGE_SHIFT);
+	iopte = alloc_consistent_cluster(iommu, size >> IO_PAGE_SHIFT);
 	if (iopte == NULL) {
 		spin_unlock_irqrestore(&iommu->lock, flags);
 		free_pages(first_page, order);
@@ -286,15 +286,15 @@
 	}
 
 	/* Ok, we're committed at this point. */
-	*dvma_addr = MAP_BASE +	((iopte - iommu->page_table) << PAGE_SHIFT);
+	*dvma_addr = MAP_BASE +	((iopte - iommu->page_table) << IO_PAGE_SHIFT);
 	ret = (void *) first_page;
-	npages = size >> PAGE_SHIFT;
+	npages = size >> IO_PAGE_SHIFT;
 	while (npages--) {
 		*iopte++ = __iopte(IOPTE_VALID | IOPTE_CACHE | IOPTE_WRITE |
 				   (__pa(first_page) & IOPTE_PAGE));
-		first_page += PAGE_SIZE;
+		first_page += IO_PAGE_SIZE;
 	}
-	iommu_flush(iommu, *dvma_addr, size >> PAGE_SHIFT);
+	iommu_flush(iommu, *dvma_addr, size >> IO_PAGE_SHIFT);
 	spin_unlock_irqrestore(&iommu->lock, flags);
 
 	return ret;
@@ -308,7 +308,7 @@
 	if (size <= 0 || sdev == NULL || cpu == NULL)
 		return;
 
-	npages = PAGE_ALIGN(size) >> PAGE_SHIFT;
+	npages = IO_PAGE_ALIGN(size) >> IO_PAGE_SHIFT;
 	iommu = sdev->bus->iommu;
 
 	spin_lock_irq(&iommu->lock);
@@ -333,25 +333,25 @@
 		BUG();
 
 	pbase = (unsigned long) ptr;
-	offset = (u32) (pbase & ~PAGE_MASK);
-	size = (PAGE_ALIGN(pbase + size) - (pbase & PAGE_MASK));
-	pbase = (unsigned long) __pa(pbase & PAGE_MASK);
+	offset = (u32) (pbase & ~IO_PAGE_MASK);
+	size = (IO_PAGE_ALIGN(pbase + size) - (pbase & IO_PAGE_MASK));
+	pbase = (unsigned long) __pa(pbase & IO_PAGE_MASK);
 
 	spin_lock_irqsave(&iommu->lock, flags);
-	npages = size >> PAGE_SHIFT;
+	npages = size >> IO_PAGE_SHIFT;
 	iopte = alloc_streaming_cluster(iommu, npages);
 	if (iopte == NULL)
 		goto bad;
-	dma_base = MAP_BASE + ((iopte - iommu->page_table) << PAGE_SHIFT);
-	npages = size >> PAGE_SHIFT;
+	dma_base = MAP_BASE + ((iopte - iommu->page_table) << IO_PAGE_SHIFT);
+	npages = size >> IO_PAGE_SHIFT;
 	iopte_bits = IOPTE_VALID | IOPTE_STBUF | IOPTE_CACHE;
 	if (dir != SBUS_DMA_TODEVICE)
 		iopte_bits |= IOPTE_WRITE;
 	while (npages--) {
 		*iopte++ = __iopte(iopte_bits | (pbase & IOPTE_PAGE));
-		pbase += PAGE_SIZE;
+		pbase += IO_PAGE_SIZE;
 	}
-	npages = size >> PAGE_SHIFT;
+	npages = size >> IO_PAGE_SHIFT;
 	spin_unlock_irqrestore(&iommu->lock, flags);
 
 	return (dma_base | offset);
@@ -365,14 +365,14 @@
 void sbus_unmap_single(struct sbus_dev *sdev, dma_addr_t dma_addr, size_t size, int direction)
 {
 	struct sbus_iommu *iommu = sdev->bus->iommu;
-	u32 dma_base = dma_addr & PAGE_MASK;
+	u32 dma_base = dma_addr & IO_PAGE_MASK;
 	unsigned long flags;
 
-	size = (PAGE_ALIGN(dma_addr + size) - dma_base);
+	size = (IO_PAGE_ALIGN(dma_addr + size) - dma_base);
 
 	spin_lock_irqsave(&iommu->lock, flags);
-	free_streaming_cluster(iommu, dma_base, size >> PAGE_SHIFT);
-	strbuf_flush(iommu, dma_base, size >> PAGE_SHIFT);
+	free_streaming_cluster(iommu, dma_base, size >> IO_PAGE_SHIFT);
+	strbuf_flush(iommu, dma_base, size >> IO_PAGE_SHIFT);
 	spin_unlock_irqrestore(&iommu->lock, flags);
 }
 
@@ -385,9 +385,9 @@
 		unsigned long pteval = ~0UL;
 		u32 dma_npages;
 
-		dma_npages = ((dma_sg->dvma_address & (PAGE_SIZE - 1UL)) +
+		dma_npages = ((dma_sg->dvma_address & (IO_PAGE_SIZE - 1UL)) +
 			      dma_sg->dvma_length +
-			      ((u32)(PAGE_SIZE - 1UL))) >> PAGE_SHIFT;
+			      ((u32)(IO_PAGE_SIZE - 1UL))) >> IO_PAGE_SHIFT;
 		do {
 			unsigned long offset;
 			signed int len;
@@ -402,15 +402,15 @@
 
 				tmp = (unsigned long) __pa(sg->address);
 				len = sg->length;
-				if (((tmp ^ pteval) >> PAGE_SHIFT) != 0UL) {
-					pteval = tmp & PAGE_MASK;
-					offset = tmp & (PAGE_SIZE - 1UL);
+				if (((tmp ^ pteval) >> IO_PAGE_SHIFT) != 0UL) {
+					pteval = tmp & IO_PAGE_MASK;
+					offset = tmp & (IO_PAGE_SIZE - 1UL);
 					break;
 				}
-				if (((tmp ^ (tmp + len - 1UL)) >> PAGE_SHIFT) != 0UL) {
-					pteval = (tmp + PAGE_SIZE) & PAGE_MASK;
+				if (((tmp ^ (tmp + len - 1UL)) >> IO_PAGE_SHIFT) != 0UL) {
+					pteval = (tmp + IO_PAGE_SIZE) & IO_PAGE_MASK;
 					offset = 0UL;
-					len -= (PAGE_SIZE - (tmp & (PAGE_SIZE - 1UL)));
+					len -= (IO_PAGE_SIZE - (tmp & (IO_PAGE_SIZE - 1UL)));
 					break;
 				}
 				sg++;
@@ -419,8 +419,8 @@
 			pteval = ((pteval & IOPTE_PAGE) | iopte_bits);
 			while (len > 0) {
 				*iopte++ = __iopte(pteval);
-				pteval += PAGE_SIZE;
-				len -= (PAGE_SIZE - offset);
+				pteval += IO_PAGE_SIZE;
+				len -= (IO_PAGE_SIZE - offset);
 				offset = 0;
 				dma_npages--;
 			}
@@ -432,14 +432,14 @@
 			 * adjusting pteval along the way.  Stop when we
 			 * detect a page crossing event.
 			 */
-			while ((pteval << (64 - PAGE_SHIFT)) != 0UL &&
+			while ((pteval << (64 - IO_PAGE_SHIFT)) != 0UL &&
 			       pteval == __pa(sg->address) &&
 			       ((pteval ^
-				 (__pa(sg->address) + sg->length - 1UL)) >> PAGE_SHIFT) == 0UL) {
+				 (__pa(sg->address) + sg->length - 1UL)) >> IO_PAGE_SHIFT) == 0UL) {
 				pteval += sg->length;
 				sg++;
 			}
-			if ((pteval << (64 - PAGE_SHIFT)) == 0UL)
+			if ((pteval << (64 - IO_PAGE_SHIFT)) == 0UL)
 				pteval = ~0UL;
 		} while (dma_npages != 0);
 		dma_sg++;
@@ -472,7 +472,7 @@
 	iopte = alloc_streaming_cluster(iommu, npages);
 	if (iopte == NULL)
 		goto bad;
-	dma_base = MAP_BASE + ((iopte - iommu->page_table) << PAGE_SHIFT);
+	dma_base = MAP_BASE + ((iopte - iommu->page_table) << IO_PAGE_SHIFT);
 
 	/* Normalize DVMA addresses. */
 	sgtmp = sg;
@@ -516,18 +516,18 @@
 		return;
 	}
 
-	dvma_base = sg[0].dvma_address & PAGE_MASK;
+	dvma_base = sg[0].dvma_address & IO_PAGE_MASK;
 	for (i = 0; i < nents; i++) {
 		if (sg[i].dvma_length == 0)
 			break;
 	}
 	i--;
-	size = PAGE_ALIGN(sg[i].dvma_address + sg[i].dvma_length) - dvma_base;
+	size = IO_PAGE_ALIGN(sg[i].dvma_address + sg[i].dvma_length) - dvma_base;
 
 	iommu = sdev->bus->iommu;
 	spin_lock_irqsave(&iommu->lock, flags);
-	free_streaming_cluster(iommu, dvma_base, size >> PAGE_SHIFT);
-	strbuf_flush(iommu, dvma_base, size >> PAGE_SHIFT);
+	free_streaming_cluster(iommu, dvma_base, size >> IO_PAGE_SHIFT);
+	strbuf_flush(iommu, dvma_base, size >> IO_PAGE_SHIFT);
 	spin_unlock_irqrestore(&iommu->lock, flags);
 }
 
@@ -536,10 +536,10 @@
 	struct sbus_iommu *iommu = sdev->bus->iommu;
 	unsigned long flags;
 
-	size = (PAGE_ALIGN(base + size) - (base & PAGE_MASK));
+	size = (IO_PAGE_ALIGN(base + size) - (base & IO_PAGE_MASK));
 
 	spin_lock_irqsave(&iommu->lock, flags);
-	strbuf_flush(iommu, base & PAGE_MASK, size >> PAGE_SHIFT);
+	strbuf_flush(iommu, base & IO_PAGE_MASK, size >> IO_PAGE_SHIFT);
 	spin_unlock_irqrestore(&iommu->lock, flags);
 }
 
@@ -550,16 +550,16 @@
 	u32 base;
 	int i;
 
-	base = sg[0].dvma_address & PAGE_MASK;
+	base = sg[0].dvma_address & IO_PAGE_MASK;
 	for (i = 0; i < nents; i++) {
 		if (sg[i].dvma_length == 0)
 			break;
 	}
 	i--;
-	size = PAGE_ALIGN(sg[i].dvma_address + sg[i].dvma_length) - base;
+	size = IO_PAGE_ALIGN(sg[i].dvma_address + sg[i].dvma_length) - base;
 
 	spin_lock_irqsave(&iommu->lock, flags);
-	strbuf_flush(iommu, base, size >> PAGE_SHIFT);
+	strbuf_flush(iommu, base, size >> IO_PAGE_SHIFT);
 	spin_unlock_irqrestore(&iommu->lock, flags);
 }
 
@@ -1123,14 +1123,14 @@
 	 * table (128K ioptes * 8 bytes per iopte).  This is
 	 * page order 7 on UltraSparc.
 	 */
-	tsb_base = __get_free_pages(GFP_ATOMIC, 7);
+	tsb_base = __get_free_pages(GFP_ATOMIC, get_order(IO_TSB_SIZE));
 	if (tsb_base == 0UL) {
 		prom_printf("sbus_iommu_init: Fatal error, cannot alloc TSB table.\n");
 		prom_halt();
 	}
 
 	iommu->page_table = (iopte_t *) tsb_base;
-	memset(iommu->page_table, 0, (PAGE_SIZE << 7));
+	memset(iommu->page_table, 0, IO_TSB_SIZE);
 
 	upa_writeq(control, iommu->iommu_regs + IOMMU_CONTROL);
 
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/kernel/smp.c linux/arch/sparc64/kernel/smp.c
--- v2.4.9/linux/arch/sparc64/kernel/smp.c	Mon Aug 27 12:41:40 2001
+++ linux/arch/sparc64/kernel/smp.c	Tue Aug 28 07:09:44 2001
@@ -702,7 +702,7 @@
 		int cpu = smp_processor_id();
 
 		start &= PAGE_MASK;
-		end   &= PAGE_MASK;
+		end    = PAGE_ALIGN(end);
 
 		if (mm == current->active_mm && atomic_read(&mm->mm_users) == 1) {
 			mm->cpu_vm_mask = (1UL << cpu);
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/kernel/sparc64_ksyms.c linux/arch/sparc64/kernel/sparc64_ksyms.c
--- v2.4.9/linux/arch/sparc64/kernel/sparc64_ksyms.c	Mon Aug 27 12:41:40 2001
+++ linux/arch/sparc64/kernel/sparc64_ksyms.c	Fri Sep  7 11:01:20 2001
@@ -1,4 +1,4 @@
-/* $Id: sparc64_ksyms.c,v 1.108 2001/06/05 03:39:50 davem Exp $
+/* $Id: sparc64_ksyms.c,v 1.111 2001/08/30 03:22:00 kanoj Exp $
  * arch/sparc64/kernel/sparc64_ksyms.c: Sparc64 specific ksyms support.
  *
  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
@@ -163,7 +163,9 @@
 /* Atomic counter implementation. */
 EXPORT_SYMBOL(__atomic_add);
 EXPORT_SYMBOL(__atomic_sub);
+#ifdef CONFIG_SMP
 EXPORT_SYMBOL(atomic_dec_and_lock);
+#endif
 
 /* Atomic bit operations. */
 EXPORT_SYMBOL(___test_and_set_bit);
@@ -206,7 +208,6 @@
 EXPORT_SYMBOL(ebus_chain);
 EXPORT_SYMBOL(isa_chain);
 EXPORT_SYMBOL(pci_memspace_mask);
-EXPORT_SYMBOL(empty_zero_page);
 EXPORT_SYMBOL(outsb);
 EXPORT_SYMBOL(outsw);
 EXPORT_SYMBOL(outsl);
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/lib/blockops.S linux/arch/sparc64/lib/blockops.S
--- v2.4.9/linux/arch/sparc64/lib/blockops.S	Thu Apr 12 12:10:25 2001
+++ linux/arch/sparc64/lib/blockops.S	Fri Sep  7 11:01:20 2001
@@ -1,4 +1,4 @@
-/* $Id: blockops.S,v 1.31 2001/04/05 11:08:12 davem Exp $
+/* $Id: blockops.S,v 1.34 2001/09/03 01:34:18 kanoj Exp $
  * blockops.S: UltraSparc block zero optimized routines.
  *
  * Copyright (C) 1996, 1998, 1999, 2000 David S. Miller (davem@redhat.com)
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/mm/fault.c linux/arch/sparc64/mm/fault.c
--- v2.4.9/linux/arch/sparc64/mm/fault.c	Mon Aug 27 12:41:40 2001
+++ linux/arch/sparc64/mm/fault.c	Fri Sep  7 11:01:20 2001
@@ -1,4 +1,4 @@
-/* $Id: fault.c,v 1.55 2001/08/09 20:18:43 davem Exp $
+/* $Id: fault.c,v 1.58 2001/09/01 00:11:16 kanoj Exp $
  * arch/sparc64/mm/fault.c: Page fault handlers for the 64-bit Sparc.
  *
  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
@@ -22,11 +22,58 @@
 #include <asm/openprom.h>
 #include <asm/oplib.h>
 #include <asm/uaccess.h>
+#include <asm/asi.h>
+#include <asm/lsu.h>
 
 #define ELEMENTS(arr) (sizeof (arr)/sizeof (arr[0]))
 
 extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS];
 
+/*
+ * To debug kernel during syscall entry.
+ */
+void syscall_trace_entry(struct pt_regs *regs)
+{
+	printk("scall entry: %s[%d]/cpu%d: %d\n", current->comm, current->pid, smp_processor_id(), (int) regs->u_regs[UREG_G1]);
+}
+
+/*
+ * To debug kernel during syscall exit.
+ */
+void syscall_trace_exit(struct pt_regs *regs)
+{
+	printk("scall exit: %s[%d]/cpu%d: %d\n", current->comm, current->pid, smp_processor_id(), (int) regs->u_regs[UREG_G1]);
+}
+
+/*
+ * To debug kernel to catch accesses to certain virtual/physical addresses.
+ * Mode = 0 selects physical watchpoints, mode = 1 selects virtual watchpoints.
+ * flags = VM_READ watches memread accesses, flags = VM_WRITE watches memwrite accesses.
+ * Caller passes in a 64bit aligned addr, with mask set to the bytes that need to be
+ * watched. This is only useful on a single cpu machine for now. After the watchpoint
+ * is detected, the process causing it will be killed, thus preventing an infinite loop.
+ */
+void set_brkpt(unsigned long addr, unsigned char mask, int flags, int mode)
+{
+	unsigned long lsubits = LSU_CONTROL_IC|LSU_CONTROL_DC|LSU_CONTROL_IM|LSU_CONTROL_DM;
+
+	__asm__ __volatile__("stxa	%0, [%1] %2\n\t"
+			     "membar	#Sync"
+			     : /* no outputs */
+			     : "r" (addr), "r" (mode ? VIRT_WATCHPOINT : PHYS_WATCHPOINT),
+			       "i" (ASI_DMMU));
+	lsubits |= ((unsigned long)mask << (mode ? 25 : 33));
+	if (flags & VM_READ)
+		lsubits |= (mode ? LSU_CONTROL_VR : LSU_CONTROL_PR);
+	if (flags & VM_WRITE)
+		lsubits |= (mode ? LSU_CONTROL_VW : LSU_CONTROL_PW);
+	__asm__ __volatile__("stxa %0, [%%g0] %1\n\t"
+			     "membar #Sync"
+			     : /* no outputs */
+			     : "r" (lsubits), "i" (ASI_LSU_CONTROL)
+			     : "memory");
+}
+
 /* Nice, simple, prom library does all the sweating for us. ;) */
 unsigned long __init prom_probe_memory (void)
 {
@@ -170,7 +217,7 @@
 	unsigned long g2;
 	unsigned char asi = ASI_P;
  
-	if (!insn)
+	if ((!insn) && (regs->tstate & TSTATE_PRIV))
 		goto cannot_handle;
 
 	/* If user insn could be read (thus insn is zero), that
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/mm/init.c linux/arch/sparc64/mm/init.c
--- v2.4.9/linux/arch/sparc64/mm/init.c	Mon Aug 27 12:41:40 2001
+++ linux/arch/sparc64/mm/init.c	Fri Sep  7 11:01:20 2001
@@ -1,4 +1,4 @@
-/*  $Id: init.c,v 1.179 2001/08/08 07:52:00 davem Exp $
+/*  $Id: init.c,v 1.189 2001/09/02 23:27:18 kanoj Exp $
  *  arch/sparc64/mm/init.c
  *
  *  Copyright (C) 1996-1999 David S. Miller (davem@caip.rutgers.edu)
@@ -27,7 +27,6 @@
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
-#include <asm/vaddrs.h>
 #include <asm/dma.h>
 #include <asm/starfire.h>
 
@@ -55,6 +54,8 @@
 extern unsigned int sparc_ramdisk_image;
 extern unsigned int sparc_ramdisk_size;
 
+struct page *mem_map_zero;
+
 int do_check_pgt_cache(int low, int high)
 {
         int freed = 0;
@@ -130,28 +131,6 @@
 	}
 }
 
-/*
- * BAD_PAGE is the page that is used for page faults when linux
- * is out-of-memory. Older versions of linux just did a
- * do_exit(), but using this instead means there is less risk
- * for a process dying in kernel mode, possibly leaving an inode
- * unused etc..
- *
- * BAD_PAGETABLE is the accompanying page-table: it is initialized
- * to point to BAD_PAGE entries.
- *
- * ZERO_PAGE is a special page that is used for zero-initialized
- * data and COW.
- */
-pte_t __bad_page(void)
-{
-	memset((void *) &empty_bad_page, 0, PAGE_SIZE);
-	return pte_mkdirty(mk_pte_phys((((unsigned long) &empty_bad_page) 
-					- ((unsigned long)&empty_zero_page)
-					+ phys_base),
-				       PAGE_SHARED));
-}
-
 void show_mem(void)
 {
 	printk("Mem-info:\n");
@@ -202,10 +181,10 @@
 	struct linux_prom_translation *trans;
 	unsigned long phys_page, tte_vaddr, tte_data;
 	void (*remap_func)(unsigned long, unsigned long, int);
-	pgd_t *pgdp;
-	pmd_t *pmdp;
+	pmd_t *pmdp, *pmd;
 	pte_t *ptep;
 	int node, n, i, tsz;
+	extern unsigned int obp_iaddr_patch[2], obp_daddr_patch[2];
 
 	node = prom_finddevice("/virtual-memory");
 	n = prom_getproplen(node, "translations");
@@ -229,36 +208,39 @@
 	}
 	n = n / sizeof(*trans);
 
+	/*
+	 * The obp translations are saved based on 8k pagesize, since obp can use
+	 * a mixture of pagesizes. Misses to the 0xf0000000 - 0x100000000, ie obp 
+	 * range, are handled in entry.S and do not use the vpte scheme (see rant
+	 * in inherit_locked_prom_mappings()).
+	 */
+#define OBP_PMD_SIZE 2048
+#define BASE_PAGE_SIZE 8192
+	pmd = __alloc_bootmem(OBP_PMD_SIZE, OBP_PMD_SIZE, 0UL);
+	if (pmd == NULL)
+		early_pgtable_allocfail("pmd");
+	memset(pmd, 0, OBP_PMD_SIZE);
 	for (i = 0; i < n; i++) {
 		unsigned long vaddr;
 
 		if (trans[i].virt >= 0xf0000000 && trans[i].virt < 0x100000000) {
 			for (vaddr = trans[i].virt;
 			     vaddr < trans[i].virt + trans[i].size;
-			     vaddr += PAGE_SIZE) {
+			     vaddr += BASE_PAGE_SIZE) {
 				unsigned long val;
 
-				pgdp = pgd_offset(&init_mm, vaddr);
-				if (pgd_none(*pgdp)) {
-					pmdp = __alloc_bootmem(PMD_TABLE_SIZE,
-							       PMD_TABLE_SIZE,
-							       0UL);
-					if (pmdp == NULL)
-						early_pgtable_allocfail("pmd");
-					memset(pmdp, 0, PMD_TABLE_SIZE);
-					pgd_set(pgdp, pmdp);
-				}
-				pmdp = pmd_offset(pgdp, vaddr);
+				pmdp = pmd + ((vaddr >> 23) & 0x7ff);
 				if (pmd_none(*pmdp)) {
-					ptep = __alloc_bootmem(PTE_TABLE_SIZE,
-							       PTE_TABLE_SIZE,
+					ptep = __alloc_bootmem(BASE_PAGE_SIZE,
+							       BASE_PAGE_SIZE,
 							       0UL);
 					if (ptep == NULL)
 						early_pgtable_allocfail("pte");
-					memset(ptep, 0, PTE_TABLE_SIZE);
+					memset(ptep, 0, BASE_PAGE_SIZE);
 					pmd_set(pmdp, ptep);
 				}
-				ptep = pte_offset(pmdp, vaddr);
+				ptep = (pte_t *)pmd_page(*pmdp) +
+						((vaddr >> 13) & 0x3ff);
 
 				val = trans[i].data;
 
@@ -267,10 +249,17 @@
 					val &= ~0x0003fe0000000000UL;
 
 				set_pte (ptep, __pte(val | _PAGE_MODIFIED));
-				trans[i].data += PAGE_SIZE;
+				trans[i].data += BASE_PAGE_SIZE;
 			}
 		}
 	}
+	phys_page = __pa(pmd);
+	obp_iaddr_patch[0] |= (phys_page >> 10);
+	obp_iaddr_patch[1] |= (phys_page & 0x3ff);
+	flushi((long)&obp_iaddr_patch[0]);
+	obp_daddr_patch[0] |= (phys_page >> 10);
+	obp_daddr_patch[1] |= (phys_page & 0x3ff);
+	flushi((long)&obp_daddr_patch[0]);
 
 	/* Now fixup OBP's idea about where we really are mapped. */
 	prom_printf("Remapping the kernel... ");
@@ -295,7 +284,7 @@
 
 	phys_page &= _PAGE_PADDR;
 	phys_page += ((unsigned long)&prom_boot_page -
-		      (unsigned long)&empty_zero_page);
+		      (unsigned long)KERNBASE);
 
 	if (tlb_type == spitfire) {
 		/* Lock this into i/d tlb entry 59 */
@@ -336,7 +325,7 @@
 		BUG();
 	}
 
-	tte_vaddr = (unsigned long) &empty_zero_page;
+	tte_vaddr = (unsigned long) KERNBASE;
 
 	/* Spitfire Errata #32 workaround */
 	__asm__ __volatile__("stxa	%0, [%1] %2\n\t"
@@ -366,7 +355,7 @@
 	remap_func((tlb_type == spitfire ?
 		    (spitfire_get_dtlb_data(sparc64_highest_locked_tlbent()) & _PAGE_PADDR) :
 		    (cheetah_get_litlb_data(sparc64_highest_locked_tlbent()) & _PAGE_PADDR)),
-		   (unsigned long) &empty_zero_page,
+		   (unsigned long) KERNBASE,
 		   prom_get_mmu_ihandle());
 
 	/* Flush out that temporary mapping. */
@@ -389,7 +378,7 @@
 		unsigned long size = trans[i].size;
 
 		if (vaddr < 0xf0000000UL) {
-			unsigned long avoid_start = (unsigned long) &empty_zero_page;
+			unsigned long avoid_start = (unsigned long) KERNBASE;
 			unsigned long avoid_end = avoid_start + (4 * 1024 * 1024);
 
 			if (vaddr < avoid_start) {
@@ -1048,7 +1037,7 @@
 	 * 4MB locked TLB translation.
 	 */
 	start_pfn  = PAGE_ALIGN((unsigned long) &_end) -
-		((unsigned long) &empty_zero_page);
+		((unsigned long) KERNBASE);
 
 	/* Adjust up to the physical address where the kernel begins. */
 	start_pfn += phys_base;
@@ -1133,7 +1122,7 @@
 	unsigned long alias_base = phys_base + PAGE_OFFSET;
 	unsigned long second_alias_page = 0;
 	unsigned long pt, flags, end_pfn, pages_avail;
-	unsigned long shift = alias_base - ((unsigned long)&empty_zero_page);
+	unsigned long shift = alias_base - ((unsigned long)KERNBASE);
 	unsigned long real_end;
 
 	set_bit(0, mmu_context_bmap);
@@ -1429,7 +1418,7 @@
 
 	addr = PAGE_OFFSET + phys_base;
 	last = PAGE_ALIGN((unsigned long)&_end) -
-		((unsigned long) &empty_zero_page);
+		((unsigned long) KERNBASE);
 	last += PAGE_OFFSET + phys_base;
 	while (addr < last) {
 		set_bit(__pa(addr) >> 22, sparc64_valid_addr_bitmap);
@@ -1441,7 +1430,20 @@
 	max_mapnr = last_valid_pfn - (phys_base >> PAGE_SHIFT);
 	high_memory = __va(last_valid_pfn << PAGE_SHIFT);
 
-	num_physpages = free_all_bootmem();
+	num_physpages = free_all_bootmem() - 1;
+
+	/*
+	 * Set up the zero page, mark it reserved, so that page count
+	 * is not manipulated when freeing the page from user ptes.
+	 */
+	mem_map_zero = _alloc_pages(GFP_KERNEL, 0);
+	if (mem_map_zero == NULL) {
+		prom_printf("paging_init: Cannot alloc zero page.\n");
+		prom_halt();
+	}
+	SetPageReserved(mem_map_zero);
+	clear_page(page_address(mem_map_zero));
+
 	codepages = (((unsigned long) &etext) - ((unsigned long)&_start));
 	codepages = PAGE_ALIGN(codepages) >> PAGE_SHIFT;
 	datapages = (((unsigned long) &edata) - ((unsigned long)&etext));
@@ -1455,7 +1457,7 @@
 		extern pgd_t empty_pg_dir[1024];
 		unsigned long addr = (unsigned long)empty_pg_dir;
 		unsigned long alias_base = phys_base + PAGE_OFFSET -
-			(long)(&empty_zero_page);
+			(long)(KERNBASE);
 		
 		memset(empty_pg_dir, 0, sizeof(empty_pg_dir));
 		addr += alias_base;
@@ -1477,16 +1479,20 @@
 
 void free_initmem (void)
 {
-	unsigned long addr;
+	unsigned long addr, initend;
 
-	addr = (unsigned long)(&__init_begin);
-	for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
+	/*
+	 * The init section is aligned to 8k in vmlinux.lds. Page align for >8k pagesizes.
+	 */
+	addr = PAGE_ALIGN((unsigned long)(&__init_begin));
+	initend = (unsigned long)(&__init_end) & PAGE_MASK;
+	for (; addr < initend; addr += PAGE_SIZE) {
 		unsigned long page;
 		struct page *p;
 
 		page = (addr +
 			((unsigned long) __va(phys_base)) -
-			((unsigned long) &empty_zero_page));
+			((unsigned long) KERNBASE));
 		p = virt_to_page(page);
 
 		ClearPageReserved(p);
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/mm/modutil.c linux/arch/sparc64/mm/modutil.c
--- v2.4.9/linux/arch/sparc64/mm/modutil.c	Thu Apr 12 12:10:25 2001
+++ linux/arch/sparc64/mm/modutil.c	Tue Aug 28 07:09:44 2001
@@ -1,4 +1,4 @@
-/*  $Id: modutil.c,v 1.8 2001/04/04 00:49:39 davem Exp $
+/*  $Id: modutil.c,v 1.9 2001/08/14 22:10:56 davem Exp $
  *  arch/sparc64/mm/modutil.c
  *
  *  Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
@@ -10,7 +10,10 @@
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <asm/vaddrs.h>
+
+#define  MODULES_VADDR	0x0000000001000000ULL  /* Where to map modules */
+#define  MODULES_LEN	0x000000007f000000ULL
+#define  MODULES_END	0x0000000080000000ULL
 
 static struct vm_struct * modvmlist = NULL;
 
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/mm/ultra.S linux/arch/sparc64/mm/ultra.S
--- v2.4.9/linux/arch/sparc64/mm/ultra.S	Sun Mar 25 18:14:21 2001
+++ linux/arch/sparc64/mm/ultra.S	Fri Sep  7 11:01:20 2001
@@ -1,4 +1,4 @@
-/* $Id: ultra.S,v 1.54 2001/03/22 07:26:04 davem Exp $
+/* $Id: ultra.S,v 1.56 2001/08/30 10:10:32 davem Exp $
  * ultra.S: Don't expand these all over the place...
  *
  * Copyright (C) 1997, 2000 David S. Miller (davem@redhat.com)
@@ -302,7 +302,7 @@
 	 nop
 
 flush_dcpage_cheetah:
-	sethi		%hi(8192), %o4
+	sethi		%hi(PAGE_SIZE), %o4
 1:	subcc		%o4, (1 << 5), %o4
 	stxa		%g0, [%o0 + %o4] ASI_DCACHE_INVALIDATE
 	membar		#Sync
@@ -440,13 +440,13 @@
 	retry
 
 xcall_flush_tlb_range:
-	sethi		%hi(8192 - 1), %g2
-	or		%g2, %lo(8192 - 1), %g2
+	sethi		%hi(PAGE_SIZE - 1), %g2
+	or		%g2, %lo(PAGE_SIZE - 1), %g2
 	andn		%g1, %g2, %g1
 	andn		%g7, %g2, %g7
 	sub		%g7, %g1, %g3
 	add		%g2, 1, %g2
-	srlx		%g3, 13, %g4
+	srlx		%g3, PAGE_SHIFT, %g4
 	cmp		%g4, 96
 
 	bgu,pn		%icc, xcall_flush_tlb_mm
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/solaris/fs.c linux/arch/sparc64/solaris/fs.c
--- v2.4.9/linux/arch/sparc64/solaris/fs.c	Sun Feb 18 19:49:54 2001
+++ linux/arch/sparc64/solaris/fs.c	Wed Sep 12 15:34:06 2001
@@ -406,21 +406,21 @@
 	u32	f_filler[16];
 };
 
-static int report_statvfs(struct inode *inode, u32 buf)
+static int report_statvfs(struct vfsmount *mnt, struct inode *inode, u32 buf)
 {
 	struct statfs s;
 	int error;
 	struct sol_statvfs *ss = (struct sol_statvfs *)A(buf);
 
-	error = vfs_statfs(inode->i_sb, &s);
+	error = vfs_statfs(mnt->mnt_sb, &s);
 	if (!error) {
-		const char *p = inode->i_sb->s_type->name;
+		const char *p = mnt->mnt_sb->s_type->name;
 		int i = 0;
 		int j = strlen (p);
 		
 		if (j > 15) j = 15;
 		if (IS_RDONLY(inode)) i = 1;
-		if (IS_NOSUID(inode)) i |= 2;
+		if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
 		if (put_user (s.f_bsize, &ss->f_bsize)		||
 		    __put_user (0, &ss->f_frsize)		||
 		    __put_user (s.f_blocks, &ss->f_blocks)	||
@@ -440,21 +440,21 @@
 	return error;
 }
 
-static int report_statvfs64(struct inode *inode, u32 buf)
+static int report_statvfs64(struct vfsmount *mnt, struct inode *inode, u32 buf)
 {
 	struct statfs s;
 	int error;
 	struct sol_statvfs64 *ss = (struct sol_statvfs64 *)A(buf);
 			
-	error = vfs_statfs(inode->i_sb, &s);
+	error = vfs_statfs(mnt->mnt_sb, &s);
 	if (!error) {
-		const char *p = inode->i_sb->s_type->name;
+		const char *p = mnt->mnt_sb->s_type->name;
 		int i = 0;
 		int j = strlen (p);
 		
 		if (j > 15) j = 15;
 		if (IS_RDONLY(inode)) i = 1;
-		if (IS_NOSUID(inode)) i |= 2;
+		if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
 		if (put_user (s.f_bsize, &ss->f_bsize)		||
 		    __put_user (0, &ss->f_frsize)		||
 		    __put_user (s.f_blocks, &ss->f_blocks)	||
@@ -482,7 +482,7 @@
 	error = user_path_walk((const char *)A(path),&nd);
 	if (!error) {
 		struct inode * inode = nd.dentry->d_inode;
-		error = report_statvfs(inode, buf);
+		error = report_statvfs(nd.mnt, inode, buf);
 		path_release(&nd);
 	}
 	return error;
@@ -496,7 +496,7 @@
 	error = -EBADF;
 	file = fget(fd);
 	if (file) {
-		error = report_statvfs(file->f_dentry->d_inode, buf);
+		error = report_statvfs(file->f_vfsmnt, file->f_dentry->d_inode, buf);
 		fput(file);
 	}
 
@@ -512,7 +512,7 @@
 	error = user_path_walk((const char *)A(path), &nd);
 	if (!error) {
 		struct inode * inode = nd.dentry->d_inode;
-		error = report_statvfs64(inode, buf);
+		error = report_statvfs64(nd.mnt, inode, buf);
 		path_release(&nd);
 	}
 	unlock_kernel();
@@ -528,7 +528,7 @@
 	file = fget(fd);
 	if (file) {
 		lock_kernel();
-		error = report_statvfs64(file->f_dentry->d_inode, buf);
+		error = report_statvfs64(file->f_vfsmnt, file->f_dentry->d_inode, buf);
 		unlock_kernel();
 		fput(file);
 	}
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/solaris/misc.c linux/arch/sparc64/solaris/misc.c
--- v2.4.9/linux/arch/sparc64/solaris/misc.c	Sun Mar 25 18:14:21 2001
+++ linux/arch/sparc64/solaris/misc.c	Mon Sep 10 13:04:33 2001
@@ -709,7 +709,7 @@
 
 struct exec_domain solaris_exec_domain = {
 	"Solaris",
-	(lcall7_func)NULL,
+	NULL,
 	1, 1,	/* PER_SVR4 personality */
 	solaris_to_linux_signals,
 	linux_to_solaris_signals,
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/solaris/timod.c linux/arch/sparc64/solaris/timod.c
--- v2.4.9/linux/arch/sparc64/solaris/timod.c	Mon Aug 27 12:41:40 2001
+++ linux/arch/sparc64/solaris/timod.c	Mon Sep 10 09:04:53 2001
@@ -699,7 +699,7 @@
 	}
 	if (ctl_maxlen >= 0 && sock->pfirst) {
 		struct T_primsg *it = sock->pfirst;
-		int l = min(int, ctl_maxlen, it->length);
+		int l = min_t(int, ctl_maxlen, it->length);
 		SCHECK_MAGIC((char*)((u64)(((char *)&it->type)+sock->offset+it->length+7)&~7),MKCTL_MAGIC);
 		SOLD("purting ctl data");
 		if(copy_to_user(ctl_buf,
diff -u --recursive --new-file v2.4.9/linux/arch/sparc64/vmlinux.lds linux/arch/sparc64/vmlinux.lds
--- v2.4.9/linux/arch/sparc64/vmlinux.lds	Tue Jul  3 17:08:19 2001
+++ linux/arch/sparc64/vmlinux.lds	Fri Sep  7 11:01:20 2001
@@ -5,7 +5,6 @@
 
 SECTIONS
 {
-  empty_zero_page = 0x0000000000400000;
   swapper_pmd_dir = 0x0000000000402000;
   empty_pg_dir = 0x0000000000403000;
   . = 0x4000;
diff -u --recursive --new-file v2.4.9/linux/drivers/acorn/block/mfmhd.c linux/drivers/acorn/block/mfmhd.c
--- v2.4.9/linux/drivers/acorn/block/mfmhd.c	Mon Aug 27 12:41:40 2001
+++ linux/drivers/acorn/block/mfmhd.c	Thu Sep 13 15:21:32 2001
@@ -1210,6 +1210,8 @@
 
 	case BLKGETSIZE:
 		return put_user (mfm[minor].nr_sects, (long *)arg);
+	case BLKGETSIZE64:
+		return put_user ((u64)mfm[minor].nr_sects << 9, (u64 *)arg);
 
 	case BLKFRASET:
 		if (!capable(CAP_SYS_ADMIN))
@@ -1311,15 +1313,13 @@
 }
 
 static struct gendisk mfm_gendisk = {
-	MAJOR_NR,		/* Major number */
-	"mfm",			/* Major name */
-	6,			/* Bits to shift to get real from partition */
-	1 << 6,			/* Number of partitions per real */
-	mfm,			/* hd struct */
-	mfm_sizes,		/* block sizes */
-	0,			/* number */
-	(void *) mfm_info,	/* internal */
-	NULL			/* next */
+	major:		MAJOR_NR,
+	major_name:	"mfm",
+	minor_shift:	6,
+	max_p:		1 << 6,
+	part:		mfm,
+	sizes:		mfm_sizes,
+	real_devices:	(void *)mfm_info,
 };
 
 static struct block_device_operations mfm_fops =
@@ -1450,10 +1450,7 @@
 	blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST);
 	read_ahead[MAJOR_NR] = 8;	/* 8 sector (4kB?) read ahread */
 
-#ifndef MODULE
-	mfm_gendisk.next = gendisk_head;
-	gendisk_head = &mfm_gendisk;
-#endif
+	add_gendisk(&mfm_gendisk);
 
 	Busy = 0;
 	lastspecifieddrive = -1;
@@ -1501,6 +1498,10 @@
 }
 
 #ifdef MODULE
+
+EXPORT_NO_SYMBOLS;
+MODULE_LICENSE("GPL");
+
 int init_module(void)
 {
 	return mfm_init();
@@ -1512,6 +1513,7 @@
 		outw (0, mfm_irqenable);	/* Required to enable IRQs from MFM podule */
 	free_irq(mfm_irq, NULL);
 	unregister_blkdev(MAJOR_NR, "mfm");
+	del_gendisk(&mfm_gendisk);
 	if (ecs)
 		ecard_release(ecs);
 	if (mfm_addr)
diff -u --recursive --new-file v2.4.9/linux/drivers/acorn/char/serial-card.c linux/drivers/acorn/char/serial-card.c
--- v2.4.9/linux/drivers/acorn/char/serial-card.c	Mon Sep 18 15:15:22 2000
+++ linux/drivers/acorn/char/serial-card.c	Thu Sep 13 15:21:32 2001
@@ -126,5 +126,7 @@
 
 EXPORT_NO_SYMBOLS;
 
+MODULE_LICENSE("GPL");
+
 module_init(INIT);
 module_exit(EXIT);
diff -u --recursive --new-file v2.4.9/linux/drivers/acorn/net/ether1.c linux/drivers/acorn/net/ether1.c
--- v2.4.9/linux/drivers/acorn/net/ether1.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/acorn/net/ether1.c	Thu Sep 13 15:21:32 2001
@@ -1102,3 +1102,5 @@
 
 module_init(ether1_init);
 module_exit(ether1_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/acorn/net/ether3.c linux/drivers/acorn/net/ether3.c
--- v2.4.9/linux/drivers/acorn/net/ether3.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/acorn/net/ether3.c	Thu Sep 13 15:21:32 2001
@@ -938,3 +938,5 @@
 
 module_init(ether3_init);
 module_exit(ether3_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/acorn/net/etherh.c linux/drivers/acorn/net/etherh.c
--- v2.4.9/linux/drivers/acorn/net/etherh.c	Mon Aug 27 12:41:40 2001
+++ linux/drivers/acorn/net/etherh.c	Thu Sep 13 15:21:32 2001
@@ -67,6 +67,7 @@
 
 MODULE_AUTHOR("Russell King");
 MODULE_DESCRIPTION("EtherH/EtherM driver");
+MODULE_LICENSE("GPL");
 
 static char version[] __initdata =
 	"EtherH/EtherM Driver (c) 2000 Russell King v1.08\n";
diff -u --recursive --new-file v2.4.9/linux/drivers/acorn/scsi/acornscsi.c linux/drivers/acorn/scsi/acornscsi.c
--- v2.4.9/linux/drivers/acorn/scsi/acornscsi.c	Mon Aug 27 12:41:40 2001
+++ linux/drivers/acorn/scsi/acornscsi.c	Thu Sep 13 15:21:32 2001
@@ -1059,7 +1059,7 @@
     /*
      * Allocate some buffer space, limited to half the buffer size
      */
-    length = min(unsigned int, host->scsi.SCp.this_residual, DMAC_BUFFER_SIZE / 2);
+    length = min_t(unsigned int, host->scsi.SCp.this_residual, DMAC_BUFFER_SIZE / 2);
     if (length) {
 	host->dma.start_addr = address = host->dma.free_addr;
 	host->dma.free_addr = (host->dma.free_addr + length) &
@@ -1187,7 +1187,7 @@
     /*
      * Allocate some buffer space, limited to half the on-board RAM size
      */
-    length = min(unsigned int, host->scsi.SCp.this_residual, DMAC_BUFFER_SIZE / 2);
+    length = min_t(unsigned int, host->scsi.SCp.this_residual, DMAC_BUFFER_SIZE / 2);
     if (length) {
 	host->dma.start_addr = address = host->dma.free_addr;
 	host->dma.free_addr = (host->dma.free_addr + length) &
@@ -1656,8 +1656,8 @@
 		 * to be in operation AFTER the target leaves message out phase.
 		 */
 		acornscsi_sbic_issuecmd(host, CMND_ASSERTATN);
-		period = max(unsigned int, message[3], sdtr_period / 4);
-		length = min(unsigned int, message[4], sdtr_size);
+		period = max_t(unsigned int, message[3], sdtr_period / 4);
+		length = min_t(unsigned int, message[4], sdtr_size);
 		msgqueue_addmsg(&host->scsi.msgs, 5, EXTENDED_MESSAGE, 3,
 				 EXTENDED_SDTR, period, length);
 		host->device[host->SCpnt->target].sync_xfer =
@@ -3158,3 +3158,6 @@
 
 module_init(acornscsi_init);
 module_exit(acornscsi_exit);
+
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/acorn/scsi/arxescsi.c linux/drivers/acorn/scsi/arxescsi.c
--- v2.4.9/linux/drivers/acorn/scsi/arxescsi.c	Thu Feb  8 16:32:44 2001
+++ linux/drivers/acorn/scsi/arxescsi.c	Thu Sep 13 15:21:32 2001
@@ -439,3 +439,4 @@
 module_init(init_arxe_scsi_driver);
 module_exit(exit_arxe_scsi_driver);
 
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/acorn/scsi/cumana_1.c linux/drivers/acorn/scsi/cumana_1.c
--- v2.4.9/linux/drivers/acorn/scsi/cumana_1.c	Thu Feb  8 16:32:44 2001
+++ linux/drivers/acorn/scsi/cumana_1.c	Thu Sep 13 15:21:32 2001
@@ -424,3 +424,6 @@
 
 module_init(cumanascsi_init);
 module_exit(cumanascsi_exit);
+
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/acorn/scsi/cumana_2.c linux/drivers/acorn/scsi/cumana_2.c
--- v2.4.9/linux/drivers/acorn/scsi/cumana_2.c	Fri Mar  2 18:38:37 2001
+++ linux/drivers/acorn/scsi/cumana_2.c	Thu Sep 13 15:21:32 2001
@@ -86,6 +86,7 @@
 MODULE_DESCRIPTION("Cumana SCSI II driver");
 MODULE_PARM(term, "1-8i");
 MODULE_PARM_DESC(term, "SCSI bus termination");
+MODULE_LICENSE("GPL");
 
 /*
  * Use term=0,1,0,0,0 to turn terminators on/off
diff -u --recursive --new-file v2.4.9/linux/drivers/acorn/scsi/ecoscsi.c linux/drivers/acorn/scsi/ecoscsi.c
--- v2.4.9/linux/drivers/acorn/scsi/ecoscsi.c	Thu Feb  8 16:32:44 2001
+++ linux/drivers/acorn/scsi/ecoscsi.c	Thu Sep 13 15:21:32 2001
@@ -292,3 +292,6 @@
 
 module_init(ecoscsi_init);
 module_exit(ecoscsi_exit);
+
+EXPORT_NO_SYMBOLS;
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/acorn/scsi/eesox.c linux/drivers/acorn/scsi/eesox.c
--- v2.4.9/linux/drivers/acorn/scsi/eesox.c	Fri Mar  2 18:38:37 2001
+++ linux/drivers/acorn/scsi/eesox.c	Thu Sep 13 15:21:32 2001
@@ -602,3 +602,5 @@
 module_init(eesox_init);
 module_exit(eesox_exit);
 
+EXPORT_NO_SYMBOLS;
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/acorn/scsi/fas216.c linux/drivers/acorn/scsi/fas216.c
--- v2.4.9/linux/drivers/acorn/scsi/fas216.c	Thu Feb  8 16:32:44 2001
+++ linux/drivers/acorn/scsi/fas216.c	Thu Sep 13 15:21:32 2001
@@ -2777,3 +2777,5 @@
 {
 }
 #endif
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/acorn/scsi/msgqueue.c linux/drivers/acorn/scsi/msgqueue.c
--- v2.4.9/linux/drivers/acorn/scsi/msgqueue.c	Thu Feb  8 16:32:44 2001
+++ linux/drivers/acorn/scsi/msgqueue.c	Thu Sep 13 15:21:32 2001
@@ -18,6 +18,7 @@
 
 MODULE_AUTHOR("Russell King");
 MODULE_DESCRIPTION("SCSI message queue handling");
+MODULE_LICENSE("GPL");
 
 /*
  * Function: struct msgqueue_entry *mqe_alloc(MsgQueue_t *msgq)
diff -u --recursive --new-file v2.4.9/linux/drivers/acorn/scsi/oak.c linux/drivers/acorn/scsi/oak.c
--- v2.4.9/linux/drivers/acorn/scsi/oak.c	Thu Feb  8 16:32:44 2001
+++ linux/drivers/acorn/scsi/oak.c	Thu Sep 13 15:21:32 2001
@@ -285,3 +285,6 @@
 
 module_init(oakscsi_init);
 module_exit(oakscsi_exit);
+
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/acorn/scsi/powertec.c linux/drivers/acorn/scsi/powertec.c
--- v2.4.9/linux/drivers/acorn/scsi/powertec.c	Fri Mar  2 18:38:37 2001
+++ linux/drivers/acorn/scsi/powertec.c	Thu Sep 13 15:21:32 2001
@@ -81,6 +81,7 @@
 MODULE_DESCRIPTION("Powertec SCSI driver");
 MODULE_PARM(term, "1-8i");
 MODULE_PARM_DESC(term, "SCSI bus termination");
+MODULE_LICENSE("GPL");
 
 static struct expansion_card *ecs[MAX_ECARDS];
 
diff -u --recursive --new-file v2.4.9/linux/drivers/acorn/scsi/queue.c linux/drivers/acorn/scsi/queue.c
--- v2.4.9/linux/drivers/acorn/scsi/queue.c	Fri Feb  9 11:30:22 2001
+++ linux/drivers/acorn/scsi/queue.c	Thu Sep 13 15:21:32 2001
@@ -27,6 +27,7 @@
 
 MODULE_AUTHOR("Russell King");
 MODULE_DESCRIPTION("SCSI command queueing");
+MODULE_LICENSE("GPL");
 
 #define DEBUG
 
diff -u --recursive --new-file v2.4.9/linux/drivers/acpi/Makefile linux/drivers/acpi/Makefile
--- v2.4.9/linux/drivers/acpi/Makefile	Tue Jul  3 17:08:19 2001
+++ linux/drivers/acpi/Makefile	Sat Sep  8 12:26:47 2001
@@ -38,9 +38,8 @@
 obj-$(CONFIG_ACPI)	+= $(foreach dir,$(acpi-subdirs),$(dir)/$(dir).o) 
 ifdef CONFIG_ACPI_KERNEL_CONFIG
    obj-$(CONFIG_ACPI) 	+= acpiconf.o osconf.o
-else
-   obj-$(CONFIG_ACPI)	+= driver.o
 endif
+obj-$(CONFIG_ACPI)	+= driver.o
 
 ifeq ($(CONFIG_ACPI_BUSMGR),y)
 	obj-y			+= ospm/ospm.o
diff -u --recursive --new-file v2.4.9/linux/drivers/acpi/include/platform/acgcc.h linux/drivers/acpi/include/platform/acgcc.h
--- v2.4.9/linux/drivers/acpi/include/platform/acgcc.h	Tue Jul  3 17:08:19 2001
+++ linux/drivers/acpi/include/platform/acgcc.h	Sat Sep  1 11:01:28 2001
@@ -39,7 +39,6 @@
 #define BREAKPOINT3
 #define disable() __cli()
 #define enable()  __sti()
-#define wbinvd()
 
 /*! [Begin] no source code translation */
 
@@ -101,7 +100,6 @@
 #define disable() __cli()
 #define enable()  __sti()
 #define halt()    __asm__ __volatile__ ("sti; hlt":::"memory")
-#define wbinvd()
 
 /*! [Begin] no source code translation
  *
diff -u --recursive --new-file v2.4.9/linux/drivers/acpi/os.c linux/drivers/acpi/os.c
--- v2.4.9/linux/drivers/acpi/os.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/acpi/os.c	Thu Sep 13 16:04:43 2001
@@ -156,7 +156,14 @@
 	}
 
 	if ((unsigned long) phys < virt_to_phys(high_memory)) {
+		struct page *page;
 		*virt = phys_to_virt((unsigned long) phys);
+	
+		/* Check for stamping */
+		page = virt_to_page(*virt);
+		if(page && !test_bit(PG_reserved, &page->flags))
+			printk(KERN_WARNING "ACPI attempting to access kernel owned memory at %08lX.\n", (unsigned long)phys);
+
 		return AE_OK;
 	}
 
diff -u --recursive --new-file v2.4.9/linux/drivers/acpi/ospm/ac_adapter/ac_osl.c linux/drivers/acpi/ospm/ac_adapter/ac_osl.c
--- v2.4.9/linux/drivers/acpi/ospm/ac_adapter/ac_osl.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/acpi/ospm/ac_adapter/ac_osl.c	Thu Sep 13 16:04:43 2001
@@ -35,6 +35,7 @@
 
 MODULE_AUTHOR("Andrew Grover");
 MODULE_DESCRIPTION("ACPI Component Architecture (CA) - AC Adapter Driver");
+MODULE_LICENSE("GPL");
 
 
 #define AC_PROC_ROOT		"ac_adapter"
diff -u --recursive --new-file v2.4.9/linux/drivers/acpi/ospm/battery/bt_osl.c linux/drivers/acpi/ospm/battery/bt_osl.c
--- v2.4.9/linux/drivers/acpi/ospm/battery/bt_osl.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/acpi/ospm/battery/bt_osl.c	Thu Sep 13 16:04:43 2001
@@ -44,6 +44,7 @@
 
 MODULE_AUTHOR("Andrew Grover");
 MODULE_DESCRIPTION("ACPI Component Architecture (CA) - Control Method Battery Driver");
+MODULE_LICENSE("GPL");
 
 
 #define BT_PROC_ROOT		"battery"
diff -u --recursive --new-file v2.4.9/linux/drivers/acpi/ospm/busmgr/Makefile linux/drivers/acpi/ospm/busmgr/Makefile
--- v2.4.9/linux/drivers/acpi/ospm/busmgr/Makefile	Tue Jul  3 17:08:19 2001
+++ linux/drivers/acpi/ospm/busmgr/Makefile	Sun Sep  2 07:48:02 2001
@@ -1,3 +1,5 @@
+export-objs	:= bm_osl.o
+
 O_TARGET	:= ospm_$(notdir $(CURDIR)).o
 obj-m		:= $(O_TARGET)
 EXTRA_CFLAGS	+= $(ACPI_CFLAGS)
diff -u --recursive --new-file v2.4.9/linux/drivers/acpi/ospm/busmgr/bm_osl.c linux/drivers/acpi/ospm/busmgr/bm_osl.c
--- v2.4.9/linux/drivers/acpi/ospm/busmgr/bm_osl.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/acpi/ospm/busmgr/bm_osl.c	Thu Sep 13 16:04:43 2001
@@ -37,6 +37,7 @@
 
 MODULE_AUTHOR("Andrew Grover");
 MODULE_DESCRIPTION("ACPI Component Architecture (CA) - ACPI Bus Manager");
+MODULE_LICENSE("GPL");
 
 
 #ifdef ACPI_DEBUG
diff -u --recursive --new-file v2.4.9/linux/drivers/acpi/ospm/button/bn_osl.c linux/drivers/acpi/ospm/button/bn_osl.c
--- v2.4.9/linux/drivers/acpi/ospm/button/bn_osl.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/acpi/ospm/button/bn_osl.c	Thu Sep 13 16:04:43 2001
@@ -35,6 +35,7 @@
 
 MODULE_AUTHOR("Andrew Grover");
 MODULE_DESCRIPTION("ACPI Component Architecture (CA) - Button Driver");
+MODULE_LICENSE("GPL");
 
 
 #define BN_PROC_ROOT		"button"
diff -u --recursive --new-file v2.4.9/linux/drivers/acpi/ospm/ec/ec_osl.c linux/drivers/acpi/ospm/ec/ec_osl.c
--- v2.4.9/linux/drivers/acpi/ospm/ec/ec_osl.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/acpi/ospm/ec/ec_osl.c	Thu Sep 13 16:04:43 2001
@@ -36,6 +36,7 @@
 
 MODULE_AUTHOR("Andrew Grover");
 MODULE_DESCRIPTION("ACPI Component Architecture (CA) - Embedded Controller Driver");
+MODULE_LICENSE("GPL");
 
 #ifdef ACPI_DEBUG
 
diff -u --recursive --new-file v2.4.9/linux/drivers/acpi/ospm/processor/pr_osl.c linux/drivers/acpi/ospm/processor/pr_osl.c
--- v2.4.9/linux/drivers/acpi/ospm/processor/pr_osl.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/acpi/ospm/processor/pr_osl.c	Thu Sep 13 16:04:43 2001
@@ -36,6 +36,7 @@
 
 MODULE_AUTHOR("Andrew Grover");
 MODULE_DESCRIPTION("ACPI Component Architecture (CA) - IA32 Processor Driver");
+MODULE_LICENSE("GPL");
 
 
 #define PR_PROC_ROOT		"processor"
diff -u --recursive --new-file v2.4.9/linux/drivers/acpi/ospm/system/sm_osl.c linux/drivers/acpi/ospm/system/sm_osl.c
--- v2.4.9/linux/drivers/acpi/ospm/system/sm_osl.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/acpi/ospm/system/sm_osl.c	Thu Sep 13 16:04:43 2001
@@ -38,6 +38,7 @@
 
 MODULE_AUTHOR("Andrew Grover");
 MODULE_DESCRIPTION("ACPI Component Architecture (CA) - ACPI System Driver");
+MODULE_LICENSE("GPL");
 
 
 #define SM_PROC_INFO		"info"
diff -u --recursive --new-file v2.4.9/linux/drivers/acpi/ospm/thermal/tz_osl.c linux/drivers/acpi/ospm/thermal/tz_osl.c
--- v2.4.9/linux/drivers/acpi/ospm/thermal/tz_osl.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/acpi/ospm/thermal/tz_osl.c	Thu Sep 13 16:04:43 2001
@@ -35,6 +35,7 @@
 
 MODULE_AUTHOR("Andrew Grover");
 MODULE_DESCRIPTION("ACPI Component Architecture (CA) - Thermal Zone Driver");
+MODULE_LICENSE("GPL");
 
 int TZP = 0;
 MODULE_PARM(TZP, "i");
diff -u --recursive --new-file v2.4.9/linux/drivers/atm/Makefile linux/drivers/atm/Makefile
--- v2.4.9/linux/drivers/atm/Makefile	Mon Mar 26 15:36:30 2001
+++ linux/drivers/atm/Makefile	Mon Aug 27 09:01:33 2001
@@ -25,6 +25,7 @@
 obj-$(CONFIG_ATM_AMBASSADOR) += ambassador.o
 obj-$(CONFIG_ATM_TCP) += atmtcp.o
 obj-$(CONFIG_ATM_IA) += iphase.o suni.o
+obj-$(CONFIG_ATM_FIRESTREAM) += firestream.o
 
 ifeq ($(CONFIG_ATM_FORE200E_PCA),y)
   FORE200E_FW_OBJS += fore200e_pca_fw.o
diff -u --recursive --new-file v2.4.9/linux/drivers/atm/ambassador.c linux/drivers/atm/ambassador.c
--- v2.4.9/linux/drivers/atm/ambassador.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/atm/ambassador.c	Thu Sep 13 15:21:32 2001
@@ -297,16 +297,16 @@
 #define UCODE2(x) #x
 #define UCODE1(x,y) UCODE2(x ## y)
 
-static const u32 __initdata ucode_start = 
+static u32 __initdata ucode_start = 
 #include UCODE(start)
 ;
 
-static const region __initdata ucode_regions[] = {
+static region __initdata ucode_regions[] = {
 #include UCODE(regions)
   { 0, 0 }
 };
 
-static const u32 __initdata ucode_data[] = {
+static u32 __initdata ucode_data[] = {
 #include UCODE(data)
   0xdeadbeef
 };
@@ -2585,6 +2585,7 @@
 
 MODULE_AUTHOR(maintainer_string);
 MODULE_DESCRIPTION(description_string);
+MODULE_LICENSE("GPL");
 MODULE_PARM(debug,   "h");
 MODULE_PARM(cmds,    "i");
 MODULE_PARM(txs,     "i");
diff -u --recursive --new-file v2.4.9/linux/drivers/atm/ambassador.h linux/drivers/atm/ambassador.h
--- v2.4.9/linux/drivers/atm/ambassador.h	Mon Dec 11 13:22:06 2000
+++ linux/drivers/atm/ambassador.h	Thu Sep 13 15:21:32 2001
@@ -664,9 +664,9 @@
   unsigned int count;
 } region;
 
-extern const region ucode_regions[];
-extern const u32 ucode_data[];
-extern const u32 ucode_start;
+static region ucode_regions[];
+static u32 ucode_data[];
+static u32 ucode_start;
 
 /* rate rounding */
 
diff -u --recursive --new-file v2.4.9/linux/drivers/atm/atmtcp.c linux/drivers/atm/atmtcp.c
--- v2.4.9/linux/drivers/atm/atmtcp.c	Fri Dec 29 14:35:47 2000
+++ linux/drivers/atm/atmtcp.c	Thu Sep 13 15:21:32 2001
@@ -420,6 +420,7 @@
 	atm_tcp_ops.remove_persistent = NULL;
 }
 
+MODULE_LICENSE("GPL");
 #else
 
 struct atm_tcp_ops atm_tcp_ops = {
diff -u --recursive --new-file v2.4.9/linux/drivers/atm/eni.c linux/drivers/atm/eni.c
--- v2.4.9/linux/drivers/atm/eni.c	Wed May 16 10:22:50 2001
+++ linux/drivers/atm/eni.c	Thu Sep 13 15:21:32 2001
@@ -2340,3 +2340,6 @@
 
 module_init(eni_init);
 module_exit(eni_cleanup);
+
+EXPORT_NO_SYMBOLS;
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/atm/firestream.c linux/drivers/atm/firestream.c
--- v2.4.9/linux/drivers/atm/firestream.c	Wed Apr 11 19:02:30 2001
+++ linux/drivers/atm/firestream.c	Thu Sep 13 15:21:32 2001
@@ -271,11 +271,11 @@
 
    150000 packets per second is close to the limit a PC is going to have
    anyway. We therefore have to disable this for production. -- REW */
-#undef IRQ_RATE_LIMIT 100
+#undef IRQ_RATE_LIMIT // 100
 
 /* Interrupts work now. Unlike serial cards, ATM cards don't work all
    that great without interrupts. -- REW */
-#undef FS_POLL_FREQ 100
+#undef FS_POLL_FREQ // 100
 
 /* 
    This driver can spew a whole lot of debugging output at you. If you
@@ -1928,8 +1928,6 @@
 
  err_out_free_atm_dev:
 	atm_dev_deregister(atm_dev);
- err_out_free_fs_dev:
-	kfree(fs_dev);
  err_out:
 	return -ENODEV;
 }
@@ -2120,3 +2118,5 @@
 module_init(firestream_init_module);
 module_exit(firestream_cleanup_module);
 
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/atm/firestream.h linux/drivers/atm/firestream.h
--- v2.4.9/linux/drivers/atm/firestream.h	Wed Apr 11 19:02:30 2001
+++ linux/drivers/atm/firestream.h	Sat Sep  8 12:28:14 2001
@@ -345,18 +345,28 @@
 #define CELLOSCONF_COST   (0x1 <<  0)
 /* Bits? */
 
-
 #define RAS0 0x1bc
 #define RAS0_DCD_XHLT (0x1 << 31)
 
 #define RAS0_VPSEL    (0x1 << 16)
 #define RAS0_VCSEL    (0x1 <<  0)
 
+#define RAS1 0x1c0
+#define RAS1_UTREG    (0x1 << 5)
+
 
 #define DMAMR 0x1cc
 #define DMAMR_TX_MODE_FULL (0x0 << 0)
 #define DMAMR_TX_MODE_PART (0x1 << 0)
 #define DMAMR_TX_MODE_NONE (0x2 << 0) /* And 3 */
+
+
+
+#define RAS2 0x280
+
+#define RAS2_NNI  (0x1 << 0)
+#define RAS2_USEL (0x1 << 1)
+#define RAS2_UBS  (0x1 << 2)
 
 
 
diff -u --recursive --new-file v2.4.9/linux/drivers/atm/fore200e.c linux/drivers/atm/fore200e.c
--- v2.4.9/linux/drivers/atm/fore200e.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/atm/fore200e.c	Thu Sep 13 15:21:32 2001
@@ -3000,3 +3000,5 @@
 #endif
     {}
 };
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/atm/horizon.c linux/drivers/atm/horizon.c
--- v2.4.9/linux/drivers/atm/horizon.c	Fri Dec 29 14:35:47 2000
+++ linux/drivers/atm/horizon.c	Thu Sep 13 15:21:32 2001
@@ -2935,6 +2935,7 @@
 
 MODULE_AUTHOR(maintainer_string);
 MODULE_DESCRIPTION(description_string);
+MODULE_LICENSE("GPL");
 MODULE_PARM(debug, "h");
 MODULE_PARM(vpi_bits, "h");
 MODULE_PARM(max_tx_size, "h");
diff -u --recursive --new-file v2.4.9/linux/drivers/atm/idt77105.c linux/drivers/atm/idt77105.c
--- v2.4.9/linux/drivers/atm/idt77105.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/atm/idt77105.c	Thu Sep 13 15:21:32 2001
@@ -374,9 +374,7 @@
             }
         }
 
-#ifdef MODULE
 	MOD_DEC_USE_COUNT;
-#endif /* MODULE */
 	return 0;
 }
 
@@ -384,6 +382,8 @@
 
 EXPORT_SYMBOL(idt77105_init);
 EXPORT_SYMBOL(idt77105_stop);
+
+MODULE_LICENSE("GPL");
 
 #ifdef MODULE
 
diff -u --recursive --new-file v2.4.9/linux/drivers/atm/nicstar.c linux/drivers/atm/nicstar.c
--- v2.4.9/linux/drivers/atm/nicstar.c	Wed Jul 25 17:10:19 2001
+++ linux/drivers/atm/nicstar.c	Thu Sep 13 15:21:32 2001
@@ -271,6 +271,7 @@
 static struct timer_list ns_timer;
 static char *mac[NS_MAX_CARDS];
 MODULE_PARM(mac, "1-" __MODULE_STRING(NS_MAX_CARDS) "s");
+MODULE_LICENSE("GPL");
 
 
 /* Functions*******************************************************************/
diff -u --recursive --new-file v2.4.9/linux/drivers/atm/suni.c linux/drivers/atm/suni.c
--- v2.4.9/linux/drivers/atm/suni.c	Fri May  5 12:37:52 2000
+++ linux/drivers/atm/suni.c	Thu Sep 13 15:21:32 2001
@@ -309,6 +309,8 @@
 EXPORT_SYMBOL(suni_init);
 
 
+MODULE_LICENSE("GPL");
+
 #ifdef MODULE
 
 
diff -u --recursive --new-file v2.4.9/linux/drivers/atm/uPD98402.c linux/drivers/atm/uPD98402.c
--- v2.4.9/linux/drivers/atm/uPD98402.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/atm/uPD98402.c	Thu Sep 13 15:21:32 2001
@@ -255,6 +255,7 @@
 
 
 #ifdef MODULE
+MODULE_LICENSE("GPL");
 
 EXPORT_SYMBOL(uPD98402_init);
 
diff -u --recursive --new-file v2.4.9/linux/drivers/atm/zatm.c linux/drivers/atm/zatm.c
--- v2.4.9/linux/drivers/atm/zatm.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/atm/zatm.c	Thu Sep 13 15:21:32 2001
@@ -1846,6 +1846,8 @@
 
 #ifdef MODULE
  
+MODULE_LICENSE("GPL");
+
 int init_module(void)
 {
 	if (!zatm_detect()) {
diff -u --recursive --new-file v2.4.9/linux/drivers/block/DAC960.c linux/drivers/block/DAC960.c
--- v2.4.9/linux/drivers/block/DAC960.c	Sun Aug 12 13:27:59 2001
+++ linux/drivers/block/DAC960.c	Mon Sep 10 12:42:31 2001
@@ -31,6 +31,7 @@
 #include <linux/completion.h>
 #include <linux/delay.h>
 #include <linux/hdreg.h>
+#include <linux/blkpg.h>
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/locks.h>
@@ -1882,7 +1883,6 @@
 static boolean DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller)
 {
   int MajorNumber = DAC960_MAJOR + Controller->ControllerNumber;
-  GenericDiskInfo_T *GenericDiskInfo;
   RequestQueue_T *RequestQueue;
   int MinorNumber;
   /*
@@ -1937,13 +1937,7 @@
   /*
     Install the Generic Disk Information structure at the end of the list.
   */
-  if ((GenericDiskInfo = gendisk_head) != NULL)
-    {
-      while (GenericDiskInfo->next != NULL)
-	GenericDiskInfo = GenericDiskInfo->next;
-      GenericDiskInfo->next = &Controller->GenericDiskInfo;
-    }
-  else gendisk_head = &Controller->GenericDiskInfo;
+  add_gendisk(&Controller->GenericDiskInfo);
   /*
     Indicate the Block Device Registration completed successfully,
   */
@@ -1979,16 +1973,7 @@
   /*
     Remove the Generic Disk Information structure from the list.
   */
-  if (gendisk_head != &Controller->GenericDiskInfo)
-    {
-      GenericDiskInfo_T *GenericDiskInfo = gendisk_head;
-      while (GenericDiskInfo != NULL &&
-	     GenericDiskInfo->next != &Controller->GenericDiskInfo)
-	GenericDiskInfo = GenericDiskInfo->next;
-      if (GenericDiskInfo != NULL)
-	GenericDiskInfo->next = GenericDiskInfo->next->next;
-    }
-  else gendisk_head = Controller->GenericDiskInfo.next;
+  del_gendisk(&Controller->GenericDiskInfo);
 }
 
 
@@ -5089,26 +5074,19 @@
 			   sizeof(DiskGeometry_T)) ? -EFAULT : 0);
     case BLKGETSIZE:
       /* Get Device Size. */
-      if ((long *) Argument == NULL) return -EINVAL;
       return put_user(Controller->GenericDiskInfo.part[MINOR(Inode->i_rdev)]
 						 .nr_sects,
 		      (long *) Argument);
+    case BLKGETSIZE64:
+      return put_user((u64)Controller->GenericDiskInfo.part[MINOR(Inode->i_rdev)].nr_sects << 9,
+		      (u64 *) Argument);
     case BLKRAGET:
-      /* Get Read-Ahead. */
-      if ((long *) Argument == NULL) return -EINVAL;
-      return put_user(read_ahead[MAJOR(Inode->i_rdev)], (long *) Argument);
     case BLKRASET:
-      /* Set Read-Ahead. */
-      if (!capable(CAP_SYS_ADMIN)) return -EACCES;
-      if (Argument > 256) return -EINVAL;
-      read_ahead[MAJOR(Inode->i_rdev)] = Argument;
-      return 0;
     case BLKFLSBUF:
-      /* Flush Buffers. */
-      if (!capable(CAP_SYS_ADMIN)) return -EACCES;
-      fsync_dev(Inode->i_rdev);
-      invalidate_buffers(Inode->i_rdev);
-      return 0;
+    case BLKBSZGET:
+    case BLKBSZSET:
+      return blk_ioctl (Inode->i_rdev, Request, Argument);
+
     case BLKRRPART:
       /* Re-Read Partition Table. */
       if (!capable(CAP_SYS_ADMIN)) return -EACCES;
diff -u --recursive --new-file v2.4.9/linux/drivers/block/Makefile linux/drivers/block/Makefile
--- v2.4.9/linux/drivers/block/Makefile	Fri Dec 29 14:07:21 2000
+++ linux/drivers/block/Makefile	Sun Sep  9 12:00:55 2001
@@ -10,7 +10,7 @@
 
 O_TARGET := block.o
 
-export-objs	:= ll_rw_blk.o blkpg.o loop.o DAC960.o
+export-objs	:= ll_rw_blk.o blkpg.o loop.o DAC960.o genhd.o
 
 obj-y	:= ll_rw_blk.o blkpg.o genhd.o elevator.o
 
diff -u --recursive --new-file v2.4.9/linux/drivers/block/acsi.c linux/drivers/block/acsi.c
--- v2.4.9/linux/drivers/block/acsi.c	Mon Aug 27 12:41:40 2001
+++ linux/drivers/block/acsi.c	Thu Sep 13 15:21:32 2001
@@ -1138,6 +1138,10 @@
 		return put_user(acsi_part[MINOR(inode->i_rdev)].nr_sects,
 				(long *) arg);
 
+	  case BLKGETSIZE64:   /* Return device size */
+		return put_user((u64)acsi_part[MINOR(inode->i_rdev)].nr_sects << 9,
+				(u64 *) arg);
+
 	  case BLKROSET:
 	  case BLKROGET:
 	  case BLKFLSBUF:
@@ -1386,16 +1390,14 @@
 extern struct block_device_operations acsi_fops;
 
 static struct gendisk acsi_gendisk = {
-	MAJOR_NR,		/* Major number */	
-	"ad",			/* Major name */
-	4,			/* Bits to shift to get real from partition */
-	1 << 4,			/* Number of partitions per real */
-	acsi_part,		/* hd struct */
-	acsi_sizes,		/* block sizes */
-	0,			/* number */
-	(void *)acsi_info,	/* internal */
-	NULL,			/* next */
-	&acsi_fops,		/* file operations */
+	major:		MAJOR_NR,
+	major_name:	"ad",
+	minor_shift:	4,
+	max_p:		1 << 4,
+	part:		acsi_part,
+	sizes:		acsi_sizes,
+	real_devices:	(void *)acsi_info,
+	fops:		&acsi_fops,
 };
 	
 #define MAX_SCSI_DEVICE_CODE 10
@@ -1792,8 +1794,7 @@
 	
 	blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST);
 	read_ahead[MAJOR_NR] = 8;		/* 8 sector (4kB) read-ahead */
-	acsi_gendisk.next = gendisk_head;
-	gendisk_head = &acsi_gendisk;
+	add_gendisk(&acsi_gendisk);
 
 #ifdef CONFIG_ATARI_SLM
 	err = slm_init();
@@ -1805,6 +1806,9 @@
 
 
 #ifdef MODULE
+
+MODULE_LICENSE("GPL");
+
 int init_module(void)
 {
 	int err;
@@ -1817,8 +1821,6 @@
 
 void cleanup_module(void)
 {
-	struct gendisk ** gdp;
-
 	del_timer( &acsi_timer );
 	blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
 	atari_stram_free( acsi_buffer );
@@ -1826,13 +1828,7 @@
 	if (devfs_unregister_blkdev( MAJOR_NR, "ad" ) != 0)
 		printk( KERN_ERR "acsi: cleanup_module failed\n");
 
-	for (gdp = &gendisk_head; *gdp; gdp = &((*gdp)->next))
-		if (*gdp == &acsi_gendisk)
-			break;
-	if (!*gdp)
-		printk( KERN_ERR "acsi: entry in disk chain missing!\n" );
-	else
-		*gdp = (*gdp)->next;
+	del_gendisk(&acsi_gendisk);
 }
 #endif
 
diff -u --recursive --new-file v2.4.9/linux/drivers/block/amiflop.c linux/drivers/block/amiflop.c
--- v2.4.9/linux/drivers/block/amiflop.c	Sat Apr 28 11:27:53 2001
+++ linux/drivers/block/amiflop.c	Thu Sep 13 15:21:32 2001
@@ -118,6 +118,7 @@
 static long int fd_def_df0 = FD_DD_3;     /* default for df0 if it doesn't identify */
 
 MODULE_PARM(fd_def_df0,"l");
+MODULE_LICENSE("GPL");
 
 /*
  *  Macros
@@ -1555,6 +1556,9 @@
 		break;
 	case BLKGETSIZE:
 		return put_user(unit[drive].blocks,(long *)param);
+		break;
+	case BLKGETSIZE64:
+		return put_user((u64)unit[drive].blocks << 9, (u64 *)param);
 		break;
 	case FDSETPRM:
 	case FDDEFPRM:
diff -u --recursive --new-file v2.4.9/linux/drivers/block/ataflop.c linux/drivers/block/ataflop.c
--- v2.4.9/linux/drivers/block/ataflop.c	Fri Feb  9 11:30:22 2001
+++ linux/drivers/block/ataflop.c	Thu Sep 13 15:21:32 2001
@@ -2056,6 +2056,9 @@
 }
 
 #ifdef MODULE
+
+MODULE_LICENSE("GPL");
+
 int init_module (void)
 {
 	if (!MACH_IS_ATARI)
diff -u --recursive --new-file v2.4.9/linux/drivers/block/blkpg.c linux/drivers/block/blkpg.c
--- v2.4.9/linux/drivers/block/blkpg.c	Sun May 20 11:34:05 2001
+++ linux/drivers/block/blkpg.c	Mon Sep 10 12:42:31 2001
@@ -54,17 +54,6 @@
  * Note that several drives may have the same major.
  */
 
-/* a linear search, superfluous when dev is a pointer */
-static struct gendisk *get_gendisk(kdev_t dev) {
-	struct gendisk *g;
-	int m = MAJOR(dev);
-
-	for (g = gendisk_head; g; g = g->next)
-		if (g->major == m)
-			break;
-	return g;
-}
-
 /*
  * Add a partition.
  *
@@ -250,6 +239,7 @@
 		case BLKGETSIZE:
 			/* Today get_gendisk() requires a linear scan;
 			   add this when dev has pointer type. */
+			/* add BLKGETSIZE64 too */
 			g = get_gendisk(dev);
 			if (!g)
 				longval = 0;
@@ -273,6 +263,29 @@
 		case BLKELVSET:
 			return blkelvset_ioctl(&blk_get_queue(dev)->elevator,
 					       (blkelv_ioctl_arg_t *) arg);
+
+		case BLKBSZGET:
+			/* get the logical block size (cf. BLKSSZGET) */
+			intval = BLOCK_SIZE;
+			if (blksize_size[MAJOR(dev)])
+				intval = blksize_size[MAJOR(dev)][MINOR(dev)];
+			return put_user (intval, (int *) arg);
+
+		case BLKBSZSET:
+			/* set the logical block size */
+			if (!capable (CAP_SYS_ADMIN))
+				return -EACCES;
+			if (!dev || !arg)
+				return -EINVAL;
+			if (get_user (intval, (int *) arg))
+				return -EFAULT;
+			if (intval > PAGE_SIZE || intval < 512 ||
+			    (intval & (intval - 1)))
+				return -EINVAL;
+			if (is_mounted (dev) || is_swap_partition (dev))
+				return -EBUSY;
+			set_blocksize (dev, intval);
+			return 0;
 
 		default:
 			return -EINVAL;
diff -u --recursive --new-file v2.4.9/linux/drivers/block/cciss.c linux/drivers/block/cciss.c
--- v2.4.9/linux/drivers/block/cciss.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/block/cciss.c	Thu Sep 13 15:21:32 2001
@@ -50,6 +50,7 @@
 /* Embedded module documentation macros - see modules.h */
 MODULE_AUTHOR("Charles M. White III - Compaq Computer Corporation");
 MODULE_DESCRIPTION("Driver for Compaq Smart Array Controller 5300");
+MODULE_LICENSE("GPL");
 
 #include "cciss_cmd.h"
 #include "cciss.h"
@@ -400,12 +401,16 @@
 		put_user(hba[ctlr]->hd[MINOR(inode->i_rdev)].start_sect, &geo->start);
 		return 0;
 	case BLKGETSIZE:
-		if (!arg) return -EINVAL;
 		put_user(hba[ctlr]->hd[MINOR(inode->i_rdev)].nr_sects, (long*)arg);
 		return 0;
+	case BLKGETSIZE64:
+		put_user((u64)hba[ctlr]->hd[MINOR(inode->i_rdev)].nr_sects << 9, (u64*)arg);
+		return 0;
 	case BLKRRPART:
 		return revalidate_logvol(inode->i_rdev, 1);
 	case BLKFLSBUF:
+	case BLKBSZSET:
+	case BLKBSZGET:
 	case BLKROSET:
 	case BLKROGET:
 	case BLKRASET:
@@ -1963,8 +1968,7 @@
 	hba[i]->gendisk.nr_real = hba[i]->num_luns;
 
 	/* Get on the disk list */ 
-	hba[i]->gendisk.next = gendisk_head;
-	gendisk_head = &(hba[i]->gendisk); 
+	add_gendisk(&(hba[i]->gendisk));
 
 	cciss_geninit(i);
 	for(j=0; j<NWD; j++)
@@ -1980,7 +1984,6 @@
 {
 	ctlr_info_t *tmp_ptr;
 	int i;
-	struct gendisk *g;
 
 	if (pdev->driver_data == NULL)
 	{
@@ -2005,19 +2008,8 @@
 	
 
 	/* remove it from the disk list */
-	if (gendisk_head == &(hba[i]->gendisk))
-	{
-		gendisk_head = hba[i]->gendisk.next;
-	} else
-	{
-		for(g=gendisk_head; g ; g=g->next)
-		{
-			if(g->next == &(hba[i]->gendisk))
-			{
-				g->next = hba[i]->gendisk.next;
-			}
-		}
-	}
+	del_gendisk(&(hba[i]->gendisk));
+
 	pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(CommandList_struct), 
 		hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle);
 	pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof( ErrorInfo_struct),
diff -u --recursive --new-file v2.4.9/linux/drivers/block/cpqarray.c linux/drivers/block/cpqarray.c
--- v2.4.9/linux/drivers/block/cpqarray.c	Sun Aug 12 13:27:59 2001
+++ linux/drivers/block/cpqarray.c	Thu Sep 13 15:21:32 2001
@@ -48,6 +48,7 @@
 /* Original author Chris Frantz - Compaq Computer Corporation */
 MODULE_AUTHOR("Compaq Computer Corporation");
 MODULE_DESCRIPTION("Driver for Compaq Smart2 Array Controllers");
+MODULE_LICENSE("GPL");
 
 #define MAJOR_NR COMPAQ_SMART2_MAJOR
 #include <linux/blk.h>
@@ -311,7 +312,6 @@
 void cleanup_module(void)
 {
 	int i;
-	struct gendisk *g;
 	char buff[4]; 
 
 	for(i=0; i<nr_ctlr; i++) {
@@ -335,16 +335,7 @@
 			hba[i]->cmd_pool_dhandle);
 		kfree(hba[i]->cmd_pool_bits);
 
-		if (gendisk_head == &ida_gendisk[i]) {
-			gendisk_head = ida_gendisk[i].next;
-		} else {
-			for(g=gendisk_head; g; g=g->next) {
-				if (g->next == &ida_gendisk[i]) {
-					g->next = ida_gendisk[i].next;
-					break;
-				}
-			}
-		}
+		del_gendisk(&ida_gendisk[i]);
 	}
 	remove_proc_entry("cpqarray", proc_root_driver);
 	kfree(ida);
@@ -550,8 +541,7 @@
 		ida_gendisk[i].nr_real = 0; 
 	
 		/* Get on the disk list */
-		ida_gendisk[i].next = gendisk_head;
-		gendisk_head = &ida_gendisk[i];
+		add_gendisk(&ida_gendisk[i]);
 
 		init_timer(&hba[i]->timer);
 		hba[i]->timer.expires = jiffies + IDA_TIMER;
@@ -1227,9 +1217,9 @@
 	case IDAGETDRVINFO:
 		return copy_to_user(&io->c.drv,&hba[ctlr]->drv[dsk],sizeof(drv_info_t));
 	case BLKGETSIZE:
-		if (!arg) return -EINVAL;
-		put_user(ida[(ctlr<<CTLR_SHIFT)+MINOR(inode->i_rdev)].nr_sects, (long*)arg);
-		return 0;
+		return put_user(ida[(ctlr<<CTLR_SHIFT)+MINOR(inode->i_rdev)].nr_sects, (long*)arg);
+	case BLKGETSIZE64:
+		return put_user((u64)(ida[(ctlr<<CTLR_SHIFT)+MINOR(inode->i_rdev)].nr_sects) << 9, (u64*)arg);
 	case BLKRRPART:
 		return revalidate_logvol(inode->i_rdev, 1);
 	case IDAPASSTHRU:
@@ -1266,6 +1256,8 @@
 	}	
 
 	case BLKFLSBUF:
+	case BLKBSZSET:
+	case BLKBSZGET:
 	case BLKROSET:
 	case BLKROGET:
 	case BLKRASET:
diff -u --recursive --new-file v2.4.9/linux/drivers/block/floppy.c linux/drivers/block/floppy.c
--- v2.4.9/linux/drivers/block/floppy.c	Sun Aug 12 13:27:59 2001
+++ linux/drivers/block/floppy.c	Mon Sep 10 12:42:31 2001
@@ -124,6 +124,11 @@
  * - s/suser/capable/
  */
 
+/*
+ * 2001/08/26 -- Paul Gortmaker - fix insmod oops on machines with no
+ * floppy controller (lingering task on list after module is gone... boom.)
+ */
+
 #define FLOPPY_SANITY_CHECK
 #undef  FLOPPY_SILENT_DCL_CLEAR
 
@@ -3492,6 +3497,10 @@
 		case BLKGETSIZE:
 			ECALL(get_floppy_geometry(drive, type, &g));
 			return put_user(g->size, (long *) param);
+
+		case BLKGETSIZE64:
+			ECALL(get_floppy_geometry(drive, type, &g));
+			return put_user((u64)g->size << 9, (u64 *) param);
 		/* BLKRRPART is not defined as floppies don't have
 		 * partition tables */
 	}
@@ -4144,7 +4153,7 @@
 	return 0;
 }
 
-static int have_no_fdc= -EIO;
+static int have_no_fdc= -ENODEV;
 
 
 int __init floppy_init(void)
@@ -4200,7 +4209,6 @@
 		del_timer(&fd_timeout);
 		blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
 		devfs_unregister_blkdev(MAJOR_NR,"fd");
-		del_timer(&fd_timeout);
 		return -EBUSY;
 	}
 
@@ -4259,9 +4267,7 @@
 	if (have_no_fdc) 
 	{
 		DPRINT("no floppy controllers found\n");
-		floppy_tq.routine = (void *)(void *) empty;
-		mark_bh(IMMEDIATE_BH);
-		schedule();
+		run_task_queue(&tq_immediate);
 		if (usage_count)
 			floppy_release_irq_and_dma();
 		blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
@@ -4472,6 +4478,7 @@
 MODULE_PARM(FLOPPY_DMA,"i");
 MODULE_AUTHOR("Alain L. Knaff");
 MODULE_SUPPORTED_DEVICE("fd");
+MODULE_LICENSE("GPL");
 
 #else
 
diff -u --recursive --new-file v2.4.9/linux/drivers/block/genhd.c linux/drivers/block/genhd.c
--- v2.4.9/linux/drivers/block/genhd.c	Wed Jul 25 17:10:19 2001
+++ linux/drivers/block/genhd.c	Sun Sep  9 12:00:55 2001
@@ -10,12 +10,137 @@
  *  (linux@arm.uk.linux.org)
  */
 
+/*
+ * TODO:  rip out the remaining init crap from this file  --hch
+ */
+
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/fs.h>
 #include <linux/genhd.h>
 #include <linux/kernel.h>
 #include <linux/blk.h>
 #include <linux/init.h>
+#include <linux/spinlock.h>
+
+
+static rwlock_t gendisk_lock;
+
+/*
+ * Global kernel list of partitioning information.
+ *
+ * XXX: you should _never_ access this directly.
+ *	the only reason this is exported is source compatiblity.
+ */
+/*static*/ struct gendisk *gendisk_head;
+
+EXPORT_SYMBOL(gendisk_head);
+
+
+/**
+ * add_gendisk - add partitioning information to kernel list
+ * @gp: per-device partitioning information
+ *
+ * This function registers the partitioning information in @gp
+ * with the kernel.
+ */
+void
+add_gendisk(struct gendisk *gp)
+{
+	write_lock(&gendisk_lock);
+	gp->next = gendisk_head;
+	gendisk_head = gp;
+	write_unlock(&gendisk_lock);
+}
+
+EXPORT_SYMBOL(add_gendisk);
+
+
+/**
+ * del_gendisk - remove partitioning information from kernel list
+ * @gp: per-device partitioning information
+ *
+ * This function unregisters the partitioning information in @gp
+ * with the kernel.
+ */
+void
+del_gendisk(struct gendisk *gp)
+{
+	struct gendisk **gpp;
+
+	write_lock(&gendisk_lock);
+	for (gpp = &gendisk_head; *gpp; gpp = &((*gpp)->next))
+		if (*gpp == gp)
+			break;
+	if (*gpp)
+		*gpp = (*gpp)->next;
+	write_unlock(&gendisk_lock);
+}
+
+EXPORT_SYMBOL(del_gendisk);
+
+
+/**
+ * get_gendisk - get partitioning information for a given device
+ * @dev: device to get partitioning information for
+ *
+ * This function gets the structure containing partitioning
+ * information for the given device @dev.
+ */
+struct gendisk *
+get_gendisk(kdev_t dev)
+{
+	struct gendisk *gp = NULL;
+	int maj = MAJOR(dev);
+
+	read_lock(&gendisk_lock);
+	for (gp = gendisk_head; gp; gp = gp->next)
+		if (gp->major == maj)
+			break;
+	read_unlock(&gendisk_lock);
+
+	return gp;
+}
+
+EXPORT_SYMBOL(get_gendisk);
+
+
+#ifdef CONFIG_PROC_FS
+int
+get_partition_list(char *page, char **start, off_t offset, int count)
+{
+	struct gendisk *gp;
+	char buf[64];
+	int len, n;
+
+	len = sprintf(page, "major minor  #blocks  name\n\n");
+	read_lock(&gendisk_lock);
+	for (gp = gendisk_head; gp; gp = gp->next) {
+		for (n = 0; n < (gp->nr_real << gp->minor_shift); n++) {
+			if (gp->part[n].nr_sects == 0)
+				continue;
+
+			len += snprintf(page + len, 63,
+					"%4d  %4d %10d %s\n",
+					gp->major, n, gp->sizes[n],
+					disk_name(gp, n, buf));
+			if (len < offset)
+				offset -= len, len = 0;
+			else if (len >= offset + count)
+				goto out;
+		}
+	}
+
+out:
+	read_unlock(&gendisk_lock);
+	*start = page + offset;
+	len -= offset;
+	if (len < 0)
+		len = 0;
+	return len > count ? count : len;
+}
+#endif
+
 
 extern int blk_dev_init(void);
 #ifdef CONFIG_BLK_DEV_DAC960
@@ -33,6 +158,7 @@
 
 int __init device_init(void)
 {
+	rwlock_init(&gendisk_lock);
 	blk_dev_init();
 	sti();
 #ifdef CONFIG_I2O
diff -u --recursive --new-file v2.4.9/linux/drivers/block/ll_rw_blk.c linux/drivers/block/ll_rw_blk.c
--- v2.4.9/linux/drivers/block/ll_rw_blk.c	Sun Aug 12 13:27:59 2001
+++ linux/drivers/block/ll_rw_blk.c	Sat Sep  8 12:00:46 2001
@@ -131,7 +131,7 @@
 	return max_sectors[MAJOR(dev)][MINOR(dev)];
 }
 
-inline request_queue_t *__blk_get_queue(kdev_t dev)
+inline request_queue_t *blk_get_queue(kdev_t dev)
 {
 	struct blk_dev_struct *bdev = blk_dev + MAJOR(dev);
 
@@ -141,22 +141,6 @@
 		return &blk_dev[MAJOR(dev)].request_queue;
 }
 
-/*
- * NOTE: the device-specific queue() functions
- * have to be atomic!
- */
-request_queue_t *blk_get_queue(kdev_t dev)
-{
-	request_queue_t *ret;
-	unsigned long flags;
-
-	spin_lock_irqsave(&io_request_lock,flags);
-	ret = __blk_get_queue(dev);
-	spin_unlock_irqrestore(&io_request_lock,flags);
-
-	return ret;
-}
-
 static int __blk_cleanup_queue(struct list_head *head)
 {
 	struct request *rq;
@@ -1272,7 +1256,6 @@
 EXPORT_SYMBOL(end_that_request_last);
 EXPORT_SYMBOL(blk_init_queue);
 EXPORT_SYMBOL(blk_get_queue);
-EXPORT_SYMBOL(__blk_get_queue);
 EXPORT_SYMBOL(blk_cleanup_queue);
 EXPORT_SYMBOL(blk_queue_headactive);
 EXPORT_SYMBOL(blk_queue_make_request);
diff -u --recursive --new-file v2.4.9/linux/drivers/block/loop.c linux/drivers/block/loop.c
--- v2.4.9/linux/drivers/block/loop.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/block/loop.c	Mon Sep 10 12:42:31 2001
@@ -62,6 +62,7 @@
 #include <linux/major.h>
 #include <linux/wait.h>
 #include <linux/blk.h>
+#include <linux/blkpg.h>
 #include <linux/init.h>
 #include <linux/devfs_fs_kernel.h>
 #include <linux/smp_lock.h>
@@ -848,11 +849,18 @@
 			err = -ENXIO;
 			break;
 		}
-		if (!arg) {
-			err = -EINVAL;
+		err = put_user(loop_sizes[lo->lo_number] << 1, (long *) arg);
+		break;
+	case BLKGETSIZE64:
+		if (lo->lo_state != Lo_bound) {
+			err = -ENXIO;
 			break;
 		}
-		err = put_user(loop_sizes[lo->lo_number] << 1, (long *) arg);
+		err = put_user((u64)loop_sizes[lo->lo_number] << 10, (u64*)arg);
+		break;
+	case BLKBSZGET:
+	case BLKBSZSET:
+		err = blk_ioctl(inode->i_rdev, cmd, arg);
 		break;
 	default:
 		err = lo->ioctl ? lo->ioctl(lo, cmd, arg) : -EINVAL;
diff -u --recursive --new-file v2.4.9/linux/drivers/block/nbd.c linux/drivers/block/nbd.c
--- v2.4.9/linux/drivers/block/nbd.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/block/nbd.c	Mon Sep 10 12:42:31 2001
@@ -446,6 +446,8 @@
 #endif
 	case BLKGETSIZE:
 		return put_user(nbd_bytesizes[dev] >> 9, (long *) arg);
+	case BLKGETSIZE64:
+		return put_user((u64)nbd_bytesizes[dev], (u64 *) arg);
 	}
 	return -EINVAL;
 }
diff -u --recursive --new-file v2.4.9/linux/drivers/block/paride/pd.c linux/drivers/block/paride/pd.c
--- v2.4.9/linux/drivers/block/paride/pd.c	Sat Apr 28 11:27:53 2001
+++ linux/drivers/block/paride/pd.c	Mon Sep 10 12:42:31 2001
@@ -287,6 +287,7 @@
 static struct hd_struct pd_hd[PD_DEVS];
 static int pd_sizes[PD_DEVS];
 static int pd_blocksizes[PD_DEVS];
+static int pd_maxsectors[PD_DEVS];
 
 #define PD_NAMELEN	8
 
@@ -343,16 +344,13 @@
 extern struct block_device_operations pd_fops;
 
 static struct gendisk pd_gendisk = {
-        PD_MAJOR,       /* Major number */
-        PD_NAME,        /* Major name */
-        PD_BITS,        /* Bits to shift to get real from partition */
-        PD_PARTNS,      /* Number of partitions per real */
-        pd_hd,          /* hd struct */
-        pd_sizes,       /* block sizes */
-        0,              /* number */
-        NULL,           /* internal */
-        NULL,           /* next */
-	&pd_fops,       /* block device operations */
+	major:		PD_MAJOR,
+	major_name:	PD_NAME,
+	minor_shift:	PD_BITS,
+	max_p:		PD_PARTNS,
+	part:		pd_hd,
+	sizes:		pd_sizes,
+	fops:		&pd_fops,
 };
 
 static struct block_device_operations pd_fops = {
@@ -385,56 +383,6 @@
 	}
 }
 
-static inline int pd_new_segment(request_queue_t *q, struct request *req, int max_segments)
-{
-	if (max_segments > cluster)
-		max_segments = cluster;
-
-	if (req->nr_segments < max_segments) {
-		req->nr_segments++;
-		return 1;
-	}
-	return 0;
-}
-
-static int pd_back_merge_fn(request_queue_t *q, struct request *req, 
-			    struct buffer_head *bh, int max_segments)
-{
-	if (req->bhtail->b_data + req->bhtail->b_size == bh->b_data)
-		return 1;
-	return pd_new_segment(q, req, max_segments);
-}
-
-static int pd_front_merge_fn(request_queue_t *q, struct request *req, 
-			     struct buffer_head *bh, int max_segments)
-{
-	if (bh->b_data + bh->b_size == req->bh->b_data)
-		return 1;
-	return pd_new_segment(q, req, max_segments);
-}
-
-static int pd_merge_requests_fn(request_queue_t *q, struct request *req,
-				struct request *next, int max_segments)
-{
-	int total_segments = req->nr_segments + next->nr_segments;
-	int same_segment;
-
-	if (max_segments > cluster)
-		max_segments = cluster;
-
-	same_segment = 0;
-	if (req->bhtail->b_data + req->bhtail->b_size == next->bh->b_data) {
-		total_segments--;
-		same_segment = 1;
-	}
-    
-	if (total_segments > max_segments)
-		return 0;
-
-	req->nr_segments = total_segments;
-	return 1;
-}
-
 int pd_init (void)
 
 {       int i;
@@ -448,19 +396,18 @@
         }
 	q = BLK_DEFAULT_QUEUE(MAJOR_NR);
 	blk_init_queue(q, DEVICE_REQUEST);
-	q->back_merge_fn = pd_back_merge_fn;
-	q->front_merge_fn = pd_front_merge_fn;
-	q->merge_requests_fn = pd_merge_requests_fn;
         read_ahead[MAJOR_NR] = 8;       /* 8 sector (4kB) read ahead */
         
 	pd_gendisk.major = major;
 	pd_gendisk.major_name = name;
-	pd_gendisk.next = gendisk_head;
-	gendisk_head = &pd_gendisk;
+	add_gendisk(&pd_gendisk);
 
 	for(i=0;i<PD_DEVS;i++) pd_blocksizes[i] = 1024;
 	blksize_size[MAJOR_NR] = pd_blocksizes;
 
+	for(i=0;i<PD_DEVS;i++) pd_maxsectors[i] = cluster;
+	max_sectors[MAJOR_NR] = pd_maxsectors;
+
 	printk("%s: %s version %s, major %d, cluster %d, nice %d\n",
 		name,name,PD_VERSION,major,cluster,nice);
 	pd_init_units();
@@ -535,6 +482,8 @@
                 if (err) return (err);
                 put_user(pd_hd[dev].nr_sects,(long *) arg);
                 return (0);
+            case BLKGETSIZE64:
+                return put_user((u64)pd_hd[dev].nr_sects << 9, (u64 *)arg);
             case BLKRRPART:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EACCES;
@@ -642,12 +591,12 @@
 	int unit;
 
         devfs_unregister_blkdev(MAJOR_NR,name);
-        for(gdp=&gendisk_head;*gdp;gdp=&((*gdp)->next))
-                if (*gdp == &pd_gendisk) break;
-        if (*gdp) *gdp = (*gdp)->next;
+	del_gendisk(&pd_gendisk);
 
 	for (unit=0;unit<PD_UNITS;unit++) 
 	   if (PD.present) pi_release(PI);
+
+	max_sectors[MAJOR_NR] = NULL;
 }
 
 #endif
diff -u --recursive --new-file v2.4.9/linux/drivers/block/paride/pf.c linux/drivers/block/paride/pf.c
--- v2.4.9/linux/drivers/block/paride/pf.c	Sun Feb  4 10:05:29 2001
+++ linux/drivers/block/paride/pf.c	Mon Sep 10 12:42:31 2001
@@ -482,11 +482,9 @@
                 put_user(0,(long *)&geo->start);
                 return 0;
             case BLKGETSIZE:
-                if (!arg) return -EINVAL;
-                err = verify_area(VERIFY_WRITE,(long *) arg,sizeof(long));
-                if (err) return (err);
-                put_user(PF.capacity,(long *) arg);
-                return (0);
+                return put_user(PF.capacity,(long *) arg);
+            case BLKGETSIZE64:
+                return put_user((u64)PF.capacity << 9,(u64 *)arg);
 	    case BLKROSET:
 	    case BLKROGET:
 	    case BLKRASET:
diff -u --recursive --new-file v2.4.9/linux/drivers/block/paride/ppc6lnx.c linux/drivers/block/paride/ppc6lnx.c
--- v2.4.9/linux/drivers/block/paride/ppc6lnx.c	Fri Apr  6 10:42:55 2001
+++ linux/drivers/block/paride/ppc6lnx.c	Fri Sep  7 09:28:38 2001
@@ -108,28 +108,11 @@
 static u8 ppc6_rd_data_byte(PPC *ppc);
 static u8 ppc6_rd_port(PPC *ppc, u8 port);
 static void ppc6_wr_port(PPC *ppc, u8 port, u8 data);
-static u8 ppc6_rd_reg(PPC *ppc, u8 reg);
-static void ppc6_wr_reg(PPC *ppc, u8 reg, u8 data);
-static u8 ppc6_version(PPC *ppc);
 static void ppc6_rd_data_blk(PPC *ppc, u8 *data, long count);
 static void ppc6_wait_for_fifo(PPC *ppc);
 static void ppc6_wr_data_blk(PPC *ppc, u8 *data, long count);
 static void ppc6_rd_port16_blk(PPC *ppc, u8 port, u8 *data, long length);
-static u16 ppc6_rd_port16(PPC *ppc, u8 port);
-static void ppc6_wr_port16(PPC *ppc, u8 port, u16 data);
 static void ppc6_wr_port16_blk(PPC *ppc, u8 port, u8 *data, long length);
-static u8 ppc6_rd_eeprom_reg(PPC *ppc);
-static void ppc6_wr_eeprom_reg(PPC *ppc, u8 data);
-static void ppc6_eeprom_start(PPC *ppc);
-static void ppc6_eeprom_end(PPC *ppc);
-static void ppc6_set_cs(PPC *ppc);
-static void ppc6_reset_cs(PPC *ppc);
-static u8 ppc6_rd_eeprom_bit(PPC *ppc);
-static void ppc6_eeprom_ready_wait(PPC *ppc);
-static void ppc6_wr_eeprom_bit(PPC *ppc, u8 bit);
-static u16 ppc6_eeprom_read(PPC *ppc, u8 addr);
-static u8 ppc6_irq_test(PPC *ppc);
-static u8 ppc6_rd_extout(PPC *ppc);
 static void ppc6_wr_extout(PPC *ppc, u8 regdata);
 static int ppc6_open(PPC *ppc);
 static void ppc6_close(PPC *ppc);
@@ -304,7 +287,7 @@
 
 static u8 ppc6_rd_data_byte(PPC *ppc)
 {
-	u8 data;
+	u8 data = 0;
 
 	switch(ppc->mode)
 	{
@@ -393,33 +376,6 @@
 
 //***************************************************************************
 
-static u8 ppc6_rd_reg(PPC *ppc, u8 reg)
-{
-	ppc6_send_cmd(ppc,(u8)(reg | ACCESS_REG | ACCESS_READ));
-
-	return(ppc6_rd_data_byte(ppc));
-}
-
-//***************************************************************************
-
-static void ppc6_wr_reg(PPC *ppc, u8 reg, u8 data)
-{
-	ppc6_send_cmd(ppc,(u8)(reg | ACCESS_REG | ACCESS_WRITE));
-
-	ppc6_wr_data_byte(ppc, data);
-}
-
-//***************************************************************************
-
-static u8 ppc6_version(PPC *ppc)
-{
-	ppc6_send_cmd(ppc,(REG_VERSION | ACCESS_REG | ACCESS_READ));
-
-	return(ppc6_rd_data_byte(ppc) & 0x3F);
-}
-
-//***************************************************************************
-
 static void ppc6_rd_data_blk(PPC *ppc, u8 *data, long count)
 {
 	switch(ppc->mode)
@@ -708,44 +664,6 @@
 
 //***************************************************************************
 
-static u16 ppc6_rd_port16(PPC *ppc, u8 port)
-{
-	u16 data;
-
-	ppc6_send_cmd(ppc, (CMD_PREFIX_SET | PREFIX_IO16));
-
-	ppc6_send_cmd(ppc, (u8)(port | ACCESS_PORT | ACCESS_READ));
-
-	data = ppc6_rd_data_byte(ppc);
-
-	ppc6_send_cmd(ppc, (u8)(port | ACCESS_PORT | ACCESS_READ));
-
-	data += (u16)ppc6_rd_data_byte(ppc) << 8;
-
-	ppc6_send_cmd(ppc, (CMD_PREFIX_RESET | PREFIX_IO16));
-
-	return(data);
-}
-
-//***************************************************************************
-
-static void ppc6_wr_port16(PPC *ppc, u8 port, u16 data)
-{
-	ppc6_send_cmd(ppc, (CMD_PREFIX_SET | PREFIX_IO16));
-
-	ppc6_send_cmd(ppc, (u8)(port | ACCESS_PORT | ACCESS_WRITE));
-
-	ppc6_wr_data_byte(ppc, (u8)data);
-
-	ppc6_send_cmd(ppc, (u8)(port | ACCESS_PORT | ACCESS_WRITE));
-
-	ppc6_wr_data_byte(ppc, (u8)(data >> 8));
-
-	ppc6_send_cmd(ppc, (CMD_PREFIX_RESET | PREFIX_IO16));
-}
-
-//***************************************************************************
-
 static void ppc6_wr_port16_blk(PPC *ppc, u8 port, u8 *data, long length)
 {
 	length = length << 1;
@@ -762,148 +680,6 @@
 	ppc6_wr_data_blk(ppc, data, length);
 
 	ppc6_send_cmd(ppc, (CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK));
-}
-
-//***************************************************************************
-
-static u8 ppc6_rd_eeprom_reg(PPC *ppc)
-{
-	ppc6_send_cmd(ppc, (REG_EEPROM | ACCESS_REG | ACCESS_READ));
-
-	return(ppc6_rd_data_byte(ppc));
-}
-
-//***************************************************************************
-
-static void ppc6_wr_eeprom_reg(PPC *ppc, u8 data)
-{
-	ppc6_send_cmd(ppc, (REG_EEPROM | ACCESS_REG | ACCESS_WRITE));
-
-	ppc6_wr_data_byte(ppc, data);
-}
-
-//***************************************************************************
-
-static void ppc6_eeprom_start(PPC *ppc)
-{
-	ppc6_wr_eeprom_reg(ppc, EEPROM_EN);
-}
-
-//***************************************************************************
-
-static void ppc6_eeprom_end(PPC *ppc)
-{
-	ppc6_wr_eeprom_reg(ppc, 0);
-}
-
-//***************************************************************************
-
-static void ppc6_set_cs(PPC *ppc)
-{
-	ppc6_wr_eeprom_reg(ppc, (u8)(ppc6_rd_eeprom_reg(ppc) | EEPROM_CS));
-}
-
-//***************************************************************************
-
-static void ppc6_reset_cs(PPC *ppc)
-{
-	ppc6_wr_eeprom_reg(ppc, (u8)(ppc6_rd_eeprom_reg(ppc) & ~EEPROM_CS));
-}
-
-//***************************************************************************
-
-static u8 ppc6_rd_eeprom_bit(PPC *ppc)
-{
-	ppc6_send_cmd(ppc, (REG_STATUS | ACCESS_REG | ACCESS_READ));
-
-	if (ppc6_rd_data_byte(ppc) & STATUS_EEPROM_DO)
-		return(1);
-	else
-		return(0);
-}
-
-//***************************************************************************
-
-static void ppc6_eeprom_ready_wait(PPC *ppc)
-{
-	ppc6_set_cs(ppc);
-
-	while(ppc6_rd_eeprom_bit(ppc));
-
-	ppc6_reset_cs(ppc);
-}
-
-//***************************************************************************
-
-static void ppc6_wr_eeprom_bit(PPC *ppc, u8 bit)
-{
-	u8 eereg;
-
-	eereg = ppc6_rd_eeprom_reg(ppc);
-
-	eereg &= ~(EEPROM_SK | EEPROM_DI);
-
-	if (bit & 1)
-		eereg |= EEPROM_DI;
-
-	ppc6_wr_eeprom_reg(ppc, eereg);
-
-	eereg |= EEPROM_SK;
-
-	ppc6_wr_eeprom_reg(ppc, eereg);
-
-	eereg &= ~EEPROM_SK;
-
-	ppc6_wr_eeprom_reg(ppc, eereg);
-}
-
-//***************************************************************************
-
-static u16 ppc6_eeprom_read(PPC *ppc, u8 addr)
-{
-	int i;
-	u16 data;
-
-	ppc6_set_cs(ppc);
-
-	ppc6_wr_eeprom_bit(ppc, 1); // Start bit
-
-	ppc6_wr_eeprom_bit(ppc, 1); // opcode 10 (read)
-	ppc6_wr_eeprom_bit(ppc, 0);
-
-	for(i=0; i<6; i++)
-		ppc6_wr_eeprom_bit(ppc, (u8)((addr >> (5 - i)) & 1));
-
-	data = 0;
-
-	for(i=0; i<16; i++)
-	{
-		ppc6_wr_eeprom_bit(ppc,0);
-
-		data = (data << 1) | ppc6_rd_eeprom_bit(ppc);
-	}
-
-	ppc6_reset_cs(ppc);
-
-	return(data);
-}
-
-//***************************************************************************
-
-static u8 ppc6_irq_test(PPC *ppc)
-{
-	ppc6_send_cmd(ppc,(REG_STATUS | ACCESS_REG | ACCESS_READ));
-
-	return(ppc6_rd_data_byte(ppc) & STATUS_IRQA);
-}
-
-//***************************************************************************
-
-static u8 ppc6_rd_extout(PPC *ppc)
-{
-	ppc6_send_cmd(ppc,(REG_VERSION | ACCESS_REG | ACCESS_READ));
-
-	return((ppc6_rd_data_byte(ppc) & 0xC0) >> 6);
 }
 
 //***************************************************************************
diff -u --recursive --new-file v2.4.9/linux/drivers/block/ps2esdi.c linux/drivers/block/ps2esdi.c
--- v2.4.9/linux/drivers/block/ps2esdi.c	Wed Jul 25 17:10:19 2001
+++ linux/drivers/block/ps2esdi.c	Mon Sep 10 12:42:31 2001
@@ -157,16 +157,14 @@
 
 static struct gendisk ps2esdi_gendisk =
 {
-	MAJOR_NR,		/* Major number */
-	"ed",			/* Major name */
-	6,			/* Bits to shift to get real from partition */
-	1 << 6,			/* Number of partitions per real disk */
-	ps2esdi,		/* hd struct */
-	ps2esdi_sizes,		/* block sizes */
-	0,			/* number */
-	(void *) ps2esdi_info,	/* internal */
-	NULL,			/* next */
-	&ps2esdi_fops,          /* file operations */
+	major:		MAJOR_NR,
+	major_name:	"ed",
+	minor_shift:	6,
+	max_p:		1 << 6,
+	part:		ps2esdi,
+	sizes:		ps2esdi_sizes,
+	real_devices:	(void *)ps2esdi_info,
+	fops:		&ps2esdi_fops,
 };
 
 /* initialization routine called by ll_rw_blk.c   */
@@ -184,8 +182,7 @@
 	read_ahead[MAJOR_NR] = 8;	/* 8 sector (4kB) read ahead */
 
 	/* some minor housekeeping - setup the global gendisk structure */
-	ps2esdi_gendisk.next = gendisk_head;
-	gendisk_head = &ps2esdi_gendisk;
+	add_gendisk(&ps2esdi_gendisk);
 	ps2esdi_geninit();
 	return 0;
 }				/* ps2esdi_init */
@@ -223,15 +220,15 @@
 void
 cleanup_module(void)
 {
-	if(ps2esdi_slot)
-	{
+	if(ps2esdi_slot) {
 		mca_mark_as_unused(ps2esdi_slot);
 		mca_set_adapter_procfn(ps2esdi_slot, NULL, NULL);
 	}
 	release_region(io_base, 4);
 	free_dma(dma_arb_level);
-  	free_irq(PS2ESDI_IRQ, NULL)
+  	free_irq(PS2ESDI_IRQ, NULL);
 	devfs_unregister_blkdev(MAJOR_NR, "ed");
+	del_gendisk(&ps2esdi_gendisk);
 	blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
 }
 #endif /* MODULE */
@@ -1117,6 +1114,9 @@
 			}
 			break;
 
+		case BLKGETSIZE64:
+			return put_user((u64)ps2esdi[MINOR(inode->i_rdev)].nr_sects << 9, (u64 *) arg);
+
 		case BLKRRPART:
                         if (!capable(CAP_SYS_ADMIN)) 
 				return -EACCES;
@@ -1127,6 +1127,8 @@
 		case BLKRASET:
 		case BLKRAGET:
 		case BLKFLSBUF:
+		case BLKBSZGET:
+		case BLKBSZSET:
 		case BLKPG:
 			return blk_ioctl(inode->i_rdev, cmd, arg);
 		}
diff -u --recursive --new-file v2.4.9/linux/drivers/block/rd.c linux/drivers/block/rd.c
--- v2.4.9/linux/drivers/block/rd.c	Wed Jul 25 17:10:19 2001
+++ linux/drivers/block/rd.c	Mon Sep 10 12:42:31 2001
@@ -100,7 +100,7 @@
 static int rd_blocksizes[NUM_RAMDISKS];		/* Size of 1024 byte blocks :)  */
 static int rd_kbsize[NUM_RAMDISKS];		/* Size in blocks of 1024 bytes */
 static devfs_handle_t devfs_handle;
-static struct inode *rd_inode[NUM_RAMDISKS];	/* Protected device inodes */
+static struct block_device *rd_bdev[NUM_RAMDISKS];/* Protected device data */
 
 /*
  * Parameters for the boot-loading of the RAM disk.  These are set by
@@ -259,7 +259,7 @@
 			/* special: we want to release the ramdisk memory,
 			   it's not like with the other blockdevices where
 			   this ioctl only flushes away the buffer cache. */
-			if ((atomic_read(&inode->i_bdev->bd_openers) > 2))
+			if ((atomic_read(&rd_bdev[minor]->bd_openers) > 2))
 				return -EBUSY;
 			destroy_buffers(inode->i_rdev);
 			rd_blocksizes[minor] = 0;
@@ -269,6 +269,9 @@
 			if (!arg)  return -EINVAL;
 			return put_user(rd_kbsize[minor] << 1, (long *) arg);
 
+         	case BLKGETSIZE64:
+			return put_user((u64)rd_kbsize[minor] << 10, (u64*)arg);
+
 		case BLKROSET:
 		case BLKROGET:
 		case BLKSSZGET:
@@ -305,7 +308,6 @@
 	lock_kernel();
 	if (!--initrd_users) {
 		blkdev_put(inode->i_bdev, BDEV_FILE);
-		iput(inode);
 		free_initrd_mem(initrd_start, initrd_end);
 		initrd_start = 0;
 	}
@@ -324,8 +326,10 @@
 
 static int rd_open(struct inode * inode, struct file * filp)
 {
+	int unit = DEVICE_NR(inode->i_rdev);
+
 #ifdef CONFIG_BLK_DEV_INITRD
-	if (DEVICE_NR(inode->i_rdev) == INITRD_MINOR) {
+	if (unit == INITRD_MINOR) {
 		if (!initrd_start) return -ENODEV;
 		initrd_users++;
 		filp->f_op = &initrd_fops;
@@ -333,16 +337,15 @@
 	}
 #endif
 
-	if (DEVICE_NR(inode->i_rdev) >= NUM_RAMDISKS)
+	if (unit >= NUM_RAMDISKS)
 		return -ENXIO;
 
 	/*
 	 * Immunize device against invalidate_buffers() and prune_icache().
 	 */
-	if (rd_inode[DEVICE_NR(inode->i_rdev)] == NULL) {
-		if (!inode->i_bdev) return -ENXIO;
-		if ((rd_inode[DEVICE_NR(inode->i_rdev)] = igrab(inode)) != NULL)
-			atomic_inc(&rd_inode[DEVICE_NR(inode->i_rdev)]->i_bdev->bd_openers);
+	if (rd_bdev[unit] == NULL) {
+		rd_bdev[unit] = bdget(kdev_t_to_nr(inode->i_rdev));
+		atomic_inc(&rd_bdev[unit]->bd_openers);
 	}
 
 	MOD_INC_USE_COUNT;
@@ -369,12 +372,11 @@
 	int i;
 
 	for (i = 0 ; i < NUM_RAMDISKS; i++) {
-		if (rd_inode[i]) {
-			/* withdraw invalidate_buffers() and prune_icache() immunity */
-			atomic_dec(&rd_inode[i]->i_bdev->bd_openers);
-			/* remove stale pointer to module address space */
-			rd_inode[i]->i_bdev->bd_op = NULL;
-			iput(rd_inode[i]);
+		struct block_device *bdev = rd_bdev[i];
+		rd_bdev[i] = NULL;
+		if (bdev) {
+			blkdev_put(bdev, BDEV_FILE);
+			bdput(bdev);
 		}
 		destroy_buffers(MKDEV(MAJOR_NR, i));
 	}
diff -u --recursive --new-file v2.4.9/linux/drivers/block/xd.c linux/drivers/block/xd.c
--- v2.4.9/linux/drivers/block/xd.c	Thu May 24 15:14:08 2001
+++ linux/drivers/block/xd.c	Thu Sep 13 15:21:32 2001
@@ -126,17 +126,16 @@
 extern struct block_device_operations xd_fops;
 
 static struct gendisk xd_gendisk = {
-	MAJOR_NR,	/* Major number */
-	"xd",		/* Major name */
-	6,		/* Bits to shift to get real from partition */
-	1 << 6,		/* Number of partitions per real */
-	xd_struct,	/* hd struct */
-	xd_sizes,	/* block sizes */
-	0,		/* number */
-	(void *) xd_info,	/* internal */
-	NULL,		/* next */
-	&xd_fops,	/* file operations */
+	major:		MAJOR_NR,
+	major_name:	"xd",
+	minor_shift:	6,
+	max_p:		1 << 6,
+	part:		xd_struct,
+	sizes:		xd_sizes,
+	real_devices:	(void *)xd_info,
+	fops:		&xd_fops,
 };
+
 static struct block_device_operations xd_fops = {
 	open:		xd_open,
 	release:	xd_release,
@@ -173,8 +172,7 @@
 	devfs_handle = devfs_mk_dir (NULL, xd_gendisk.major_name, NULL);
 	blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST);
 	read_ahead[MAJOR_NR] = 8;	/* 8 sector (4kB) read ahead */
-	xd_gendisk.next = gendisk_head;
-	gendisk_head = &xd_gendisk;
+	add_gendisk(&xd_gendisk);
 	xd_geninit();
 
 	return 0;
@@ -339,6 +337,8 @@
 		case BLKGETSIZE:
 			if (!arg) return -EINVAL;
 			return put_user(xd_struct[MINOR(inode->i_rdev)].nr_sects,(long *) arg);
+		case BLKGETSIZE64:
+			return put_user((u64)xd_struct[MINOR(inode->i_rdev)].nr_sects << 9, (u64 *)arg);
 		case HDIO_SET_DMA:
 			if (!capable(CAP_SYS_ADMIN)) return -EACCES;
 			if (xdc_busy) return -EBUSY;
@@ -376,9 +376,7 @@
 	int target = DEVICE_NR(inode->i_rdev);
 	if (target < xd_drives) {
 		xd_access[target]--;
-#ifdef MODULE
 		MOD_DEC_USE_COUNT;
-#endif /* MODULE */
 	}
 	return 0;
 }
@@ -1110,20 +1108,16 @@
 MODULE_PARM(xd_geo, "3-6i");
 MODULE_PARM(nodma, "i");
 
+MODULE_LICENSE("GPL");
+
 static void xd_done (void)
 {
-	struct gendisk ** gdp;
-	
 	blksize_size[MAJOR_NR] = NULL;
 	blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
 	blk_size[MAJOR_NR] = NULL;
 	hardsect_size[MAJOR_NR] = NULL;
 	read_ahead[MAJOR_NR] = 0;
-	for (gdp = &gendisk_head; *gdp; gdp = &((*gdp)->next))
-		if (*gdp == &xd_gendisk)
-			break;
-	if (*gdp)
-		*gdp = (*gdp)->next;
+	del_gendisk(&xd_gendisk);
 	release_region(xd_iobase,4);
 }
 
diff -u --recursive --new-file v2.4.9/linux/drivers/block/z2ram.c linux/drivers/block/z2ram.c
--- v2.4.9/linux/drivers/block/z2ram.c	Fri Feb  9 11:30:22 2001
+++ linux/drivers/block/z2ram.c	Thu Sep 13 15:21:32 2001
@@ -376,6 +376,9 @@
 }
 
 #if defined(MODULE)
+
+MODULE_LICENSE("GPL");
+
 int
 init_module( void )
 {
diff -u --recursive --new-file v2.4.9/linux/drivers/bluetooth/Config.in linux/drivers/bluetooth/Config.in
--- v2.4.9/linux/drivers/bluetooth/Config.in	Tue Jul  3 17:08:19 2001
+++ linux/drivers/bluetooth/Config.in	Fri Sep  7 09:28:38 2001
@@ -3,6 +3,6 @@
 
 dep_tristate 'HCI USB driver' CONFIG_BLUEZ_HCIUSB $CONFIG_BLUEZ $CONFIG_USB
 dep_tristate 'HCI UART driver' CONFIG_BLUEZ_HCIUART $CONFIG_BLUEZ
-dep_tristate 'HCI EMU (virtual device) driver' CONFIG_BLUEZ_HCIEMU $CONFIG_BLUEZ
+dep_tristate 'HCI VHCI virtual HCI device driver' CONFIG_BLUEZ_HCIVHCI $CONFIG_BLUEZ
 
 endmenu
diff -u --recursive --new-file v2.4.9/linux/drivers/bluetooth/Makefile linux/drivers/bluetooth/Makefile
--- v2.4.9/linux/drivers/bluetooth/Makefile	Tue Jul  3 17:08:19 2001
+++ linux/drivers/bluetooth/Makefile	Fri Sep  7 09:28:38 2001
@@ -6,6 +6,6 @@
 
 obj-$(CONFIG_BLUEZ_HCIUSB)	+= hci_usb.o
 obj-$(CONFIG_BLUEZ_HCIUART)	+= hci_uart.o
-obj-$(CONFIG_BLUEZ_HCIEMU)	+= hci_emu.o
+obj-$(CONFIG_BLUEZ_HCIVHCI)	+= hci_vhci.o
 
 include $(TOPDIR)/Rules.make
diff -u --recursive --new-file v2.4.9/linux/drivers/bluetooth/hci_emu.c linux/drivers/bluetooth/hci_emu.c
--- v2.4.9/linux/drivers/bluetooth/hci_emu.c	Mon Aug 27 12:41:40 2001
+++ linux/drivers/bluetooth/hci_emu.c	Wed Dec 31 16:00:00 1969
@@ -1,330 +0,0 @@
-/* 
-   BlueZ - Bluetooth protocol stack for Linux
-   Copyright (C) 2000-2001 Qualcomm Incorporated
-
-   Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License version 2 as
-   published by the Free Software Foundation;
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
-   IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
-   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
-   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
-   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
-   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
-   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
-   SOFTWARE IS DISCLAIMED.
-*/
-
-/*
- * BlueZ HCI virtual device driver.
- *
- * $Id: hci_emu.c,v 1.1 2001/06/01 08:12:10 davem Exp $ 
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/major.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/poll.h>
-#include <linux/fcntl.h>
-#include <linux/init.h>
-#include <linux/random.h>
-
-#include <linux/skbuff.h>
-#include <linux/miscdevice.h>
-
-#include <asm/system.h>
-#include <asm/uaccess.h>
-
-#include <net/bluetooth/bluetooth.h>
-#include <net/bluetooth/bluez.h>
-#include <net/bluetooth/hci_core.h>
-#include <net/bluetooth/hci_emu.h>
-
-/* HCI device part */
-
-int hci_emu_open(struct hci_dev *hdev)
-{
-	hdev->flags |= HCI_RUNNING;
-	return 0;
-}
-
-int hci_emu_flush(struct hci_dev *hdev)
-{
-	struct hci_emu_struct *hci_emu = (struct hci_emu_struct *) hdev->driver_data;
-	bluez_skb_queue_purge(&hci_emu->readq);
-	return 0;
-}
-
-int hci_emu_close(struct hci_dev *hdev)
-{
-	hdev->flags &= ~HCI_RUNNING;
-	hci_emu_flush(hdev);
-	return 0;
-}
-
-int hci_emu_send_frame(struct sk_buff *skb)
-{
-	struct hci_dev* hdev = (struct hci_dev *) skb->dev;
-	struct hci_emu_struct *hci_emu;
-
-	if (!hdev) {
-		ERR("Frame for uknown device (hdev=NULL)");
-		return -ENODEV;
-	}
-
-	if (!(hdev->flags & HCI_RUNNING))
-		return -EBUSY;
-
-	hci_emu = (struct hci_emu_struct *) hdev->driver_data;
-
-	memcpy(skb_push(skb, 1), &skb->pkt_type, 1);
-	skb_queue_tail(&hci_emu->readq, skb);
-
-	if (hci_emu->flags & HCI_EMU_FASYNC)
-		kill_fasync(&hci_emu->fasync, SIGIO, POLL_IN);
-	wake_up_interruptible(&hci_emu->read_wait);
-
-	return 0;
-}
-
-/* Character device part */
-
-/* Poll */
-static unsigned int hci_emu_chr_poll(struct file *file, poll_table * wait)
-{  
-	struct hci_emu_struct *hci_emu = (struct hci_emu_struct *) file->private_data;
-
-	poll_wait(file, &hci_emu->read_wait, wait);
- 
-	if (skb_queue_len(&hci_emu->readq))
-		return POLLIN | POLLRDNORM;
-
-	return POLLOUT | POLLWRNORM;
-}
-
-/* Get packet from user space buffer(already verified) */
-static __inline__ ssize_t hci_emu_get_user(struct hci_emu_struct *hci_emu, const char *buf, size_t count)
-{
-	struct sk_buff *skb;
-
-	if (count > HCI_EMU_MAX_FRAME)
-		return -EINVAL;
-
-	if (!(skb = bluez_skb_alloc(count, GFP_KERNEL)))
-		return -ENOMEM;
-	
-	copy_from_user(skb_put(skb, count), buf, count); 
-
-	skb->dev = (void *) &hci_emu->hdev;
-	skb->pkt_type = *((__u8 *) skb->data);
-	skb_pull(skb, 1);
-
-	hci_recv_frame(skb);
-
-	return count;
-} 
-
-/* Write */
-static ssize_t hci_emu_chr_write(struct file * file, const char * buf, 
-			     size_t count, loff_t *pos)
-{
-	struct hci_emu_struct *hci_emu = (struct hci_emu_struct *) file->private_data;
-
-	if (verify_area(VERIFY_READ, buf, count))
-		return -EFAULT;
-
-	return hci_emu_get_user(hci_emu, buf, count);
-}
-
-/* Put packet to user space buffer(already verified) */
-static __inline__ ssize_t hci_emu_put_user(struct hci_emu_struct *hci_emu,
-				       struct sk_buff *skb, char *buf, int count)
-{
-	int len = count, total = 0;
-	char *ptr = buf;
-
-	len = MIN(skb->len, len); 
-	copy_to_user(ptr, skb->data, len); 
-	total += len;
-
-	hci_emu->hdev.stat.byte_tx += len;
-	switch (skb->pkt_type) {
-		case HCI_COMMAND_PKT:
-			hci_emu->hdev.stat.cmd_tx++;
-			break;
-
-		case HCI_ACLDATA_PKT:
-			hci_emu->hdev.stat.acl_tx++;
-			break;
-
-		case HCI_SCODATA_PKT:
-			hci_emu->hdev.stat.cmd_tx++;
-			break;
-	};
-
-	return total;
-}
-
-/* Read */
-static ssize_t hci_emu_chr_read(struct file * file, char * buf, size_t count, loff_t *pos)
-{
-	struct hci_emu_struct *hci_emu = (struct hci_emu_struct *) file->private_data;
-	DECLARE_WAITQUEUE(wait, current);
-	struct sk_buff *skb;
-	ssize_t ret = 0;
-
-	add_wait_queue(&hci_emu->read_wait, &wait);
-	while (count) {
-		current->state = TASK_INTERRUPTIBLE;
-
-		/* Read frames from device queue */
-		if (!(skb = skb_dequeue(&hci_emu->readq))) {
-			if (file->f_flags & O_NONBLOCK) {
-				ret = -EAGAIN;
-				break;
-			}
-			if (signal_pending(current)) {
-				ret = -ERESTARTSYS;
-				break;
-			}
-
-			/* Nothing to read, let's sleep */
-			schedule();
-			continue;
-		}
-
-		if (!verify_area(VERIFY_WRITE, buf, count))
-			ret = hci_emu_put_user(hci_emu, skb, buf, count);
-		else
-			ret = -EFAULT;
-
-		bluez_skb_free(skb);
-		break;
-	}
-
-	current->state = TASK_RUNNING;
-	remove_wait_queue(&hci_emu->read_wait, &wait);
-
-	return ret;
-}
-
-static int hci_emu_chr_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
-{
-	return -EINVAL;
-}
-
-static int hci_emu_chr_fasync(int fd, struct file *file, int on)
-{
-	struct hci_emu_struct *hci_emu = (struct hci_emu_struct *) file->private_data;
-	int ret;
-
-	if ((ret = fasync_helper(fd, file, on, &hci_emu->fasync)) < 0)
-		return ret; 
- 
-	if (on)
-		hci_emu->flags |= HCI_EMU_FASYNC;
-	else 
-		hci_emu->flags &= ~HCI_EMU_FASYNC;
-
-	return 0;
-}
-
-static int hci_emu_chr_open(struct inode *inode, struct file * file)
-{
-	struct hci_emu_struct *hci_emu = NULL; 
-	struct hci_dev *hdev;
-
-	if (!(hci_emu = kmalloc(sizeof(struct hci_emu_struct), GFP_KERNEL)))
-		return -ENOMEM;
-
-	memset(hci_emu, 0, sizeof(struct hci_emu_struct));
-
-	skb_queue_head_init(&hci_emu->readq);
-	init_waitqueue_head(&hci_emu->read_wait);
-
-	/* Initialize and register HCI device */
-	hdev = &hci_emu->hdev;
-
-	hdev->type = HCI_EMU;
-	hdev->driver_data = hci_emu;
-
-	hdev->open  = hci_emu_open;
-	hdev->close = hci_emu_close;
-	hdev->flush = hci_emu_flush;
-	hdev->send  = hci_emu_send_frame;
-
-	if (hci_register_dev(hdev) < 0) {
-		kfree(hci_emu);
-		return -EBUSY;
-	}
-
-	file->private_data = hci_emu;
-	return 0;   
-}
-
-static int hci_emu_chr_close(struct inode *inode, struct file *file)
-{
-	struct hci_emu_struct *hci_emu = (struct hci_emu_struct *) file->private_data;
-
-	if (hci_unregister_dev(&hci_emu->hdev) < 0) {
-		ERR("Can't unregister HCI device %s", hci_emu->hdev.name);
-	}
-
-	kfree(hci_emu);
-	file->private_data = NULL;
-
-	return 0;
-}
-
-static struct file_operations hci_emu_fops = {
-	owner:	THIS_MODULE,	
-	llseek:	no_llseek,
-	read:	hci_emu_chr_read,
-	write:	hci_emu_chr_write,
-	poll:	hci_emu_chr_poll,
-	ioctl:	hci_emu_chr_ioctl,
-	open:	hci_emu_chr_open,
-	release:hci_emu_chr_close,
-	fasync:	hci_emu_chr_fasync		
-};
-
-static struct miscdevice hci_emu_miscdev=
-{
-        HCI_EMU_MINOR,
-        "hci_emu",
-        &hci_emu_fops
-};
-
-int __init hci_emu_init(void)
-{
-	INF("BlueZ HCI EMU driver ver %s Copyright (C) 2000,2001 Qualcomm Inc",  
-		BLUEZ_VER);
-	INF("Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>");
-
-	if (misc_register(&hci_emu_miscdev)) {
-		ERR("Can't register misc device %d\n", HCI_EMU_MINOR);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-void hci_emu_cleanup(void)
-{
-	misc_deregister(&hci_emu_miscdev);
-}
-
-module_init(hci_emu_init);
-module_exit(hci_emu_cleanup);
diff -u --recursive --new-file v2.4.9/linux/drivers/bluetooth/hci_uart.c linux/drivers/bluetooth/hci_uart.c
--- v2.4.9/linux/drivers/bluetooth/hci_uart.c	Mon Aug 27 12:41:40 2001
+++ linux/drivers/bluetooth/hci_uart.c	Fri Sep  7 09:28:38 2001
@@ -25,8 +25,9 @@
 /*
  * BlueZ HCI UART driver.
  *
- * $Id: hci_uart.c,v 1.1 2001/06/01 08:12:10 davem Exp $    
+ * $Id: hci_uart.c,v 1.5 2001/07/05 18:42:44 maxk Exp $    
  */
+#define VERSION "1.0"
 
 #include <linux/config.h>
 #include <linux/module.h>
@@ -84,7 +85,7 @@
 	DBG("hdev %p tty %p", hdev, tty);
 
 	/* Drop TX queue */
-	bluez_skb_queue_purge(&n_hci->txq);
+	skb_queue_purge(&n_hci->txq);
 
 	/* Flush any pending characters in the driver and discipline. */
 	if (tty->ldisc.flush_buffer)
@@ -139,7 +140,7 @@
 
 		if (len == skb->len) {
 			/* Full frame was sent */
-			bluez_skb_free(skb);
+			kfree_skb(skb);
 		} else {
 			/* Subtract sent part and requeue  */
 			skb_pull(skb, len);
@@ -334,7 +335,7 @@
 		hci_recv_frame(n_hci->rx_skb);
 	} else if (len > room) {
 		ERR("Data length is to large");
-		bluez_skb_free(n_hci->rx_skb);
+		kfree_skb(n_hci->rx_skb);
 		n_hci->hdev.stat.err_rx++;
 	} else {
 		n_hci->rx_state = WAIT_DATA;
@@ -356,7 +357,7 @@
 	hci_sco_hdr   *sh;
 	register int len, type, dlen;
 
-	DBG("count %d state %d rx_count %d", count, n_hci->rx_state, n_hci->rx_count);
+	DBG("count %d state %ld rx_count %ld", count, n_hci->rx_state, n_hci->rx_count);
 
 	n_hci->hdev.stat.byte_rx += count;
 
@@ -441,7 +442,7 @@
 		ptr++; count--;
 
 		/* Allocate packet */
-		if (!(n_hci->rx_skb = bluez_skb_alloc(HCI_MAX_READ, GFP_ATOMIC))) {
+		if (!(n_hci->rx_skb = bluez_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
 			ERR("Can't allocate mem for new packet");
 
 			n_hci->rx_state = WAIT_PACKET_TYPE;
@@ -536,7 +537,7 @@
 	int err;
 
 	INF("BlueZ HCI UART driver ver %s Copyright (C) 2000,2001 Qualcomm Inc", 
-		BLUEZ_VER);
+		VERSION);
 	INF("Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>");
 
 	/* Register the tty discipline */
@@ -573,3 +574,7 @@
 
 module_init(n_hci_init);
 module_exit(n_hci_cleanup);
+
+MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>");
+MODULE_DESCRIPTION("BlueZ HCI UART driver ver " VERSION);
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/bluetooth/hci_usb.c linux/drivers/bluetooth/hci_usb.c
--- v2.4.9/linux/drivers/bluetooth/hci_usb.c	Mon Aug 27 12:41:40 2001
+++ linux/drivers/bluetooth/hci_usb.c	Fri Sep  7 09:28:38 2001
@@ -28,8 +28,9 @@
  *    Copyright (c) 2000 Greg Kroah-Hartman        <greg@kroah.com>
  *    Copyright (c) 2000 Mark Douglas Corner       <mcorner@umich.edu>
  *
- * $Id: hci_usb.c,v 1.1 2001/06/01 08:12:10 davem Exp $    
+ * $Id: hci_usb.c,v 1.5 2001/07/05 18:42:44 maxk Exp $    
  */
+#define VERSION "1.0"
 
 #include <linux/config.h>
 #include <linux/module.h>
@@ -106,7 +107,7 @@
 		usb_free_urb(husb->write_urb);
 
 	if (husb->intr_skb)
-		bluez_skb_free(husb->intr_skb);
+		kfree_skb(husb->intr_skb);
 }
 
 /* ------- Interface to HCI layer ------ */
@@ -139,8 +140,8 @@
 	DBG("%s", hdev->name);
 
 	/* Drop TX queues */
-	bluez_skb_queue_purge(&husb->tx_ctrl_q);
-	bluez_skb_queue_purge(&husb->tx_write_q);
+	skb_queue_purge(&husb->tx_ctrl_q);
+	skb_queue_purge(&husb->tx_write_q);
 
 	return 0;
 }
@@ -173,7 +174,7 @@
 		goto done;
 
 	if (hci_usb_ctrl_msg(husb, skb)){
-		bluez_skb_free(skb);
+		kfree_skb(skb);
 		goto done;
 	}
 
@@ -271,7 +272,7 @@
 		DBG("%s ctrl status: %d", hdev->name, urb->status);
 
 	clear_bit(HCI_TX_CTRL, &husb->tx_state);
-	bluez_skb_free(skb);
+	kfree_skb(skb);
 
 	/* Wake up device */
 	hci_usb_ctrl_wakeup(husb);
@@ -294,7 +295,7 @@
 		DBG("%s bulk write status: %d", hdev->name, urb->status);
 
 	clear_bit(HCI_TX_WRITE, &husb->tx_state);
-	bluez_skb_free(skb);
+	kfree_skb(skb);
 
 	/* Wake up device */
 	hci_usb_write_wakeup(husb);
@@ -352,7 +353,7 @@
 		if (count > husb->intr_count) {
 			ERR("%s bad frame len %d (expected %d)", husb->hdev.name, count, husb->intr_count);
 
-			bluez_skb_free(skb);
+			kfree_skb(skb);
 			husb->intr_skb = NULL;
 			husb->intr_count = 0;
 			return;
@@ -563,7 +564,7 @@
 
 	ep = bulk_in_ep;
 	pipe = usb_rcvbulkpipe(udev, ep->bEndpointAddress);
-	size = HCI_USB_MAX_READ;
+	size = HCI_MAX_FRAME_SIZE;
 
 	if (!(buf = kmalloc(size, GFP_KERNEL))) {
 		ERR("Can't allocate: read buffer");
@@ -652,7 +653,7 @@
 	int err;
 
 	INF("BlueZ HCI USB driver ver %s Copyright (C) 2000,2001 Qualcomm Inc",  
-		BLUEZ_VER);
+		VERSION);
 	INF("Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>");
 
 	if ((err = usb_register(&hci_usb_driver)) < 0)
@@ -668,3 +669,7 @@
 
 module_init(hci_usb_init);
 module_exit(hci_usb_cleanup);
+
+MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>");
+MODULE_DESCRIPTION("BlueZ HCI USB driver ver " VERSION);
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/bluetooth/hci_vhci.c linux/drivers/bluetooth/hci_vhci.c
--- v2.4.9/linux/drivers/bluetooth/hci_vhci.c	Wed Dec 31 16:00:00 1969
+++ linux/drivers/bluetooth/hci_vhci.c	Fri Sep  7 09:28:38 2001
@@ -0,0 +1,340 @@
+/* 
+   BlueZ - Bluetooth protocol stack for Linux
+   Copyright (C) 2000-2001 Qualcomm Incorporated
+
+   Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License version 2 as
+   published by the Free Software Foundation;
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
+   IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
+   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
+   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
+   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
+   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+   SOFTWARE IS DISCLAIMED.
+*/
+
+/*
+ * BlueZ HCI virtual device driver.
+ *
+ * $Id: hci_vhci.c,v 1.3 2001/08/03 04:19:50 maxk Exp $ 
+ */
+#define VERSION "1.0"
+
+#include <linux/config.h>
+#include <linux/module.h>
+
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/major.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/poll.h>
+#include <linux/fcntl.h>
+#include <linux/init.h>
+#include <linux/random.h>
+
+#include <linux/skbuff.h>
+#include <linux/miscdevice.h>
+
+#include <asm/system.h>
+#include <asm/uaccess.h>
+
+#include <net/bluetooth/bluetooth.h>
+#include <net/bluetooth/bluez.h>
+#include <net/bluetooth/hci_core.h>
+#include <net/bluetooth/hci_vhci.h>
+
+/* HCI device part */
+
+int hci_vhci_open(struct hci_dev *hdev)
+{
+	hdev->flags |= HCI_RUNNING;
+	return 0;
+}
+
+int hci_vhci_flush(struct hci_dev *hdev)
+{
+	struct hci_vhci_struct *hci_vhci = (struct hci_vhci_struct *) hdev->driver_data;
+	skb_queue_purge(&hci_vhci->readq);
+	return 0;
+}
+
+int hci_vhci_close(struct hci_dev *hdev)
+{
+	hdev->flags &= ~HCI_RUNNING;
+	hci_vhci_flush(hdev);
+	return 0;
+}
+
+int hci_vhci_send_frame(struct sk_buff *skb)
+{
+	struct hci_dev* hdev = (struct hci_dev *) skb->dev;
+	struct hci_vhci_struct *hci_vhci;
+
+	if (!hdev) {
+		ERR("Frame for uknown device (hdev=NULL)");
+		return -ENODEV;
+	}
+
+	if (!(hdev->flags & HCI_RUNNING))
+		return -EBUSY;
+
+	hci_vhci = (struct hci_vhci_struct *) hdev->driver_data;
+
+	memcpy(skb_push(skb, 1), &skb->pkt_type, 1);
+	skb_queue_tail(&hci_vhci->readq, skb);
+
+	if (hci_vhci->flags & VHCI_FASYNC)
+		kill_fasync(&hci_vhci->fasync, SIGIO, POLL_IN);
+	wake_up_interruptible(&hci_vhci->read_wait);
+
+	return 0;
+}
+
+/* Character device part */
+
+/* Poll */
+static unsigned int hci_vhci_chr_poll(struct file *file, poll_table * wait)
+{  
+	struct hci_vhci_struct *hci_vhci = (struct hci_vhci_struct *) file->private_data;
+
+	poll_wait(file, &hci_vhci->read_wait, wait);
+ 
+	if (skb_queue_len(&hci_vhci->readq))
+		return POLLIN | POLLRDNORM;
+
+	return POLLOUT | POLLWRNORM;
+}
+
+/* Get packet from user space buffer(already verified) */
+static inline ssize_t hci_vhci_get_user(struct hci_vhci_struct *hci_vhci, const char *buf, size_t count)
+{
+	struct sk_buff *skb;
+
+	if (count > HCI_MAX_FRAME_SIZE)
+		return -EINVAL;
+
+	if (!(skb = bluez_skb_alloc(count, GFP_KERNEL)))
+		return -ENOMEM;
+	
+	copy_from_user(skb_put(skb, count), buf, count); 
+
+	skb->dev = (void *) &hci_vhci->hdev;
+	skb->pkt_type = *((__u8 *) skb->data);
+	skb_pull(skb, 1);
+
+	hci_recv_frame(skb);
+
+	return count;
+} 
+
+/* Write */
+static ssize_t hci_vhci_chr_write(struct file * file, const char * buf, 
+			     size_t count, loff_t *pos)
+{
+	struct hci_vhci_struct *hci_vhci = (struct hci_vhci_struct *) file->private_data;
+
+	if (verify_area(VERIFY_READ, buf, count))
+		return -EFAULT;
+
+	return hci_vhci_get_user(hci_vhci, buf, count);
+}
+
+/* Put packet to user space buffer(already verified) */
+static inline ssize_t hci_vhci_put_user(struct hci_vhci_struct *hci_vhci,
+				       struct sk_buff *skb, char *buf, int count)
+{
+	int len = count, total = 0;
+	char *ptr = buf;
+
+	len = MIN(skb->len, len); 
+	copy_to_user(ptr, skb->data, len); 
+	total += len;
+
+	hci_vhci->hdev.stat.byte_tx += len;
+	switch (skb->pkt_type) {
+		case HCI_COMMAND_PKT:
+			hci_vhci->hdev.stat.cmd_tx++;
+			break;
+
+		case HCI_ACLDATA_PKT:
+			hci_vhci->hdev.stat.acl_tx++;
+			break;
+
+		case HCI_SCODATA_PKT:
+			hci_vhci->hdev.stat.cmd_tx++;
+			break;
+	};
+
+	return total;
+}
+
+/* Read */
+static ssize_t hci_vhci_chr_read(struct file * file, char * buf, size_t count, loff_t *pos)
+{
+	struct hci_vhci_struct *hci_vhci = (struct hci_vhci_struct *) file->private_data;
+	DECLARE_WAITQUEUE(wait, current);
+	struct sk_buff *skb;
+	ssize_t ret = 0;
+
+	add_wait_queue(&hci_vhci->read_wait, &wait);
+	while (count) {
+		current->state = TASK_INTERRUPTIBLE;
+
+		/* Read frames from device queue */
+		if (!(skb = skb_dequeue(&hci_vhci->readq))) {
+			if (file->f_flags & O_NONBLOCK) {
+				ret = -EAGAIN;
+				break;
+			}
+			if (signal_pending(current)) {
+				ret = -ERESTARTSYS;
+				break;
+			}
+
+			/* Nothing to read, let's sleep */
+			schedule();
+			continue;
+		}
+
+		if (!verify_area(VERIFY_WRITE, buf, count))
+			ret = hci_vhci_put_user(hci_vhci, skb, buf, count);
+		else
+			ret = -EFAULT;
+
+		kfree_skb(skb);
+		break;
+	}
+
+	current->state = TASK_RUNNING;
+	remove_wait_queue(&hci_vhci->read_wait, &wait);
+
+	return ret;
+}
+
+static loff_t hci_vhci_chr_lseek(struct file * file, loff_t offset, int origin)
+{
+	return -ESPIPE;
+}
+
+static int hci_vhci_chr_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+{
+	return -EINVAL;
+}
+
+static int hci_vhci_chr_fasync(int fd, struct file *file, int on)
+{
+	struct hci_vhci_struct *hci_vhci = (struct hci_vhci_struct *) file->private_data;
+	int ret;
+
+	if ((ret = fasync_helper(fd, file, on, &hci_vhci->fasync)) < 0)
+		return ret; 
+ 
+	if (on)
+		hci_vhci->flags |= VHCI_FASYNC;
+	else 
+		hci_vhci->flags &= ~VHCI_FASYNC;
+
+	return 0;
+}
+
+static int hci_vhci_chr_open(struct inode *inode, struct file * file)
+{
+	struct hci_vhci_struct *hci_vhci = NULL; 
+	struct hci_dev *hdev;
+
+	if (!(hci_vhci = kmalloc(sizeof(struct hci_vhci_struct), GFP_KERNEL)))
+		return -ENOMEM;
+
+	memset(hci_vhci, 0, sizeof(struct hci_vhci_struct));
+
+	skb_queue_head_init(&hci_vhci->readq);
+	init_waitqueue_head(&hci_vhci->read_wait);
+
+	/* Initialize and register HCI device */
+	hdev = &hci_vhci->hdev;
+
+	hdev->type = HCI_VHCI;
+	hdev->driver_data = hci_vhci;
+
+	hdev->open  = hci_vhci_open;
+	hdev->close = hci_vhci_close;
+	hdev->flush = hci_vhci_flush;
+	hdev->send  = hci_vhci_send_frame;
+
+	if (hci_register_dev(hdev) < 0) {
+		kfree(hci_vhci);
+		return -EBUSY;
+	}
+
+	file->private_data = hci_vhci;
+	return 0;   
+}
+
+static int hci_vhci_chr_close(struct inode *inode, struct file *file)
+{
+	struct hci_vhci_struct *hci_vhci = (struct hci_vhci_struct *) file->private_data;
+
+	if (hci_unregister_dev(&hci_vhci->hdev) < 0) {
+		ERR("Can't unregister HCI device %s", hci_vhci->hdev.name);
+	}
+
+	kfree(hci_vhci);
+	file->private_data = NULL;
+
+	return 0;
+}
+
+static struct file_operations hci_vhci_fops = {
+	owner:	THIS_MODULE,	
+	llseek:	hci_vhci_chr_lseek,
+	read:	hci_vhci_chr_read,
+	write:	hci_vhci_chr_write,
+	poll:	hci_vhci_chr_poll,
+	ioctl:	hci_vhci_chr_ioctl,
+	open:	hci_vhci_chr_open,
+	release:hci_vhci_chr_close,
+	fasync:	hci_vhci_chr_fasync		
+};
+
+static struct miscdevice hci_vhci_miscdev=
+{
+        VHCI_MINOR,
+        "hci_vhci",
+        &hci_vhci_fops
+};
+
+int __init hci_vhci_init(void)
+{
+	INF("BlueZ VHCI driver ver %s Copyright (C) 2000,2001 Qualcomm Inc",  
+		VERSION);
+	INF("Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>");
+
+	if (misc_register(&hci_vhci_miscdev)) {
+		ERR("Can't register misc device %d\n", VHCI_MINOR);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+void hci_vhci_cleanup(void)
+{
+	misc_deregister(&hci_vhci_miscdev);
+}
+
+module_init(hci_vhci_init);
+module_exit(hci_vhci_cleanup);
+
+MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>");
+MODULE_DESCRIPTION("BlueZ VHCI driver ver " VERSION);
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/cdrom/aztcd.c linux/drivers/cdrom/aztcd.c
--- v2.4.9/linux/drivers/cdrom/aztcd.c	Thu Oct 26 23:35:47 2000
+++ linux/drivers/cdrom/aztcd.c	Sun Sep  9 10:43:02 2001
@@ -167,7 +167,7 @@
 
 #include <linux/version.h>
 
-#define MAJOR_NR AZTECH_CDROM_MAJOR 
+#define MAJOR_NR AZTECH_CDROM_MAJOR
 
 #include <linux/blk.h>
 #include "aztcd.h"
@@ -185,19 +185,13 @@
 #include <linux/major.h>
 #include <linux/devfs_fs_kernel.h>
 
-#ifndef AZT_KERNEL_PRIOR_2_1
 #include <linux/init.h>
-#endif
 
 #include <asm/system.h>
 #include <asm/io.h>
 
-#ifdef AZT_KERNEL_PRIOR_2_1
-#include <asm/segment.h>
-#else
 #include <asm/uaccess.h>
-static int aztcd_blocksizes[1] = {2048};
-#endif
+static int aztcd_blocksizes[1] = { 2048 };
 
 
 /*###########################################################################
@@ -206,7 +200,7 @@
 */
 #define SET_TIMER(func, jifs)   delay_timer.expires = jiffies + (jifs); \
                                 delay_timer.function = (void *) (func); \
-                                add_timer(&delay_timer); 
+                                add_timer(&delay_timer);
 
 #define CLEAR_TIMER             del_timer(&delay_timer);
 
@@ -219,17 +213,17 @@
 #define SWITCH_IDE_SLAVE  outb_p(0xa0,azt_port+6); \
 	                  outb_p(0x10,azt_port+6); \
 	                  outb_p(0x00,azt_port+7); \
-	                  outb_p(0x10,azt_port+6); 
+	                  outb_p(0x10,azt_port+6);
 #define SWITCH_IDE_MASTER outb_p(0xa0,azt_port+6);
 
 
 #if 0
 #define AZT_TEST
-#define AZT_TEST1 /* <int-..> */
-#define AZT_TEST2 /* do_aztcd_request */
-#define AZT_TEST3 /* AZT_S_state */
-#define AZT_TEST4 /* QUICK_LOOP-counter */
-#define AZT_TEST5 /* port(1) state */
+#define AZT_TEST1		/* <int-..> */
+#define AZT_TEST2		/* do_aztcd_request */
+#define AZT_TEST3		/* AZT_S_state */
+#define AZT_TEST4		/* QUICK_LOOP-counter */
+#define AZT_TEST5		/* port(1) state */
 #define AZT_DEBUG
 #define AZT_DEBUG_MULTISESSION
 #endif
@@ -243,30 +237,23 @@
 
 #define READ_TIMEOUT 3000
 
-#define azt_port aztcd  /*needed for the modutils*/
-
-#ifndef AZT_KERNEL_PRIOR_2_1 
-#define  memcpy_fromfs copy_from_user
-#define  memcpy_tofs   copy_to_user
-#endif
+#define azt_port aztcd		/*needed for the modutils */
 
 /*##########################################################################
   Type Definitions
   ##########################################################################
 */
-enum azt_state_e 
-{ AZT_S_IDLE,    /* 0 */
-  AZT_S_START,   /* 1 */
-  AZT_S_MODE,    /* 2 */
-  AZT_S_READ,    /* 3 */
-  AZT_S_DATA,    /* 4 */
-  AZT_S_STOP,    /* 5 */
-  AZT_S_STOPPING /* 6 */
+enum azt_state_e { AZT_S_IDLE,	/* 0 */
+	AZT_S_START,		/* 1 */
+	AZT_S_MODE,		/* 2 */
+	AZT_S_READ,		/* 3 */
+	AZT_S_DATA,		/* 4 */
+	AZT_S_STOP,		/* 5 */
+	AZT_S_STOPPING		/* 6 */
 };
-enum azt_read_modes 
-{ AZT_MODE_0,     /*read mode for audio disks, not supported by Aztech firmware*/
-  AZT_MODE_1,     /*read mode for normal CD-ROMs*/
-  AZT_MODE_2      /*read mode for XA CD-ROMs*/
+enum azt_read_modes { AZT_MODE_0,	/*read mode for audio disks, not supported by Aztech firmware */
+	AZT_MODE_1,		/*read mode for normal CD-ROMs */
+	AZT_MODE_2		/*read mode for XA CD-ROMs */
 };
 
 /*##########################################################################
@@ -275,20 +262,20 @@
 */
 static int aztPresent = 0;
 
-static volatile int azt_transfer_is_active=0;
+static volatile int azt_transfer_is_active = 0;
 
-static char azt_buf[CD_FRAMESIZE_RAW*AZT_BUF_SIZ];/*buffer for block size conversion*/
+static char azt_buf[CD_FRAMESIZE_RAW * AZT_BUF_SIZ];	/*buffer for block size conversion */
 #if AZT_PRIVATE_IOCTLS
-static char buf[CD_FRAMESIZE_RAW];              /*separate buffer for the ioctls*/
+static char buf[CD_FRAMESIZE_RAW];	/*separate buffer for the ioctls */
 #endif
 
 static volatile int azt_buf_bn[AZT_BUF_SIZ], azt_next_bn;
 static volatile int azt_buf_in, azt_buf_out = -1;
-static volatile int azt_error=0;
-static int azt_open_count=0;
+static volatile int azt_error = 0;
+static int azt_open_count = 0;
 static volatile enum azt_state_e azt_state = AZT_S_IDLE;
 #ifdef AZT_TEST3
-static volatile enum azt_state_e azt_state_old = AZT_S_STOP;  
+static volatile enum azt_state_e azt_state_old = AZT_S_STOP;
 static volatile int azt_st_old = 0;
 #endif
 static volatile enum azt_read_modes azt_read_mode = AZT_MODE_1;
@@ -298,15 +285,13 @@
 
 static int azt_port = AZT_BASE_ADDR;
 
-#ifndef AZT_KERNEL_PRIOR_2_1
 MODULE_PARM(azt_port, "i");
-#endif
 
 static int azt_port_auto[16] = AZT_BASE_AUTO;
 
-static char  azt_cont = 0;
-static char  azt_init_end = 0;
-static char  azt_auto_eject = AZT_AUTO_EJECT;
+static char azt_cont = 0;
+static char azt_init_end = 0;
+static char azt_auto_eject = AZT_AUTO_EJECT;
 
 static int AztTimeout, AztTries;
 static DECLARE_WAIT_QUEUE_HEAD(azt_waitq);
@@ -316,7 +301,7 @@
 static struct azt_Toc Toc[MAX_TRACKS];
 static struct azt_Play_msf azt_Play;
 
-static int  aztAudioStatus = CDROM_AUDIO_NO_STATUS;
+static int aztAudioStatus = CDROM_AUDIO_NO_STATUS;
 static char aztDiskChanged = 1;
 static char aztTocUpToDate = 0;
 
@@ -329,54 +314,51 @@
   ###########################################################################
 */
 /* CDROM Drive Low Level I/O Functions */
-void        op_ok(void);
-void        pa_ok(void);
-void        sten_low(void);
-void        dten_low(void);
-void        statusAzt(void);
+void op_ok(void);
+void pa_ok(void);
+void sten_low(void);
+void dten_low(void);
+void statusAzt(void);
 static void aztStatTimer(void);
 
 /* CDROM Drive Command Functions */
-static int  aztSendCmd(int cmd);
-static int  sendAztCmd(int cmd, struct azt_Play_msf *params);
-static int  aztSeek(struct azt_Play_msf *params);
-static int  aztSetDiskType(int type);
-static int  aztStatus(void);
-static int  getAztStatus(void);
-static int  aztPlay(struct azt_Play_msf *arg);
+static int aztSendCmd(int cmd);
+static int sendAztCmd(int cmd, struct azt_Play_msf *params);
+static int aztSeek(struct azt_Play_msf *params);
+static int aztSetDiskType(int type);
+static int aztStatus(void);
+static int getAztStatus(void);
+static int aztPlay(struct azt_Play_msf *arg);
 static void aztCloseDoor(void);
 static void aztLockDoor(void);
 static void aztUnlockDoor(void);
-static int  aztGetValue(unsigned char *result);
-static int  aztGetQChannelInfo(struct azt_Toc *qp);
-static int  aztUpdateToc(void);
-static int  aztGetDiskInfo(void);
-#if AZT_MULTISESSION 
- static int aztGetMultiDiskInfo(void);
+static int aztGetValue(unsigned char *result);
+static int aztGetQChannelInfo(struct azt_Toc *qp);
+static int aztUpdateToc(void);
+static int aztGetDiskInfo(void);
+#if AZT_MULTISESSION
+static int aztGetMultiDiskInfo(void);
 #endif
-static int  aztGetToc(int multi);
+static int aztGetToc(int multi);
 
 /* Kernel Interface Functions */
-static int  check_aztcd_media_change(kdev_t full_dev);
-static int  aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg);
+static int check_aztcd_media_change(kdev_t full_dev);
+static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
+		       unsigned long arg);
 static void azt_transfer(void);
 static void do_aztcd_request(request_queue_t *);
 static void azt_invalidate_buffers(void);
-int         aztcd_open(struct inode *ip, struct file *fp);
+int aztcd_open(struct inode *ip, struct file *fp);
 
-#ifdef AZT_KERNEL_PRIOR_2_1
-static void aztcd_release(struct inode * inode, struct file * file);
-#else
-static int  aztcd_release(struct inode * inode, struct file * file);
-#endif
+static int aztcd_release(struct inode *inode, struct file *file);
 
-int       aztcd_init(void);
+int aztcd_init(void);
 
 static struct block_device_operations azt_fops = {
-	open:			aztcd_open,
-	release:		aztcd_release,
-	ioctl:			aztcd_ioctl,
-	check_media_change:	check_aztcd_media_change,
+	open:aztcd_open,
+	release:aztcd_release,
+	ioctl:aztcd_ioctl,
+	check_media_change:check_aztcd_media_change,
 };
 
 /* Aztcd State Machine: Controls Drive Operating State */
@@ -386,7 +368,7 @@
 static void azt_hsg2msf(long hsg, struct msf *msf);
 static long azt_msf2hsg(struct msf *mp);
 static void azt_bin2bcd(unsigned char *p);
-static int  azt_bcd2bin(unsigned char bcd);
+static int azt_bcd2bin(unsigned char bcd);
 
 /*##########################################################################
   CDROM Drive Low Level I/O Functions
@@ -397,53 +379,64 @@
 /* Wait for OP_OK = drive answers with AFL_OP_OK after receiving a command*/
 # define OP_OK op_ok()
 void op_ok(void)
-{ aztTimeOutCount=0; 
-  do { aztIndatum=inb(DATA_PORT);
-       aztTimeOutCount++;
-       if (aztTimeOutCount>=AZT_TIMEOUT)
-	{ printk("aztcd: Error Wait OP_OK\n");
-	  break;
-	}
-     } while (aztIndatum!=AFL_OP_OK);
+{
+	aztTimeOutCount = 0;
+	do {
+		aztIndatum = inb(DATA_PORT);
+		aztTimeOutCount++;
+		if (aztTimeOutCount >= AZT_TIMEOUT) {
+			printk("aztcd: Error Wait OP_OK\n");
+			break;
+		}
+	} while (aztIndatum != AFL_OP_OK);
 }
 
 /* Wait for PA_OK = drive answers with AFL_PA_OK after receiving parameters*/
 # define PA_OK pa_ok()
 void pa_ok(void)
-{ aztTimeOutCount=0; 
-  do { aztIndatum=inb(DATA_PORT);
-       aztTimeOutCount++;
-       if (aztTimeOutCount>=AZT_TIMEOUT)
-	{ printk("aztcd: Error Wait PA_OK\n");
-	  break;
-	}
-     } while (aztIndatum!=AFL_PA_OK);
+{
+	aztTimeOutCount = 0;
+	do {
+		aztIndatum = inb(DATA_PORT);
+		aztTimeOutCount++;
+		if (aztTimeOutCount >= AZT_TIMEOUT) {
+			printk("aztcd: Error Wait PA_OK\n");
+			break;
+		}
+	} while (aztIndatum != AFL_PA_OK);
 }
-     
+
 /* Wait for STEN=Low = handshake signal 'AFL_.._OK available or command executed*/
 # define STEN_LOW  sten_low()
 void sten_low(void)
-{ aztTimeOutCount=0; 
-  do { aztIndatum=inb(STATUS_PORT);
-       aztTimeOutCount++;
-       if (aztTimeOutCount>=AZT_TIMEOUT)
-	{ if (azt_init_end) printk("aztcd: Error Wait STEN_LOW commands:%x\n",aztCmd);
-	  break;
-	}
-     } while (aztIndatum&AFL_STATUS);
+{
+	aztTimeOutCount = 0;
+	do {
+		aztIndatum = inb(STATUS_PORT);
+		aztTimeOutCount++;
+		if (aztTimeOutCount >= AZT_TIMEOUT) {
+			if (azt_init_end)
+				printk
+				    ("aztcd: Error Wait STEN_LOW commands:%x\n",
+				     aztCmd);
+			break;
+		}
+	} while (aztIndatum & AFL_STATUS);
 }
 
 /* Wait for DTEN=Low = handshake signal 'Data available'*/
 # define DTEN_LOW dten_low()
 void dten_low(void)
-{ aztTimeOutCount=0; 
-  do { aztIndatum=inb(STATUS_PORT);
-       aztTimeOutCount++;
-       if (aztTimeOutCount>=AZT_TIMEOUT)
-	{ printk("aztcd: Error Wait DTEN_OK\n");
-	  break;
-	}
-     } while (aztIndatum&AFL_DATA);
+{
+	aztTimeOutCount = 0;
+	do {
+		aztIndatum = inb(STATUS_PORT);
+		aztTimeOutCount++;
+		if (aztTimeOutCount >= AZT_TIMEOUT) {
+			printk("aztcd: Error Wait DTEN_OK\n");
+			break;
+		}
+	} while (aztIndatum & AFL_DATA);
 }
 
 /* 
@@ -452,25 +445,29 @@
 */
 #define STEN_LOW_WAIT   statusAzt()
 void statusAzt(void)
-{ AztTimeout = AZT_STATUS_DELAY;
-  SET_TIMER(aztStatTimer, HZ/100); 
-  sleep_on(&azt_waitq);
-  if (AztTimeout <= 0) printk("aztcd: Error Wait STEN_LOW_WAIT command:%x\n",aztCmd);
-  return;
+{
+	AztTimeout = AZT_STATUS_DELAY;
+	SET_TIMER(aztStatTimer, HZ / 100);
+	sleep_on(&azt_waitq);
+	if (AztTimeout <= 0)
+		printk("aztcd: Error Wait STEN_LOW_WAIT command:%x\n",
+		       aztCmd);
+	return;
 }
 
 static void aztStatTimer(void)
-{ if (!(inb(STATUS_PORT) & AFL_STATUS))
-     { wake_up(&azt_waitq);
-       return;
-     }
-  AztTimeout--;
-  if (AztTimeout <= 0)
-     { wake_up(&azt_waitq);
-       printk("aztcd: Error aztStatTimer: Timeout\n");
-       return;
-     }
-  SET_TIMER(aztStatTimer, HZ/100);
+{
+	if (!(inb(STATUS_PORT) & AFL_STATUS)) {
+		wake_up(&azt_waitq);
+		return;
+	}
+	AztTimeout--;
+	if (AztTimeout <= 0) {
+		wake_up(&azt_waitq);
+		printk("aztcd: Error aztStatTimer: Timeout\n");
+		return;
+	}
+	SET_TIMER(aztStatTimer, HZ / 100);
 }
 
 /*##########################################################################
@@ -481,111 +478,125 @@
  * Send a single command, return -1 on error, else 0
 */
 static int aztSendCmd(int cmd)
-{  unsigned char data;
-   int retry;
+{
+	unsigned char data;
+	int retry;
 
 #ifdef AZT_DEBUG
-   printk("aztcd: Executing command %x\n",cmd);
+	printk("aztcd: Executing command %x\n", cmd);
 #endif
 
-   if ((azt_port==0x1f0)||(azt_port==0x170))  
-      SWITCH_IDE_SLAVE; /*switch IDE interface to slave configuration*/
-   
-   aztCmd=cmd;
-   outb(POLLED,MODE_PORT);
-   do { if (inb(STATUS_PORT)&AFL_STATUS) break;
-	inb(DATA_PORT);    /* if status left from last command, read and */
-      } while (1);         /* discard it */
-   do { if (inb(STATUS_PORT)&AFL_DATA) break;
-	inb(DATA_PORT);    /* if data left from last command, read and */
-      } while (1);         /* discard it */
-   for (retry=0;retry<AZT_RETRY_ATTEMPTS;retry++)
-     { outb((unsigned char) cmd,CMD_PORT);
-       STEN_LOW;
-       data=inb(DATA_PORT);
-       if (data==AFL_OP_OK)
-	 { return 0;}           /*OP_OK?*/
-       if (data==AFL_OP_ERR)
-	 { STEN_LOW;
-	   data=inb(DATA_PORT);
-	   printk("### Error 1 aztcd: aztSendCmd %x  Error Code %x\n",cmd,data);
-	 }
-     }
-   if (retry>=AZT_RETRY_ATTEMPTS)
-     { printk("### Error 2 aztcd: aztSendCmd %x \n",cmd);
-       azt_error=0xA5;
-     }
-   RETURNM("aztSendCmd",-1);
+	if ((azt_port == 0x1f0) || (azt_port == 0x170))
+		SWITCH_IDE_SLAVE;	/*switch IDE interface to slave configuration */
+
+	aztCmd = cmd;
+	outb(POLLED, MODE_PORT);
+	do {
+		if (inb(STATUS_PORT) & AFL_STATUS)
+			break;
+		inb(DATA_PORT);	/* if status left from last command, read and */
+	} while (1);		/* discard it */
+	do {
+		if (inb(STATUS_PORT) & AFL_DATA)
+			break;
+		inb(DATA_PORT);	/* if data left from last command, read and */
+	} while (1);		/* discard it */
+	for (retry = 0; retry < AZT_RETRY_ATTEMPTS; retry++) {
+		outb((unsigned char) cmd, CMD_PORT);
+		STEN_LOW;
+		data = inb(DATA_PORT);
+		if (data == AFL_OP_OK) {
+			return 0;
+		}		/*OP_OK? */
+		if (data == AFL_OP_ERR) {
+			STEN_LOW;
+			data = inb(DATA_PORT);
+			printk
+			    ("### Error 1 aztcd: aztSendCmd %x  Error Code %x\n",
+			     cmd, data);
+		}
+	}
+	if (retry >= AZT_RETRY_ATTEMPTS) {
+		printk("### Error 2 aztcd: aztSendCmd %x \n", cmd);
+		azt_error = 0xA5;
+	}
+	RETURNM("aztSendCmd", -1);
 }
 
 /*
  * Send a play or read command to the drive, return -1 on error, else 0
 */
 static int sendAztCmd(int cmd, struct azt_Play_msf *params)
-{  unsigned char data;
-   int retry;
+{
+	unsigned char data;
+	int retry;
 
 #ifdef AZT_DEBUG
-   printk("aztcd: play start=%02x:%02x:%02x  end=%02x:%02x:%02x\n", \
-	   params->start.min, params->start.sec, params->start.frame, \
-	   params->end.min,   params->end.sec,   params->end.frame);
-#endif   
-   for (retry=0;retry<AZT_RETRY_ATTEMPTS;retry++)
-     { aztSendCmd(cmd);
-       outb(params -> start.min,CMD_PORT);
-       outb(params -> start.sec,CMD_PORT);
-       outb(params -> start.frame,CMD_PORT);
-       outb(params -> end.min,CMD_PORT);
-       outb(params -> end.sec,CMD_PORT);
-       outb(params -> end.frame,CMD_PORT);
-       STEN_LOW;
-       data=inb(DATA_PORT);
-       if (data==AFL_PA_OK)
-	 { return 0;}           /*PA_OK ?*/
-       if (data==AFL_PA_ERR)
-	 { STEN_LOW;
-	   data=inb(DATA_PORT);
-	   printk("### Error 1 aztcd: sendAztCmd %x  Error Code %x\n",cmd,data);
-	 }
-     }
-   if (retry>=AZT_RETRY_ATTEMPTS)
-     { printk("### Error 2 aztcd: sendAztCmd %x\n ",cmd);
-       azt_error=0xA5;
-     }
-   RETURNM("sendAztCmd",-1);
+	printk("aztcd: play start=%02x:%02x:%02x  end=%02x:%02x:%02x\n",
+	       params->start.min, params->start.sec, params->start.frame,
+	       params->end.min, params->end.sec, params->end.frame);
+#endif
+	for (retry = 0; retry < AZT_RETRY_ATTEMPTS; retry++) {
+		aztSendCmd(cmd);
+		outb(params->start.min, CMD_PORT);
+		outb(params->start.sec, CMD_PORT);
+		outb(params->start.frame, CMD_PORT);
+		outb(params->end.min, CMD_PORT);
+		outb(params->end.sec, CMD_PORT);
+		outb(params->end.frame, CMD_PORT);
+		STEN_LOW;
+		data = inb(DATA_PORT);
+		if (data == AFL_PA_OK) {
+			return 0;
+		}		/*PA_OK ? */
+		if (data == AFL_PA_ERR) {
+			STEN_LOW;
+			data = inb(DATA_PORT);
+			printk
+			    ("### Error 1 aztcd: sendAztCmd %x  Error Code %x\n",
+			     cmd, data);
+		}
+	}
+	if (retry >= AZT_RETRY_ATTEMPTS) {
+		printk("### Error 2 aztcd: sendAztCmd %x\n ", cmd);
+		azt_error = 0xA5;
+	}
+	RETURNM("sendAztCmd", -1);
 }
 
 /*
  * Send a seek command to the drive, return -1 on error, else 0
 */
 static int aztSeek(struct azt_Play_msf *params)
-{  unsigned char data;
-   int retry;
+{
+	unsigned char data;
+	int retry;
 
 #ifdef AZT_DEBUG
-   printk("aztcd: aztSeek %02x:%02x:%02x\n", \
-	   params->start.min, params->start.sec, params->start.frame);
-#endif   
-   for (retry=0;retry<AZT_RETRY_ATTEMPTS;retry++)
-     { aztSendCmd(ACMD_SEEK);
-       outb(params -> start.min,CMD_PORT);
-       outb(params -> start.sec,CMD_PORT);
-       outb(params -> start.frame,CMD_PORT);
-       STEN_LOW;
-       data=inb(DATA_PORT);
-       if (data==AFL_PA_OK)
-	 { return 0;}           /*PA_OK ?*/
-       if (data==AFL_PA_ERR)
-	 { STEN_LOW;
-	   data=inb(DATA_PORT);
-	   printk("### Error 1 aztcd: aztSeek\n");
-	 }
-     }
-   if (retry>=AZT_RETRY_ATTEMPTS)
-     { printk("### Error 2 aztcd: aztSeek\n ");
-       azt_error=0xA5;
-     }
-   RETURNM("aztSeek",-1);
+	printk("aztcd: aztSeek %02x:%02x:%02x\n",
+	       params->start.min, params->start.sec, params->start.frame);
+#endif
+	for (retry = 0; retry < AZT_RETRY_ATTEMPTS; retry++) {
+		aztSendCmd(ACMD_SEEK);
+		outb(params->start.min, CMD_PORT);
+		outb(params->start.sec, CMD_PORT);
+		outb(params->start.frame, CMD_PORT);
+		STEN_LOW;
+		data = inb(DATA_PORT);
+		if (data == AFL_PA_OK) {
+			return 0;
+		}		/*PA_OK ? */
+		if (data == AFL_PA_ERR) {
+			STEN_LOW;
+			data = inb(DATA_PORT);
+			printk("### Error 1 aztcd: aztSeek\n");
+		}
+	}
+	if (retry >= AZT_RETRY_ATTEMPTS) {
+		printk("### Error 2 aztcd: aztSeek\n ");
+		azt_error = 0xA5;
+	}
+	RETURNM("aztSeek", -1);
 }
 
 /* Send a Set Disk Type command
@@ -593,79 +604,86 @@
    dent on which mode is set ???
 */
 static int aztSetDiskType(int type)
-{  unsigned char data;
-   int retry;
+{
+	unsigned char data;
+	int retry;
 
 #ifdef AZT_DEBUG
-   printk("aztcd: set disk type command: type= %i\n",type);
+	printk("aztcd: set disk type command: type= %i\n", type);
 #endif
-   for (retry=0;retry<AZT_RETRY_ATTEMPTS;retry++)
-     { aztSendCmd(ACMD_SET_DISK_TYPE);
-       outb(type,CMD_PORT);
-       STEN_LOW;
-       data=inb(DATA_PORT);
-       if (data==AFL_PA_OK)     /*PA_OK ?*/
-	 { azt_read_mode=type;
-	   return 0;            
-	 }  
-       if (data==AFL_PA_ERR)
-	 { STEN_LOW;
-	   data=inb(DATA_PORT);
-	   printk("### Error 1 aztcd: aztSetDiskType %x Error Code %x\n",type,data);
-	 }
-     }
-   if (retry>=AZT_RETRY_ATTEMPTS)
-     { printk("### Error 2 aztcd: aztSetDiskType %x\n ",type);
-       azt_error=0xA5;
-     }
-   RETURNM("aztSetDiskType",-1);
+	for (retry = 0; retry < AZT_RETRY_ATTEMPTS; retry++) {
+		aztSendCmd(ACMD_SET_DISK_TYPE);
+		outb(type, CMD_PORT);
+		STEN_LOW;
+		data = inb(DATA_PORT);
+		if (data == AFL_PA_OK) {	/*PA_OK ? */
+			azt_read_mode = type;
+			return 0;
+		}
+		if (data == AFL_PA_ERR) {
+			STEN_LOW;
+			data = inb(DATA_PORT);
+			printk
+			    ("### Error 1 aztcd: aztSetDiskType %x Error Code %x\n",
+			     type, data);
+		}
+	}
+	if (retry >= AZT_RETRY_ATTEMPTS) {
+		printk("### Error 2 aztcd: aztSetDiskType %x\n ", type);
+		azt_error = 0xA5;
+	}
+	RETURNM("aztSetDiskType", -1);
 }
 
 
 /* used in azt_poll to poll the status, expects another program to issue a 
  * ACMD_GET_STATUS directly before 
  */
-static int aztStatus(void)  
-{       int st;
+static int aztStatus(void)
+{
+	int st;
 /*	int i;
 
 	i = inb(STATUS_PORT) & AFL_STATUS;    is STEN=0?    ???
 	if (!i)
-*/      STEN_LOW;
-        if (aztTimeOutCount<AZT_TIMEOUT)	
-	{   	st = inb(DATA_PORT) & 0xFF;
+*/ STEN_LOW;
+	if (aztTimeOutCount < AZT_TIMEOUT) {
+		st = inb(DATA_PORT) & 0xFF;
 		return st;
-	}
-	else
-		RETURNM("aztStatus",-1);
+	} else
+		RETURNM("aztStatus", -1);
 }
 
 /*
  * Get the drive status
  */
 static int getAztStatus(void)
-{       int st;
+{
+	int st;
 
-	if (aztSendCmd(ACMD_GET_STATUS)) RETURNM("getAztStatus 1",-1);
+	if (aztSendCmd(ACMD_GET_STATUS))
+		RETURNM("getAztStatus 1", -1);
 	STEN_LOW;
 	st = inb(DATA_PORT) & 0xFF;
 #ifdef AZT_DEBUG
-	printk("aztcd: Status = %x\n",st);
+	printk("aztcd: Status = %x\n", st);
 #endif
-	if ((st == 0xFF)||(st&AST_CMD_CHECK))
-	 { printk("aztcd: AST_CMD_CHECK error or no status available\n");
-	   return -1;
-	 }
-
-	if (((st&AST_MODE_BITS)!=AST_BUSY) && (aztAudioStatus == CDROM_AUDIO_PLAY))
-	   /* XXX might be an error? look at q-channel? */
-	   aztAudioStatus = CDROM_AUDIO_COMPLETED;
-
-	if ((st & AST_DSK_CHG)||(st & AST_NOT_READY))
-	 { aztDiskChanged = 1;
-	   aztTocUpToDate = 0;
-	   aztAudioStatus = CDROM_AUDIO_NO_STATUS;
-	 }
+	if ((st == 0xFF) || (st & AST_CMD_CHECK)) {
+		printk
+		    ("aztcd: AST_CMD_CHECK error or no status available\n");
+		return -1;
+	}
+
+	if (((st & AST_MODE_BITS) != AST_BUSY)
+	    && (aztAudioStatus == CDROM_AUDIO_PLAY))
+		/* XXX might be an error? look at q-channel? */
+		aztAudioStatus = CDROM_AUDIO_COMPLETED;
+
+	if ((st & AST_DSK_CHG) || (st & AST_NOT_READY)) {
+		aztDiskChanged = 1;
+		aztTocUpToDate = 0;
+		aztAudioStatus = CDROM_AUDIO_NO_STATUS;
+	}
 	return st;
 }
 
@@ -674,7 +692,9 @@
  * Send a 'Play' command and get the status.  Use only from the top half.
  */
 static int aztPlay(struct azt_Play_msf *arg)
-{       if (sendAztCmd(ACMD_PLAY_AUDIO, arg) < 0) RETURNM("aztPlay",-1);
+{
+	if (sendAztCmd(ACMD_PLAY_AUDIO, arg) < 0)
+		RETURNM("aztPlay", -1);
 	return 0;
 }
 
@@ -685,27 +705,27 @@
  */
 static void aztCloseDoor(void)
 {
-  aztSendCmd(ACMD_CLOSE);
-  STEN_LOW;
-  return;
+	aztSendCmd(ACMD_CLOSE);
+	STEN_LOW;
+	return;
 }
 
 static void aztLockDoor(void)
 {
 #if AZT_ALLOW_TRAY_LOCK
-  aztSendCmd(ACMD_LOCK);
-  STEN_LOW;
+	aztSendCmd(ACMD_LOCK);
+	STEN_LOW;
 #endif
-  return;
+	return;
 }
 
 static void aztUnlockDoor(void)
 {
 #if AZT_ALLOW_TRAY_LOCK
-  aztSendCmd(ACMD_UNLOCK);
-  STEN_LOW;
+	aztSendCmd(ACMD_UNLOCK);
+	STEN_LOW;
 #endif
-  return;
+	return;
 }
 
 /*
@@ -714,11 +734,12 @@
  * be issued with aztSendCmd() directly before
  */
 static int aztGetValue(unsigned char *result)
-{       int s;
+{
+	int s;
 
 	STEN_LOW;
-	if (aztTimeOutCount>=AZT_TIMEOUT)
-	{       printk("aztcd: aztGetValue timeout\n");
+	if (aztTimeOutCount >= AZT_TIMEOUT) {
+		printk("aztcd: aztGetValue timeout\n");
 		return -1;
 	}
 	s = inb(DATA_PORT) & 0xFF;
@@ -731,42 +752,55 @@
  * table of contents.
  */
 int aztGetQChannelInfo(struct azt_Toc *qp)
-{       unsigned char notUsed;
+{
+	unsigned char notUsed;
 	int st;
 
 #ifdef AZT_DEBUG
-	printk("aztcd: starting aztGetQChannelInfo  Time:%li\n",jiffies);
+	printk("aztcd: starting aztGetQChannelInfo  Time:%li\n", jiffies);
 #endif
-	if ((st=getAztStatus())==-1)        RETURNM("aztGetQChannelInfo 1",-1);
-	if (aztSendCmd(ACMD_GET_Q_CHANNEL)) RETURNM("aztGetQChannelInfo 2",-1);
-	/*STEN_LOW_WAIT; ??? Dosemu0.60's cdrom.c does not like STEN_LOW_WAIT here*/
-	if (aztGetValue(&notUsed)) RETURNM("aztGetQChannelInfo 3",-1); /*??? Nullbyte einlesen*/
-	if ((st&AST_MODE_BITS)==AST_INITIAL)
-	 { qp->ctrl_addr=0;      /* when audio stop ACMD_GET_Q_CHANNEL returns */
-	   qp->track=0;          /* only one byte with Aztech drives */
-	   qp->pointIndex=0;
-	   qp->trackTime.min=0;
-	   qp->trackTime.sec=0;
-	   qp->trackTime.frame=0;
-	   qp->diskTime.min=0;
-	   qp->diskTime.sec=0;
-	   qp->diskTime.frame=0;
-	   return 0;  
-	 }
-	else
-	 { if (aztGetValue(&qp -> ctrl_addr) < 0)       RETURNM("aztGetQChannelInfo 4",-1);
-	   if (aztGetValue(&qp -> track) < 0)           RETURNM("aztGetQChannelInfo 4",-1);
-	   if (aztGetValue(&qp -> pointIndex) < 0)      RETURNM("aztGetQChannelInfo 4",-1);
-	   if (aztGetValue(&qp -> trackTime.min) < 0)   RETURNM("aztGetQChannelInfo 4",-1);
-	   if (aztGetValue(&qp -> trackTime.sec) < 0)   RETURNM("aztGetQChannelInfo 4",-1);
-	   if (aztGetValue(&qp -> trackTime.frame) < 0) RETURNM("aztGetQChannelInfo 4",-1);
-	   if (aztGetValue(&notUsed) < 0)               RETURNM("aztGetQChannelInfo 4",-1);
-	   if (aztGetValue(&qp -> diskTime.min) < 0)    RETURNM("aztGetQChannelInfo 4",-1);
-	   if (aztGetValue(&qp -> diskTime.sec) < 0)    RETURNM("aztGetQChannelInfo 4",-1);
-	   if (aztGetValue(&qp -> diskTime.frame) < 0)  RETURNM("aztGetQChannelInfo 4",-1);
-	 }
+	if ((st = getAztStatus()) == -1)
+		RETURNM("aztGetQChannelInfo 1", -1);
+	if (aztSendCmd(ACMD_GET_Q_CHANNEL))
+		RETURNM("aztGetQChannelInfo 2", -1);
+	/*STEN_LOW_WAIT; ??? Dosemu0.60's cdrom.c does not like STEN_LOW_WAIT here */
+	if (aztGetValue(&notUsed))
+		RETURNM("aztGetQChannelInfo 3", -1);	/*??? Nullbyte einlesen */
+	if ((st & AST_MODE_BITS) == AST_INITIAL) {
+		qp->ctrl_addr = 0;	/* when audio stop ACMD_GET_Q_CHANNEL returns */
+		qp->track = 0;	/* only one byte with Aztech drives */
+		qp->pointIndex = 0;
+		qp->trackTime.min = 0;
+		qp->trackTime.sec = 0;
+		qp->trackTime.frame = 0;
+		qp->diskTime.min = 0;
+		qp->diskTime.sec = 0;
+		qp->diskTime.frame = 0;
+		return 0;
+	} else {
+		if (aztGetValue(&qp->ctrl_addr) < 0)
+			RETURNM("aztGetQChannelInfo 4", -1);
+		if (aztGetValue(&qp->track) < 0)
+			RETURNM("aztGetQChannelInfo 4", -1);
+		if (aztGetValue(&qp->pointIndex) < 0)
+			RETURNM("aztGetQChannelInfo 4", -1);
+		if (aztGetValue(&qp->trackTime.min) < 0)
+			RETURNM("aztGetQChannelInfo 4", -1);
+		if (aztGetValue(&qp->trackTime.sec) < 0)
+			RETURNM("aztGetQChannelInfo 4", -1);
+		if (aztGetValue(&qp->trackTime.frame) < 0)
+			RETURNM("aztGetQChannelInfo 4", -1);
+		if (aztGetValue(&notUsed) < 0)
+			RETURNM("aztGetQChannelInfo 4", -1);
+		if (aztGetValue(&qp->diskTime.min) < 0)
+			RETURNM("aztGetQChannelInfo 4", -1);
+		if (aztGetValue(&qp->diskTime.sec) < 0)
+			RETURNM("aztGetQChannelInfo 4", -1);
+		if (aztGetValue(&qp->diskTime.frame) < 0)
+			RETURNM("aztGetQChannelInfo 4", -1);
+	}
 #ifdef AZT_DEBUG
-	printk("aztcd: exiting aztGetQChannelInfo  Time:%li\n",jiffies);
+	printk("aztcd: exiting aztGetQChannelInfo  Time:%li\n", jiffies);
 #endif
 	return 0;
 }
@@ -775,11 +809,12 @@
  * Read the table of contents (TOC) and TOC header if necessary
  */
 static int aztUpdateToc()
-{       int st;
+{
+	int st;
 
 #ifdef AZT_DEBUG
-	printk("aztcd: starting aztUpdateToc  Time:%li\n",jiffies);
-#endif  
+	printk("aztcd: starting aztUpdateToc  Time:%li\n", jiffies);
+#endif
 	if (aztTocUpToDate)
 		return 0;
 
@@ -789,57 +824,63 @@
 	if (aztGetToc(0) < 0)
 		return -EIO;
 
-        /*audio disk detection
-          with my Aztech drive there is no audio status bit, so I use the copy
-          protection bit of the first track. If this track is copy protected 
-          (copy bit = 0), I assume, it's an audio  disk. Strange, but works ??? */
-        if (!(Toc[DiskInfo.first].ctrl_addr & 0x40)) 
-           DiskInfo.audio=1;
-        else 
-           DiskInfo.audio=0;
-
-        /* XA detection */
-	if (! DiskInfo.audio) 
-	   { azt_Play.start.min   = 0;  /*XA detection only seems to work*/
-             azt_Play.start.sec   = 2;  /*when we play a track*/
-	     azt_Play.start.frame = 0;
-	     azt_Play.end.min     = 0;
-	     azt_Play.end.sec     = 0;
-	     azt_Play.end.frame   = 1;
-	     if (sendAztCmd(ACMD_PLAY_READ, &azt_Play)) return -1;
-	     DTEN_LOW;
-	     for (st=0;st<CD_FRAMESIZE;st++) inb(DATA_PORT);
-           } 
-        DiskInfo.xa = getAztStatus() & AST_MODE;
-        if (DiskInfo.xa) 
-           { printk("aztcd: XA support experimental - mail results to Werner.Zimmermann@fht-esslingen.de\n");
-           }
-        
-        /*multisession detection
-          support for multisession CDs is done automatically with Aztech drives,
-          we don't have to take care about TOC redirection; if we want the isofs
-          to take care about redirection, we have to set AZT_MULTISESSION to 1*/
-        DiskInfo.multi=0;
+	/*audio disk detection
+	   with my Aztech drive there is no audio status bit, so I use the copy
+	   protection bit of the first track. If this track is copy protected 
+	   (copy bit = 0), I assume, it's an audio  disk. Strange, but works ??? */
+	if (!(Toc[DiskInfo.first].ctrl_addr & 0x40))
+		DiskInfo.audio = 1;
+	else
+		DiskInfo.audio = 0;
+
+	/* XA detection */
+	if (!DiskInfo.audio) {
+		azt_Play.start.min = 0;	/*XA detection only seems to work */
+		azt_Play.start.sec = 2;	/*when we play a track */
+		azt_Play.start.frame = 0;
+		azt_Play.end.min = 0;
+		azt_Play.end.sec = 0;
+		azt_Play.end.frame = 1;
+		if (sendAztCmd(ACMD_PLAY_READ, &azt_Play))
+			return -1;
+		DTEN_LOW;
+		for (st = 0; st < CD_FRAMESIZE; st++)
+			inb(DATA_PORT);
+	}
+	DiskInfo.xa = getAztStatus() & AST_MODE;
+	if (DiskInfo.xa) {
+		printk
+		    ("aztcd: XA support experimental - mail results to Werner.Zimmermann@fht-esslingen.de\n");
+	}
+
+	/*multisession detection
+	   support for multisession CDs is done automatically with Aztech drives,
+	   we don't have to take care about TOC redirection; if we want the isofs
+	   to take care about redirection, we have to set AZT_MULTISESSION to 1 */
+	DiskInfo.multi = 0;
 #if AZT_MULTISESSION
-  	if (DiskInfo.xa) 
-  	   { aztGetMultiDiskInfo(); /*here Disk.Info.multi is set*/
-  	   }
-#endif
-        if (DiskInfo.multi)
-           { DiskInfo.lastSession.min  = Toc[DiskInfo.next].diskTime.min;
-	     DiskInfo.lastSession.sec  = Toc[DiskInfo.next].diskTime.sec;
-             DiskInfo.lastSession.frame= Toc[DiskInfo.next].diskTime.frame;
-             printk("aztcd: Multisession support experimental\n");
-           }
-        else
-           { DiskInfo.lastSession.min  = Toc[DiskInfo.first].diskTime.min;
-	     DiskInfo.lastSession.sec  = Toc[DiskInfo.first].diskTime.sec;
-             DiskInfo.lastSession.frame= Toc[DiskInfo.first].diskTime.frame;
-           }
+	if (DiskInfo.xa) {
+		aztGetMultiDiskInfo();	/*here Disk.Info.multi is set */
+	}
+#endif
+	if (DiskInfo.multi) {
+		DiskInfo.lastSession.min = Toc[DiskInfo.next].diskTime.min;
+		DiskInfo.lastSession.sec = Toc[DiskInfo.next].diskTime.sec;
+		DiskInfo.lastSession.frame =
+		    Toc[DiskInfo.next].diskTime.frame;
+		printk("aztcd: Multisession support experimental\n");
+	} else {
+		DiskInfo.lastSession.min =
+		    Toc[DiskInfo.first].diskTime.min;
+		DiskInfo.lastSession.sec =
+		    Toc[DiskInfo.first].diskTime.sec;
+		DiskInfo.lastSession.frame =
+		    Toc[DiskInfo.first].diskTime.frame;
+	}
 
 	aztTocUpToDate = 1;
 #ifdef AZT_DEBUG
-	printk("aztcd: exiting aztUpdateToc  Time:%li\n",jiffies);
+	printk("aztcd: exiting aztUpdateToc  Time:%li\n", jiffies);
 #endif
 	return 0;
 }
@@ -849,56 +890,58 @@
  * track
  */
 static int aztGetDiskInfo()
-{ int limit;
-  unsigned char test;
-  struct azt_Toc qInfo;
-
-#ifdef AZT_DEBUG
-  printk("aztcd: starting aztGetDiskInfo  Time:%li\n",jiffies);
-#endif
-  if (aztSendCmd(ACMD_SEEK_TO_LEADIN)) RETURNM("aztGetDiskInfo 1",-1);
-  STEN_LOW_WAIT;
-  test=0;
-  for (limit=300;limit>0;limit--)
-   {  if (aztGetQChannelInfo(&qInfo)<0) RETURNM("aztGetDiskInfo 2",-1);
-      if (qInfo.pointIndex==0xA0)   /*Number of FirstTrack*/
-	{ DiskInfo.first = qInfo.diskTime.min;
-	  DiskInfo.first = azt_bcd2bin(DiskInfo.first);
-	  test=test|0x01;
-	}
-      if (qInfo.pointIndex==0xA1)   /*Number of LastTrack*/
-	{ DiskInfo.last  = qInfo.diskTime.min;
-	  DiskInfo.last  = azt_bcd2bin(DiskInfo.last);
-	  test=test|0x02;
-	}
-      if (qInfo.pointIndex==0xA2)   /*DiskLength*/
-	{ DiskInfo.diskLength.min=qInfo.diskTime.min;
-	  DiskInfo.diskLength.sec=qInfo.diskTime.sec;
-	  DiskInfo.diskLength.frame=qInfo.diskTime.frame;
-	  test=test|0x04;
-	}
-      if ((qInfo.pointIndex==DiskInfo.first)&&(test&0x01))   /*StartTime of First Track*/
-	{ DiskInfo.firstTrack.min=qInfo.diskTime.min;
-	  DiskInfo.firstTrack.sec=qInfo.diskTime.sec;
-	  DiskInfo.firstTrack.frame=qInfo.diskTime.frame;
-	  test=test|0x08;
-	}
-      if (test==0x0F) break;
-   }
-#ifdef AZT_DEBUG
-  printk ("aztcd: exiting aztGetDiskInfo  Time:%li\n",jiffies);
-  printk("Disk Info: first %d last %d length %02X:%02X.%02X dez  first %02X:%02X.%02X dez\n",
-  	  DiskInfo.first,
-	  DiskInfo.last,
-	  DiskInfo.diskLength.min,
-	  DiskInfo.diskLength.sec,
-	  DiskInfo.diskLength.frame,
-	  DiskInfo.firstTrack.min,
-	  DiskInfo.firstTrack.sec,
-	  DiskInfo.firstTrack.frame);
+{
+	int limit;
+	unsigned char test;
+	struct azt_Toc qInfo;
+
+#ifdef AZT_DEBUG
+	printk("aztcd: starting aztGetDiskInfo  Time:%li\n", jiffies);
+#endif
+	if (aztSendCmd(ACMD_SEEK_TO_LEADIN))
+		RETURNM("aztGetDiskInfo 1", -1);
+	STEN_LOW_WAIT;
+	test = 0;
+	for (limit = 300; limit > 0; limit--) {
+		if (aztGetQChannelInfo(&qInfo) < 0)
+			RETURNM("aztGetDiskInfo 2", -1);
+		if (qInfo.pointIndex == 0xA0) {	/*Number of FirstTrack */
+			DiskInfo.first = qInfo.diskTime.min;
+			DiskInfo.first = azt_bcd2bin(DiskInfo.first);
+			test = test | 0x01;
+		}
+		if (qInfo.pointIndex == 0xA1) {	/*Number of LastTrack */
+			DiskInfo.last = qInfo.diskTime.min;
+			DiskInfo.last = azt_bcd2bin(DiskInfo.last);
+			test = test | 0x02;
+		}
+		if (qInfo.pointIndex == 0xA2) {	/*DiskLength */
+			DiskInfo.diskLength.min = qInfo.diskTime.min;
+			DiskInfo.diskLength.sec = qInfo.diskTime.sec;
+			DiskInfo.diskLength.frame = qInfo.diskTime.frame;
+			test = test | 0x04;
+		}
+		if ((qInfo.pointIndex == DiskInfo.first) && (test & 0x01)) {	/*StartTime of First Track */
+			DiskInfo.firstTrack.min = qInfo.diskTime.min;
+			DiskInfo.firstTrack.sec = qInfo.diskTime.sec;
+			DiskInfo.firstTrack.frame = qInfo.diskTime.frame;
+			test = test | 0x08;
+		}
+		if (test == 0x0F)
+			break;
+	}
+#ifdef AZT_DEBUG
+	printk("aztcd: exiting aztGetDiskInfo  Time:%li\n", jiffies);
+	printk
+	    ("Disk Info: first %d last %d length %02X:%02X.%02X dez  first %02X:%02X.%02X dez\n",
+	     DiskInfo.first, DiskInfo.last, DiskInfo.diskLength.min,
+	     DiskInfo.diskLength.sec, DiskInfo.diskLength.frame,
+	     DiskInfo.firstTrack.min, DiskInfo.firstTrack.sec,
+	     DiskInfo.firstTrack.frame);
 #endif
-  if (test!=0x0F) return -1;
-  return 0;
+	if (test != 0x0F)
+		return -1;
+	return 0;
 }
 
 #if AZT_MULTISESSION
@@ -906,93 +949,105 @@
  * Get Multisession Disk Info
  */
 static int aztGetMultiDiskInfo(void)
-{ int limit, k=5;
-  unsigned char test;
-  struct azt_Toc qInfo;
-
-#ifdef AZT_DEBUG
-  printk("aztcd: starting aztGetMultiDiskInfo\n");
-#endif
-
-  do { azt_Play.start.min   = Toc[DiskInfo.last+1].diskTime.min;
-       azt_Play.start.sec   = Toc[DiskInfo.last+1].diskTime.sec;
-       azt_Play.start.frame = Toc[DiskInfo.last+1].diskTime.frame;
-       test=0;
-
-       for (limit=30;limit>0;limit--)   /*Seek for LeadIn of next session*/
-           { if (aztSeek(&azt_Play)) RETURNM("aztGetMultiDiskInfo 1",-1);
-             if (aztGetQChannelInfo(&qInfo)<0) RETURNM("aztGetMultiDiskInfo 2",-1);
-             if ((qInfo.track==0)&&(qInfo.pointIndex)) break;  /*LeadIn found*/
-             if ((azt_Play.start.sec+=10) > 59)
-                { azt_Play.start.sec=0;
-                  azt_Play.start.min++;
-                }
-           }
-       if (!limit) break;  /*Check, if a leadin track was found, if not we're
-                             at the end of the disk*/
+{
+	int limit, k = 5;
+	unsigned char test;
+	struct azt_Toc qInfo;
+
+#ifdef AZT_DEBUG
+	printk("aztcd: starting aztGetMultiDiskInfo\n");
+#endif
+
+	do {
+		azt_Play.start.min = Toc[DiskInfo.last + 1].diskTime.min;
+		azt_Play.start.sec = Toc[DiskInfo.last + 1].diskTime.sec;
+		azt_Play.start.frame =
+		    Toc[DiskInfo.last + 1].diskTime.frame;
+		test = 0;
+
+		for (limit = 30; limit > 0; limit--) {	/*Seek for LeadIn of next session */
+			if (aztSeek(&azt_Play))
+				RETURNM("aztGetMultiDiskInfo 1", -1);
+			if (aztGetQChannelInfo(&qInfo) < 0)
+				RETURNM("aztGetMultiDiskInfo 2", -1);
+			if ((qInfo.track == 0) && (qInfo.pointIndex))
+				break;	/*LeadIn found */
+			if ((azt_Play.start.sec += 10) > 59) {
+				azt_Play.start.sec = 0;
+				azt_Play.start.min++;
+			}
+		}
+		if (!limit)
+			break;	/*Check, if a leadin track was found, if not we're
+				   at the end of the disk */
 #ifdef AZT_DEBUG_MULTISESSION
-       printk("leadin found track %d  pointIndex %x  limit %d\n",qInfo.track,qInfo.pointIndex,limit);
+		printk("leadin found track %d  pointIndex %x  limit %d\n",
+		       qInfo.track, qInfo.pointIndex, limit);
 #endif
-       for (limit=300;limit>0;limit--)
-           { if (++azt_Play.start.frame>74)
-                { azt_Play.start.frame=0;
-                  if (azt_Play.start.sec > 59)
-                     { azt_Play.start.sec=0;
-                       azt_Play.start.min++;
-                     }
-                }     
-             if (aztSeek(&azt_Play)) RETURNM("aztGetMultiDiskInfo 3",-1);
-             if (aztGetQChannelInfo(&qInfo)<0) RETURNM("aztGetMultiDiskInfo 4",-1);
-             if (qInfo.pointIndex==0xA0)   /*Number of NextTrack*/
-	        { DiskInfo.next = qInfo.diskTime.min;
-	          DiskInfo.next = azt_bcd2bin(DiskInfo.next);
-	          test=test|0x01;
-	        }
-             if (qInfo.pointIndex==0xA1)   /*Number of LastTrack*/
-	 	{ DiskInfo.last  = qInfo.diskTime.min;
-	   	  DiskInfo.last  = azt_bcd2bin(DiskInfo.last);
-	   	  test=test|0x02;
-	 	}
-      	     if (qInfo.pointIndex==0xA2)   /*DiskLength*/
-	 	{ DiskInfo.diskLength.min  =qInfo.diskTime.min;
-	   	  DiskInfo.diskLength.sec  =qInfo.diskTime.sec;
-	   	  DiskInfo.diskLength.frame=qInfo.diskTime.frame;
-	  	  test=test|0x04;
-	 	}
-      	     if ((qInfo.pointIndex==DiskInfo.next)&&(test&0x01))   /*StartTime of Next Track*/
-		{ DiskInfo.nextSession.min=qInfo.diskTime.min;
-	  	  DiskInfo.nextSession.sec=qInfo.diskTime.sec;
-	  	  DiskInfo.nextSession.frame=qInfo.diskTime.frame;
-	  	  test=test|0x08;
+		for (limit = 300; limit > 0; limit--) {
+			if (++azt_Play.start.frame > 74) {
+				azt_Play.start.frame = 0;
+				if (azt_Play.start.sec > 59) {
+					azt_Play.start.sec = 0;
+					azt_Play.start.min++;
+				}
+			}
+			if (aztSeek(&azt_Play))
+				RETURNM("aztGetMultiDiskInfo 3", -1);
+			if (aztGetQChannelInfo(&qInfo) < 0)
+				RETURNM("aztGetMultiDiskInfo 4", -1);
+			if (qInfo.pointIndex == 0xA0) {	/*Number of NextTrack */
+				DiskInfo.next = qInfo.diskTime.min;
+				DiskInfo.next = azt_bcd2bin(DiskInfo.next);
+				test = test | 0x01;
+			}
+			if (qInfo.pointIndex == 0xA1) {	/*Number of LastTrack */
+				DiskInfo.last = qInfo.diskTime.min;
+				DiskInfo.last = azt_bcd2bin(DiskInfo.last);
+				test = test | 0x02;
+			}
+			if (qInfo.pointIndex == 0xA2) {	/*DiskLength */
+				DiskInfo.diskLength.min =
+				    qInfo.diskTime.min;
+				DiskInfo.diskLength.sec =
+				    qInfo.diskTime.sec;
+				DiskInfo.diskLength.frame =
+				    qInfo.diskTime.frame;
+				test = test | 0x04;
+			}
+			if ((qInfo.pointIndex == DiskInfo.next) && (test & 0x01)) {	/*StartTime of Next Track */
+				DiskInfo.nextSession.min =
+				    qInfo.diskTime.min;
+				DiskInfo.nextSession.sec =
+				    qInfo.diskTime.sec;
+				DiskInfo.nextSession.frame =
+				    qInfo.diskTime.frame;
+				test = test | 0x08;
+			}
+			if (test == 0x0F)
+				break;
 		}
-      	     if (test==0x0F) break;
-   	   }
 #ifdef AZT_DEBUG_MULTISESSION
-       printk ("MultiDisk Info: first %d next %d last %d length %02x:%02x.%02x dez  first %02x:%02x.%02x dez  next %02x:%02x.%02x dez\n",
-     		DiskInfo.first,
-		DiskInfo.next,
-		DiskInfo.last,
-		DiskInfo.diskLength.min,
-		DiskInfo.diskLength.sec,
-		DiskInfo.diskLength.frame,
-		DiskInfo.firstTrack.min,
-		DiskInfo.firstTrack.sec,
-		DiskInfo.firstTrack.frame,
-		DiskInfo.nextSession.min,
-		DiskInfo.nextSession.sec,
-		DiskInfo.nextSession.frame);
-#endif
-       if (test!=0x0F) 
-           break;
-       else 
-           DiskInfo.multi=1;   /*found TOC of more than one session*/
-       aztGetToc(1);
-     } while(--k);
+		printk
+		    ("MultiDisk Info: first %d next %d last %d length %02x:%02x.%02x dez  first %02x:%02x.%02x dez  next %02x:%02x.%02x dez\n",
+		     DiskInfo.first, DiskInfo.next, DiskInfo.last,
+		     DiskInfo.diskLength.min, DiskInfo.diskLength.sec,
+		     DiskInfo.diskLength.frame, DiskInfo.firstTrack.min,
+		     DiskInfo.firstTrack.sec, DiskInfo.firstTrack.frame,
+		     DiskInfo.nextSession.min, DiskInfo.nextSession.sec,
+		     DiskInfo.nextSession.frame);
+#endif
+		if (test != 0x0F)
+			break;
+		else
+			DiskInfo.multi = 1;	/*found TOC of more than one session */
+		aztGetToc(1);
+	} while (--k);
 
 #ifdef AZT_DEBUG
-  printk ("aztcd: exiting aztGetMultiDiskInfo  Time:%li\n",jiffies);
+	printk("aztcd: exiting aztGetMultiDiskInfo  Time:%li\n", jiffies);
 #endif
-  return 0;
+	return 0;
 }
 #endif
 
@@ -1000,75 +1055,81 @@
  * Read the table of contents (TOC)
  */
 static int aztGetToc(int multi)
-{ int i, px;
-  int limit;
-  struct azt_Toc qInfo;
-
-#ifdef AZT_DEBUG
-  printk("aztcd: starting aztGetToc  Time:%li\n",jiffies);
-#endif
-  if (!multi)
-     { for (i = 0; i < MAX_TRACKS; i++)
- 	    Toc[i].pointIndex = 0;
-       i = DiskInfo.last + 3;
-     }
-  else
-     { for (i = DiskInfo.next; i < MAX_TRACKS; i++)
-     	    Toc[i].pointIndex = 0; 
-       i = DiskInfo.last + 4 - DiskInfo.next;
-     }
+{
+	int i, px;
+	int limit;
+	struct azt_Toc qInfo;
+
+#ifdef AZT_DEBUG
+	printk("aztcd: starting aztGetToc  Time:%li\n", jiffies);
+#endif
+	if (!multi) {
+		for (i = 0; i < MAX_TRACKS; i++)
+			Toc[i].pointIndex = 0;
+		i = DiskInfo.last + 3;
+	} else {
+		for (i = DiskInfo.next; i < MAX_TRACKS; i++)
+			Toc[i].pointIndex = 0;
+		i = DiskInfo.last + 4 - DiskInfo.next;
+	}
 
 /*Is there a good reason to stop motor before TOC read?
   if (aztSendCmd(ACMD_STOP)) RETURNM("aztGetToc 1",-1);
       STEN_LOW_WAIT;
 */
 
-  if (!multi)
-     { azt_mode = 0x05;
-       if (aztSendCmd(ACMD_SEEK_TO_LEADIN)) RETURNM("aztGetToc 2",-1);
-       STEN_LOW_WAIT;
-     }
-  for (limit = 300; limit > 0; limit--)
-      { if (multi)
-           { if (++azt_Play.start.sec > 59)
-                { azt_Play.start.sec=0;
-                  azt_Play.start.min++;
-                }
-             if (aztSeek(&azt_Play)) RETURNM("aztGetToc 3",-1);
-           }
-	if (aztGetQChannelInfo(&qInfo) < 0)
-	    break;
-
-	px = azt_bcd2bin(qInfo.pointIndex);
-
-	if (px > 0 && px < MAX_TRACKS && qInfo.track == 0)
-  	    if (Toc[px].pointIndex == 0)
-	       { Toc[px] = qInfo;
-		 i--;
-	       }
-
-	if (i <= 0)
-	    break;
-      }
-
-  Toc[DiskInfo.last + 1].diskTime = DiskInfo.diskLength;
-  Toc[DiskInfo.last].trackTime    = DiskInfo.diskLength;
-
-#ifdef AZT_DEBUG_MULTISESSION 
-  printk("aztcd: exiting aztGetToc\n");
-  for (i = 1; i <= DiskInfo.last+1; i++)
-       printk("i = %2d ctl-adr = %02X track %2d px %02X %02X:%02X.%02X dez  %02X:%02X.%02X dez\n",
-               i, Toc[i].ctrl_addr, Toc[i].track, Toc[i].pointIndex,
-               Toc[i].trackTime.min, Toc[i].trackTime.sec, Toc[i].trackTime.frame,
-               Toc[i].diskTime.min, Toc[i].diskTime.sec, Toc[i].diskTime.frame);
-  for (i = 100; i < 103; i++)
-       printk("i = %2d ctl-adr = %02X track %2d px %02X %02X:%02X.%02X dez  %02X:%02X.%02X dez\n",
-               i, Toc[i].ctrl_addr, Toc[i].track, Toc[i].pointIndex,
-               Toc[i].trackTime.min, Toc[i].trackTime.sec, Toc[i].trackTime.frame,
-               Toc[i].diskTime.min, Toc[i].diskTime.sec, Toc[i].diskTime.frame);
+	if (!multi) {
+		azt_mode = 0x05;
+		if (aztSendCmd(ACMD_SEEK_TO_LEADIN))
+			RETURNM("aztGetToc 2", -1);
+		STEN_LOW_WAIT;
+	}
+	for (limit = 300; limit > 0; limit--) {
+		if (multi) {
+			if (++azt_Play.start.sec > 59) {
+				azt_Play.start.sec = 0;
+				azt_Play.start.min++;
+			}
+			if (aztSeek(&azt_Play))
+				RETURNM("aztGetToc 3", -1);
+		}
+		if (aztGetQChannelInfo(&qInfo) < 0)
+			break;
+
+		px = azt_bcd2bin(qInfo.pointIndex);
+
+		if (px > 0 && px < MAX_TRACKS && qInfo.track == 0)
+			if (Toc[px].pointIndex == 0) {
+				Toc[px] = qInfo;
+				i--;
+			}
+
+		if (i <= 0)
+			break;
+	}
+
+	Toc[DiskInfo.last + 1].diskTime = DiskInfo.diskLength;
+	Toc[DiskInfo.last].trackTime = DiskInfo.diskLength;
+
+#ifdef AZT_DEBUG_MULTISESSION
+	printk("aztcd: exiting aztGetToc\n");
+	for (i = 1; i <= DiskInfo.last + 1; i++)
+		printk
+		    ("i = %2d ctl-adr = %02X track %2d px %02X %02X:%02X.%02X dez  %02X:%02X.%02X dez\n",
+		     i, Toc[i].ctrl_addr, Toc[i].track, Toc[i].pointIndex,
+		     Toc[i].trackTime.min, Toc[i].trackTime.sec,
+		     Toc[i].trackTime.frame, Toc[i].diskTime.min,
+		     Toc[i].diskTime.sec, Toc[i].diskTime.frame);
+	for (i = 100; i < 103; i++)
+		printk
+		    ("i = %2d ctl-adr = %02X track %2d px %02X %02X:%02X.%02X dez  %02X:%02X.%02X dez\n",
+		     i, Toc[i].ctrl_addr, Toc[i].track, Toc[i].pointIndex,
+		     Toc[i].trackTime.min, Toc[i].trackTime.sec,
+		     Toc[i].trackTime.frame, Toc[i].diskTime.min,
+		     Toc[i].diskTime.sec, Toc[i].diskTime.frame);
 #endif
 
-  return limit > 0 ? 0 : -1;
+	return limit > 0 ? 0 : -1;
 }
 
 
@@ -1080,163 +1141,186 @@
 #ifndef MODULE
 static int __init aztcd_setup(char *str)
 {
-    int ints[4];
-    
-    (void)get_options(str, ARRAY_SIZE(ints), ints);
-    
-    if (ints[0] > 0)
-        azt_port = ints[1];
-    if (ints[1] > 1)
-        azt_cont = ints[2];
-    return 1;
+	int ints[4];
+
+	(void) get_options(str, ARRAY_SIZE(ints), ints);
+
+	if (ints[0] > 0)
+		azt_port = ints[1];
+	if (ints[1] > 1)
+		azt_cont = ints[2];
+	return 1;
 }
 
 __setup("aztcd=", aztcd_setup);
 
-#endif /* !MODULE */
+#endif				/* !MODULE */
 
 /* 
  * Checking if the media has been changed
 */
 static int check_aztcd_media_change(kdev_t full_dev)
-{ if (aztDiskChanged)          /* disk changed */
-     { aztDiskChanged=0;
-       return 1;
-     }
-  else
-       return 0;               /* no change */
+{
+	if (aztDiskChanged) {	/* disk changed */
+		aztDiskChanged = 0;
+		return 1;
+	} else
+		return 0;	/* no change */
 }
 
 /*
  * Kernel IO-controls
 */
-static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg)
-{       int i, st;
+static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
+		       unsigned long arg)
+{
+	int i;
 	struct azt_Toc qInfo;
 	struct cdrom_ti ti;
 	struct cdrom_tochdr tocHdr;
 	struct cdrom_msf msf;
 	struct cdrom_tocentry entry;
-	struct azt_Toc *tocPtr;            
+	struct azt_Toc *tocPtr;
 	struct cdrom_subchnl subchnl;
-        struct cdrom_volctrl volctrl;
+	struct cdrom_volctrl volctrl;
 
 #ifdef AZT_DEBUG
-	printk("aztcd: starting aztcd_ioctl - Command:%x   Time: %li\n",cmd, jiffies);
-        printk("aztcd Status %x\n", getAztStatus());
-#endif
-	if (!ip) RETURNM("aztcd_ioctl 1",-EINVAL);
-	if (getAztStatus()<0) RETURNM("aztcd_ioctl 2", -EIO);
-	if ((!aztTocUpToDate)||(aztDiskChanged))
-	{ if ((i=aztUpdateToc())<0) RETURNM("aztcd_ioctl 3", i); /* error reading TOC */
+	printk("aztcd: starting aztcd_ioctl - Command:%x   Time: %li\n",
+	       cmd, jiffies);
+	printk("aztcd Status %x\n", getAztStatus());
+#endif
+	if (!ip)
+		RETURNM("aztcd_ioctl 1", -EINVAL);
+	if (getAztStatus() < 0)
+		RETURNM("aztcd_ioctl 2", -EIO);
+	if ((!aztTocUpToDate) || (aztDiskChanged)) {
+		if ((i = aztUpdateToc()) < 0)
+			RETURNM("aztcd_ioctl 3", i);	/* error reading TOC */
 	}
 
-	switch (cmd)
-	{
-	case CDROMSTART:     /* Spin up the drive. Don't know, what to do,
-	                        at least close the tray */
-#if AZT_PRIVATE_IOCTLS 
-	        if (aztSendCmd(ACMD_CLOSE)) RETURNM("aztcd_ioctl 4",-1);
-	        STEN_LOW_WAIT;
+	switch (cmd) {
+	case CDROMSTART:	/* Spin up the drive. Don't know, what to do,
+				   at least close the tray */
+#if AZT_PRIVATE_IOCTLS
+		if (aztSendCmd(ACMD_CLOSE))
+			RETURNM("aztcd_ioctl 4", -1);
+		STEN_LOW_WAIT;
 #endif
 		break;
-	case CDROMSTOP:      /* Spin down the drive */
-		if (aztSendCmd(ACMD_STOP)) RETURNM("aztcd_ioctl 5",-1);
+	case CDROMSTOP:	/* Spin down the drive */
+		if (aztSendCmd(ACMD_STOP))
+			RETURNM("aztcd_ioctl 5", -1);
 		STEN_LOW_WAIT;
 		/* should we do anything if it fails? */
 		aztAudioStatus = CDROM_AUDIO_NO_STATUS;
 		break;
-	case CDROMPAUSE:     /* Pause the drive */
-                if (aztAudioStatus != CDROM_AUDIO_PLAY) return -EINVAL; 
-
-		if (aztGetQChannelInfo(&qInfo) < 0)
-		{ /* didn't get q channel info */
-		  aztAudioStatus = CDROM_AUDIO_NO_STATUS;
-		  RETURNM("aztcd_ioctl 7",0);
+	case CDROMPAUSE:	/* Pause the drive */
+		if (aztAudioStatus != CDROM_AUDIO_PLAY)
+			return -EINVAL;
+
+		if (aztGetQChannelInfo(&qInfo) < 0) {	/* didn't get q channel info */
+			aztAudioStatus = CDROM_AUDIO_NO_STATUS;
+			RETURNM("aztcd_ioctl 7", 0);
 		}
-		azt_Play.start = qInfo.diskTime;        /* remember restart point */
+		azt_Play.start = qInfo.diskTime;	/* remember restart point */
 
-		if (aztSendCmd(ACMD_PAUSE)) RETURNM("aztcd_ioctl 8",-1);
+		if (aztSendCmd(ACMD_PAUSE))
+			RETURNM("aztcd_ioctl 8", -1);
 		STEN_LOW_WAIT;
 		aztAudioStatus = CDROM_AUDIO_PAUSED;
 		break;
-	case CDROMRESUME:    /* Play it again, Sam */
-		if (aztAudioStatus != CDROM_AUDIO_PAUSED) return -EINVAL;
+	case CDROMRESUME:	/* Play it again, Sam */
+		if (aztAudioStatus != CDROM_AUDIO_PAUSED)
+			return -EINVAL;
 		/* restart the drive at the saved position. */
 		i = aztPlay(&azt_Play);
-		if (i < 0)
-		{ aztAudioStatus = CDROM_AUDIO_ERROR;
-		  return -EIO;
+		if (i < 0) {
+			aztAudioStatus = CDROM_AUDIO_ERROR;
+			return -EIO;
 		}
 		aztAudioStatus = CDROM_AUDIO_PLAY;
 		break;
-	case CDROMMULTISESSION: /*multisession support -- experimental*/
-	        { struct cdrom_multisession ms;
-#ifdef AZT_DEBUG
-   		  printk("aztcd ioctl MULTISESSION\n");
+	case CDROMMULTISESSION:	/*multisession support -- experimental */
+		{
+			struct cdrom_multisession ms;
+#ifdef AZT_DEBUG
+			printk("aztcd ioctl MULTISESSION\n");
+#endif
+			if (copy_from_user
+			    (&ms, (void *) arg,
+			     sizeof(struct cdrom_multisession)))
+				return -EFAULT;
+			if (ms.addr_format == CDROM_MSF) {
+				ms.addr.msf.minute =
+				    azt_bcd2bin(DiskInfo.lastSession.min);
+				ms.addr.msf.second =
+				    azt_bcd2bin(DiskInfo.lastSession.sec);
+				ms.addr.msf.frame =
+				    azt_bcd2bin(DiskInfo.lastSession.
+						frame);
+			} else if (ms.addr_format == CDROM_LBA)
+				ms.addr.lba =
+				    azt_msf2hsg(&DiskInfo.lastSession);
+			else
+				return -EINVAL;
+			ms.xa_flag = DiskInfo.xa;
+			if (copy_to_user
+			    ((void *) arg, &ms,
+			     sizeof(struct cdrom_multisession)))
+				return -EFAULT;
+#ifdef AZT_DEBUG
+			if (ms.addr_format == CDROM_MSF)
+				printk
+				    ("aztcd multisession xa:%d, msf:%02x:%02x.%02x [%02x:%02x.%02x])\n",
+				     ms.xa_flag, ms.addr.msf.minute,
+				     ms.addr.msf.second, ms.addr.msf.frame,
+				     DiskInfo.lastSession.min,
+				     DiskInfo.lastSession.sec,
+				     DiskInfo.lastSession.frame);
+			else
+				printk
+				    ("aztcd multisession %d, lba:0x%08x [%02x:%02x.%02x])\n",
+				     ms.xa_flag, ms.addr.lba,
+				     DiskInfo.lastSession.min,
+				     DiskInfo.lastSession.sec,
+				     DiskInfo.lastSession.frame);
 #endif
-		  st = verify_area(VERIFY_WRITE, (void*) arg, sizeof(struct cdrom_multisession));
-		  if (st) return st;
-		  memcpy_fromfs(&ms, (void*) arg, sizeof(struct cdrom_multisession));
-		  if (ms.addr_format == CDROM_MSF) 
-		     { ms.addr.msf.minute = azt_bcd2bin(DiskInfo.lastSession.min);
-		       ms.addr.msf.second = azt_bcd2bin(DiskInfo.lastSession.sec);
-		       ms.addr.msf.frame  = azt_bcd2bin(DiskInfo.lastSession.frame);
-		     } 
-		  else if (ms.addr_format == CDROM_LBA)
-		       ms.addr.lba = azt_msf2hsg(&DiskInfo.lastSession);
-		  else
-		       return -EINVAL;
-		  ms.xa_flag = DiskInfo.xa;
-	  	  memcpy_tofs((void*) arg, &ms, sizeof(struct cdrom_multisession));
-#ifdef AZT_DEBUG 
- 		  if (ms.addr_format == CDROM_MSF) 
-                      printk("aztcd multisession xa:%d, msf:%02x:%02x.%02x [%02x:%02x.%02x])\n",
-			      ms.xa_flag, ms.addr.msf.minute, ms.addr.msf.second, 
-			      ms.addr.msf.frame, DiskInfo.lastSession.min,
-			      DiskInfo.lastSession.sec, DiskInfo.lastSession.frame);
-		  else
-		      printk("aztcd multisession %d, lba:0x%08x [%02x:%02x.%02x])\n",
-			      ms.xa_flag, ms.addr.lba, DiskInfo.lastSession.min,
-			      DiskInfo.lastSession.sec, DiskInfo.lastSession.frame);
-#endif
-   		  return 0;
-		}
-	case CDROMPLAYTRKIND:     /* Play a track.  This currently ignores index. */
-		st = verify_area(VERIFY_READ, (void *) arg, sizeof ti);
-		if (st) return st;
-		memcpy_fromfs(&ti, (void *) arg, sizeof ti);
+			return 0;
+		}
+	case CDROMPLAYTRKIND:	/* Play a track.  This currently ignores index. */
+		if (copy_from_user(&ti, (void *) arg, sizeof ti))
+			return -EFAULT;
 		if (ti.cdti_trk0 < DiskInfo.first
-			|| ti.cdti_trk0 > DiskInfo.last
-			|| ti.cdti_trk1 < ti.cdti_trk0)
-		{ return -EINVAL;
+		    || ti.cdti_trk0 > DiskInfo.last
+		    || ti.cdti_trk1 < ti.cdti_trk0) {
+			return -EINVAL;
 		}
 		if (ti.cdti_trk1 > DiskInfo.last)
-		    ti.cdti_trk1 = DiskInfo.last;
+			ti.cdti_trk1 = DiskInfo.last;
 		azt_Play.start = Toc[ti.cdti_trk0].diskTime;
 		azt_Play.end = Toc[ti.cdti_trk1 + 1].diskTime;
 #ifdef AZT_DEBUG
-printk("aztcd play: %02x:%02x.%02x to %02x:%02x.%02x\n",
-	azt_Play.start.min, azt_Play.start.sec, azt_Play.start.frame,
-	azt_Play.end.min, azt_Play.end.sec, azt_Play.end.frame);
+		printk("aztcd play: %02x:%02x.%02x to %02x:%02x.%02x\n",
+		       azt_Play.start.min, azt_Play.start.sec,
+		       azt_Play.start.frame, azt_Play.end.min,
+		       azt_Play.end.sec, azt_Play.end.frame);
 #endif
 		i = aztPlay(&azt_Play);
-		if (i < 0)
-		{ aztAudioStatus = CDROM_AUDIO_ERROR;
-		  return -EIO;
+		if (i < 0) {
+			aztAudioStatus = CDROM_AUDIO_ERROR;
+			return -EIO;
 		}
 		aztAudioStatus = CDROM_AUDIO_PLAY;
 		break;
-	case CDROMPLAYMSF:   /* Play starting at the given MSF address. */
+	case CDROMPLAYMSF:	/* Play starting at the given MSF address. */
 /*              if (aztAudioStatus == CDROM_AUDIO_PLAY) 
 		{ if (aztSendCmd(ACMD_STOP)) RETURNM("aztcd_ioctl 9",-1);
 		  STEN_LOW;
 		  aztAudioStatus = CDROM_AUDIO_NO_STATUS;
 		}
 */
-		st = verify_area(VERIFY_READ, (void *) arg, sizeof msf);
-		if (st) return st;
-		memcpy_fromfs(&msf, (void *) arg, sizeof msf);
+		if (copy_from_user(&msf, (void *) arg, sizeof msf))
+			return -EFAULT;
 		/* convert to bcd */
 		azt_bin2bcd(&msf.cdmsf_min0);
 		azt_bin2bcd(&msf.cdmsf_sec0);
@@ -1251,171 +1335,190 @@
 		azt_Play.end.sec = msf.cdmsf_sec1;
 		azt_Play.end.frame = msf.cdmsf_frame1;
 #ifdef AZT_DEBUG
-printk("aztcd play: %02x:%02x.%02x to %02x:%02x.%02x\n",
-azt_Play.start.min, azt_Play.start.sec, azt_Play.start.frame,
-azt_Play.end.min, azt_Play.end.sec, azt_Play.end.frame);
+		printk("aztcd play: %02x:%02x.%02x to %02x:%02x.%02x\n",
+		       azt_Play.start.min, azt_Play.start.sec,
+		       azt_Play.start.frame, azt_Play.end.min,
+		       azt_Play.end.sec, azt_Play.end.frame);
 #endif
 		i = aztPlay(&azt_Play);
-		if (i < 0)
-		{ aztAudioStatus = CDROM_AUDIO_ERROR;
-		  return -EIO;
+		if (i < 0) {
+			aztAudioStatus = CDROM_AUDIO_ERROR;
+			return -EIO;
 		}
 		aztAudioStatus = CDROM_AUDIO_PLAY;
 		break;
 
-	case CDROMREADTOCHDR:        /* Read the table of contents header */
-		st = verify_area(VERIFY_WRITE, (void *) arg, sizeof tocHdr);
-		if (st) return st;
+	case CDROMREADTOCHDR:	/* Read the table of contents header */
 		tocHdr.cdth_trk0 = DiskInfo.first;
 		tocHdr.cdth_trk1 = DiskInfo.last;
-		memcpy_tofs((void *) arg, &tocHdr, sizeof tocHdr);
+		if (copy_to_user((void *) arg, &tocHdr, sizeof tocHdr))
+			return -EFAULT;
 		break;
-	case CDROMREADTOCENTRY:      /* Read an entry in the table of contents */
-		st = verify_area(VERIFY_WRITE, (void *) arg, sizeof entry);
-		if (st) return st;
-		memcpy_fromfs(&entry, (void *) arg, sizeof entry);
-		if ((!aztTocUpToDate)||aztDiskChanged) aztUpdateToc();
+	case CDROMREADTOCENTRY:	/* Read an entry in the table of contents */
+		if (copy_from_user(&entry, (void *) arg, sizeof entry))
+			return -EFAULT;
+		if ((!aztTocUpToDate) || aztDiskChanged)
+			aztUpdateToc();
 		if (entry.cdte_track == CDROM_LEADOUT)
-		  tocPtr = &Toc[DiskInfo.last + 1];
+			tocPtr = &Toc[DiskInfo.last + 1];
 		else if (entry.cdte_track > DiskInfo.last
-				|| entry.cdte_track < DiskInfo.first)
-		{ return -EINVAL;
-		}
-		else 
-		  tocPtr = &Toc[entry.cdte_track];
-		entry.cdte_adr = tocPtr -> ctrl_addr;
-		entry.cdte_ctrl = tocPtr -> ctrl_addr >> 4;
+			 || entry.cdte_track < DiskInfo.first) {
+			return -EINVAL;
+		} else
+			tocPtr = &Toc[entry.cdte_track];
+		entry.cdte_adr = tocPtr->ctrl_addr;
+		entry.cdte_ctrl = tocPtr->ctrl_addr >> 4;
 		if (entry.cdte_format == CDROM_LBA)
-		  entry.cdte_addr.lba = azt_msf2hsg(&tocPtr -> diskTime);
-		else if (entry.cdte_format == CDROM_MSF)
-		{ entry.cdte_addr.msf.minute = azt_bcd2bin(tocPtr -> diskTime.min);
-		  entry.cdte_addr.msf.second = azt_bcd2bin(tocPtr -> diskTime.sec);
-		  entry.cdte_addr.msf.frame  = azt_bcd2bin(tocPtr -> diskTime.frame);
+			entry.cdte_addr.lba =
+			    azt_msf2hsg(&tocPtr->diskTime);
+		else if (entry.cdte_format == CDROM_MSF) {
+			entry.cdte_addr.msf.minute =
+			    azt_bcd2bin(tocPtr->diskTime.min);
+			entry.cdte_addr.msf.second =
+			    azt_bcd2bin(tocPtr->diskTime.sec);
+			entry.cdte_addr.msf.frame =
+			    azt_bcd2bin(tocPtr->diskTime.frame);
+		} else {
+			return -EINVAL;
 		}
-		else
-		{ return -EINVAL;
-		}
-		memcpy_tofs((void *) arg, &entry, sizeof entry);
+		if (copy_to_user((void *) arg, &entry, sizeof entry))
+			return -EFAULT;
 		break;
-	case CDROMSUBCHNL:   /* Get subchannel info */
-		st = verify_area(VERIFY_WRITE, (void *) arg, sizeof(struct cdrom_subchnl));
-		if (st) { 
-#ifdef AZT_DEBUG
-		          printk("aztcd: exiting aztcd_ioctl - Error 1 - Command:%x\n",cmd);
-#endif
-		          return st;
-		        }  
-		memcpy_fromfs(&subchnl, (void *) arg, sizeof (struct cdrom_subchnl));
-		if (aztGetQChannelInfo(&qInfo) < 0)
-		if (st) { 
-#ifdef AZT_DEBUG
-		          printk("aztcd: exiting aztcd_ioctl - Error 3 - Command:%x\n",cmd);
+	case CDROMSUBCHNL:	/* Get subchannel info */
+		if (copy_from_user
+		    (&subchnl, (void *) arg, sizeof(struct cdrom_subchnl)))
+			return -EFAULT;
+		if (aztGetQChannelInfo(&qInfo) < 0) {
+#ifdef AZT_DEBUG
+			printk
+			    ("aztcd: exiting aztcd_ioctl - Error 3 - Command:%x\n",
+			     cmd);
 #endif
-     		  	  return -EIO;
-     		  	}  
+			return -EIO;
+		}
 		subchnl.cdsc_audiostatus = aztAudioStatus;
 		subchnl.cdsc_adr = qInfo.ctrl_addr;
 		subchnl.cdsc_ctrl = qInfo.ctrl_addr >> 4;
 		subchnl.cdsc_trk = azt_bcd2bin(qInfo.track);
 		subchnl.cdsc_ind = azt_bcd2bin(qInfo.pointIndex);
-		if (subchnl.cdsc_format == CDROM_LBA)
-		{ subchnl.cdsc_absaddr.lba = azt_msf2hsg(&qInfo.diskTime);
-		  subchnl.cdsc_reladdr.lba = azt_msf2hsg(&qInfo.trackTime);
-		}
-		else  /*default*/
-		{ subchnl.cdsc_format = CDROM_MSF;
-		  subchnl.cdsc_absaddr.msf.minute = azt_bcd2bin(qInfo.diskTime.min);
-		  subchnl.cdsc_absaddr.msf.second = azt_bcd2bin(qInfo.diskTime.sec);
-		  subchnl.cdsc_absaddr.msf.frame  = azt_bcd2bin(qInfo.diskTime.frame);
-		  subchnl.cdsc_reladdr.msf.minute = azt_bcd2bin(qInfo.trackTime.min);
-		  subchnl.cdsc_reladdr.msf.second = azt_bcd2bin(qInfo.trackTime.sec);
-		  subchnl.cdsc_reladdr.msf.frame  = azt_bcd2bin(qInfo.trackTime.frame);
+		if (subchnl.cdsc_format == CDROM_LBA) {
+			subchnl.cdsc_absaddr.lba =
+			    azt_msf2hsg(&qInfo.diskTime);
+			subchnl.cdsc_reladdr.lba =
+			    azt_msf2hsg(&qInfo.trackTime);
+		} else {	/*default */
+			subchnl.cdsc_format = CDROM_MSF;
+			subchnl.cdsc_absaddr.msf.minute =
+			    azt_bcd2bin(qInfo.diskTime.min);
+			subchnl.cdsc_absaddr.msf.second =
+			    azt_bcd2bin(qInfo.diskTime.sec);
+			subchnl.cdsc_absaddr.msf.frame =
+			    azt_bcd2bin(qInfo.diskTime.frame);
+			subchnl.cdsc_reladdr.msf.minute =
+			    azt_bcd2bin(qInfo.trackTime.min);
+			subchnl.cdsc_reladdr.msf.second =
+			    azt_bcd2bin(qInfo.trackTime.sec);
+			subchnl.cdsc_reladdr.msf.frame =
+			    azt_bcd2bin(qInfo.trackTime.frame);
 		}
-		memcpy_tofs((void *) arg, &subchnl, sizeof (struct cdrom_subchnl));
+		if (copy_to_user
+		    ((void *) arg, &subchnl, sizeof(struct cdrom_subchnl)))
+			return -EFAULT;
 		break;
-	case CDROMVOLCTRL:   /* Volume control 
-	 * With my Aztech CD268-01A volume control does not work, I can only
-	   turn the channels on (any value !=0) or off (value==0). Maybe it
-           works better with your drive */
-                st=verify_area(VERIFY_READ,(void *) arg, sizeof(volctrl));
-                if (st) return (st);
-                memcpy_fromfs(&volctrl,(char *) arg,sizeof(volctrl));
+	case CDROMVOLCTRL:	/* Volume control 
+				   * With my Aztech CD268-01A volume control does not work, I can only
+				   turn the channels on (any value !=0) or off (value==0). Maybe it
+				   works better with your drive */
+		if (copy_from_user
+		    (&volctrl, (char *) arg, sizeof(volctrl)))
+			return -EFAULT;
 		azt_Play.start.min = 0x21;
 		azt_Play.start.sec = 0x84;
 		azt_Play.start.frame = volctrl.channel0;
-		azt_Play.end.min =     volctrl.channel1;
-		azt_Play.end.sec =     volctrl.channel2;
-		azt_Play.end.frame =   volctrl.channel3;
-                sendAztCmd(ACMD_SET_VOLUME, &azt_Play);
-                STEN_LOW_WAIT;
-                break;
+		azt_Play.end.min = volctrl.channel1;
+		azt_Play.end.sec = volctrl.channel2;
+		azt_Play.end.frame = volctrl.channel3;
+		sendAztCmd(ACMD_SET_VOLUME, &azt_Play);
+		STEN_LOW_WAIT;
+		break;
 	case CDROMEJECT:
-                aztUnlockDoor(); /* Assume user knows what they're doing */
-	       /* all drives can at least stop! */
-		if (aztAudioStatus == CDROM_AUDIO_PLAY) 
-		{ if (aztSendCmd(ACMD_STOP)) RETURNM("azt_ioctl 10",-1);
-		  STEN_LOW_WAIT;
+		aztUnlockDoor();	/* Assume user knows what they're doing */
+		/* all drives can at least stop! */
+		if (aztAudioStatus == CDROM_AUDIO_PLAY) {
+			if (aztSendCmd(ACMD_STOP))
+				RETURNM("azt_ioctl 10", -1);
+			STEN_LOW_WAIT;
 		}
-		if (aztSendCmd(ACMD_EJECT)) RETURNM("azt_ioctl 11",-1);
+		if (aztSendCmd(ACMD_EJECT))
+			RETURNM("azt_ioctl 11", -1);
 		STEN_LOW_WAIT;
 		aztAudioStatus = CDROM_AUDIO_NO_STATUS;
 		break;
 	case CDROMEJECT_SW:
 		azt_auto_eject = (char) arg;
-		break;	
-        case CDROMRESET:
-        	outb(ACMD_SOFT_RESET,CMD_PORT);   /*send reset*/
-	        STEN_LOW;
-	        if (inb(DATA_PORT)!=AFL_OP_OK)    /*OP_OK?*/
-	          { printk("aztcd: AZTECH CD-ROM drive does not respond\n");
-                  }
-                break;
+		break;
+	case CDROMRESET:
+		outb(ACMD_SOFT_RESET, CMD_PORT);	/*send reset */
+		STEN_LOW;
+		if (inb(DATA_PORT) != AFL_OP_OK) {	/*OP_OK? */
+			printk
+			    ("aztcd: AZTECH CD-ROM drive does not respond\n");
+		}
+		break;
 /*Take care, the following code is not compatible with other CD-ROM drivers,
   use it at your own risk with cdplay.c. Set AZT_PRIVATE_IOCTLS to 0 in aztcd.h,
   if you do not want to use it!
-*/                  
-#if AZT_PRIVATE_IOCTLS 
-	case CDROMREADCOOKED: /*read data in mode 1 (2048 Bytes)*/
-	case CDROMREADRAW:    /*read data in mode 2 (2336 Bytes)*/
-		{ st = verify_area(VERIFY_WRITE, (void *) arg, sizeof buf);
-		  if (st) return st;
-		  memcpy_fromfs(&msf, (void *) arg, sizeof msf);
-		  /* convert to bcd */
-		  azt_bin2bcd(&msf.cdmsf_min0);
-		  azt_bin2bcd(&msf.cdmsf_sec0);
-		  azt_bin2bcd(&msf.cdmsf_frame0);
-		  msf.cdmsf_min1=0;
-		  msf.cdmsf_sec1=0;
-		  msf.cdmsf_frame1=1; /*read only one frame*/
-		  azt_Play.start.min = msf.cdmsf_min0;
-		  azt_Play.start.sec = msf.cdmsf_sec0;
-		  azt_Play.start.frame = msf.cdmsf_frame0;
-		  azt_Play.end.min = msf.cdmsf_min1;
-		  azt_Play.end.sec = msf.cdmsf_sec1;
-		  azt_Play.end.frame = msf.cdmsf_frame1;
-		  if (cmd==CDROMREADRAW)
-		  { if (DiskInfo.xa)
-		       { return -1;         /*XA Disks can't be read raw*/
-		       }
-		    else   
-		       { if (sendAztCmd(ACMD_PLAY_READ_RAW, &azt_Play)) return -1;
-		         DTEN_LOW;
-		         insb(DATA_PORT,buf,CD_FRAMESIZE_RAW);
-		         memcpy_tofs((void *) arg, &buf, CD_FRAMESIZE_RAW);
-		       }  
-		  }
-		  else /*CDROMREADCOOKED*/
-		  { if (sendAztCmd(ACMD_PLAY_READ, &azt_Play)) return -1;
-		    DTEN_LOW;
-		    insb(DATA_PORT,buf,CD_FRAMESIZE);
-		    memcpy_tofs((void *) arg, &buf, CD_FRAMESIZE);
-		  }
-		 } 
-                break;
-	case CDROMSEEK:    /*seek msf address*/
-		st = verify_area(VERIFY_READ,  (void *) arg, sizeof msf);
-		if (st) return st;
-		memcpy_fromfs(&msf, (void *) arg, sizeof msf);
+*/
+#if AZT_PRIVATE_IOCTLS
+	case CDROMREADCOOKED:	/*read data in mode 1 (2048 Bytes) */
+	case CDROMREADRAW:	/*read data in mode 2 (2336 Bytes) */
+		{
+			if (copy_from_user(&msf, (void *) arg, sizeof msf))
+				return -EFAULT;
+			/* convert to bcd */
+			azt_bin2bcd(&msf.cdmsf_min0);
+			azt_bin2bcd(&msf.cdmsf_sec0);
+			azt_bin2bcd(&msf.cdmsf_frame0);
+			msf.cdmsf_min1 = 0;
+			msf.cdmsf_sec1 = 0;
+			msf.cdmsf_frame1 = 1;	/*read only one frame */
+			azt_Play.start.min = msf.cdmsf_min0;
+			azt_Play.start.sec = msf.cdmsf_sec0;
+			azt_Play.start.frame = msf.cdmsf_frame0;
+			azt_Play.end.min = msf.cdmsf_min1;
+			azt_Play.end.sec = msf.cdmsf_sec1;
+			azt_Play.end.frame = msf.cdmsf_frame1;
+			if (cmd == CDROMREADRAW) {
+				if (DiskInfo.xa) {
+					return -1;	/*XA Disks can't be read raw */
+				} else {
+					if (sendAztCmd
+					    (ACMD_PLAY_READ_RAW,
+					     &azt_Play))
+						return -1;
+					DTEN_LOW;
+					insb(DATA_PORT, buf,
+					     CD_FRAMESIZE_RAW);
+					if (copy_to_user
+					    ((void *) arg, &buf,
+					     CD_FRAMESIZE_RAW))
+						return -EFAULT;
+				}
+			} else
+				/*CDROMREADCOOKED*/ {
+				if (sendAztCmd(ACMD_PLAY_READ, &azt_Play))
+					return -1;
+				DTEN_LOW;
+				insb(DATA_PORT, buf, CD_FRAMESIZE);
+				if (copy_to_user
+				    ((void *) arg, &buf, CD_FRAMESIZE))
+					return -EFAULT;
+				}
+		}
+		break;
+	case CDROMSEEK:	/*seek msf address */
+		if (copy_from_user(&msf, (void *) arg, sizeof msf))
+			return -EFAULT;
 		/* convert to bcd */
 		azt_bin2bcd(&msf.cdmsf_min0);
 		azt_bin2bcd(&msf.cdmsf_sec0);
@@ -1423,18 +1526,20 @@
 		azt_Play.start.min = msf.cdmsf_min0;
 		azt_Play.start.sec = msf.cdmsf_sec0;
 		azt_Play.start.frame = msf.cdmsf_frame0;
-		if (aztSeek(&azt_Play)) return -1;
-                break;
-#endif /*end of incompatible code*/       
-	case CDROMREADMODE1: /*set read data in mode 1*/
-                return aztSetDiskType(AZT_MODE_1);
-	case CDROMREADMODE2: /*set read data in mode 2*/
-                return aztSetDiskType(AZT_MODE_2);	    
+		if (aztSeek(&azt_Play))
+			return -1;
+		break;
+#endif				/*end of incompatible code */
+	case CDROMREADMODE1:	/*set read data in mode 1 */
+		return aztSetDiskType(AZT_MODE_1);
+	case CDROMREADMODE2:	/*set read data in mode 2 */
+		return aztSetDiskType(AZT_MODE_2);
 	default:
 		return -EINVAL;
 	}
 #ifdef AZT_DEBUG
-        printk("aztcd: exiting aztcd_ioctl Command:%x  Time:%li\n",cmd,jiffies);
+	printk("aztcd: exiting aztcd_ioctl Command:%x  Time:%li\n", cmd,
+	       jiffies);
 #endif
 	return 0;
 }
@@ -1444,131 +1549,139 @@
  * When Linux gets variable block sizes this will probably go away.
  */
 static void azt_transfer(void)
-{ 
+{
 #ifdef AZT_TEST
-  printk("aztcd: executing azt_transfer Time:%li\n",jiffies);
+	printk("aztcd: executing azt_transfer Time:%li\n", jiffies);
 #endif
-  if (CURRENT_VALID) {
-    while (CURRENT -> nr_sectors) {
-      int bn = CURRENT -> sector / 4;
-      int i;
-      for (i = 0; i < AZT_BUF_SIZ && azt_buf_bn[i] != bn; ++i)
-	;
-      if (i < AZT_BUF_SIZ) {
-	int offs = (i * 4 + (CURRENT -> sector & 3)) * 512;
-	int nr_sectors = 4 - (CURRENT -> sector & 3);
-	if (azt_buf_out != i) {
-	  azt_buf_out = i;
-	  if (azt_buf_bn[i] != bn) {
-	    azt_buf_out = -1;
-	    continue;
-	  }
-	}
-	if (nr_sectors > CURRENT -> nr_sectors)
-	  nr_sectors = CURRENT -> nr_sectors;
-	memcpy(CURRENT -> buffer, azt_buf + offs, nr_sectors * 512);
-	CURRENT -> nr_sectors -= nr_sectors;
-	CURRENT -> sector += nr_sectors;
-	CURRENT -> buffer += nr_sectors * 512;
-      } else {
-	azt_buf_out = -1;
-	break;
-      }
-    }
-  }
+	if (CURRENT_VALID) {
+		while (CURRENT->nr_sectors) {
+			int bn = CURRENT->sector / 4;
+			int i;
+			for (i = 0; i < AZT_BUF_SIZ && azt_buf_bn[i] != bn;
+			     ++i);
+			if (i < AZT_BUF_SIZ) {
+				int offs =
+				    (i * 4 + (CURRENT->sector & 3)) * 512;
+				int nr_sectors = 4 - (CURRENT->sector & 3);
+				if (azt_buf_out != i) {
+					azt_buf_out = i;
+					if (azt_buf_bn[i] != bn) {
+						azt_buf_out = -1;
+						continue;
+					}
+				}
+				if (nr_sectors > CURRENT->nr_sectors)
+					nr_sectors = CURRENT->nr_sectors;
+				memcpy(CURRENT->buffer, azt_buf + offs,
+				       nr_sectors * 512);
+				CURRENT->nr_sectors -= nr_sectors;
+				CURRENT->sector += nr_sectors;
+				CURRENT->buffer += nr_sectors * 512;
+			} else {
+				azt_buf_out = -1;
+				break;
+			}
+		}
+	}
 }
 
 static void do_aztcd_request(request_queue_t * q)
 {
 #ifdef AZT_TEST
-  printk(" do_aztcd_request(%ld+%ld) Time:%li\n", CURRENT -> sector, CURRENT -> nr_sectors,jiffies);
+	printk(" do_aztcd_request(%ld+%ld) Time:%li\n", CURRENT->sector,
+	       CURRENT->nr_sectors, jiffies);
 #endif
-  if (DiskInfo.audio) 
-    { printk("aztcd: Error, tried to mount an Audio CD\n");
-      end_request(0);
-      return;
-    }
-  azt_transfer_is_active = 1;
-  while (CURRENT_VALID) {
-    if (CURRENT->bh) {
-      if (!buffer_locked(CURRENT->bh))
-	panic(DEVICE_NAME ": block not locked");
-    }
-    azt_transfer();
-    if (CURRENT -> nr_sectors == 0) {
-      end_request(1);
-    } else {
-      azt_buf_out = -1;         /* Want to read a block not in buffer */
-      if (azt_state == AZT_S_IDLE) {
-	if ((!aztTocUpToDate)||aztDiskChanged) {
-	  if (aztUpdateToc() < 0) {
-	    while (CURRENT_VALID)
-	      end_request(0);
-	    break;
-	  }
-	}
-	azt_state = AZT_S_START;
-	AztTries = 5;
-	SET_TIMER(azt_poll, HZ/100);
-      }
-      break;
-    }
-  }
-  azt_transfer_is_active = 0;
+	if (DiskInfo.audio) {
+		printk("aztcd: Error, tried to mount an Audio CD\n");
+		end_request(0);
+		return;
+	}
+	azt_transfer_is_active = 1;
+	while (CURRENT_VALID) {
+		if (CURRENT->bh) {
+			if (!buffer_locked(CURRENT->bh))
+				panic(DEVICE_NAME ": block not locked");
+		}
+		azt_transfer();
+		if (CURRENT->nr_sectors == 0) {
+			end_request(1);
+		} else {
+			azt_buf_out = -1;	/* Want to read a block not in buffer */
+			if (azt_state == AZT_S_IDLE) {
+				if ((!aztTocUpToDate) || aztDiskChanged) {
+					if (aztUpdateToc() < 0) {
+						while (CURRENT_VALID)
+							end_request(0);
+						break;
+					}
+				}
+				azt_state = AZT_S_START;
+				AztTries = 5;
+				SET_TIMER(azt_poll, HZ / 100);
+			}
+			break;
+		}
+	}
+	azt_transfer_is_active = 0;
 #ifdef AZT_TEST2
-  printk("azt_next_bn:%x  azt_buf_in:%x azt_buf_out:%x  azt_buf_bn:%x\n", \
-	  azt_next_bn, azt_buf_in, azt_buf_out, azt_buf_bn[azt_buf_in]);
-  printk(" do_aztcd_request ends  Time:%li\n",jiffies);
+	printk
+	    ("azt_next_bn:%x  azt_buf_in:%x azt_buf_out:%x  azt_buf_bn:%x\n",
+	     azt_next_bn, azt_buf_in, azt_buf_out, azt_buf_bn[azt_buf_in]);
+	printk(" do_aztcd_request ends  Time:%li\n", jiffies);
 #endif
 }
 
 
 static void azt_invalidate_buffers(void)
-{ int i;
+{
+	int i;
 
 #ifdef AZT_DEBUG
-  printk("aztcd: executing azt_invalidate_buffers\n");
+	printk("aztcd: executing azt_invalidate_buffers\n");
 #endif
-  for (i = 0; i < AZT_BUF_SIZ; ++i)
-    azt_buf_bn[i] = -1;
-  azt_buf_out = -1;
+	for (i = 0; i < AZT_BUF_SIZ; ++i)
+		azt_buf_bn[i] = -1;
+	azt_buf_out = -1;
 }
 
 /*
  * Open the device special file.  Check that a disk is in.
  */
 int aztcd_open(struct inode *ip, struct file *fp)
-{       int st;
+{
+	int st;
 
 #ifdef AZT_DEBUG
 	printk("aztcd: starting aztcd_open\n");
 #endif
 
 	if (aztPresent == 0)
-		return -ENXIO;                  /* no hardware */
+		return -ENXIO;	/* no hardware */
 
-        MOD_INC_USE_COUNT;
+	MOD_INC_USE_COUNT;
+
+	if (!azt_open_count && azt_state == AZT_S_IDLE) {
+		azt_invalidate_buffers();
 
-	if (!azt_open_count && azt_state == AZT_S_IDLE) 
-	  { azt_invalidate_buffers();
+		st = getAztStatus();	/* check drive status */
+		if (st == -1)
+			goto err_out;	/* drive doesn't respond */
+
+		if (st & AST_DOOR_OPEN) {	/* close door, then get the status again. */
+			printk("aztcd: Door Open?\n");
+			aztCloseDoor();
+			st = getAztStatus();
+		}
+
+		if ((st & AST_NOT_READY) || (st & AST_DSK_CHG)) {	/*no disk in drive or changed */
+			printk
+			    ("aztcd: Disk Changed or No Disk in Drive?\n");
+			aztTocUpToDate = 0;
+		}
+		if (aztUpdateToc())
+			goto err_out;
 
-	    st = getAztStatus();                    /* check drive status */
-	    if (st == -1) goto err_out;              /* drive doesn't respond */
-
-            if (st & AST_DOOR_OPEN)
-               { /* close door, then get the status again. */
-	         printk("aztcd: Door Open?\n");
-                 aztCloseDoor();     
-                 st = getAztStatus();
-               }        
-
-	    if ((st & AST_NOT_READY) || (st & AST_DSK_CHG)) /*no disk in drive or changed*/
-	       { printk("aztcd: Disk Changed or No Disk in Drive?\n");
-                 aztTocUpToDate=0;
-               }
-            if (aztUpdateToc())	goto err_out;
-	       
-	  }
+	}
 	++azt_open_count;
 	aztLockDoor();
 
@@ -1577,7 +1690,7 @@
 #endif
 	return 0;
 
-err_out:
+      err_out:
 	MOD_DEC_USE_COUNT;
 	return -EIO;
 }
@@ -1586,29 +1699,22 @@
 /*
  * On close, we flush all azt blocks from the buffer cache.
  */
-#ifdef AZT_KERNEL_PRIOR_2_1
-static void aztcd_release(struct inode * inode, struct file * file)
-#else
-static int  aztcd_release(struct inode * inode, struct file * file)
-#endif
-{ 
+static int aztcd_release(struct inode *inode, struct file *file)
+{
 #ifdef AZT_DEBUG
-  printk("aztcd: executing aztcd_release\n");
-  printk("inode: %p, inode->i_rdev: %x    file: %p\n",inode,inode->i_rdev,file);
-#endif
-  MOD_DEC_USE_COUNT;
-  if (!--azt_open_count) {
-	azt_invalidate_buffers();
-	aztUnlockDoor();
-        if (azt_auto_eject)
-           aztSendCmd(ACMD_EJECT);
-        CLEAR_TIMER;
-  }
-#ifdef AZT_KERNEL_PRIOR_2_1
-  return;
-#else
-  return 0;
+	printk("aztcd: executing aztcd_release\n");
+	printk("inode: %p, inode->i_rdev: %x    file: %p\n", inode,
+	       inode->i_rdev, file);
 #endif
+	MOD_DEC_USE_COUNT;
+	if (!--azt_open_count) {
+		azt_invalidate_buffers();
+		aztUnlockDoor();
+		if (azt_auto_eject)
+			aztSendCmd(ACMD_EJECT);
+		CLEAR_TIMER;
+	}
+	return 0;
 }
 
 
@@ -1618,222 +1724,244 @@
  */
 
 int __init aztcd_init(void)
-{       long int count, max_count;
+{
+	long int count, max_count;
 	unsigned char result[50];
 	int st;
 	int i = 0;
 
-	if (azt_port == 0) 
-	{ printk("aztcd: no Aztech CD-ROM Initialization");
-          return -EIO;
+	if (azt_port == 0) {
+		printk("aztcd: no Aztech CD-ROM Initialization");
+		return -EIO;
 	}
 
-	printk("aztcd: AZTECH, ORCHID, OKANO, WEARNES, TXC, CyDROM CD-ROM Driver\n"); 
+	printk
+	    ("aztcd: AZTECH, ORCHID, OKANO, WEARNES, TXC, CyDROM CD-ROM Driver\n");
 	printk("aztcd: (C) 1994-98 W.Zimmermann\n");
-	if (azt_port == -1) 
-	{ printk("aztcd: KernelVersion=%s DriverVersion=%s For IDE/ATAPI-drives use ide-cd.c\n",UTS_RELEASE,AZT_VERSION);
+	if (azt_port == -1) {
+		printk
+		    ("aztcd: KernelVersion=%s DriverVersion=%s For IDE/ATAPI-drives use ide-cd.c\n",
+		     UTS_RELEASE, AZT_VERSION);
+	} else
+		printk
+		    ("aztcd: DriverVersion=%s BaseAddress=0x%x  For IDE/ATAPI-drives use ide-cd.c\n",
+		     AZT_VERSION, azt_port);
+	printk
+	    ("aztcd: If you have problems, read /usr/src/linux/Documentation/cdrom/aztcd\n");
+
+
+#ifdef AZT_SW32			/*CDROM connected to Soundwave32 card */
+	if ((0xFF00 & inw(AZT_SW32_ID_REG)) != 0x4500) {
+		printk
+		    ("aztcd: no Soundwave32 card detected at base:%x init:%x config:%x id:%x\n",
+		     AZT_SW32_BASE_ADDR, AZT_SW32_INIT,
+		     AZT_SW32_CONFIG_REG, AZT_SW32_ID_REG);
+		return -EIO;
+	} else {
+		printk(KERN_INFO
+		       "aztcd: Soundwave32 card detected at %x  Version %x\n",
+		       AZT_SW32_BASE_ADDR, inw(AZT_SW32_ID_REG));
+		outw(AZT_SW32_INIT, AZT_SW32_CONFIG_REG);
+		for (count = 0; count < 10000; count++);	/*delay a bit */
 	}
-        else
-	  printk("aztcd: DriverVersion=%s BaseAddress=0x%x  For IDE/ATAPI-drives use ide-cd.c\n",AZT_VERSION,azt_port);
-	printk("aztcd: If you have problems, read /usr/src/linux/Documentation/cdrom/aztcd\n");
-
- 
-#ifdef AZT_SW32   /*CDROM connected to Soundwave32 card*/
-        if ((0xFF00 & inw(AZT_SW32_ID_REG)) != 0x4500)
-           { printk("aztcd: no Soundwave32 card detected at base:%x init:%x config:%x id:%x\n",
-		 AZT_SW32_BASE_ADDR,AZT_SW32_INIT,AZT_SW32_CONFIG_REG,AZT_SW32_ID_REG);
-                 return -EIO;
-	   }
-        else                
-           { printk(KERN_INFO "aztcd: Soundwave32 card detected at %x  Version %x\n",
-	 	 AZT_SW32_BASE_ADDR, inw(AZT_SW32_ID_REG));
-	     outw(AZT_SW32_INIT,AZT_SW32_CONFIG_REG);
-	     for (count=0;count<10000;count++);          /*delay a bit*/    	 
-           }
-#endif	
+#endif
 
 	/* check for presence of drive */
 
-        if (azt_port == -1) 			/* autoprobing */
-        { for (i=0;(azt_port_auto[i]!=0)&&(i<16);i++)
-          { azt_port = azt_port_auto[i];
-            printk("aztcd: Autoprobing BaseAddress=0x%x \n",azt_port);
-            st = check_region(azt_port, 4);  /*proprietary interfaces need 4 bytes*/
-  	    if (st) continue;
-
-	    outb(POLLED,MODE_PORT);              
-	    inb(CMD_PORT);
-	    inb(CMD_PORT);
-	    outb(ACMD_GET_VERSION,CMD_PORT); /*Try to get version info*/
-
-            aztTimeOutCount=0;   
-  	    do { aztIndatum=inb(STATUS_PORT);
-	         aztTimeOutCount++; 
-	         if (aztTimeOutCount>=AZT_FAST_TIMEOUT) break; 
-	       } while (aztIndatum&AFL_STATUS); 
-	    if (inb(DATA_PORT)==AFL_OP_OK) 
-	      break;
-          }
-          if ((azt_port_auto[i]==0)||(i==16))  
-          { printk("aztcd: no AZTECH CD-ROM drive found\n");
-            return -EIO;
-          }
-        } 
-        else					/* no autoprobing */
-        { if ((azt_port==0x1f0)||(azt_port==0x170))  
-            st = check_region(azt_port, 8);  /*IDE-interfaces need 8 bytes*/
-          else
-            st = check_region(azt_port, 4);  /*proprietary interfaces need 4 bytes*/
-	  if (st) 
-	  { printk("aztcd: conflict, I/O port (%X) already used\n",azt_port);
-            return -EIO;
-	  }
-	
-          if ((azt_port==0x1f0)||(azt_port==0x170))  
-            SWITCH_IDE_SLAVE;  /*switch IDE interface to slave configuration*/
-        
-          outb(POLLED,MODE_PORT);              
-	  inb(CMD_PORT);
-	  inb(CMD_PORT);
-	  outb(ACMD_GET_VERSION,CMD_PORT); /*Try to get version info*/
-
-          aztTimeOutCount=0;   
-	  do { aztIndatum=inb(STATUS_PORT);
-	       aztTimeOutCount++; 
-	       if (aztTimeOutCount>=AZT_FAST_TIMEOUT) break; 
-	     } while (aztIndatum&AFL_STATUS); 
+	if (azt_port == -1) {	/* autoprobing */
+		for (i = 0; (azt_port_auto[i] != 0) && (i < 16); i++) {
+			azt_port = azt_port_auto[i];
+			printk("aztcd: Autoprobing BaseAddress=0x%x \n",
+			       azt_port);
+			st = check_region(azt_port, 4);	/*proprietary interfaces need 4 bytes */
+			if (st)
+				continue;
+
+			outb(POLLED, MODE_PORT);
+			inb(CMD_PORT);
+			inb(CMD_PORT);
+			outb(ACMD_GET_VERSION, CMD_PORT);	/*Try to get version info */
+
+			aztTimeOutCount = 0;
+			do {
+				aztIndatum = inb(STATUS_PORT);
+				aztTimeOutCount++;
+				if (aztTimeOutCount >= AZT_FAST_TIMEOUT)
+					break;
+			} while (aztIndatum & AFL_STATUS);
+			if (inb(DATA_PORT) == AFL_OP_OK)
+				break;
+		}
+		if ((azt_port_auto[i] == 0) || (i == 16)) {
+			printk("aztcd: no AZTECH CD-ROM drive found\n");
+			return -EIO;
+		}
+	} else {		/* no autoprobing */
+		if ((azt_port == 0x1f0) || (azt_port == 0x170))
+			st = check_region(azt_port, 8);	/*IDE-interfaces need 8 bytes */
+		else
+			st = check_region(azt_port, 4);	/*proprietary interfaces need 4 bytes */
+		if (st) {
+			printk
+			    ("aztcd: conflict, I/O port (%X) already used\n",
+			     azt_port);
+			return -EIO;
+		}
 
-  	  if (inb(DATA_PORT)!=AFL_OP_OK) /*OP_OK? If not, reset and try again*/
-             { 
+		if ((azt_port == 0x1f0) || (azt_port == 0x170))
+			SWITCH_IDE_SLAVE;	/*switch IDE interface to slave configuration */
+
+		outb(POLLED, MODE_PORT);
+		inb(CMD_PORT);
+		inb(CMD_PORT);
+		outb(ACMD_GET_VERSION, CMD_PORT);	/*Try to get version info */
+
+		aztTimeOutCount = 0;
+		do {
+			aztIndatum = inb(STATUS_PORT);
+			aztTimeOutCount++;
+			if (aztTimeOutCount >= AZT_FAST_TIMEOUT)
+				break;
+		} while (aztIndatum & AFL_STATUS);
+
+		if (inb(DATA_PORT) != AFL_OP_OK) {	/*OP_OK? If not, reset and try again */
 #ifndef MODULE
-               if (azt_cont!=0x79)   
-	          { printk("aztcd: no AZTECH CD-ROM drive found-Try boot parameter aztcd=<BaseAddress>,0x79\n");
-	            return -EIO;
-                  }
-#else        
-               if (0)
-                  {
-                  }
-#endif	     
-               else   
-       	          { printk("aztcd: drive reset - please wait\n");
-	            for (count=0;count<50;count++)
-	              { inb(STATUS_PORT);    /*removing all data from earlier tries*/
-	                inb(DATA_PORT);
-	              }
-	            outb(POLLED,MODE_PORT);          
-	            inb(CMD_PORT);
-	            inb(CMD_PORT);
-		    getAztStatus(); 		    /*trap errors*/
-	            outb(ACMD_SOFT_RESET,CMD_PORT); /*send reset*/
-	            STEN_LOW;
-	            if (inb(DATA_PORT)!=AFL_OP_OK)    /*OP_OK?*/
-	               { printk("aztcd: no AZTECH CD-ROM drive found\n");
-                         return -EIO;
-	               } 
-	            
-	            for (count = 0; count < AZT_TIMEOUT; count++)
-	            	barrier();	/* Stop gcc 2.96 being smart */
-	            
-	            if ((st=getAztStatus())==-1)
-	               { printk("aztcd: Drive Status Error Status=%x\n",st);
-                         return -EIO;
-	               }
-#ifdef AZT_DEBUG
-	            printk("aztcd: Status = %x\n",st);
-#endif
-	            outb(POLLED,MODE_PORT);            
-	            inb(CMD_PORT);
-	            inb(CMD_PORT);
-	            outb(ACMD_GET_VERSION,CMD_PORT); /*GetVersion*/
-	            STEN_LOW;
-	            OP_OK;
-	          } 
-             }
+			if (azt_cont != 0x79) {
+				printk
+				    ("aztcd: no AZTECH CD-ROM drive found-Try boot parameter aztcd=<BaseAddress>,0x79\n");
+				return -EIO;
+			}
+#else
+			if (0) {
+			}
+#endif
+			else {
+				printk
+				    ("aztcd: drive reset - please wait\n");
+				for (count = 0; count < 50; count++) {
+					inb(STATUS_PORT);	/*removing all data from earlier tries */
+					inb(DATA_PORT);
+				}
+				outb(POLLED, MODE_PORT);
+				inb(CMD_PORT);
+				inb(CMD_PORT);
+				getAztStatus();	/*trap errors */
+				outb(ACMD_SOFT_RESET, CMD_PORT);	/*send reset */
+				STEN_LOW;
+				if (inb(DATA_PORT) != AFL_OP_OK) {	/*OP_OK? */
+					printk
+					    ("aztcd: no AZTECH CD-ROM drive found\n");
+					return -EIO;
+				}
+
+				for (count = 0; count < AZT_TIMEOUT;
+				     count++)
+					barrier();	/* Stop gcc 2.96 being smart */
+
+				if ((st = getAztStatus()) == -1) {
+					printk
+					    ("aztcd: Drive Status Error Status=%x\n",
+					     st);
+					return -EIO;
+				}
+#ifdef AZT_DEBUG
+				printk("aztcd: Status = %x\n", st);
+#endif
+				outb(POLLED, MODE_PORT);
+				inb(CMD_PORT);
+				inb(CMD_PORT);
+				outb(ACMD_GET_VERSION, CMD_PORT);	/*GetVersion */
+				STEN_LOW;
+				OP_OK;
+			}
+		}
 	}
-	
-	azt_init_end=1;
+
+	azt_init_end = 1;
 	STEN_LOW;
-	result[0]=inb(DATA_PORT);        /*reading in a null byte???*/
-	for (count=1;count<50;count++)   /*Reading version string*/
-	 { aztTimeOutCount=0;            /*here we must implement STEN_LOW differently*/
-	   do { aztIndatum=inb(STATUS_PORT);/*because we want to exit by timeout*/
-		aztTimeOutCount++; 
-		if (aztTimeOutCount>=AZT_FAST_TIMEOUT) break; 
-	      } while (aztIndatum&AFL_STATUS); 
-	   if (aztTimeOutCount>=AZT_FAST_TIMEOUT) break;  /*all chars read?*/
-	   result[count]=inb(DATA_PORT);
-	 }
-	if (count>30) max_count=30;  /*print max.30 chars of the version string*/
-	else          max_count=count;
+	result[0] = inb(DATA_PORT);	/*reading in a null byte??? */
+	for (count = 1; count < 50; count++) {	/*Reading version string */
+		aztTimeOutCount = 0;	/*here we must implement STEN_LOW differently */
+		do {
+			aztIndatum = inb(STATUS_PORT);	/*because we want to exit by timeout */
+			aztTimeOutCount++;
+			if (aztTimeOutCount >= AZT_FAST_TIMEOUT)
+				break;
+		} while (aztIndatum & AFL_STATUS);
+		if (aztTimeOutCount >= AZT_FAST_TIMEOUT)
+			break;	/*all chars read? */
+		result[count] = inb(DATA_PORT);
+	}
+	if (count > 30)
+		max_count = 30;	/*print max.30 chars of the version string */
+	else
+		max_count = count;
 	printk(KERN_INFO "aztcd: FirmwareVersion=");
-	for (count=1;count<max_count;count++) printk("%c",result[count]);
+	for (count = 1; count < max_count; count++)
+		printk("%c", result[count]);
 	printk("<<>> ");
 
-	if ((result[1]=='A')&&(result[2]=='Z')&&(result[3]=='T'))
-	 { printk("AZTECH drive detected\n"); /*AZTECH*/    
-	 }
-	else if ((result[2]=='C')&&(result[3]=='D')&&(result[4]=='D'))
-	 { printk("ORCHID or WEARNES drive detected\n"); /*ORCHID or WEARNES*/
-	 }
-	else if ((result[1]==0x03)&&(result[2]=='5'))
-	 { printk("TXC or CyCDROM drive detected\n"); /*Conrad TXC, CyCDROM*/
-	 }
-	else                                             /*OTHERS or none*/
-	 { printk("\nunknown drive or firmware version detected\n");
-	   printk("aztcd may not run stable, if you want to try anyhow,\n");
-	   printk("boot with: aztcd=<BaseAddress>,0x79\n");
-	   if ((azt_cont!=0x79))     
-	     { printk("aztcd: FirmwareVersion=");
-	       for (count=1;count<5;count++) printk("%c",result[count]);
-	       printk("<<>> ");
-	       printk("Aborted\n");
-               return -EIO;
-	     }
-	 }
-	devfs_register (NULL, "aztcd", DEVFS_FL_DEFAULT, MAJOR_NR, 0,
-			S_IFBLK | S_IRUGO | S_IWUGO, &azt_fops, NULL);
-	if (devfs_register_blkdev(MAJOR_NR, "aztcd", &azt_fops) != 0)
-	{
+	if ((result[1] == 'A') && (result[2] == 'Z') && (result[3] == 'T')) {
+		printk("AZTECH drive detected\n");
+	/*AZTECH*/}
+		else if ((result[2] == 'C') && (result[3] == 'D')
+			 && (result[4] == 'D')) {
+		printk("ORCHID or WEARNES drive detected\n");	/*ORCHID or WEARNES */
+	} else if ((result[1] == 0x03) && (result[2] == '5')) {
+		printk("TXC or CyCDROM drive detected\n");	/*Conrad TXC, CyCDROM */
+	} else {		/*OTHERS or none */
+		printk("\nunknown drive or firmware version detected\n");
+		printk
+		    ("aztcd may not run stable, if you want to try anyhow,\n");
+		printk("boot with: aztcd=<BaseAddress>,0x79\n");
+		if ((azt_cont != 0x79)) {
+			printk("aztcd: FirmwareVersion=");
+			for (count = 1; count < 5; count++)
+				printk("%c", result[count]);
+			printk("<<>> ");
+			printk("Aborted\n");
+			return -EIO;
+		}
+	}
+	devfs_register(NULL, "aztcd", DEVFS_FL_DEFAULT, MAJOR_NR, 0,
+		       S_IFBLK | S_IRUGO | S_IWUGO, &azt_fops, NULL);
+	if (devfs_register_blkdev(MAJOR_NR, "aztcd", &azt_fops) != 0) {
 		printk("aztcd: Unable to get major %d for Aztech CD-ROM\n",
 		       MAJOR_NR);
-                return -EIO;
+		return -EIO;
 	}
 	blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST);
-#ifndef AZT_KERNEL_PRIOR_2_1
 	blksize_size[MAJOR_NR] = aztcd_blocksizes;
-#endif
 	read_ahead[MAJOR_NR] = 4;
-	register_disk(NULL, MKDEV(MAJOR_NR,0), 1, &azt_fops, 0);
+	register_disk(NULL, MKDEV(MAJOR_NR, 0), 1, &azt_fops, 0);
+
+	if ((azt_port == 0x1f0) || (azt_port == 0x170))
+		request_region(azt_port, 8, "aztcd");	/*IDE-interface */
+	else
+		request_region(azt_port, 4, "aztcd");	/*proprietary interface */
 
-        if ((azt_port==0x1f0)||(azt_port==0x170))  
-	   request_region(azt_port, 8, "aztcd");  /*IDE-interface*/
-        else
-	   request_region(azt_port, 4, "aztcd");  /*proprietary interface*/
-        
 	azt_invalidate_buffers();
 	aztPresent = 1;
 	aztCloseDoor();
-        return (0);
+	return (0);
 }
 
 void __exit aztcd_exit(void)
 {
-  devfs_unregister(devfs_find_handle(NULL, "aztcd", 0, 0, DEVFS_SPECIAL_BLK,
-				     0));
-  if ((devfs_unregister_blkdev(MAJOR_NR, "aztcd") == -EINVAL))    
-    { printk("What's that: can't unregister aztcd\n");
-      return;
-    }
-  blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
-  if ((azt_port==0x1f0)||(azt_port==0x170))  
-    { SWITCH_IDE_MASTER;
-      release_region(azt_port,8);  /*IDE-interface*/
-    }
-  else
-      release_region(azt_port,4);  /*proprietary interface*/
-  printk(KERN_INFO "aztcd module released.\n");
-}   
+	devfs_unregister(devfs_find_handle
+			 (NULL, "aztcd", 0, 0, DEVFS_SPECIAL_BLK, 0));
+	if ((devfs_unregister_blkdev(MAJOR_NR, "aztcd") == -EINVAL)) {
+		printk("What's that: can't unregister aztcd\n");
+		return;
+	}
+	blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
+	if ((azt_port == 0x1f0) || (azt_port == 0x170)) {
+		SWITCH_IDE_MASTER;
+		release_region(azt_port, 8);	/*IDE-interface */
+	} else
+		release_region(azt_port, 4);	/*proprietary interface */
+	printk(KERN_INFO "aztcd module released.\n");
+}
 
 #ifdef MODULE
 module_init(aztcd_init);
@@ -1846,405 +1974,485 @@
 */
 static void azt_poll(void)
 {
-    int st = 0;
-    int loop_ctl = 1;
-    int skip = 0;
-
-    if (azt_error) {                            
-	if (aztSendCmd(ACMD_GET_ERROR)) RETURN("azt_poll 1");
-	STEN_LOW;
-	azt_error=inb(DATA_PORT)&0xFF;
-	printk("aztcd: I/O error 0x%02x\n", azt_error);
-	azt_invalidate_buffers();
+	int st = 0;
+	int loop_ctl = 1;
+	int skip = 0;
+
+	if (azt_error) {
+		if (aztSendCmd(ACMD_GET_ERROR))
+			RETURN("azt_poll 1");
+		STEN_LOW;
+		azt_error = inb(DATA_PORT) & 0xFF;
+		printk("aztcd: I/O error 0x%02x\n", azt_error);
+		azt_invalidate_buffers();
 #ifdef WARN_IF_READ_FAILURE
-	if (AztTries == 5)
-	  printk("aztcd: Read of Block %d Failed - Maybe Audio Disk?\n", azt_next_bn);
-#endif
-	if (!AztTries--) {
-	  printk("aztcd: Read of Block %d Failed, Maybe Audio Disk? Giving up\n", azt_next_bn);
-	  if (azt_transfer_is_active) {
-	    AztTries = 0;
-	    loop_ctl = 0;
-	  }
-	  if (CURRENT_VALID)
-	    end_request(0);
-	  AztTries = 5;
-	}
-    azt_error = 0;
-    azt_state = AZT_S_STOP;
-    }
-
-    while (loop_ctl)
-    {
-      loop_ctl = 0;   /* each case must flip this back to 1 if we want
-			 to come back up here */
-      switch (azt_state) {
+		if (AztTries == 5)
+			printk
+			    ("aztcd: Read of Block %d Failed - Maybe Audio Disk?\n",
+			     azt_next_bn);
+#endif
+		if (!AztTries--) {
+			printk
+			    ("aztcd: Read of Block %d Failed, Maybe Audio Disk? Giving up\n",
+			     azt_next_bn);
+			if (azt_transfer_is_active) {
+				AztTries = 0;
+				loop_ctl = 0;
+			}
+			if (CURRENT_VALID)
+				end_request(0);
+			AztTries = 5;
+		}
+		azt_error = 0;
+		azt_state = AZT_S_STOP;
+	}
+
+	while (loop_ctl) {
+		loop_ctl = 0;	/* each case must flip this back to 1 if we want
+				   to come back up here */
+		switch (azt_state) {
 
-	case AZT_S_IDLE:
+		case AZT_S_IDLE:
 #ifdef AZT_TEST3
-	  if (azt_state!=azt_state_old) {
-	    azt_state_old=azt_state;
-	    printk("AZT_S_IDLE\n");
-	    }
+			if (azt_state != azt_state_old) {
+				azt_state_old = azt_state;
+				printk("AZT_S_IDLE\n");
+			}
 #endif
-	  return;
+			return;
 
-	case AZT_S_START:
+		case AZT_S_START:
 #ifdef AZT_TEST3
-	  if (azt_state!=azt_state_old) {
-	    azt_state_old=azt_state;
-	    printk("AZT_S_START\n");
-	  }
-#endif
-	  if(aztSendCmd(ACMD_GET_STATUS)) RETURN("azt_poll 2");  /*result will be checked by aztStatus() */
-	  azt_state = azt_mode == 1 ? AZT_S_READ : AZT_S_MODE;
-	  AztTimeout = 3000;
-	  break;
+			if (azt_state != azt_state_old) {
+				azt_state_old = azt_state;
+				printk("AZT_S_START\n");
+			}
+#endif
+			if (aztSendCmd(ACMD_GET_STATUS))
+				RETURN("azt_poll 2");	/*result will be checked by aztStatus() */
+			azt_state =
+			    azt_mode == 1 ? AZT_S_READ : AZT_S_MODE;
+			AztTimeout = 3000;
+			break;
 
-	case AZT_S_MODE:
+		case AZT_S_MODE:
 #ifdef AZT_TEST3
-	  if (azt_state!=azt_state_old) {
-	    azt_state_old=azt_state;
-	    printk("AZT_S_MODE\n");
-	  }
-#endif
-	  if (!skip) {
-	    if ((st = aztStatus()) != -1) {
-	      if ((st & AST_DSK_CHG)||(st & AST_NOT_READY)) {
-		aztDiskChanged = 1;
-		aztTocUpToDate = 0;
-		azt_invalidate_buffers();
-		end_request(0);
-		printk("aztcd: Disk Changed or Not Ready 1 - Unmount Disk!\n");
-	      }
-	    } else break;
-	  }
-	  skip = 0;
-
-	  if ((st & AST_DOOR_OPEN)||(st & AST_NOT_READY)) {
-	    aztDiskChanged = 1;
-	    aztTocUpToDate = 0;
-            printk("aztcd: Disk Changed or Not Ready 2 - Unmount Disk!\n");
-            end_request(0);
-	    printk((st & AST_DOOR_OPEN) ? "aztcd: door open\n" : "aztcd: disk removed\n");
-	    if (azt_transfer_is_active) {
-	      azt_state = AZT_S_START;
-	      loop_ctl = 1;   /* goto immediately */
-	      break;
-	    }
-	    azt_state = AZT_S_IDLE;
-	    while (CURRENT_VALID)
-	      end_request(0);
-	    return;
-	  }
-				
+			if (azt_state != azt_state_old) {
+				azt_state_old = azt_state;
+				printk("AZT_S_MODE\n");
+			}
+#endif
+			if (!skip) {
+				if ((st = aztStatus()) != -1) {
+					if ((st & AST_DSK_CHG)
+					    || (st & AST_NOT_READY)) {
+						aztDiskChanged = 1;
+						aztTocUpToDate = 0;
+						azt_invalidate_buffers();
+						end_request(0);
+						printk
+						    ("aztcd: Disk Changed or Not Ready 1 - Unmount Disk!\n");
+					}
+				} else
+					break;
+			}
+			skip = 0;
+
+			if ((st & AST_DOOR_OPEN) || (st & AST_NOT_READY)) {
+				aztDiskChanged = 1;
+				aztTocUpToDate = 0;
+				printk
+				    ("aztcd: Disk Changed or Not Ready 2 - Unmount Disk!\n");
+				end_request(0);
+				printk((st & AST_DOOR_OPEN) ?
+				       "aztcd: door open\n" :
+				       "aztcd: disk removed\n");
+				if (azt_transfer_is_active) {
+					azt_state = AZT_S_START;
+					loop_ctl = 1;	/* goto immediately */
+					break;
+				}
+				azt_state = AZT_S_IDLE;
+				while (CURRENT_VALID)
+					end_request(0);
+				return;
+			}
+
 /*	  if (aztSendCmd(ACMD_SET_MODE)) RETURN("azt_poll 3");
 	  outb(0x01, DATA_PORT);          
 	  PA_OK;
 	  STEN_LOW;
-*/        if (aztSendCmd(ACMD_GET_STATUS)) RETURN("azt_poll 4");
-	  STEN_LOW;
-	  azt_mode = 1;
-	  azt_state = AZT_S_READ;
-	  AztTimeout = 3000;
+*/
+			if (aztSendCmd(ACMD_GET_STATUS))
+				RETURN("azt_poll 4");
+			STEN_LOW;
+			azt_mode = 1;
+			azt_state = AZT_S_READ;
+			AztTimeout = 3000;
 
-	  break;
+			break;
 
 
-	case AZT_S_READ:
+		case AZT_S_READ:
 #ifdef AZT_TEST3
-	  if (azt_state!=azt_state_old)  {
-	    azt_state_old=azt_state;
-	    printk("AZT_S_READ\n");
-	  }
-#endif
-	  if (!skip) {
-	      if ((st = aztStatus()) != -1) {
-		if ((st & AST_DSK_CHG)||(st & AST_NOT_READY)) {
-		aztDiskChanged = 1;
-		aztTocUpToDate = 0;
-		azt_invalidate_buffers();
-		printk("aztcd: Disk Changed or Not Ready 3 - Unmount Disk!\n");
-                end_request(0);               
-		}
-	      } else break;
-	  } 
-	    
-	  skip = 0;
-	  if ((st & AST_DOOR_OPEN)||(st & AST_NOT_READY)) {
-	    aztDiskChanged = 1;
-	    aztTocUpToDate = 0;
-	    printk((st & AST_DOOR_OPEN) ? "aztcd: door open\n" : "aztcd: disk removed\n");
-	    if (azt_transfer_is_active) {
-	      azt_state = AZT_S_START;
-	      loop_ctl = 1;
-	      break;
-	    }
-	    azt_state = AZT_S_IDLE;
-	    while (CURRENT_VALID)
-	    end_request(0);
-	    return;
-	  }
-
-	  if (CURRENT_VALID) {
-	    struct azt_Play_msf msf;
-	    int i;
-	    azt_next_bn = CURRENT -> sector / 4;
-	    azt_hsg2msf(azt_next_bn, &msf.start);
-	    i = 0;
-	    /* find out in which track we are */
-	    while (azt_msf2hsg(&msf.start)>azt_msf2hsg(&Toc[++i].trackTime)) {};
-	    if (azt_msf2hsg(&msf.start)<azt_msf2hsg(&Toc[i].trackTime)-AZT_BUF_SIZ)
-               { azt_read_count=AZT_BUF_SIZ;  /*fast, because we read ahead*/
-               /*azt_read_count=CURRENT->nr_sectors;    slow, no read ahead*/
-               }
-	    else /* don't read beyond end of track */           
-#if AZT_MULTISESSION 
-               { azt_read_count=(azt_msf2hsg(&Toc[i].trackTime)/4)*4-azt_msf2hsg(&msf.start);  
-                 if (azt_read_count < 0) azt_read_count=0;
-		 if (azt_read_count > AZT_BUF_SIZ) azt_read_count=AZT_BUF_SIZ;
-                 printk("aztcd: warning - trying to read beyond end of track\n");
+			if (azt_state != azt_state_old) {
+				azt_state_old = azt_state;
+				printk("AZT_S_READ\n");
+			}
+#endif
+			if (!skip) {
+				if ((st = aztStatus()) != -1) {
+					if ((st & AST_DSK_CHG)
+					    || (st & AST_NOT_READY)) {
+						aztDiskChanged = 1;
+						aztTocUpToDate = 0;
+						azt_invalidate_buffers();
+						printk
+						    ("aztcd: Disk Changed or Not Ready 3 - Unmount Disk!\n");
+						end_request(0);
+					}
+				} else
+					break;
+			}
+
+			skip = 0;
+			if ((st & AST_DOOR_OPEN) || (st & AST_NOT_READY)) {
+				aztDiskChanged = 1;
+				aztTocUpToDate = 0;
+				printk((st & AST_DOOR_OPEN) ?
+				       "aztcd: door open\n" :
+				       "aztcd: disk removed\n");
+				if (azt_transfer_is_active) {
+					azt_state = AZT_S_START;
+					loop_ctl = 1;
+					break;
+				}
+				azt_state = AZT_S_IDLE;
+				while (CURRENT_VALID)
+					end_request(0);
+				return;
+			}
+
+			if (CURRENT_VALID) {
+				struct azt_Play_msf msf;
+				int i;
+				azt_next_bn = CURRENT->sector / 4;
+				azt_hsg2msf(azt_next_bn, &msf.start);
+				i = 0;
+				/* find out in which track we are */
+				while (azt_msf2hsg(&msf.start) >
+				       azt_msf2hsg(&Toc[++i].trackTime)) {
+				};
+				if (azt_msf2hsg(&msf.start) <
+				    azt_msf2hsg(&Toc[i].trackTime) -
+				    AZT_BUF_SIZ) {
+					azt_read_count = AZT_BUF_SIZ;	/*fast, because we read ahead */
+					/*azt_read_count=CURRENT->nr_sectors;    slow, no read ahead */
+				} else	/* don't read beyond end of track */
+#if AZT_MULTISESSION
+				{
+					azt_read_count =
+					    (azt_msf2hsg(&Toc[i].trackTime)
+					     / 4) * 4 -
+					    azt_msf2hsg(&msf.start);
+					if (azt_read_count < 0)
+						azt_read_count = 0;
+					if (azt_read_count > AZT_BUF_SIZ)
+						azt_read_count =
+						    AZT_BUF_SIZ;
+					printk
+					    ("aztcd: warning - trying to read beyond end of track\n");
 /*               printk("%i %i %li %li\n",i,azt_read_count,azt_msf2hsg(&msf.start),azt_msf2hsg(&Toc[i].trackTime));
-*/             }
+*/ }
 #else
-	       { azt_read_count=AZT_BUF_SIZ;
-	       }
-#endif
-	    msf.end.min = 0;
-	    msf.end.sec = 0;            
-	    msf.end.frame = azt_read_count ;/*Mitsumi here reads 0xffffff sectors*/
+				{
+					azt_read_count = AZT_BUF_SIZ;
+				}
+#endif
+				msf.end.min = 0;
+				msf.end.sec = 0;
+				msf.end.frame = azt_read_count;	/*Mitsumi here reads 0xffffff sectors */
 #ifdef AZT_TEST3
-	    printk("---reading msf-address %x:%x:%x  %x:%x:%x\n",msf.start.min,msf.start.sec,msf.start.frame,msf.end.min,msf.end.sec,msf.end.frame);
-	    printk("azt_next_bn:%x  azt_buf_in:%x azt_buf_out:%x  azt_buf_bn:%x\n", \
-		    azt_next_bn, azt_buf_in, azt_buf_out, azt_buf_bn[azt_buf_in]);
-#endif 
-            if (azt_read_mode==AZT_MODE_2)
-               { sendAztCmd(ACMD_PLAY_READ_RAW, &msf); /*XA disks in raw mode*/
-               }
-            else
-               { sendAztCmd(ACMD_PLAY_READ, &msf);     /*others in cooked mode*/
-               }
-	    azt_state = AZT_S_DATA;
-	    AztTimeout = READ_TIMEOUT;
-	  } else {
-	    azt_state = AZT_S_STOP;
-	    loop_ctl = 1;
-	    break;
-	  }
+				printk
+				    ("---reading msf-address %x:%x:%x  %x:%x:%x\n",
+				     msf.start.min, msf.start.sec,
+				     msf.start.frame, msf.end.min,
+				     msf.end.sec, msf.end.frame);
+				printk
+				    ("azt_next_bn:%x  azt_buf_in:%x azt_buf_out:%x  azt_buf_bn:%x\n",
+				     azt_next_bn, azt_buf_in, azt_buf_out,
+				     azt_buf_bn[azt_buf_in]);
+#endif
+				if (azt_read_mode == AZT_MODE_2) {
+					sendAztCmd(ACMD_PLAY_READ_RAW, &msf);	/*XA disks in raw mode */
+				} else {
+					sendAztCmd(ACMD_PLAY_READ, &msf);	/*others in cooked mode */
+				}
+				azt_state = AZT_S_DATA;
+				AztTimeout = READ_TIMEOUT;
+			} else {
+				azt_state = AZT_S_STOP;
+				loop_ctl = 1;
+				break;
+			}
 
-	  break;
+			break;
 
 
-	case AZT_S_DATA:
+		case AZT_S_DATA:
 #ifdef AZT_TEST3
-	  if (azt_state!=azt_state_old)  {
-	    azt_state_old=azt_state;
-	    printk("AZT_S_DATA\n");
-	  }
+			if (azt_state != azt_state_old) {
+				azt_state_old = azt_state;
+				printk("AZT_S_DATA\n");
+			}
 #endif
 
-	  st = inb(STATUS_PORT) & AFL_STATUSorDATA; 
+			st = inb(STATUS_PORT) & AFL_STATUSorDATA;
 
-	  switch (st) {
+			switch (st) {
 
-	    case AFL_DATA:
+			case AFL_DATA:
 #ifdef AZT_TEST3
-	      if (st!=azt_st_old)  {
-		azt_st_old=st; 
-		printk("---AFL_DATA st:%x\n",st);
-	      }
-#endif
-	      if (!AztTries--) {
-		printk("aztcd: Read of Block %d Failed, Maybe Audio Disk ? Giving up\n", azt_next_bn);
-		if (azt_transfer_is_active) {
-		  AztTries = 0;
-		  break;
-		}
-		if (CURRENT_VALID)
-		  end_request(0);
-		AztTries = 5;
-	      }
-	      azt_state = AZT_S_START;
-	      AztTimeout = READ_TIMEOUT;
-	      loop_ctl = 1;
-	      break;
+				if (st != azt_st_old) {
+					azt_st_old = st;
+					printk("---AFL_DATA st:%x\n", st);
+				}
+#endif
+				if (!AztTries--) {
+					printk
+					    ("aztcd: Read of Block %d Failed, Maybe Audio Disk ? Giving up\n",
+					     azt_next_bn);
+					if (azt_transfer_is_active) {
+						AztTries = 0;
+						break;
+					}
+					if (CURRENT_VALID)
+						end_request(0);
+					AztTries = 5;
+				}
+				azt_state = AZT_S_START;
+				AztTimeout = READ_TIMEOUT;
+				loop_ctl = 1;
+				break;
 
-	    case AFL_STATUSorDATA:
+			case AFL_STATUSorDATA:
 #ifdef AZT_TEST3
-	      if (st!=azt_st_old)  {
-		azt_st_old=st;
-		printk("---AFL_STATUSorDATA st:%x\n",st);
-	      }
+				if (st != azt_st_old) {
+					azt_st_old = st;
+					printk
+					    ("---AFL_STATUSorDATA st:%x\n",
+					     st);
+				}
 #endif
-	      break;
+				break;
 
-	    default:
+			default:
 #ifdef AZT_TEST3
-	      if (st!=azt_st_old)  {
-		azt_st_old=st;
-		printk("---default: st:%x\n",st);
-	      }
-#endif
-	      AztTries = 5;
-	      if (!CURRENT_VALID && azt_buf_in == azt_buf_out) {
-		azt_state = AZT_S_STOP;
-		loop_ctl = 1;
-		break;
-	      }
-	      if (azt_read_count<=0)
-		printk("aztcd: warning - try to read 0 frames\n");
-	      while (azt_read_count)      /*??? fast read ahead loop*/
-	       { azt_buf_bn[azt_buf_in] = -1;
-		 DTEN_LOW;                      /*??? unsolved problem, very
-						      seldom we get timeouts
-						      here, don't now the real
-						      reason. With my drive this
-						      sometimes also happens with
-						      Aztech's original driver under
-						      DOS. Is it a hardware bug? 
-						      I tried to recover from such
-						      situations here. Zimmermann*/
-		 if (aztTimeOutCount>=AZT_TIMEOUT) 
-		  { printk("read_count:%d CURRENT->nr_sectors:%ld azt_buf_in:%d\n", azt_read_count,CURRENT->nr_sectors,azt_buf_in);
-		    printk("azt_transfer_is_active:%x\n",azt_transfer_is_active);
-		    azt_read_count=0;
-		    azt_state = AZT_S_STOP;
-		    loop_ctl = 1;
-		    end_request(1);  /*should we have here (1) or (0)? */
-		  }
-		 else
-		  { if (azt_read_mode==AZT_MODE_2)
-		       { insb(DATA_PORT, azt_buf + CD_FRAMESIZE_RAW * azt_buf_in, CD_FRAMESIZE_RAW);
-		       }
-		    else
-		       { insb(DATA_PORT, azt_buf + CD_FRAMESIZE * azt_buf_in, CD_FRAMESIZE);
-                       }
-		    azt_read_count--;
+				if (st != azt_st_old) {
+					azt_st_old = st;
+					printk("---default: st:%x\n", st);
+				}
+#endif
+				AztTries = 5;
+				if (!CURRENT_VALID
+				    && azt_buf_in == azt_buf_out) {
+					azt_state = AZT_S_STOP;
+					loop_ctl = 1;
+					break;
+				}
+				if (azt_read_count <= 0)
+					printk
+					    ("aztcd: warning - try to read 0 frames\n");
+				while (azt_read_count) {	/*??? fast read ahead loop */
+					azt_buf_bn[azt_buf_in] = -1;
+					DTEN_LOW;	/*??? unsolved problem, very
+							   seldom we get timeouts
+							   here, don't now the real
+							   reason. With my drive this
+							   sometimes also happens with
+							   Aztech's original driver under
+							   DOS. Is it a hardware bug? 
+							   I tried to recover from such
+							   situations here. Zimmermann */
+					if (aztTimeOutCount >= AZT_TIMEOUT) {
+						printk
+						    ("read_count:%d CURRENT->nr_sectors:%ld azt_buf_in:%d\n",
+						     azt_read_count,
+						     CURRENT->nr_sectors,
+						     azt_buf_in);
+						printk
+						    ("azt_transfer_is_active:%x\n",
+						     azt_transfer_is_active);
+						azt_read_count = 0;
+						azt_state = AZT_S_STOP;
+						loop_ctl = 1;
+						end_request(1);	/*should we have here (1) or (0)? */
+					} else {
+						if (azt_read_mode ==
+						    AZT_MODE_2) {
+							insb(DATA_PORT,
+							     azt_buf +
+							     CD_FRAMESIZE_RAW
+							     * azt_buf_in,
+							     CD_FRAMESIZE_RAW);
+						} else {
+							insb(DATA_PORT,
+							     azt_buf +
+							     CD_FRAMESIZE *
+							     azt_buf_in,
+							     CD_FRAMESIZE);
+						}
+						azt_read_count--;
 #ifdef AZT_TEST3
-		    printk("AZT_S_DATA; ---I've read data- read_count: %d\n",azt_read_count);
-		    printk("azt_next_bn:%d  azt_buf_in:%d azt_buf_out:%d  azt_buf_bn:%d\n", \
-			 azt_next_bn, azt_buf_in, azt_buf_out, azt_buf_bn[azt_buf_in]);
-#endif
-		    azt_buf_bn[azt_buf_in] = azt_next_bn++;
-		    if (azt_buf_out == -1)
-		      azt_buf_out = azt_buf_in;
-		    azt_buf_in = azt_buf_in + 1 == AZT_BUF_SIZ ? 0 : azt_buf_in + 1;
-		  }
-	       }
-	      if (!azt_transfer_is_active) {
-		while (CURRENT_VALID) {
-		  azt_transfer();
-		  if (CURRENT -> nr_sectors == 0)
-		    end_request(1);
-		  else
-		    break;
-		}
-	      }
-
-	      if (CURRENT_VALID
-		&& (CURRENT -> sector / 4 < azt_next_bn ||
-		CURRENT -> sector / 4 > azt_next_bn + AZT_BUF_SIZ)) {
-		azt_state = AZT_S_STOP;
-		loop_ctl = 1;
-		break;
-	      }
-	      AztTimeout = READ_TIMEOUT;   
-	      if (azt_read_count==0) {
-		azt_state = AZT_S_STOP; 
-		loop_ctl = 1;
-		break;           
-	      } 
-	      break;
-	    }
-    break;
+						printk
+						    ("AZT_S_DATA; ---I've read data- read_count: %d\n",
+						     azt_read_count);
+						printk
+						    ("azt_next_bn:%d  azt_buf_in:%d azt_buf_out:%d  azt_buf_bn:%d\n",
+						     azt_next_bn,
+						     azt_buf_in,
+						     azt_buf_out,
+						     azt_buf_bn
+						     [azt_buf_in]);
+#endif
+						azt_buf_bn[azt_buf_in] =
+						    azt_next_bn++;
+						if (azt_buf_out == -1)
+							azt_buf_out =
+							    azt_buf_in;
+						azt_buf_in =
+						    azt_buf_in + 1 ==
+						    AZT_BUF_SIZ ? 0 :
+						    azt_buf_in + 1;
+					}
+				}
+				if (!azt_transfer_is_active) {
+					while (CURRENT_VALID) {
+						azt_transfer();
+						if (CURRENT->nr_sectors ==
+						    0)
+							end_request(1);
+						else
+							break;
+					}
+				}
+
+				if (CURRENT_VALID
+				    && (CURRENT->sector / 4 < azt_next_bn
+					|| CURRENT->sector / 4 >
+					azt_next_bn + AZT_BUF_SIZ)) {
+					azt_state = AZT_S_STOP;
+					loop_ctl = 1;
+					break;
+				}
+				AztTimeout = READ_TIMEOUT;
+				if (azt_read_count == 0) {
+					azt_state = AZT_S_STOP;
+					loop_ctl = 1;
+					break;
+				}
+				break;
+			}
+			break;
 
 
-	case AZT_S_STOP:
+		case AZT_S_STOP:
 #ifdef AZT_TEST3
-	  if (azt_state!=azt_state_old) {
-	    azt_state_old=azt_state;
-	    printk("AZT_S_STOP\n");
-	  }
-#endif
-	  if (azt_read_count!=0) printk("aztcd: discard data=%x frames\n",azt_read_count);
-	  while (azt_read_count!=0) {
-	    int i;
-	    if ( !(inb(STATUS_PORT) & AFL_DATA) ) {
-	      if (azt_read_mode==AZT_MODE_2)
-	         for (i=0; i<CD_FRAMESIZE_RAW; i++) inb(DATA_PORT);
-	      else   
-	         for (i=0; i<CD_FRAMESIZE; i++) inb(DATA_PORT);
-	    }
-	    azt_read_count--;
-	  }  
-	  if (aztSendCmd(ACMD_GET_STATUS)) RETURN("azt_poll 5");
-	  azt_state = AZT_S_STOPPING;
-	  AztTimeout = 1000;
-	  break;
+			if (azt_state != azt_state_old) {
+				azt_state_old = azt_state;
+				printk("AZT_S_STOP\n");
+			}
+#endif
+			if (azt_read_count != 0)
+				printk("aztcd: discard data=%x frames\n",
+				       azt_read_count);
+			while (azt_read_count != 0) {
+				int i;
+				if (!(inb(STATUS_PORT) & AFL_DATA)) {
+					if (azt_read_mode == AZT_MODE_2)
+						for (i = 0;
+						     i < CD_FRAMESIZE_RAW;
+						     i++)
+							inb(DATA_PORT);
+					else
+						for (i = 0;
+						     i < CD_FRAMESIZE; i++)
+							inb(DATA_PORT);
+				}
+				azt_read_count--;
+			}
+			if (aztSendCmd(ACMD_GET_STATUS))
+				RETURN("azt_poll 5");
+			azt_state = AZT_S_STOPPING;
+			AztTimeout = 1000;
+			break;
 
-	case AZT_S_STOPPING:
+		case AZT_S_STOPPING:
 #ifdef AZT_TEST3
-	  if (azt_state!=azt_state_old) {
-	    azt_state_old=azt_state;
-	    printk("AZT_S_STOPPING\n");
-	  }
-#endif
-
-	  if ((st = aztStatus()) == -1 && AztTimeout)
-	    break;
-
-	  if ((st != -1) && ((st & AST_DSK_CHG)||(st & AST_NOT_READY))) {
-	    aztDiskChanged = 1;
-	    aztTocUpToDate = 0;
-	    azt_invalidate_buffers();
-	    printk("aztcd: Disk Changed or Not Ready 4 - Unmount Disk!\n");
-	    end_request(0);
-	  }
-
+			if (azt_state != azt_state_old) {
+				azt_state_old = azt_state;
+				printk("AZT_S_STOPPING\n");
+			}
+#endif
+
+			if ((st = aztStatus()) == -1 && AztTimeout)
+				break;
+
+			if ((st != -1)
+			    && ((st & AST_DSK_CHG)
+				|| (st & AST_NOT_READY))) {
+				aztDiskChanged = 1;
+				aztTocUpToDate = 0;
+				azt_invalidate_buffers();
+				printk
+				    ("aztcd: Disk Changed or Not Ready 4 - Unmount Disk!\n");
+				end_request(0);
+			}
 
 #ifdef AZT_TEST3
-	  printk("CURRENT_VALID %d azt_mode %d\n",
-	     CURRENT_VALID, azt_mode);
+			printk("CURRENT_VALID %d azt_mode %d\n",
+			       CURRENT_VALID, azt_mode);
 #endif
 
-	  if (CURRENT_VALID) {
-	    if (st != -1) {
-	      if (azt_mode == 1) {
-		azt_state = AZT_S_READ;
-		loop_ctl = 1;
-		skip = 1;
-		break;
-	      } else {
-		azt_state = AZT_S_MODE;
-		loop_ctl = 1;
-		skip = 1;
-		break;
-	      }
-	    } else {
-	      azt_state = AZT_S_START;
-	      AztTimeout = 1;
-	    }
-	  } else {
-	    azt_state = AZT_S_IDLE;
-	    return;
-	  }
-	  break;
+			if (CURRENT_VALID) {
+				if (st != -1) {
+					if (azt_mode == 1) {
+						azt_state = AZT_S_READ;
+						loop_ctl = 1;
+						skip = 1;
+						break;
+					} else {
+						azt_state = AZT_S_MODE;
+						loop_ctl = 1;
+						skip = 1;
+						break;
+					}
+				} else {
+					azt_state = AZT_S_START;
+					AztTimeout = 1;
+				}
+			} else {
+				azt_state = AZT_S_IDLE;
+				return;
+			}
+			break;
+
+		default:
+			printk("aztcd: invalid state %d\n", azt_state);
+			return;
+		}		/* case */
+	}			/* while */
 
-	default:
-	  printk("aztcd: invalid state %d\n", azt_state);
-	  return;
-      }  /* case */
-    } /* while */
-  
-
-   if (!AztTimeout--) 
-    { printk("aztcd: timeout in state %d\n", azt_state);
-      azt_state = AZT_S_STOP;
-      if (aztSendCmd(ACMD_STOP)) RETURN("azt_poll 6"); 
-      STEN_LOW_WAIT;     
-    };
 
-  SET_TIMER(azt_poll, HZ/100);
+	if (!AztTimeout--) {
+		printk("aztcd: timeout in state %d\n", azt_state);
+		azt_state = AZT_S_STOP;
+		if (aztSendCmd(ACMD_STOP))
+			RETURN("azt_poll 6");
+		STEN_LOW_WAIT;
+	};
+
+	SET_TIMER(azt_poll, HZ / 100);
 }
 
 
@@ -2253,28 +2461,34 @@
   ###########################################################################
 */
 static void azt_hsg2msf(long hsg, struct msf *msf)
-{       hsg += 150;
-	msf -> min = hsg / 4500;
+{
+	hsg += 150;
+	msf->min = hsg / 4500;
 	hsg %= 4500;
-	msf -> sec = hsg / 75;
-	msf -> frame = hsg % 75;
+	msf->sec = hsg / 75;
+	msf->frame = hsg % 75;
 #ifdef AZT_DEBUG
-	if (msf->min  >=70) printk("aztcd: Error hsg2msf address Minutes\n");
-	if (msf->sec  >=60) printk("aztcd: Error hsg2msf address Seconds\n");
-	if (msf->frame>=75) printk("aztcd: Error hsg2msf address Frames\n");
-#endif
-	azt_bin2bcd(&msf -> min);           /* convert to BCD */
-	azt_bin2bcd(&msf -> sec);
-	azt_bin2bcd(&msf -> frame);
+	if (msf->min >= 70)
+		printk("aztcd: Error hsg2msf address Minutes\n");
+	if (msf->sec >= 60)
+		printk("aztcd: Error hsg2msf address Seconds\n");
+	if (msf->frame >= 75)
+		printk("aztcd: Error hsg2msf address Frames\n");
+#endif
+	azt_bin2bcd(&msf->min);	/* convert to BCD */
+	azt_bin2bcd(&msf->sec);
+	azt_bin2bcd(&msf->frame);
 }
 
 static long azt_msf2hsg(struct msf *mp)
-{ return azt_bcd2bin(mp -> frame) + azt_bcd2bin(mp -> sec) * 75
-		                  + azt_bcd2bin(mp -> min) * 4500 - CD_MSF_OFFSET;
+{
+	return azt_bcd2bin(mp->frame) + azt_bcd2bin(mp->sec) * 75
+	    + azt_bcd2bin(mp->min) * 4500 - CD_MSF_OFFSET;
 }
 
 static void azt_bin2bcd(unsigned char *p)
-{       int u, t;
+{
+	int u, t;
 
 	u = *p % 10;
 	t = *p / 10;
@@ -2282,5 +2496,9 @@
 }
 
 static int azt_bcd2bin(unsigned char bcd)
-{       return (bcd >> 4) * 10 + (bcd & 0xF);
+{
+	return (bcd >> 4) * 10 + (bcd & 0xF);
 }
+
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/cdrom/cdu31a.c linux/drivers/cdrom/cdu31a.c
--- v2.4.9/linux/drivers/cdrom/cdu31a.c	Fri Feb  9 11:30:22 2001
+++ linux/drivers/cdrom/cdu31a.c	Fri Sep  7 09:28:38 2001
@@ -179,7 +179,7 @@
 #define MAJOR_NR CDU31A_CDROM_MAJOR
 #include <linux/blk.h>
 
-#define CDU31A_READAHEAD 4  /* 128 sector, 64kB, 32 reads read-ahead */
+#define CDU31A_READAHEAD 4	/* 128 sector, 64kB, 32 reads read-ahead */
 #define CDU31A_MAX_CONSECUTIVE_ATTENTIONS 10
 
 #define DEBUG 0
@@ -192,25 +192,12 @@
 ** Default is polled and no DMA.  DMA is not recommended for double-speed
 ** drives.
 */
-static struct
-{
-   unsigned short base;         /* I/O Base Address */
-   short          int_num;      /* Interrupt Number (-1 means scan for it,
-                                   0 means don't use) */
-} cdu31a_addresses[] __initdata =
-{
-#if 0	/* No autoconfig any more. See Note at beginning
-	   of this file. */
-   { 0x340,     0 },    /* Standard configuration Sony Interface */
-   { 0x1f88,    0 },    /* Fusion CD-16 */
-   { 0x230,     0 },    /* SoundBlaster 16 card */
-   { 0x360,     0 },    /* Secondary standard Sony Interface */
-   { 0x320,     0 },    /* Secondary standard Sony Interface */
-   { 0x330,     0 },    /* Secondary standard Sony Interface */
-   { 0x634,     0 },    /* Sound FX SC400 */
-   { 0x654,     0 },    /* Sound FX SC400 */
-#endif
-   { 0 }
+static struct {
+	unsigned short base;	/* I/O Base Address */
+	short int_num;		/* Interrupt Number (-1 means scan for it,
+				   0 means don't use) */
+} cdu31a_addresses[] __initdata = {
+	{0}
 };
 
 static int handle_sony_cd_attention(void);
@@ -220,17 +207,16 @@
 /*static int scd_open(struct inode *inode, struct file *filp);*/
 static int scd_open(struct cdrom_device_info *, int);
 static void do_sony_cd_cmd(unsigned char cmd,
-                           unsigned char *params,
-                           unsigned int num_params,
-                           unsigned char *result_buffer,
-                           unsigned int *result_size);
-static void size_to_buf(unsigned int size,
-                        unsigned char *buf);
+			   unsigned char *params,
+			   unsigned int num_params,
+			   unsigned char *result_buffer,
+			   unsigned int *result_size);
+static void size_to_buf(unsigned int size, unsigned char *buf);
 
 /* Parameters for the read-ahead. */
-static unsigned int sony_next_block;      /* Next 512 byte block offset */
-static unsigned int sony_blocks_left = 0; /* Number of 512 byte blocks left
-                                             in the current read command. */
+static unsigned int sony_next_block;	/* Next 512 byte block offset */
+static unsigned int sony_blocks_left = 0;	/* Number of 512 byte blocks left
+						   in the current read command. */
 
 
 /* The base I/O address of the Sony Interface.  This is a variable (not a
@@ -252,48 +238,48 @@
 static volatile unsigned short sony_cd_fifost_reg;
 
 
-static int sony_spun_up = 0;               /* Has the drive been spun up? */
+static int sony_spun_up = 0;	/* Has the drive been spun up? */
 
-static int sony_speed = 0;                 /* Last wanted speed */
+static int sony_speed = 0;	/* Last wanted speed */
 
-static int sony_xa_mode = 0;               /* Is an XA disk in the drive
-					      and the drive a CDU31A? */
+static int sony_xa_mode = 0;	/* Is an XA disk in the drive
+				   and the drive a CDU31A? */
 
-static int sony_raw_data_mode = 1;         /* 1 if data tracks, 0 if audio.
-                                              For raw data reads. */
+static int sony_raw_data_mode = 1;	/* 1 if data tracks, 0 if audio.
+					   For raw data reads. */
 
-static unsigned int sony_usage = 0;        /* How many processes have the
-                                              drive open. */
+static unsigned int sony_usage = 0;	/* How many processes have the
+					   drive open. */
 
-static int sony_pas_init = 0;		   /* Initialize the Pro-Audio
-					      Spectrum card? */
+static int sony_pas_init = 0;	/* Initialize the Pro-Audio
+				   Spectrum card? */
 
-static struct s_sony_session_toc single_toc;  /* Holds the
-					         table of
-					         contents. */
+static struct s_sony_session_toc single_toc;	/* Holds the
+						   table of
+						   contents. */
 
-static struct s_all_sessions_toc sony_toc; /* entries gathered from all
-                                                sessions */
+static struct s_all_sessions_toc sony_toc;	/* entries gathered from all
+						   sessions */
 
-static int sony_toc_read = 0;		   /* Has the TOC been read for
-					      the drive? */
+static int sony_toc_read = 0;	/* Has the TOC been read for
+				   the drive? */
 
-static struct s_sony_subcode last_sony_subcode; /* Points to the last
-                                                   subcode address read */
+static struct s_sony_subcode last_sony_subcode;	/* Points to the last
+						   subcode address read */
 
-static volatile int sony_inuse = 0;  /* Is the drive in use?  Only one operation
-					at a time allowed */
+static volatile int sony_inuse = 0;	/* Is the drive in use?  Only one operation
+					   at a time allowed */
 
 static DECLARE_WAIT_QUEUE_HEAD(sony_wait);	/* Things waiting for the drive */
 
-static struct task_struct *has_cd_task = NULL;  /* The task that is currently
+static struct task_struct *has_cd_task = NULL;	/* The task that is currently
 						   using the CDROM drive, or
 						   NULL if none. */
 
-static int is_double_speed = 0; /* does the drive support double speed ? */
-static int is_a_cdu31a = 1;     /* Is the drive a CDU31A? */
+static int is_double_speed = 0;	/* does the drive support double speed ? */
+static int is_a_cdu31a = 1;	/* Is the drive a CDU31A? */
 
-static int is_auto_eject = 1;   /* Door has been locked? 1=No/0=Yes */
+static int is_auto_eject = 1;	/* Door has been locked? 1=No/0=Yes */
 
 /*
  * The audio status uses the values from read subchannel data as specified
@@ -319,7 +305,7 @@
    interrupts. */
 DECLARE_WAIT_QUEUE_HEAD(cdu31a_irq_wait);
 
-static int curr_control_reg = 0; /* Current value of the control register */
+static int curr_control_reg = 0;	/* Current value of the control register */
 
 /* A disk changed variable.  When a disk change is detected, it will
    all be set to TRUE.  As the upper layers ask for disk_changed status
@@ -348,25 +334,23 @@
  * This routine returns 1 if the disk has been changed since the last
  * check or 0 if it hasn't.
  */
-static int
-scd_disk_change(kdev_t full_dev)
+static int scd_disk_change(kdev_t full_dev)
 {
-   int retval;
+	int retval;
 
-   retval = disk_changed;
-   disk_changed = 0;
+	retval = disk_changed;
+	disk_changed = 0;
 
-   return retval;
+	return retval;
 }
 
 /*
  * Uniform cdrom interface function
  * report back, if disc has changed from time of last request.
  */
-static int
-scd_media_changed(struct cdrom_device_info *cdi, int disc_nr)
+static int scd_media_changed(struct cdrom_device_info *cdi, int disc_nr)
 {
-  return scd_disk_change(cdi->dev);
+	return scd_disk_change(cdi->dev);
 }
 
 /*
@@ -375,56 +359,51 @@
  */
 static int scd_drive_status(struct cdrom_device_info *cdi, int slot_nr)
 {
-  if (CDSL_CURRENT != slot_nr) {
-     /* we have no changer support */
-     return -EINVAL;
-  }
-  if (scd_spinup() == 0) {
-         sony_spun_up = 1;
-  }
-  return sony_spun_up ? CDS_DISC_OK : CDS_DRIVE_NOT_READY;
-}
-
-static inline void
-enable_interrupts(void)
-{
-   curr_control_reg |= (  SONY_ATTN_INT_EN_BIT
-                        | SONY_RES_RDY_INT_EN_BIT
-                        | SONY_DATA_RDY_INT_EN_BIT);
-   outb(curr_control_reg, sony_cd_control_reg);
-}
-
-static inline void
-disable_interrupts(void)
-{
-   curr_control_reg &= ~(  SONY_ATTN_INT_EN_BIT
-                         | SONY_RES_RDY_INT_EN_BIT
-                         | SONY_DATA_RDY_INT_EN_BIT);
-   outb(curr_control_reg, sony_cd_control_reg);
+	if (CDSL_CURRENT != slot_nr) {
+		/* we have no changer support */
+		return -EINVAL;
+	}
+	if (scd_spinup() == 0) {
+		sony_spun_up = 1;
+	}
+	return sony_spun_up ? CDS_DISC_OK : CDS_DRIVE_NOT_READY;
+}
+
+static inline void enable_interrupts(void)
+{
+	curr_control_reg |= (SONY_ATTN_INT_EN_BIT
+			     | SONY_RES_RDY_INT_EN_BIT
+			     | SONY_DATA_RDY_INT_EN_BIT);
+	outb(curr_control_reg, sony_cd_control_reg);
+}
+
+static inline void disable_interrupts(void)
+{
+	curr_control_reg &= ~(SONY_ATTN_INT_EN_BIT
+			      | SONY_RES_RDY_INT_EN_BIT
+			      | SONY_DATA_RDY_INT_EN_BIT);
+	outb(curr_control_reg, sony_cd_control_reg);
 }
 
 /*
  * Wait a little while (used for polling the drive).  If in initialization,
  * setting a timeout doesn't work, so just loop for a while.
  */
-static inline void
-sony_sleep(void)
+static inline void sony_sleep(void)
 {
-   unsigned long flags;
+	unsigned long flags;
 
-   if (cdu31a_irq <= 0)
-   {
-      current->state = TASK_INTERRUPTIBLE;
-      schedule_timeout(0);
-   }
-   else /* Interrupt driven */
-   {
-      save_flags(flags);
-      cli();
-      enable_interrupts();
-      interruptible_sleep_on(&cdu31a_irq_wait);
-      restore_flags(flags);
-   }
+	if (cdu31a_irq <= 0) {
+		current->state = TASK_INTERRUPTIBLE;
+		schedule_timeout(0);
+	} else {		/* Interrupt driven */
+
+		save_flags(flags);
+		cli();
+		enable_interrupts();
+		interruptible_sleep_on(&cdu31a_irq_wait);
+		restore_flags(flags);
+	}
 }
 
 
@@ -432,272 +411,276 @@
  * The following are convenience routine to read various status and set
  * various conditions in the drive.
  */
-static inline int
-is_attention(void)
+static inline int is_attention(void)
 {
-   return((inb(sony_cd_status_reg) & SONY_ATTN_BIT) != 0);
+	return ((inb(sony_cd_status_reg) & SONY_ATTN_BIT) != 0);
 }
 
-static inline int
-is_busy(void)
+static inline int is_busy(void)
 {
-   return((inb(sony_cd_status_reg) & SONY_BUSY_BIT) != 0);
+	return ((inb(sony_cd_status_reg) & SONY_BUSY_BIT) != 0);
 }
 
-static inline int
-is_data_ready(void)
+static inline int is_data_ready(void)
 {
-   return((inb(sony_cd_status_reg) & SONY_DATA_RDY_BIT) != 0);
+	return ((inb(sony_cd_status_reg) & SONY_DATA_RDY_BIT) != 0);
 }
 
-static inline int
-is_data_requested(void)
+static inline int is_data_requested(void)
 {
-   return((inb(sony_cd_status_reg) & SONY_DATA_REQUEST_BIT) != 0);
+	return ((inb(sony_cd_status_reg) & SONY_DATA_REQUEST_BIT) != 0);
 }
 
-static inline int
-is_result_ready(void)
+static inline int is_result_ready(void)
 {
-   return((inb(sony_cd_status_reg) & SONY_RES_RDY_BIT) != 0);
+	return ((inb(sony_cd_status_reg) & SONY_RES_RDY_BIT) != 0);
 }
 
-static inline int
-is_param_write_rdy(void)
+static inline int is_param_write_rdy(void)
 {
-   return((inb(sony_cd_fifost_reg) & SONY_PARAM_WRITE_RDY_BIT) != 0);
+	return ((inb(sony_cd_fifost_reg) & SONY_PARAM_WRITE_RDY_BIT) != 0);
 }
 
-static inline int
-is_result_reg_not_empty(void)
+static inline int is_result_reg_not_empty(void)
 {
-   return((inb(sony_cd_fifost_reg) & SONY_RES_REG_NOT_EMP_BIT) != 0);
+	return ((inb(sony_cd_fifost_reg) & SONY_RES_REG_NOT_EMP_BIT) != 0);
 }
 
-static inline void
-reset_drive(void)
+static inline void reset_drive(void)
 {
-   curr_control_reg = 0;
-   readahead_dataleft = 0;
-   sony_toc_read = 0;
-   outb(SONY_DRIVE_RESET_BIT, sony_cd_control_reg);
+	curr_control_reg = 0;
+	readahead_dataleft = 0;
+	sony_toc_read = 0;
+	outb(SONY_DRIVE_RESET_BIT, sony_cd_control_reg);
 }
 
 /*
  * Uniform cdrom interface function
  * reset drive and return when it is ready
  */
-static int scd_reset(struct cdrom_device_info * cdi)
+static int scd_reset(struct cdrom_device_info *cdi)
 {
-  int retry_count;
+	int retry_count;
 
-  reset_drive();
+	reset_drive();
 
-  retry_count = jiffies + SONY_RESET_TIMEOUT;
-  while (time_before(jiffies, retry_count) && (!is_attention()))
-  {
-     sony_sleep();
-  }
+	retry_count = jiffies + SONY_RESET_TIMEOUT;
+	while (time_before(jiffies, retry_count) && (!is_attention())) {
+		sony_sleep();
+	}
 
-  return 0;
+	return 0;
 }
 
-static inline void
-clear_attention(void)
+static inline void clear_attention(void)
 {
-   outb(curr_control_reg | SONY_ATTN_CLR_BIT, sony_cd_control_reg);
+	outb(curr_control_reg | SONY_ATTN_CLR_BIT, sony_cd_control_reg);
 }
 
-static inline void
-clear_result_ready(void)
+static inline void clear_result_ready(void)
 {
-   outb(curr_control_reg | SONY_RES_RDY_CLR_BIT, sony_cd_control_reg);
+	outb(curr_control_reg | SONY_RES_RDY_CLR_BIT, sony_cd_control_reg);
 }
 
-static inline void
-clear_data_ready(void)
+static inline void clear_data_ready(void)
 {
-   outb(curr_control_reg | SONY_DATA_RDY_CLR_BIT, sony_cd_control_reg);
+	outb(curr_control_reg | SONY_DATA_RDY_CLR_BIT,
+	     sony_cd_control_reg);
 }
 
-static inline void
-clear_param_reg(void)
+static inline void clear_param_reg(void)
 {
-   outb(curr_control_reg | SONY_PARAM_CLR_BIT, sony_cd_control_reg);
+	outb(curr_control_reg | SONY_PARAM_CLR_BIT, sony_cd_control_reg);
 }
 
-static inline unsigned char
-read_status_register(void)
+static inline unsigned char read_status_register(void)
 {
-   return(inb(sony_cd_status_reg));
+	return (inb(sony_cd_status_reg));
 }
 
-static inline unsigned char
-read_result_register(void)
+static inline unsigned char read_result_register(void)
 {
-   return(inb(sony_cd_result_reg));
+	return (inb(sony_cd_result_reg));
 }
 
-static inline unsigned char
-read_data_register(void)
+static inline unsigned char read_data_register(void)
 {
-   return(inb(sony_cd_read_reg));
+	return (inb(sony_cd_read_reg));
 }
 
-static inline void
-write_param(unsigned char param)
+static inline void write_param(unsigned char param)
 {
-   outb(param, sony_cd_param_reg);
+	outb(param, sony_cd_param_reg);
 }
 
-static inline void
-write_cmd(unsigned char cmd)
+static inline void write_cmd(unsigned char cmd)
 {
-   outb(curr_control_reg | SONY_RES_RDY_INT_EN_BIT, sony_cd_control_reg);
-   outb(cmd, sony_cd_cmd_reg);
+	outb(curr_control_reg | SONY_RES_RDY_INT_EN_BIT,
+	     sony_cd_control_reg);
+	outb(cmd, sony_cd_cmd_reg);
 }
 
-static void
-cdu31a_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static void cdu31a_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-   unsigned char val;
+	unsigned char val;
+
+	if (abort_read_started) {
+		/* We might be waiting for an abort to finish.  Don't
+		   disable interrupts yet, though, because we handle
+		   this one here. */
+		/* Clear out the result registers. */
+		while (is_result_reg_not_empty()) {
+			val = read_result_register();
+		}
+		clear_data_ready();
+		clear_result_ready();
 
-   if (abort_read_started)
-   {
-      /* We might be waiting for an abort to finish.  Don't
-         disable interrupts yet, though, because we handle
-         this one here. */
-      /* Clear out the result registers. */
-      while (is_result_reg_not_empty())
-      {
-         val = read_result_register();
-      }
-      clear_data_ready();
-      clear_result_ready();
-
-      /* Clear out the data */
-      while (is_data_requested())
-      {
-         val = read_data_register();
-      }
-      abort_read_started = 0;
-
-      /* If something was waiting, wake it up now. */
-      if (waitqueue_active(&cdu31a_irq_wait))
-      {
-         disable_interrupts();
-         wake_up(&cdu31a_irq_wait);
-      }
-   }
-   else if (waitqueue_active(&cdu31a_irq_wait))
-   {
-      disable_interrupts();
-      wake_up(&cdu31a_irq_wait);
-   }
-   else
-   {
-      disable_interrupts();
-      printk("CDU31A: Got an interrupt but nothing was waiting\n");
-   }
+		/* Clear out the data */
+		while (is_data_requested()) {
+			val = read_data_register();
+		}
+		abort_read_started = 0;
+
+		/* If something was waiting, wake it up now. */
+		if (waitqueue_active(&cdu31a_irq_wait)) {
+			disable_interrupts();
+			wake_up(&cdu31a_irq_wait);
+		}
+	} else if (waitqueue_active(&cdu31a_irq_wait)) {
+		disable_interrupts();
+		wake_up(&cdu31a_irq_wait);
+	} else {
+		disable_interrupts();
+		printk
+		    ("CDU31A: Got an interrupt but nothing was waiting\n");
+	}
 }
 
 /*
  * give more verbose error messages
  */
-static unsigned char *translate_error( unsigned char err_code )
+static unsigned char *translate_error(unsigned char err_code)
 {
-   static unsigned char errbuf[80];
+	static unsigned char errbuf[80];
 
-   switch (err_code) {
-     case 0x10: return "illegal command ";
-     case 0x11: return "illegal parameter ";
-
-     case 0x20: return "not loaded ";
-     case 0x21: return "no disc ";
-     case 0x22: return "not spinning ";
-     case 0x23: return "spinning ";
-     case 0x25: return "spindle servo ";
-     case 0x26: return "focus servo ";
-     case 0x29: return "eject mechanism ";
-     case 0x2a: return "audio playing ";
-     case 0x2c: return "emergency eject ";
-
-     case 0x30: return "focus ";
-     case 0x31: return "frame sync ";
-     case 0x32: return "subcode address ";
-     case 0x33: return "block sync ";
-     case 0x34: return "header address ";
-
-     case 0x40: return "illegal track read ";
-     case 0x41: return "mode 0 read ";
-     case 0x42: return "illegal mode read ";
-     case 0x43: return "illegal block size read ";
-     case 0x44: return "mode read ";
-     case 0x45: return "form read ";
-     case 0x46: return "leadout read ";
-     case 0x47: return "buffer overrun ";
-
-     case 0x53: return "unrecoverable CIRC ";
-     case 0x57: return "unrecoverable LECC ";
-
-     case 0x60: return "no TOC ";
-     case 0x61: return "invalid subcode data ";
-     case 0x63: return "focus on TOC read ";
-     case 0x64: return "frame sync on TOC read ";
-     case 0x65: return "TOC data ";
-
-     case 0x70: return "hardware failure ";
-     case 0x91: return "leadin ";
-     case 0x92: return "leadout ";
-     case 0x93: return "data track ";
-   }
-   sprintf(errbuf, "unknown 0x%02x ", err_code);
-   return errbuf;
+	switch (err_code) {
+	case 0x10:
+		return "illegal command ";
+	case 0x11:
+		return "illegal parameter ";
+
+	case 0x20:
+		return "not loaded ";
+	case 0x21:
+		return "no disc ";
+	case 0x22:
+		return "not spinning ";
+	case 0x23:
+		return "spinning ";
+	case 0x25:
+		return "spindle servo ";
+	case 0x26:
+		return "focus servo ";
+	case 0x29:
+		return "eject mechanism ";
+	case 0x2a:
+		return "audio playing ";
+	case 0x2c:
+		return "emergency eject ";
+
+	case 0x30:
+		return "focus ";
+	case 0x31:
+		return "frame sync ";
+	case 0x32:
+		return "subcode address ";
+	case 0x33:
+		return "block sync ";
+	case 0x34:
+		return "header address ";
+
+	case 0x40:
+		return "illegal track read ";
+	case 0x41:
+		return "mode 0 read ";
+	case 0x42:
+		return "illegal mode read ";
+	case 0x43:
+		return "illegal block size read ";
+	case 0x44:
+		return "mode read ";
+	case 0x45:
+		return "form read ";
+	case 0x46:
+		return "leadout read ";
+	case 0x47:
+		return "buffer overrun ";
+
+	case 0x53:
+		return "unrecoverable CIRC ";
+	case 0x57:
+		return "unrecoverable LECC ";
+
+	case 0x60:
+		return "no TOC ";
+	case 0x61:
+		return "invalid subcode data ";
+	case 0x63:
+		return "focus on TOC read ";
+	case 0x64:
+		return "frame sync on TOC read ";
+	case 0x65:
+		return "TOC data ";
+
+	case 0x70:
+		return "hardware failure ";
+	case 0x91:
+		return "leadin ";
+	case 0x92:
+		return "leadout ";
+	case 0x93:
+		return "data track ";
+	}
+	sprintf(errbuf, "unknown 0x%02x ", err_code);
+	return errbuf;
 }
 
 /*
  * Set the drive parameters so the drive will auto-spin-up when a
  * disk is inserted.
  */
-static void
-set_drive_params(int want_doublespeed)
+static void set_drive_params(int want_doublespeed)
 {
-   unsigned char res_reg[12];
-   unsigned int res_size;
-   unsigned char params[3];
-
-
-   params[0] = SONY_SD_AUTO_SPIN_DOWN_TIME;
-   params[1] = 0x00; /* Never spin down the drive. */
-   do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD,
-                  params,
-                  2,
-                  res_reg,
-                  &res_size);
-   if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20))
-   {
-      printk("  Unable to set spin-down time: 0x%2.2x\n", res_reg[1]);
-   }
-
-   params[0] = SONY_SD_MECH_CONTROL;
-   params[1] = SONY_AUTO_SPIN_UP_BIT; /* Set auto spin up */
-
-   if (is_auto_eject) params[1] |= SONY_AUTO_EJECT_BIT;
-   
-   if (is_double_speed && want_doublespeed)
-   {
-      params[1] |= SONY_DOUBLE_SPEED_BIT; /* Set the drive to double speed if 
-                                             possible */
-   }
-   do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD,
-                  params,
-                  2,
-                  res_reg,
-                  &res_size);
-   if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20))
-   {
-      printk("  Unable to set mechanical parameters: 0x%2.2x\n", res_reg[1]);
-   }
+	unsigned char res_reg[12];
+	unsigned int res_size;
+	unsigned char params[3];
+
+
+	params[0] = SONY_SD_AUTO_SPIN_DOWN_TIME;
+	params[1] = 0x00;	/* Never spin down the drive. */
+	do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD,
+		       params, 2, res_reg, &res_size);
+	if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20)) {
+		printk("  Unable to set spin-down time: 0x%2.2x\n",
+		       res_reg[1]);
+	}
+
+	params[0] = SONY_SD_MECH_CONTROL;
+	params[1] = SONY_AUTO_SPIN_UP_BIT;	/* Set auto spin up */
+
+	if (is_auto_eject)
+		params[1] |= SONY_AUTO_EJECT_BIT;
+
+	if (is_double_speed && want_doublespeed) {
+		params[1] |= SONY_DOUBLE_SPEED_BIT;	/* Set the drive to double speed if 
+							   possible */
+	}
+	do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD,
+		       params, 2, res_reg, &res_size);
+	if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20)) {
+		printk("  Unable to set mechanical parameters: 0x%2.2x\n",
+		       res_reg[1]);
+	}
 }
 
 /*
@@ -706,13 +689,13 @@
  */
 static int scd_select_speed(struct cdrom_device_info *cdi, int speed)
 {
-  if (speed == 0)
-    sony_speed = 1;
-  else 
-    sony_speed = speed - 1;
+	if (speed == 0)
+		sony_speed = 1;
+	else
+		sony_speed = speed - 1;
 
-  set_drive_params(sony_speed);
-  return 0;
+	set_drive_params(sony_speed);
+	return 0;
 }
 
 /*
@@ -721,77 +704,69 @@
  */
 static int scd_lock_door(struct cdrom_device_info *cdi, int lock)
 {
-   if (lock == 0 && sony_usage == 1)
-   {
-      /* Unlock the door, only if nobody is using the drive */
-      is_auto_eject = 1;
-   } else {
-      is_auto_eject = 0;
-   }
-   set_drive_params(sony_speed);
-   return 0;
+	if (lock == 0 && sony_usage == 1) {
+		/* Unlock the door, only if nobody is using the drive */
+		is_auto_eject = 1;
+	} else {
+		is_auto_eject = 0;
+	}
+	set_drive_params(sony_speed);
+	return 0;
 }
 
 /*
  * This code will reset the drive and attempt to restore sane parameters.
  */
-static void
-restart_on_error(void)
+static void restart_on_error(void)
 {
-   unsigned char res_reg[12];
-   unsigned int res_size;
-   unsigned int retry_count;
-
-
-   printk("cdu31a: Resetting drive on error\n");
-   reset_drive();
-   retry_count = jiffies + SONY_RESET_TIMEOUT;
-   while (time_before(jiffies, retry_count) && (!is_attention()))
-   {
-      sony_sleep();
-   }
-   set_drive_params(sony_speed);
-   do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, &res_size);
-   if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20))
-   {
-      printk("cdu31a: Unable to spin up drive: 0x%2.2x\n", res_reg[1]);
-   }
+	unsigned char res_reg[12];
+	unsigned int res_size;
+	unsigned int retry_count;
+
+
+	printk("cdu31a: Resetting drive on error\n");
+	reset_drive();
+	retry_count = jiffies + SONY_RESET_TIMEOUT;
+	while (time_before(jiffies, retry_count) && (!is_attention())) {
+		sony_sleep();
+	}
+	set_drive_params(sony_speed);
+	do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, &res_size);
+	if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20)) {
+		printk("cdu31a: Unable to spin up drive: 0x%2.2x\n",
+		       res_reg[1]);
+	}
 
-   current->state = TASK_INTERRUPTIBLE;
-   schedule_timeout(2*HZ);
+	current->state = TASK_INTERRUPTIBLE;
+	schedule_timeout(2 * HZ);
 
-   sony_get_toc();
+	sony_get_toc();
 }
 
 /*
  * This routine writes data to the parameter register.  Since this should
  * happen fairly fast, it is polled with no OS waits between.
  */
-static int
-write_params(unsigned char *params,
-             int num_params)
+static int write_params(unsigned char *params, int num_params)
 {
-   unsigned int retry_count;
+	unsigned int retry_count;
 
 
-   retry_count = SONY_READY_RETRIES;
-   while ((retry_count > 0) && (!is_param_write_rdy()))
-   {
-      retry_count--;
-   }
-   if (!is_param_write_rdy())
-   {
-      return -EIO;
-   }
-
-   while (num_params > 0)
-   {
-      write_param(*params);
-      params++;
-      num_params--;
-   }
+	retry_count = SONY_READY_RETRIES;
+	while ((retry_count > 0) && (!is_param_write_rdy())) {
+		retry_count--;
+	}
+	if (!is_param_write_rdy()) {
+		return -EIO;
+	}
+
+	while (num_params > 0) {
+		write_param(*params);
+		params++;
+		num_params--;
+	}
 
-   return 0;
+	return 0;
 }
 
 
@@ -802,134 +777,125 @@
  * the drive manual.
  */
 static void
-get_result(unsigned char *result_buffer,
-           unsigned int *result_size)
+get_result(unsigned char *result_buffer, unsigned int *result_size)
 {
-   unsigned char a, b;
-   int i;
-   unsigned int retry_count;
-
-
-   while (handle_sony_cd_attention())
-      ;
-   /* Wait for the result data to be ready */
-   retry_count = jiffies + SONY_JIFFIES_TIMEOUT;
-   while (time_before(jiffies, retry_count) && (is_busy() || (!(is_result_ready()))))
-   {
-      sony_sleep();
-
-      while (handle_sony_cd_attention())
-         ;
-   }
-   if (is_busy() || (!(is_result_ready())))
-   {
-#if DEBUG
-      printk("CDU31A timeout out %d\n", __LINE__);
-#endif
-      result_buffer[0] = 0x20;
-      result_buffer[1] = SONY_TIMEOUT_OP_ERR;
-      *result_size = 2;
-      return;
-   }
-
-   /*
-    * Get the first two bytes.  This determines what else needs
-    * to be done.
-    */
-   clear_result_ready();
-   a = read_result_register();
-   *result_buffer = a;
-   result_buffer++;
-
-   /* Check for block error status result. */
-   if ((a & 0xf0) == 0x50)
-   {
-      *result_size = 1;
-      return;
-   }
-
-   b = read_result_register();
-   *result_buffer = b;
-   result_buffer++;
-   *result_size = 2;
-
-   /*
-    * 0x20 means an error occurred.  Byte 2 will have the error code.
-    * Otherwise, the command succeeded, byte 2 will have the count of
-    * how many more status bytes are coming.
-    *
-    * The result register can be read 10 bytes at a time, a wait for
-    * result ready to be asserted must be done between every 10 bytes.
-    */
-   if ((a & 0xf0) != 0x20)
-   {
-      if (b > 8)
-      {
-         for (i=0; i<8; i++)
-         {
-            *result_buffer = read_result_register();
-            result_buffer++;
-            (*result_size)++;
-         }
-         b = b - 8;
-
-         while (b > 10)
-         {
-            retry_count = SONY_READY_RETRIES;
-            while ((retry_count > 0) && (!is_result_ready()))
-            {
-               retry_count--;
-            }
-            if (!is_result_ready())
-            {
-#if DEBUG
-               printk("CDU31A timeout out %d\n", __LINE__);
-#endif
-               result_buffer[0] = 0x20;
-               result_buffer[1] = SONY_TIMEOUT_OP_ERR;
-               *result_size = 2;
-               return;
-            }
-
-            clear_result_ready();
-                                
-            for (i=0; i<10; i++)
-            {
-               *result_buffer = read_result_register();
-               result_buffer++;
-               (*result_size)++;
-            }
-            b = b - 10;
-         }
-
-         if (b > 0)
-         {
-            retry_count = SONY_READY_RETRIES;
-            while ((retry_count > 0) && (!is_result_ready()))
-            {
-               retry_count--;
-            }
-            if (!is_result_ready())
-            {
-#if DEBUG
-               printk("CDU31A timeout out %d\n", __LINE__);
-#endif
-               result_buffer[0] = 0x20;
-               result_buffer[1] = SONY_TIMEOUT_OP_ERR;
-               *result_size = 2;
-               return;
-            }
-         }
-      }
-
-      while (b > 0)
-      {
-         *result_buffer = read_result_register();
-         result_buffer++;
-         (*result_size)++;
-         b--;
-      }
-   }
+	unsigned char a, b;
+	int i;
+	unsigned int retry_count;
+
+
+	while (handle_sony_cd_attention());
+	/* Wait for the result data to be ready */
+	retry_count = jiffies + SONY_JIFFIES_TIMEOUT;
+	while (time_before(jiffies, retry_count)
+	       && (is_busy() || (!(is_result_ready())))) {
+		sony_sleep();
+
+		while (handle_sony_cd_attention());
+	}
+	if (is_busy() || (!(is_result_ready()))) {
+#if DEBUG
+		printk("CDU31A timeout out %d\n", __LINE__);
+#endif
+		result_buffer[0] = 0x20;
+		result_buffer[1] = SONY_TIMEOUT_OP_ERR;
+		*result_size = 2;
+		return;
+	}
+
+	/*
+	 * Get the first two bytes.  This determines what else needs
+	 * to be done.
+	 */
+	clear_result_ready();
+	a = read_result_register();
+	*result_buffer = a;
+	result_buffer++;
+
+	/* Check for block error status result. */
+	if ((a & 0xf0) == 0x50) {
+		*result_size = 1;
+		return;
+	}
+
+	b = read_result_register();
+	*result_buffer = b;
+	result_buffer++;
+	*result_size = 2;
+
+	/*
+	 * 0x20 means an error occurred.  Byte 2 will have the error code.
+	 * Otherwise, the command succeeded, byte 2 will have the count of
+	 * how many more status bytes are coming.
+	 *
+	 * The result register can be read 10 bytes at a time, a wait for
+	 * result ready to be asserted must be done between every 10 bytes.
+	 */
+	if ((a & 0xf0) != 0x20) {
+		if (b > 8) {
+			for (i = 0; i < 8; i++) {
+				*result_buffer = read_result_register();
+				result_buffer++;
+				(*result_size)++;
+			}
+			b = b - 8;
+
+			while (b > 10) {
+				retry_count = SONY_READY_RETRIES;
+				while ((retry_count > 0)
+				       && (!is_result_ready())) {
+					retry_count--;
+				}
+				if (!is_result_ready()) {
+#if DEBUG
+					printk("CDU31A timeout out %d\n",
+					       __LINE__);
+#endif
+					result_buffer[0] = 0x20;
+					result_buffer[1] =
+					    SONY_TIMEOUT_OP_ERR;
+					*result_size = 2;
+					return;
+				}
+
+				clear_result_ready();
+
+				for (i = 0; i < 10; i++) {
+					*result_buffer =
+					    read_result_register();
+					result_buffer++;
+					(*result_size)++;
+				}
+				b = b - 10;
+			}
+
+			if (b > 0) {
+				retry_count = SONY_READY_RETRIES;
+				while ((retry_count > 0)
+				       && (!is_result_ready())) {
+					retry_count--;
+				}
+				if (!is_result_ready()) {
+#if DEBUG
+					printk("CDU31A timeout out %d\n",
+					       __LINE__);
+#endif
+					result_buffer[0] = 0x20;
+					result_buffer[1] =
+					    SONY_TIMEOUT_OP_ERR;
+					*result_size = 2;
+					return;
+				}
+			}
+		}
+
+		while (b > 0) {
+			*result_buffer = read_result_register();
+			result_buffer++;
+			(*result_size)++;
+			b--;
+		}
+	}
 }
 
 /*
@@ -939,95 +905,81 @@
  */
 static void
 do_sony_cd_cmd(unsigned char cmd,
-               unsigned char *params,
-               unsigned int num_params,
-               unsigned char *result_buffer,
-               unsigned int *result_size)
-{
-   unsigned int retry_count;
-   int num_retries;
-   int recursive_call;
-   unsigned long flags;
-
-
-   save_flags(flags);
-   cli();
-   if (current != has_cd_task) /* Allow recursive calls to this routine */
-   {
-      while (sony_inuse)
-      {
-         interruptible_sleep_on(&sony_wait);
-         if (signal_pending(current))
-         {
-            result_buffer[0] = 0x20;
-            result_buffer[1] = SONY_SIGNAL_OP_ERR;
-            *result_size = 2;
-            restore_flags(flags);
-            return;
-         }
-      }
-      sony_inuse = 1;
-      has_cd_task = current;
-      recursive_call = 0;
-   }
-   else
-   {
-      recursive_call = 1;
-   }
+	       unsigned char *params,
+	       unsigned int num_params,
+	       unsigned char *result_buffer, unsigned int *result_size)
+{
+	unsigned int retry_count;
+	int num_retries;
+	int recursive_call;
+	unsigned long flags;
+
+
+	save_flags(flags);
+	cli();
+	if (current != has_cd_task) {	/* Allow recursive calls to this routine */
+		while (sony_inuse) {
+			interruptible_sleep_on(&sony_wait);
+			if (signal_pending(current)) {
+				result_buffer[0] = 0x20;
+				result_buffer[1] = SONY_SIGNAL_OP_ERR;
+				*result_size = 2;
+				restore_flags(flags);
+				return;
+			}
+		}
+		sony_inuse = 1;
+		has_cd_task = current;
+		recursive_call = 0;
+	} else {
+		recursive_call = 1;
+	}
 
-   num_retries = 0;
+	num_retries = 0;
 retry_cd_operation:
 
-   while (handle_sony_cd_attention())
-      ;
+	while (handle_sony_cd_attention());
+
+	sti();
 
-   sti();
-   
-   retry_count = jiffies + SONY_JIFFIES_TIMEOUT;
-   while (time_before(jiffies, retry_count) && (is_busy()))
-   {
-      sony_sleep();
-      
-      while (handle_sony_cd_attention())
-         ;
-   }
-   if (is_busy())
-   {
-#if DEBUG
-      printk("CDU31A timeout out %d\n", __LINE__);
-#endif
-      result_buffer[0] = 0x20;
-      result_buffer[1] = SONY_TIMEOUT_OP_ERR;
-      *result_size = 2;
-   }
-   else
-   {
-      clear_result_ready();
-      clear_param_reg();
-
-      write_params(params, num_params);
-      write_cmd(cmd);
-
-      get_result(result_buffer, result_size);
-   }
-
-   if (   ((result_buffer[0] & 0xf0) == 0x20)
-       && (num_retries < MAX_CDU31A_RETRIES))
-   {
-      num_retries++;
-      current->state = TASK_INTERRUPTIBLE;
-      schedule_timeout(HZ/10);  /* Wait .1 seconds on retries */
-      goto retry_cd_operation;
-   }
-
-   if (!recursive_call)
-   {
-      has_cd_task = NULL;
-      sony_inuse = 0;
-      wake_up_interruptible(&sony_wait);
-   }
+	retry_count = jiffies + SONY_JIFFIES_TIMEOUT;
+	while (time_before(jiffies, retry_count) && (is_busy())) {
+		sony_sleep();
+
+		while (handle_sony_cd_attention());
+	}
+	if (is_busy()) {
+#if DEBUG
+		printk("CDU31A timeout out %d\n", __LINE__);
+#endif
+		result_buffer[0] = 0x20;
+		result_buffer[1] = SONY_TIMEOUT_OP_ERR;
+		*result_size = 2;
+	} else {
+		clear_result_ready();
+		clear_param_reg();
+
+		write_params(params, num_params);
+		write_cmd(cmd);
+
+		get_result(result_buffer, result_size);
+	}
+
+	if (((result_buffer[0] & 0xf0) == 0x20)
+	    && (num_retries < MAX_CDU31A_RETRIES)) {
+		num_retries++;
+		current->state = TASK_INTERRUPTIBLE;
+		schedule_timeout(HZ / 10);	/* Wait .1 seconds on retries */
+		goto retry_cd_operation;
+	}
+
+	if (!recursive_call) {
+		has_cd_task = NULL;
+		sony_inuse = 0;
+		wake_up_interruptible(&sony_wait);
+	}
 
-   restore_flags(flags);
+	restore_flags(flags);
 }
 
 
@@ -1040,120 +992,114 @@
  * a 0), and returns a 0 if it happens too many times.  This will help
  * prevent a lockup.
  */
-static int
-handle_sony_cd_attention(void)
+static int handle_sony_cd_attention(void)
 {
-   unsigned char atten_code;
-   static int num_consecutive_attentions = 0;
-   volatile int val;
+	unsigned char atten_code;
+	static int num_consecutive_attentions = 0;
+	volatile int val;
 
 
 #if 0*DEBUG
-   printk("Entering handle_sony_cd_attention\n");
+	printk("Entering handle_sony_cd_attention\n");
 #endif
-   if (is_attention())
-   {
-      if (num_consecutive_attentions > CDU31A_MAX_CONSECUTIVE_ATTENTIONS)
-      {
-         printk("cdu31a: Too many consecutive attentions: %d\n",
-                num_consecutive_attentions);
-         num_consecutive_attentions = 0;
-#if DEBUG
-         printk("Leaving handle_sony_cd_attention at %d\n", __LINE__);
-#endif
-         return(0);
-      }
-
-      clear_attention();
-      atten_code = read_result_register();
-
-      switch (atten_code)
-      {
-       /* Someone changed the CD.  Mark it as changed */
-      case SONY_MECH_LOADED_ATTN:
-         disk_changed = 1;
-	 sony_toc_read = 0;
-         sony_audio_status = CDROM_AUDIO_NO_STATUS;
-         sony_blocks_left = 0;
-         break;
-
-      case SONY_SPIN_DOWN_COMPLETE_ATTN:
-         /* Mark the disk as spun down. */
-         sony_spun_up = 0;
-         break;
-
-      case SONY_AUDIO_PLAY_DONE_ATTN:
-         sony_audio_status = CDROM_AUDIO_COMPLETED;
-         read_subcode();
-         break;
-
-      case SONY_EJECT_PUSHED_ATTN:
-         if (is_auto_eject)
-         {
-            sony_audio_status = CDROM_AUDIO_INVALID;
-         }
-         break;
-
-      case SONY_LEAD_IN_ERR_ATTN:
-      case SONY_LEAD_OUT_ERR_ATTN:
-      case SONY_DATA_TRACK_ERR_ATTN:
-      case SONY_AUDIO_PLAYBACK_ERR_ATTN:
-         sony_audio_status = CDROM_AUDIO_ERROR;
-         break;
-      }
-
-      num_consecutive_attentions++;
-#if DEBUG
-      printk("Leaving handle_sony_cd_attention at %d\n", __LINE__);
-#endif
-      return(1);
-   }
-   else if (abort_read_started)
-   {
-      while (is_result_reg_not_empty())
-      {
-         val = read_result_register();
-      }
-      clear_data_ready();
-      clear_result_ready();
-      /* Clear out the data */
-      while (is_data_requested())
-      {
-         val = read_data_register();
-      }
-      abort_read_started = 0;
+	if (is_attention()) {
+		if (num_consecutive_attentions >
+		    CDU31A_MAX_CONSECUTIVE_ATTENTIONS) {
+			printk
+			    ("cdu31a: Too many consecutive attentions: %d\n",
+			     num_consecutive_attentions);
+			num_consecutive_attentions = 0;
+#if DEBUG
+			printk("Leaving handle_sony_cd_attention at %d\n",
+			       __LINE__);
+#endif
+			return (0);
+		}
+
+		clear_attention();
+		atten_code = read_result_register();
+
+		switch (atten_code) {
+			/* Someone changed the CD.  Mark it as changed */
+		case SONY_MECH_LOADED_ATTN:
+			disk_changed = 1;
+			sony_toc_read = 0;
+			sony_audio_status = CDROM_AUDIO_NO_STATUS;
+			sony_blocks_left = 0;
+			break;
+
+		case SONY_SPIN_DOWN_COMPLETE_ATTN:
+			/* Mark the disk as spun down. */
+			sony_spun_up = 0;
+			break;
+
+		case SONY_AUDIO_PLAY_DONE_ATTN:
+			sony_audio_status = CDROM_AUDIO_COMPLETED;
+			read_subcode();
+			break;
+
+		case SONY_EJECT_PUSHED_ATTN:
+			if (is_auto_eject) {
+				sony_audio_status = CDROM_AUDIO_INVALID;
+			}
+			break;
+
+		case SONY_LEAD_IN_ERR_ATTN:
+		case SONY_LEAD_OUT_ERR_ATTN:
+		case SONY_DATA_TRACK_ERR_ATTN:
+		case SONY_AUDIO_PLAYBACK_ERR_ATTN:
+			sony_audio_status = CDROM_AUDIO_ERROR;
+			break;
+		}
+
+		num_consecutive_attentions++;
+#if DEBUG
+		printk("Leaving handle_sony_cd_attention at %d\n",
+		       __LINE__);
+#endif
+		return (1);
+	} else if (abort_read_started) {
+		while (is_result_reg_not_empty()) {
+			val = read_result_register();
+		}
+		clear_data_ready();
+		clear_result_ready();
+		/* Clear out the data */
+		while (is_data_requested()) {
+			val = read_data_register();
+		}
+		abort_read_started = 0;
 #if DEBUG
-      printk("Leaving handle_sony_cd_attention at %d\n", __LINE__);
+		printk("Leaving handle_sony_cd_attention at %d\n",
+		       __LINE__);
 #endif
-      return(1);
-   }
+		return (1);
+	}
 
-   num_consecutive_attentions = 0;
+	num_consecutive_attentions = 0;
 #if 0*DEBUG
-   printk("Leaving handle_sony_cd_attention at %d\n", __LINE__);
+	printk("Leaving handle_sony_cd_attention at %d\n", __LINE__);
 #endif
-   return(0);
+	return (0);
 }
 
 
 /* Convert from an integer 0-99 to BCD */
-static inline unsigned int
-int_to_bcd(unsigned int val)
+static inline unsigned int int_to_bcd(unsigned int val)
 {
-   int retval;
+	int retval;
 
 
-   retval = (val / 10) << 4;
-   retval = retval | val % 10;
-   return(retval);
+	retval = (val / 10) << 4;
+	retval = retval | val % 10;
+	return (retval);
 }
 
 
 /* Convert from BCD to an integer from 0-99 */
-static unsigned int
-bcd_to_int(unsigned int bcd)
+static unsigned int bcd_to_int(unsigned int bcd)
 {
-   return((((bcd >> 4) & 0x0f) * 10) + (bcd & 0x0f));
+	return ((((bcd >> 4) & 0x0f) * 10) + (bcd & 0x0f));
 }
 
 
@@ -1161,32 +1107,30 @@
  * Convert a logical sector value (like the OS would want to use for
  * a block device) to an MSF format.
  */
-static void
-log_to_msf(unsigned int log, unsigned char *msf)
+static void log_to_msf(unsigned int log, unsigned char *msf)
 {
-   log = log + LOG_START_OFFSET;
-   msf[0] = int_to_bcd(log / 4500);
-   log = log % 4500;
-   msf[1] = int_to_bcd(log / 75);
-   msf[2] = int_to_bcd(log % 75);
+	log = log + LOG_START_OFFSET;
+	msf[0] = int_to_bcd(log / 4500);
+	log = log % 4500;
+	msf[1] = int_to_bcd(log / 75);
+	msf[2] = int_to_bcd(log % 75);
 }
 
 
 /*
  * Convert an MSF format to a logical sector.
  */
-static unsigned int
-msf_to_log(unsigned char *msf)
+static unsigned int msf_to_log(unsigned char *msf)
 {
-   unsigned int log;
+	unsigned int log;
 
 
-   log = msf[2];
-   log += msf[1] * 75;
-   log += msf[0] * 4500;
-   log = log - LOG_START_OFFSET;
+	log = msf[2];
+	log += msf[1] * 75;
+	log += msf[0] * 4500;
+	log = log - LOG_START_OFFSET;
 
-   return log;
+	return log;
 }
 
 
@@ -1194,14 +1138,12 @@
  * Take in integer size value and put it into a buffer like
  * the drive would want to see a number-of-sector value.
  */
-static void
-size_to_buf(unsigned int size,
-            unsigned char *buf)
+static void size_to_buf(unsigned int size, unsigned char *buf)
 {
-   buf[0] = size / 65536;
-   size = size % 65536;
-   buf[1] = size / 256;
-   buf[2] = size % 256;
+	buf[0] = size / 65536;
+	size = size % 65536;
+	buf[1] = size / 256;
+	buf[2] = size % 256;
 }
 
 /* Starts a read operation. Returns 0 on success and 1 on failure. 
@@ -1211,430 +1153,380 @@
    operation if the requested sector is not the next one from the
    drive. */
 static int
-start_request(unsigned int sector,
-              unsigned int nsect,
-              int          read_nsect_only)
-{
-   unsigned char params[6];
-   unsigned int read_size;
-   unsigned int retry_count;
-
-
-#if DEBUG
-   printk("Entering start_request\n");
-#endif
-   log_to_msf(sector, params);
-   /* If requested, read exactly what was asked. */
-   if (read_nsect_only)
-   {
-      read_size = nsect;
-   }
-   /*
-    * If the full read-ahead would go beyond the end of the media, trim
-    * it back to read just till the end of the media.
-    */
-   else if ((sector + nsect) >= sony_toc.lead_out_start_lba)
-   {
-      read_size = sony_toc.lead_out_start_lba - sector;
-   }
-   /* Read the full readahead amount. */
-   else
-   {
-      read_size = CDU31A_READAHEAD / 4;
-   }
-   size_to_buf(read_size, &params[3]);
-
-   /*
-    * Clear any outstanding attentions and wait for the drive to
-    * complete any pending operations.
-    */
-   while (handle_sony_cd_attention())
-      ;
-
-   retry_count = jiffies + SONY_JIFFIES_TIMEOUT;
-   while (time_before(jiffies, retry_count) && (is_busy()))
-   {
-      sony_sleep();
-      
-      while (handle_sony_cd_attention())
-         ;
-   }
-
-   if (is_busy())
-   {
-      printk("CDU31A: Timeout while waiting to issue command\n");
-#if DEBUG
-      printk("Leaving start_request at %d\n", __LINE__);
-#endif
-      return(1);
-   }
-   else
-   {
-      /* Issue the command */
-      clear_result_ready();
-      clear_param_reg();
-
-      write_params(params, 6);
-      write_cmd(SONY_READ_BLKERR_STAT_CMD);
-
-      sony_blocks_left = read_size * 4;
-      sony_next_block = sector * 4;
-      readahead_dataleft = 0;
-      readahead_bad = 0;
+start_request(unsigned int sector, unsigned int nsect, int read_nsect_only)
+{
+	unsigned char params[6];
+	unsigned int read_size;
+	unsigned int retry_count;
+
+
+#if DEBUG
+	printk("Entering start_request\n");
+#endif
+	log_to_msf(sector, params);
+	/* If requested, read exactly what was asked. */
+	if (read_nsect_only) {
+		read_size = nsect;
+	}
+	/*
+	 * If the full read-ahead would go beyond the end of the media, trim
+	 * it back to read just till the end of the media.
+	 */
+	else if ((sector + nsect) >= sony_toc.lead_out_start_lba) {
+		read_size = sony_toc.lead_out_start_lba - sector;
+	}
+	/* Read the full readahead amount. */
+	else {
+		read_size = CDU31A_READAHEAD / 4;
+	}
+	size_to_buf(read_size, &params[3]);
+
+	/*
+	 * Clear any outstanding attentions and wait for the drive to
+	 * complete any pending operations.
+	 */
+	while (handle_sony_cd_attention());
+
+	retry_count = jiffies + SONY_JIFFIES_TIMEOUT;
+	while (time_before(jiffies, retry_count) && (is_busy())) {
+		sony_sleep();
+
+		while (handle_sony_cd_attention());
+	}
+
+	if (is_busy()) {
+		printk("CDU31A: Timeout while waiting to issue command\n");
+#if DEBUG
+		printk("Leaving start_request at %d\n", __LINE__);
+#endif
+		return (1);
+	} else {
+		/* Issue the command */
+		clear_result_ready();
+		clear_param_reg();
+
+		write_params(params, 6);
+		write_cmd(SONY_READ_BLKERR_STAT_CMD);
+
+		sony_blocks_left = read_size * 4;
+		sony_next_block = sector * 4;
+		readahead_dataleft = 0;
+		readahead_bad = 0;
 #if DEBUG
-      printk("Leaving start_request at %d\n", __LINE__);
+		printk("Leaving start_request at %d\n", __LINE__);
 #endif
-      return(0);
-   }
+		return (0);
+	}
 #if DEBUG
-   printk("Leaving start_request at %d\n", __LINE__);
+	printk("Leaving start_request at %d\n", __LINE__);
 #endif
 }
 
 /* Abort a pending read operation.  Clear all the drive status and
    readahead variables. */
-static void
-abort_read(void)
+static void abort_read(void)
 {
-   unsigned char result_reg[2];
-   int           result_size;
-   volatile int  val;
-
-
-   do_sony_cd_cmd(SONY_ABORT_CMD, NULL, 0, result_reg, &result_size);
-   if ((result_reg[0] & 0xf0) == 0x20)
-   {
-      printk("CDU31A: Error aborting read, %s error\n",
-             translate_error(
-             result_reg[1]));
-   }
-
-   while (is_result_reg_not_empty())
-   {
-      val = read_result_register();
-   }
-   clear_data_ready();
-   clear_result_ready();
-   /* Clear out the data */
-   while (is_data_requested())
-   {
-      val = read_data_register();
-   }
-
-   sony_blocks_left = 0;
-   readahead_dataleft = 0;
-   readahead_bad = 0;
+	unsigned char result_reg[2];
+	int result_size;
+	volatile int val;
+
+
+	do_sony_cd_cmd(SONY_ABORT_CMD, NULL, 0, result_reg, &result_size);
+	if ((result_reg[0] & 0xf0) == 0x20) {
+		printk("CDU31A: Error aborting read, %s error\n",
+		       translate_error(result_reg[1]));
+	}
+
+	while (is_result_reg_not_empty()) {
+		val = read_result_register();
+	}
+	clear_data_ready();
+	clear_result_ready();
+	/* Clear out the data */
+	while (is_data_requested()) {
+		val = read_data_register();
+	}
+
+	sony_blocks_left = 0;
+	readahead_dataleft = 0;
+	readahead_bad = 0;
 }
 
 /* Called when the timer times out.  This will abort the
    pending read operation. */
-static void
-handle_abort_timeout(unsigned long data)
+static void handle_abort_timeout(unsigned long data)
 {
-   unsigned long flags;
+	unsigned long flags;
 
 #if DEBUG
-   printk("Entering handle_abort_timeout\n");
+	printk("Entering handle_abort_timeout\n");
 #endif
-   save_flags(flags);
-   cli();
-   /* If it is in use, ignore it. */
-   if (!sony_inuse)
-   {
-      /* We can't use abort_read(), because it will sleep
-         or schedule in the timer interrupt.  Just start
-         the operation, finish it on the next access to
-         the drive. */
-      clear_result_ready();
-      clear_param_reg();
-      write_cmd(SONY_ABORT_CMD);
-
-      sony_blocks_left = 0;
-      readahead_dataleft = 0;
-      readahead_bad = 0;
-      abort_read_started = 1;
-   }
-   restore_flags(flags);
+	save_flags(flags);
+	cli();
+	/* If it is in use, ignore it. */
+	if (!sony_inuse) {
+		/* We can't use abort_read(), because it will sleep
+		   or schedule in the timer interrupt.  Just start
+		   the operation, finish it on the next access to
+		   the drive. */
+		clear_result_ready();
+		clear_param_reg();
+		write_cmd(SONY_ABORT_CMD);
+
+		sony_blocks_left = 0;
+		readahead_dataleft = 0;
+		readahead_bad = 0;
+		abort_read_started = 1;
+	}
+	restore_flags(flags);
 #if DEBUG
-   printk("Leaving handle_abort_timeout\n");
+	printk("Leaving handle_abort_timeout\n");
 #endif
 }
 
 /* Actually get data and status from the drive. */
 static void
-input_data(char         *buffer,
-           unsigned int bytesleft,
-           unsigned int nblocks,
-           unsigned int offset,
-           unsigned int skip)
-{
-   int i;
-   volatile unsigned char val;
+input_data(char *buffer,
+	   unsigned int bytesleft,
+	   unsigned int nblocks, unsigned int offset, unsigned int skip)
+{
+	int i;
+	volatile unsigned char val;
 
 
 #if DEBUG
-   printk("Entering input_data\n");
-#endif
-   /* If an XA disk on a CDU31A, skip the first 12 bytes of data from
-      the disk.  The real data is after that. */
-   if (sony_xa_mode)
-   {
-      for(i=0; i<CD_XA_HEAD; i++)
-      {
-         val = read_data_register();
-      }
-   }
-
-   clear_data_ready();
-
-   if (bytesleft == 2048) /* 2048 byte direct buffer transfer */
-   {
-      insb(sony_cd_read_reg, buffer, 2048);
-      readahead_dataleft = 0;
-   }
-   else
-   {
-      /* If the input read did not align with the beginning of the block,
-	 skip the necessary bytes. */
-      if (skip != 0)
-      {
-         insb(sony_cd_read_reg, readahead_buffer, skip);
-      }
-
-      /* Get the data into the buffer. */
-      insb(sony_cd_read_reg, &buffer[offset], bytesleft);
-
-      /* Get the rest of the data into the readahead buffer at the
-	 proper location. */
-      readahead_dataleft = (2048 - skip) - bytesleft;
-      insb(sony_cd_read_reg,
-           readahead_buffer + bytesleft,
-           readahead_dataleft);
-   }
-   sony_blocks_left -= nblocks;
-   sony_next_block += nblocks; 
-
-   /* If an XA disk, we have to clear out the rest of the unused
-      error correction data. */
-   if (sony_xa_mode)
-   {
-      for(i=0; i<CD_XA_TAIL; i++)
-      {
-         val = read_data_register();
-      }
-   }
+	printk("Entering input_data\n");
+#endif
+	/* If an XA disk on a CDU31A, skip the first 12 bytes of data from
+	   the disk.  The real data is after that. */
+	if (sony_xa_mode) {
+		for (i = 0; i < CD_XA_HEAD; i++) {
+			val = read_data_register();
+		}
+	}
+
+	clear_data_ready();
+
+	if (bytesleft == 2048) {	/* 2048 byte direct buffer transfer */
+		insb(sony_cd_read_reg, buffer, 2048);
+		readahead_dataleft = 0;
+	} else {
+		/* If the input read did not align with the beginning of the block,
+		   skip the necessary bytes. */
+		if (skip != 0) {
+			insb(sony_cd_read_reg, readahead_buffer, skip);
+		}
+
+		/* Get the data into the buffer. */
+		insb(sony_cd_read_reg, &buffer[offset], bytesleft);
+
+		/* Get the rest of the data into the readahead buffer at the
+		   proper location. */
+		readahead_dataleft = (2048 - skip) - bytesleft;
+		insb(sony_cd_read_reg,
+		     readahead_buffer + bytesleft, readahead_dataleft);
+	}
+	sony_blocks_left -= nblocks;
+	sony_next_block += nblocks;
+
+	/* If an XA disk, we have to clear out the rest of the unused
+	   error correction data. */
+	if (sony_xa_mode) {
+		for (i = 0; i < CD_XA_TAIL; i++) {
+			val = read_data_register();
+		}
+	}
 #if DEBUG
-   printk("Leaving input_data at %d\n", __LINE__);
+	printk("Leaving input_data at %d\n", __LINE__);
 #endif
 }
 
 /* read data from the drive.  Note the nsect must be <= 4. */
 static void
-read_data_block(char          *buffer,
-                unsigned int  block,
-                unsigned int  nblocks,
-                unsigned char res_reg[],
-                int           *res_size)
-{
-   unsigned int retry_count;
-   unsigned int bytesleft;
-   unsigned int offset;
-   unsigned int skip;
-
-
-#if DEBUG
-   printk("Entering read_data_block\n");
-#endif
-
-   res_reg[0] = 0;
-   res_reg[1] = 0;
-   *res_size = 0;
-   bytesleft = nblocks * 512;
-   offset = 0;
-
-   /* If the data in the read-ahead does not match the block offset,
-      then fix things up. */
-   if (((block % 4) * 512) != ((2048 - readahead_dataleft) % 2048))
-   {
-      sony_next_block += block % 4;
-      sony_blocks_left -= block % 4;
-      skip = (block % 4) * 512;
-   }
-   else
-   {
-      skip = 0;
-   }
-
-   /* We have readahead data in the buffer, get that first before we
-      decide if a read is necessary. */
-   if (readahead_dataleft != 0)
-   {
-      if (bytesleft > readahead_dataleft)
-      {
-	 /* The readahead will not fill the requested buffer, but
-	    get the data out of the readahead into the buffer. */
-         memcpy(buffer,
-                readahead_buffer + (2048 - readahead_dataleft),
-                readahead_dataleft);
-         readahead_dataleft = 0;
-         bytesleft -= readahead_dataleft;
-         offset += readahead_dataleft;
-      }
-      else
-      {
-	 /* The readahead will fill the whole buffer, get the data
-	    and return. */
-         memcpy(buffer,
-                readahead_buffer + (2048 - readahead_dataleft),
-                bytesleft);
-         readahead_dataleft -= bytesleft;
-         bytesleft = 0;
-         sony_blocks_left -= nblocks;
-         sony_next_block += nblocks;
-
-	 /* If the data in the readahead is bad, return an error so the
-	    driver will abort the buffer. */
-         if (readahead_bad)
-         {
-            res_reg[0] = 0x20;
-            res_reg[1] = SONY_BAD_DATA_ERR;
-            *res_size = 2;
-         }
-
-         if (readahead_dataleft == 0)
-         {
-            readahead_bad = 0;
-         }
-
-         /* Final transfer is done for read command, get final result. */
-         if (sony_blocks_left == 0)
-         {
-            get_result(res_reg, res_size);
-         }
-#if DEBUG
-         printk("Leaving read_data_block at %d\n", __LINE__);
-#endif
-         return;
-      }
-   }
-
-   /* Wait for the drive to tell us we have something */
-   retry_count = jiffies + SONY_JIFFIES_TIMEOUT;
-   while (time_before(jiffies, retry_count) && !(is_data_ready()))
-   {
-      while (handle_sony_cd_attention())
-         ;
-
-      sony_sleep();
-   }
-   if (!(is_data_ready()))
-   {
-      if (is_result_ready())
-      {
-         get_result(res_reg, res_size);
-         if ((res_reg[0] & 0xf0) != 0x20)
-         {
-            printk("CDU31A: Got result that should have been error: %d\n",
-                   res_reg[0]);
-            res_reg[0] = 0x20;
-            res_reg[1] = SONY_BAD_DATA_ERR;
-            *res_size = 2;
-         }
-         abort_read();
-      }
-      else
-      {
-#if DEBUG
-         printk("CDU31A timeout out %d\n", __LINE__);
-#endif
-         res_reg[0] = 0x20;
-         res_reg[1] = SONY_TIMEOUT_OP_ERR;
-         *res_size = 2;
-         abort_read();
-      }
-   }
-   else
-   {
-      input_data(buffer, bytesleft, nblocks, offset, skip);
-
-      /* Wait for the status from the drive. */
-      retry_count = jiffies + SONY_JIFFIES_TIMEOUT;
-      while (time_before(jiffies, retry_count) && !(is_result_ready()))
-      {
-         while (handle_sony_cd_attention())
-            ;
-
-         sony_sleep();
-      }
-
-      if (!is_result_ready())
-      {
-#if DEBUG
-         printk("CDU31A timeout out %d\n", __LINE__);
-#endif
-         res_reg[0] = 0x20;
-         res_reg[1] = SONY_TIMEOUT_OP_ERR;
-         *res_size = 2;
-         abort_read();
-      }
-      else
-      {
-         get_result(res_reg, res_size);
-
-	 /* If we got a buffer status, handle that. */
-         if ((res_reg[0] & 0xf0) == 0x50)
-         {
-
-            if (   (res_reg[0] == SONY_NO_CIRC_ERR_BLK_STAT)
-                || (res_reg[0] == SONY_NO_LECC_ERR_BLK_STAT)
-                || (res_reg[0] == SONY_RECOV_LECC_ERR_BLK_STAT))
-            {
-	       /* The data was successful, but if data was read from
-		  the readahead  and it was bad, set the whole
-		  buffer as bad. */
-               if (readahead_bad)
-               {
-                  readahead_bad = 0;
-                  res_reg[0] = 0x20;
-                  res_reg[1] = SONY_BAD_DATA_ERR;
-                  *res_size = 2;
-               }
-            }
-            else
-            {
-               printk("CDU31A: Data block error: 0x%x\n", res_reg[0]);
-               res_reg[0] = 0x20;
-               res_reg[1] = SONY_BAD_DATA_ERR;
-               *res_size = 2;
-
-               /* Data is in the readahead buffer but an error was returned.
-                  Make sure future requests don't use the data. */
-               if (bytesleft != 2048)
-               {
-                  readahead_bad = 1;
-               }
-            }
-
-            /* Final transfer is done for read command, get final result. */
-            if (sony_blocks_left == 0)
-            {
-               get_result(res_reg, res_size);
-            }
-         }
-         else if ((res_reg[0] & 0xf0) != 0x20)
-         {
-            /* The drive gave me bad status, I don't know what to do.
-               Reset the driver and return an error. */
-            printk("CDU31A: Invalid block status: 0x%x\n", res_reg[0]);
-            restart_on_error();
-            res_reg[0] = 0x20;
-            res_reg[1] = SONY_BAD_DATA_ERR;
-            *res_size = 2;
-         }
-      }
-   }
+read_data_block(char *buffer,
+		unsigned int block,
+		unsigned int nblocks,
+		unsigned char res_reg[], int *res_size)
+{
+	unsigned int retry_count;
+	unsigned int bytesleft;
+	unsigned int offset;
+	unsigned int skip;
+
+
+#if DEBUG
+	printk("Entering read_data_block\n");
+#endif
+
+	res_reg[0] = 0;
+	res_reg[1] = 0;
+	*res_size = 0;
+	bytesleft = nblocks * 512;
+	offset = 0;
+
+	/* If the data in the read-ahead does not match the block offset,
+	   then fix things up. */
+	if (((block % 4) * 512) != ((2048 - readahead_dataleft) % 2048)) {
+		sony_next_block += block % 4;
+		sony_blocks_left -= block % 4;
+		skip = (block % 4) * 512;
+	} else {
+		skip = 0;
+	}
+
+	/* We have readahead data in the buffer, get that first before we
+	   decide if a read is necessary. */
+	if (readahead_dataleft != 0) {
+		if (bytesleft > readahead_dataleft) {
+			/* The readahead will not fill the requested buffer, but
+			   get the data out of the readahead into the buffer. */
+			memcpy(buffer,
+			       readahead_buffer + (2048 -
+						   readahead_dataleft),
+			       readahead_dataleft);
+			readahead_dataleft = 0;
+			bytesleft -= readahead_dataleft;
+			offset += readahead_dataleft;
+		} else {
+			/* The readahead will fill the whole buffer, get the data
+			   and return. */
+			memcpy(buffer,
+			       readahead_buffer + (2048 -
+						   readahead_dataleft),
+			       bytesleft);
+			readahead_dataleft -= bytesleft;
+			bytesleft = 0;
+			sony_blocks_left -= nblocks;
+			sony_next_block += nblocks;
+
+			/* If the data in the readahead is bad, return an error so the
+			   driver will abort the buffer. */
+			if (readahead_bad) {
+				res_reg[0] = 0x20;
+				res_reg[1] = SONY_BAD_DATA_ERR;
+				*res_size = 2;
+			}
+
+			if (readahead_dataleft == 0) {
+				readahead_bad = 0;
+			}
+
+			/* Final transfer is done for read command, get final result. */
+			if (sony_blocks_left == 0) {
+				get_result(res_reg, res_size);
+			}
+#if DEBUG
+			printk("Leaving read_data_block at %d\n",
+			       __LINE__);
+#endif
+			return;
+		}
+	}
+
+	/* Wait for the drive to tell us we have something */
+	retry_count = jiffies + SONY_JIFFIES_TIMEOUT;
+	while (time_before(jiffies, retry_count) && !(is_data_ready())) {
+		while (handle_sony_cd_attention());
+
+		sony_sleep();
+	}
+	if (!(is_data_ready())) {
+		if (is_result_ready()) {
+			get_result(res_reg, res_size);
+			if ((res_reg[0] & 0xf0) != 0x20) {
+				printk
+				    ("CDU31A: Got result that should have been error: %d\n",
+				     res_reg[0]);
+				res_reg[0] = 0x20;
+				res_reg[1] = SONY_BAD_DATA_ERR;
+				*res_size = 2;
+			}
+			abort_read();
+		} else {
+#if DEBUG
+			printk("CDU31A timeout out %d\n", __LINE__);
+#endif
+			res_reg[0] = 0x20;
+			res_reg[1] = SONY_TIMEOUT_OP_ERR;
+			*res_size = 2;
+			abort_read();
+		}
+	} else {
+		input_data(buffer, bytesleft, nblocks, offset, skip);
+
+		/* Wait for the status from the drive. */
+		retry_count = jiffies + SONY_JIFFIES_TIMEOUT;
+		while (time_before(jiffies, retry_count)
+		       && !(is_result_ready())) {
+			while (handle_sony_cd_attention());
+
+			sony_sleep();
+		}
+
+		if (!is_result_ready()) {
+#if DEBUG
+			printk("CDU31A timeout out %d\n", __LINE__);
+#endif
+			res_reg[0] = 0x20;
+			res_reg[1] = SONY_TIMEOUT_OP_ERR;
+			*res_size = 2;
+			abort_read();
+		} else {
+			get_result(res_reg, res_size);
+
+			/* If we got a buffer status, handle that. */
+			if ((res_reg[0] & 0xf0) == 0x50) {
+
+				if ((res_reg[0] ==
+				     SONY_NO_CIRC_ERR_BLK_STAT)
+				    || (res_reg[0] ==
+					SONY_NO_LECC_ERR_BLK_STAT)
+				    || (res_reg[0] ==
+					SONY_RECOV_LECC_ERR_BLK_STAT)) {
+					/* The data was successful, but if data was read from
+					   the readahead  and it was bad, set the whole
+					   buffer as bad. */
+					if (readahead_bad) {
+						readahead_bad = 0;
+						res_reg[0] = 0x20;
+						res_reg[1] =
+						    SONY_BAD_DATA_ERR;
+						*res_size = 2;
+					}
+				} else {
+					printk
+					    ("CDU31A: Data block error: 0x%x\n",
+					     res_reg[0]);
+					res_reg[0] = 0x20;
+					res_reg[1] = SONY_BAD_DATA_ERR;
+					*res_size = 2;
+
+					/* Data is in the readahead buffer but an error was returned.
+					   Make sure future requests don't use the data. */
+					if (bytesleft != 2048) {
+						readahead_bad = 1;
+					}
+				}
+
+				/* Final transfer is done for read command, get final result. */
+				if (sony_blocks_left == 0) {
+					get_result(res_reg, res_size);
+				}
+			} else if ((res_reg[0] & 0xf0) != 0x20) {
+				/* The drive gave me bad status, I don't know what to do.
+				   Reset the driver and return an error. */
+				printk
+				    ("CDU31A: Invalid block status: 0x%x\n",
+				     res_reg[0]);
+				restart_on_error();
+				res_reg[0] = 0x20;
+				res_reg[1] = SONY_BAD_DATA_ERR;
+				*res_size = 2;
+			}
+		}
+	}
 #if DEBUG
-   printk("Leaving read_data_block at %d\n", __LINE__);
+	printk("Leaving read_data_block at %d\n", __LINE__);
 #endif
 }
 
@@ -1646,230 +1538,215 @@
  * uses 1024 byte blocks and the drive uses 2048 byte blocks.  Since most
  * data access on a CD is done sequentially, this saves a lot of operations.
  */
-static void
-do_cdu31a_request(request_queue_t * q)
+static void do_cdu31a_request(request_queue_t * q)
 {
-   int block;
-   int nblock;
-   unsigned char res_reg[12];
-   unsigned int res_size;
-   int num_retries;
-   unsigned long flags;
-
-
-#if DEBUG
-         printk("Entering do_cdu31a_request\n");
-#endif
-
-   /* 
-    * Make sure no one else is using the driver; wait for them
-    * to finish if it is so.
-    */
-   save_flags(flags);
-   cli();
-   while (sony_inuse)
-   {
-      interruptible_sleep_on(&sony_wait);
-      if (signal_pending(current))
-      {
-         restore_flags(flags);
-         if (!QUEUE_EMPTY && CURRENT->rq_status != RQ_INACTIVE)
-         {
-            end_request(0);
-         }
-         restore_flags(flags);
-#if DEBUG
-         printk("Leaving do_cdu31a_request at %d\n", __LINE__);
-#endif
-         return;
-      }
-   }
-   sony_inuse = 1;
-   has_cd_task = current;
-
-   /* Get drive status before doing anything. */
-   while (handle_sony_cd_attention())
-      ;
-
-   /* Make sure we have a valid TOC. */
-   sony_get_toc(); 
-
-   spin_unlock_irq(&io_request_lock);
-
-   /* Make sure the timer is cancelled. */
-   del_timer(&cdu31a_abort_timer);
-
-   while (1)
-   {
-cdu31a_request_startover:
-      /*
-       * The beginning here is stolen from the hard disk driver.  I hope
-       * it's right.
-       */
-      if (QUEUE_EMPTY || CURRENT->rq_status == RQ_INACTIVE)
-      {
-         goto end_do_cdu31a_request;
-      }
-
-      if (!sony_spun_up)
-      {
-         scd_spinup();
-      }
-
-      /* I don't use INIT_REQUEST because it calls return, which would
-         return without unlocking the device.  It shouldn't matter,
-         but just to be safe... */
-      if (MAJOR(CURRENT->rq_dev) != MAJOR_NR)
-      {
-	 panic(DEVICE_NAME ": request list destroyed");
-      }
-      if (CURRENT->bh)
-      {
-	 if (!buffer_locked(CURRENT->bh))
-         {
-	    panic(DEVICE_NAME ": block not locked");
-         }
-      }
-
-      block = CURRENT->sector;
-      nblock = CURRENT->nr_sectors;
-
-      if (!sony_toc_read)
-      {
-	 printk("CDU31A: TOC not read\n");
-	 end_request(0);
-	 goto cdu31a_request_startover;
-      }
-
-      switch(CURRENT->cmd)
-      {
-      case READ:
-         /*
-          * If the block address is invalid or the request goes beyond the end of
-          * the media, return an error.
-          */
+	int block;
+	int nblock;
+	unsigned char res_reg[12];
+	unsigned int res_size;
+	int num_retries;
+	unsigned long flags;
+
+
+#if DEBUG
+	printk("Entering do_cdu31a_request\n");
+#endif
+
+	/* 
+	 * Make sure no one else is using the driver; wait for them
+	 * to finish if it is so.
+	 */
+	save_flags(flags);
+	cli();
+	while (sony_inuse) {
+		interruptible_sleep_on(&sony_wait);
+		if (signal_pending(current)) {
+			restore_flags(flags);
+			if (!QUEUE_EMPTY
+			    && CURRENT->rq_status != RQ_INACTIVE) {
+				end_request(0);
+			}
+			restore_flags(flags);
+#if DEBUG
+			printk("Leaving do_cdu31a_request at %d\n",
+			       __LINE__);
+#endif
+			return;
+		}
+	}
+	sony_inuse = 1;
+	has_cd_task = current;
+
+	/* Get drive status before doing anything. */
+	while (handle_sony_cd_attention());
+
+	/* Make sure we have a valid TOC. */
+	sony_get_toc();
+
+	spin_unlock_irq(&io_request_lock);
+
+	/* Make sure the timer is cancelled. */
+	del_timer(&cdu31a_abort_timer);
+
+	while (1) {
+	      cdu31a_request_startover:
+		/*
+		 * The beginning here is stolen from the hard disk driver.  I hope
+		 * it's right.
+		 */
+		if (QUEUE_EMPTY || CURRENT->rq_status == RQ_INACTIVE) {
+			goto end_do_cdu31a_request;
+		}
+
+		if (!sony_spun_up) {
+			scd_spinup();
+		}
+
+		/* I don't use INIT_REQUEST because it calls return, which would
+		   return without unlocking the device.  It shouldn't matter,
+		   but just to be safe... */
+		if (MAJOR(CURRENT->rq_dev) != MAJOR_NR) {
+			panic(DEVICE_NAME ": request list destroyed");
+		}
+		if (CURRENT->bh) {
+			if (!buffer_locked(CURRENT->bh)) {
+				panic(DEVICE_NAME ": block not locked");
+			}
+		}
+
+		block = CURRENT->sector;
+		nblock = CURRENT->nr_sectors;
+
+		if (!sony_toc_read) {
+			printk("CDU31A: TOC not read\n");
+			end_request(0);
+			goto cdu31a_request_startover;
+		}
+
+		switch (CURRENT->cmd) {
+		case READ:
+			/*
+			 * If the block address is invalid or the request goes beyond the end of
+			 * the media, return an error.
+			 */
 #if 0
-	 if ((block / 4) < sony_toc.start_track_lba)
-	 {
-            printk("CDU31A: Request before beginning of media\n");
-            end_request(0);
-            goto cdu31a_request_startover;
-	 }
-#endif
-         if ((block / 4) >= sony_toc.lead_out_start_lba)
-         {
-            printk("CDU31A: Request past end of media\n");
-            end_request(0);
-            goto cdu31a_request_startover;
-         }
-         if (((block + nblock) / 4) >= sony_toc.lead_out_start_lba)
-         {
-            printk("CDU31A: Request past end of media\n");
-            end_request(0);
-            goto cdu31a_request_startover;
-         }
-
-         num_retries = 0;
-
-try_read_again:
-         while (handle_sony_cd_attention())
-            ;
-
-         if (!sony_toc_read)
-         {
-	    printk("CDU31A: TOC not read\n");
-	    end_request(0);
-	    goto cdu31a_request_startover;
-         }
-
-	 /* If no data is left to be read from the drive, start the
-	    next request. */
-         if (sony_blocks_left == 0)
-         {
-            if (start_request(block / 4, CDU31A_READAHEAD / 4, 0))
-            {
-               end_request(0);
-               goto cdu31a_request_startover;
-            }
-         }
-	 /* If the requested block is not the next one waiting in
-	    the driver, abort the current operation and start a
-	    new one. */
-         else if (block != sony_next_block)
-         {
-#if DEBUG
-            printk("CDU31A Warning: Read for block %d, expected %d\n",
-                   block,
-                   sony_next_block);
-#endif
-            abort_read();
-            if (!sony_toc_read)
-            {
-	       printk("CDU31A: TOC not read\n");
-	       end_request(0);
-               goto cdu31a_request_startover;
-            }
-            if (start_request(block / 4, CDU31A_READAHEAD / 4, 0))
-            {
-               printk("CDU31a: start request failed\n");
-               end_request(0);
-               goto cdu31a_request_startover;
-            }
-         }
-
-         read_data_block(CURRENT->buffer, block, nblock, res_reg, &res_size);
-         if (res_reg[0] == 0x20)
-         {
-            if (num_retries > MAX_CDU31A_RETRIES)
-            {
-               end_request(0);
-               goto cdu31a_request_startover;
-            }
-
-            num_retries++;
-            if (res_reg[1] == SONY_NOT_SPIN_ERR)
-            {
-               do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, &res_size);
-            }
-            else
-            {
-               printk("CDU31A: %s error for block %d, nblock %d\n", translate_error(res_reg[1]), block, nblock);
-            }
-            goto try_read_again;
-         }
-         else
-         {
-            end_request(1);
-         }
-         break;
-            
-      case WRITE:
-         end_request(0);
-         break;
-            
-      default:
-         panic("CDU31A: Unknown cmd");
-      }
-   }
+			if ((block / 4) < sony_toc.start_track_lba) {
+				printk
+				    ("CDU31A: Request before beginning of media\n");
+				end_request(0);
+				goto cdu31a_request_startover;
+			}
+#endif
+			if ((block / 4) >= sony_toc.lead_out_start_lba) {
+				printk
+				    ("CDU31A: Request past end of media\n");
+				end_request(0);
+				goto cdu31a_request_startover;
+			}
+			if (((block + nblock) / 4) >=
+			    sony_toc.lead_out_start_lba) {
+				printk
+				    ("CDU31A: Request past end of media\n");
+				end_request(0);
+				goto cdu31a_request_startover;
+			}
+
+			num_retries = 0;
+
+		      try_read_again:
+			while (handle_sony_cd_attention());
+
+			if (!sony_toc_read) {
+				printk("CDU31A: TOC not read\n");
+				end_request(0);
+				goto cdu31a_request_startover;
+			}
+
+			/* If no data is left to be read from the drive, start the
+			   next request. */
+			if (sony_blocks_left == 0) {
+				if (start_request
+				    (block / 4, CDU31A_READAHEAD / 4, 0)) {
+					end_request(0);
+					goto cdu31a_request_startover;
+				}
+			}
+			/* If the requested block is not the next one waiting in
+			   the driver, abort the current operation and start a
+			   new one. */
+			else if (block != sony_next_block) {
+#if DEBUG
+				printk
+				    ("CDU31A Warning: Read for block %d, expected %d\n",
+				     block, sony_next_block);
+#endif
+				abort_read();
+				if (!sony_toc_read) {
+					printk("CDU31A: TOC not read\n");
+					end_request(0);
+					goto cdu31a_request_startover;
+				}
+				if (start_request
+				    (block / 4, CDU31A_READAHEAD / 4, 0)) {
+					printk
+					    ("CDU31a: start request failed\n");
+					end_request(0);
+					goto cdu31a_request_startover;
+				}
+			}
+
+			read_data_block(CURRENT->buffer, block, nblock,
+					res_reg, &res_size);
+			if (res_reg[0] == 0x20) {
+				if (num_retries > MAX_CDU31A_RETRIES) {
+					end_request(0);
+					goto cdu31a_request_startover;
+				}
+
+				num_retries++;
+				if (res_reg[1] == SONY_NOT_SPIN_ERR) {
+					do_sony_cd_cmd(SONY_SPIN_UP_CMD,
+						       NULL, 0, res_reg,
+						       &res_size);
+				} else {
+					printk
+					    ("CDU31A: %s error for block %d, nblock %d\n",
+					     translate_error(res_reg[1]),
+					     block, nblock);
+				}
+				goto try_read_again;
+			} else {
+				end_request(1);
+			}
+			break;
+
+		case WRITE:
+			end_request(0);
+			break;
+
+		default:
+			panic("CDU31A: Unknown cmd");
+		}
+	}
 
-end_do_cdu31a_request:
-   spin_lock_irq(&io_request_lock);
+      end_do_cdu31a_request:
+	spin_lock_irq(&io_request_lock);
 #if 0
-   /* After finished, cancel any pending operations. */
-   abort_read();
+	/* After finished, cancel any pending operations. */
+	abort_read();
 #else
-   /* Start a timer to time out after a while to disable
-      the read. */
-   cdu31a_abort_timer.expires = jiffies + 2*HZ; /* Wait 2 seconds */
-   add_timer(&cdu31a_abort_timer);
+	/* Start a timer to time out after a while to disable
+	   the read. */
+	cdu31a_abort_timer.expires = jiffies + 2 * HZ;	/* Wait 2 seconds */
+	add_timer(&cdu31a_abort_timer);
 #endif
 
-   has_cd_task = NULL;
-   sony_inuse = 0;
-   wake_up_interruptible(&sony_wait);
-   restore_flags(flags);
+	has_cd_task = NULL;
+	sony_inuse = 0;
+	wake_up_interruptible(&sony_wait);
+	restore_flags(flags);
 #if DEBUG
-   printk("Leaving do_cdu31a_request at %d\n", __LINE__);
+	printk("Leaving do_cdu31a_request at %d\n", __LINE__);
 #endif
 }
 
@@ -1878,356 +1755,473 @@
  * Read the table of contents from the drive and set up TOC if
  * successful.
  */
-static void
-sony_get_toc(void)
+static void sony_get_toc(void)
 {
-   unsigned char res_reg[2];
-   unsigned int res_size;
-   unsigned char parms[1];
-   int session;
-   int num_spin_ups;
-   int totaltracks = 0;
-   int mint = 99;
-   int maxt = 0;
-
-#if DEBUG
-   printk("Entering sony_get_toc\n");
-#endif
-
-   num_spin_ups = 0;
-   if (!sony_toc_read)
-   {
-respinup_on_gettoc:
-      /* Ignore the result, since it might error if spinning already. */
-      do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, &res_size);
-
-      do_sony_cd_cmd(SONY_READ_TOC_CMD, NULL, 0, res_reg, &res_size);
-
-      /* The drive sometimes returns error 0.  I don't know why, but ignore
-         it.  It seems to mean the drive has already done the operation. */
-      if ((res_size < 2) || ((res_reg[0] != 0) && (res_reg[1] != 0)))
-      {
-         /* If the drive is already playing, it's ok.  */
-         if ((res_reg[1] == SONY_AUDIO_PLAYING_ERR) || (res_reg[1] == 0))
-         {
-            goto gettoc_drive_spinning;
-         }
-
-         /* If the drive says it is not spun up (even though we just did it!)
-            then retry the operation at least a few times. */
-         if (   (res_reg[1] == SONY_NOT_SPIN_ERR)
-             && (num_spin_ups < MAX_CDU31A_RETRIES))
-         {
-            num_spin_ups++;
-            goto respinup_on_gettoc;
-         }
-
-         printk("cdu31a: Error reading TOC: %x %s\n",
-                res_reg[0], translate_error(res_reg[1]));
-	 return;
-      }
-
-gettoc_drive_spinning:
-
-      /* The idea here is we keep asking for sessions until the command
-	 fails.  Then we know what the last valid session on the disk is.
-	 No need to check session 0, since session 0 is the same as session
-         1; the command returns different information if you give it 0. 
-        */
-#if DEBUG
-      memset(&sony_toc, 0x0e, sizeof(sony_toc));
-      memset(&single_toc, 0x0f, sizeof(single_toc));
-#endif
-      session = 1;
-      while (1)
-      {
+	unsigned char res_reg[2];
+	unsigned int res_size;
+	unsigned char parms[1];
+	int session;
+	int num_spin_ups;
+	int totaltracks = 0;
+	int mint = 99;
+	int maxt = 0;
+
+#if DEBUG
+	printk("Entering sony_get_toc\n");
+#endif
+
+	num_spin_ups = 0;
+	if (!sony_toc_read) {
+	      respinup_on_gettoc:
+		/* Ignore the result, since it might error if spinning already. */
+		do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg,
+			       &res_size);
+
+		do_sony_cd_cmd(SONY_READ_TOC_CMD, NULL, 0, res_reg,
+			       &res_size);
+
+		/* The drive sometimes returns error 0.  I don't know why, but ignore
+		   it.  It seems to mean the drive has already done the operation. */
+		if ((res_size < 2)
+		    || ((res_reg[0] != 0) && (res_reg[1] != 0))) {
+			/* If the drive is already playing, it's ok.  */
+			if ((res_reg[1] == SONY_AUDIO_PLAYING_ERR)
+			    || (res_reg[1] == 0)) {
+				goto gettoc_drive_spinning;
+			}
+
+			/* If the drive says it is not spun up (even though we just did it!)
+			   then retry the operation at least a few times. */
+			if ((res_reg[1] == SONY_NOT_SPIN_ERR)
+			    && (num_spin_ups < MAX_CDU31A_RETRIES)) {
+				num_spin_ups++;
+				goto respinup_on_gettoc;
+			}
+
+			printk("cdu31a: Error reading TOC: %x %s\n",
+			       res_reg[0], translate_error(res_reg[1]));
+			return;
+		}
+
+	      gettoc_drive_spinning:
+
+		/* The idea here is we keep asking for sessions until the command
+		   fails.  Then we know what the last valid session on the disk is.
+		   No need to check session 0, since session 0 is the same as session
+		   1; the command returns different information if you give it 0. 
+		 */
+#if DEBUG
+		memset(&sony_toc, 0x0e, sizeof(sony_toc));
+		memset(&single_toc, 0x0f, sizeof(single_toc));
+#endif
+		session = 1;
+		while (1) {
 /* This seems to slow things down enough to make it work.  This
  * appears to be a problem in do_sony_cd_cmd.  This printk seems 
  * to address the symptoms...  -Erik */
 #if 1
-         printk("cdu31a: Trying session %d\n", session);
+			printk("cdu31a: Trying session %d\n", session);
 #endif
-	 parms[0] = session;
-	 do_sony_cd_cmd(SONY_READ_TOC_SPEC_CMD,
-			parms,
-			1, 
-			res_reg,
-			&res_size);
-
-#if DEBUG
-         printk("%2.2x %2.2x\n", res_reg[0], res_reg[1]);
-#endif
-
-	 if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20))
-	 {
-	    /* An error reading the TOC, this must be past the last session. */
-	     if (session == 1)
-		    printk("Yikes! Couldn't read any sessions!");
-	    break;
-         }
-#if DEBUG
-         printk("Reading session %d\n", session);
-#endif
-
-         parms[0] = session;
-         do_sony_cd_cmd(SONY_REQ_TOC_DATA_SPEC_CMD,
-		     parms,
-		     1, 
-		     (unsigned char *) &single_toc, 
-		     &res_size);
-         if ((res_size < 2) || ((single_toc.exec_status[0] & 0xf0) == 0x20))
-         {
-            printk("cdu31a: Error reading session %d: %x %s\n",
-                session,
-                single_toc.exec_status[0],
-                translate_error(single_toc.exec_status[1]));
-	    /* An error reading the TOC.  Return without sony_toc_read
-	       set. */
-	    return;
-         }
-#if DEBUG
-      printk("add0 %01x, con0 %01x, poi0 %02x, 1st trk %d, dsktyp %x, dum0 %x\n",
-              single_toc.address0, single_toc.control0, single_toc.point0,
-              bcd_to_int(single_toc.first_track_num), single_toc.disk_type, single_toc.dummy0);
-      printk("add1 %01x, con1 %01x, poi1 %02x, lst trk %d, dummy1 %x, dum2 %x\n",
-              single_toc.address1, single_toc.control1, single_toc.point1,
-              bcd_to_int(single_toc.last_track_num), single_toc.dummy1, single_toc.dummy2);
-      printk("add2 %01x, con2 %01x, poi2 %02x leadout start min %d, sec %d, frame %d\n",
-              single_toc.address2, single_toc.control2, single_toc.point2,
-              bcd_to_int(single_toc.lead_out_start_msf[0]),
-              bcd_to_int(single_toc.lead_out_start_msf[1]),
-              bcd_to_int(single_toc.lead_out_start_msf[2]));
-      if (res_size > 18 && single_toc.pointb0 > 0xaf)
-      printk("addb0 %01x, conb0 %01x, poib0 %02x, nextsession min %d, sec %d, frame %d\n"
-             "#mode5_ptrs %02d, max_start_outer_leadout_msf min %d, sec %d, frame %d\n",
-              single_toc.addressb0, single_toc.controlb0, single_toc.pointb0,
-              bcd_to_int(single_toc.next_poss_prog_area_msf[0]),
-              bcd_to_int(single_toc.next_poss_prog_area_msf[1]),
-              bcd_to_int(single_toc.next_poss_prog_area_msf[2]),
-              single_toc.num_mode_5_pointers,
-              bcd_to_int(single_toc.max_start_outer_leadout_msf[0]),
-              bcd_to_int(single_toc.max_start_outer_leadout_msf[1]),
-              bcd_to_int(single_toc.max_start_outer_leadout_msf[2]));
-      if (res_size > 27 && single_toc.pointb1 > 0xaf)
-      printk("addb1 %01x, conb1 %01x, poib1 %02x, %x %x %x %x #skipint_ptrs %d, #skiptrkassign %d %x\n",
-              single_toc.addressb1, single_toc.controlb1, single_toc.pointb1,
-              single_toc.dummyb0_1[0],
-              single_toc.dummyb0_1[1],
-              single_toc.dummyb0_1[2],
-              single_toc.dummyb0_1[3],
-              single_toc.num_skip_interval_pointers,
-              single_toc.num_skip_track_assignments,
-              single_toc.dummyb0_2);
-      if (res_size > 36 && single_toc.pointb2 > 0xaf)
-      printk("addb2 %01x, conb2 %01x, poib2 %02x, %02x %02x %02x %02x %02x %02x %02x\n",
-              single_toc.addressb2, single_toc.controlb2, single_toc.pointb2,
-              single_toc.tracksb2[0],
-              single_toc.tracksb2[1],
-              single_toc.tracksb2[2],
-              single_toc.tracksb2[3],
-              single_toc.tracksb2[4],
-              single_toc.tracksb2[5],
-              single_toc.tracksb2[6]);
-      if (res_size > 45 && single_toc.pointb3 > 0xaf)
-      printk("addb3 %01x, conb3 %01x, poib3 %02x, %02x %02x %02x %02x %02x %02x %02x\n",
-              single_toc.addressb3, single_toc.controlb3, single_toc.pointb3,
-              single_toc.tracksb3[0],
-              single_toc.tracksb3[1],
-              single_toc.tracksb3[2],
-              single_toc.tracksb3[3],
-              single_toc.tracksb3[4],
-              single_toc.tracksb3[5],
-              single_toc.tracksb3[6]);
-      if (res_size > 54 && single_toc.pointb4 > 0xaf)
-      printk("addb4 %01x, conb4 %01x, poib4 %02x, %02x %02x %02x %02x %02x %02x %02x\n",
-              single_toc.addressb4, single_toc.controlb4, single_toc.pointb4,
-              single_toc.tracksb4[0],
-              single_toc.tracksb4[1],
-              single_toc.tracksb4[2],
-              single_toc.tracksb4[3],
-              single_toc.tracksb4[4],
-              single_toc.tracksb4[5],
-              single_toc.tracksb4[6]);
-      if (res_size > 63 && single_toc.pointc0 > 0xaf)
-      printk("addc0 %01x, conc0 %01x, poic0 %02x, %02x %02x %02x %02x %02x %02x %02x\n",
-              single_toc.addressc0, single_toc.controlc0, single_toc.pointc0,
-              single_toc.dummyc0[0],
-              single_toc.dummyc0[1],
-              single_toc.dummyc0[2],
-              single_toc.dummyc0[3],
-              single_toc.dummyc0[4],
-              single_toc.dummyc0[5],
-              single_toc.dummyc0[6]);
+			parms[0] = session;
+			do_sony_cd_cmd(SONY_READ_TOC_SPEC_CMD,
+				       parms, 1, res_reg, &res_size);
+
+#if DEBUG
+			printk("%2.2x %2.2x\n", res_reg[0], res_reg[1]);
+#endif
+
+			if ((res_size < 2)
+			    || ((res_reg[0] & 0xf0) == 0x20)) {
+				/* An error reading the TOC, this must be past the last session. */
+				if (session == 1)
+					printk
+					    ("Yikes! Couldn't read any sessions!");
+				break;
+			}
+#if DEBUG
+			printk("Reading session %d\n", session);
+#endif
+
+			parms[0] = session;
+			do_sony_cd_cmd(SONY_REQ_TOC_DATA_SPEC_CMD,
+				       parms,
+				       1,
+				       (unsigned char *) &single_toc,
+				       &res_size);
+			if ((res_size < 2)
+			    || ((single_toc.exec_status[0] & 0xf0) ==
+				0x20)) {
+				printk
+				    ("cdu31a: Error reading session %d: %x %s\n",
+				     session, single_toc.exec_status[0],
+				     translate_error(single_toc.
+						     exec_status[1]));
+				/* An error reading the TOC.  Return without sony_toc_read
+				   set. */
+				return;
+			}
+#if DEBUG
+			printk
+			    ("add0 %01x, con0 %01x, poi0 %02x, 1st trk %d, dsktyp %x, dum0 %x\n",
+			     single_toc.address0, single_toc.control0,
+			     single_toc.point0,
+			     bcd_to_int(single_toc.first_track_num),
+			     single_toc.disk_type, single_toc.dummy0);
+			printk
+			    ("add1 %01x, con1 %01x, poi1 %02x, lst trk %d, dummy1 %x, dum2 %x\n",
+			     single_toc.address1, single_toc.control1,
+			     single_toc.point1,
+			     bcd_to_int(single_toc.last_track_num),
+			     single_toc.dummy1, single_toc.dummy2);
+			printk
+			    ("add2 %01x, con2 %01x, poi2 %02x leadout start min %d, sec %d, frame %d\n",
+			     single_toc.address2, single_toc.control2,
+			     single_toc.point2,
+			     bcd_to_int(single_toc.lead_out_start_msf[0]),
+			     bcd_to_int(single_toc.lead_out_start_msf[1]),
+			     bcd_to_int(single_toc.lead_out_start_msf[2]));
+			if (res_size > 18 && single_toc.pointb0 > 0xaf)
+				printk
+				    ("addb0 %01x, conb0 %01x, poib0 %02x, nextsession min %d, sec %d, frame %d\n"
+				     "#mode5_ptrs %02d, max_start_outer_leadout_msf min %d, sec %d, frame %d\n",
+				     single_toc.addressb0,
+				     single_toc.controlb0,
+				     single_toc.pointb0,
+				     bcd_to_int(single_toc.
+						next_poss_prog_area_msf
+						[0]),
+				     bcd_to_int(single_toc.
+						next_poss_prog_area_msf
+						[1]),
+				     bcd_to_int(single_toc.
+						next_poss_prog_area_msf
+						[2]),
+				     single_toc.num_mode_5_pointers,
+				     bcd_to_int(single_toc.
+						max_start_outer_leadout_msf
+						[0]),
+				     bcd_to_int(single_toc.
+						max_start_outer_leadout_msf
+						[1]),
+				     bcd_to_int(single_toc.
+						max_start_outer_leadout_msf
+						[2]));
+			if (res_size > 27 && single_toc.pointb1 > 0xaf)
+				printk
+				    ("addb1 %01x, conb1 %01x, poib1 %02x, %x %x %x %x #skipint_ptrs %d, #skiptrkassign %d %x\n",
+				     single_toc.addressb1,
+				     single_toc.controlb1,
+				     single_toc.pointb1,
+				     single_toc.dummyb0_1[0],
+				     single_toc.dummyb0_1[1],
+				     single_toc.dummyb0_1[2],
+				     single_toc.dummyb0_1[3],
+				     single_toc.num_skip_interval_pointers,
+				     single_toc.num_skip_track_assignments,
+				     single_toc.dummyb0_2);
+			if (res_size > 36 && single_toc.pointb2 > 0xaf)
+				printk
+				    ("addb2 %01x, conb2 %01x, poib2 %02x, %02x %02x %02x %02x %02x %02x %02x\n",
+				     single_toc.addressb2,
+				     single_toc.controlb2,
+				     single_toc.pointb2,
+				     single_toc.tracksb2[0],
+				     single_toc.tracksb2[1],
+				     single_toc.tracksb2[2],
+				     single_toc.tracksb2[3],
+				     single_toc.tracksb2[4],
+				     single_toc.tracksb2[5],
+				     single_toc.tracksb2[6]);
+			if (res_size > 45 && single_toc.pointb3 > 0xaf)
+				printk
+				    ("addb3 %01x, conb3 %01x, poib3 %02x, %02x %02x %02x %02x %02x %02x %02x\n",
+				     single_toc.addressb3,
+				     single_toc.controlb3,
+				     single_toc.pointb3,
+				     single_toc.tracksb3[0],
+				     single_toc.tracksb3[1],
+				     single_toc.tracksb3[2],
+				     single_toc.tracksb3[3],
+				     single_toc.tracksb3[4],
+				     single_toc.tracksb3[5],
+				     single_toc.tracksb3[6]);
+			if (res_size > 54 && single_toc.pointb4 > 0xaf)
+				printk
+				    ("addb4 %01x, conb4 %01x, poib4 %02x, %02x %02x %02x %02x %02x %02x %02x\n",
+				     single_toc.addressb4,
+				     single_toc.controlb4,
+				     single_toc.pointb4,
+				     single_toc.tracksb4[0],
+				     single_toc.tracksb4[1],
+				     single_toc.tracksb4[2],
+				     single_toc.tracksb4[3],
+				     single_toc.tracksb4[4],
+				     single_toc.tracksb4[5],
+				     single_toc.tracksb4[6]);
+			if (res_size > 63 && single_toc.pointc0 > 0xaf)
+				printk
+				    ("addc0 %01x, conc0 %01x, poic0 %02x, %02x %02x %02x %02x %02x %02x %02x\n",
+				     single_toc.addressc0,
+				     single_toc.controlc0,
+				     single_toc.pointc0,
+				     single_toc.dummyc0[0],
+				     single_toc.dummyc0[1],
+				     single_toc.dummyc0[2],
+				     single_toc.dummyc0[3],
+				     single_toc.dummyc0[4],
+				     single_toc.dummyc0[5],
+				     single_toc.dummyc0[6]);
 #endif
 #undef DEBUG
 #define DEBUG 0
 
-      sony_toc.lead_out_start_msf[0] = bcd_to_int(single_toc.lead_out_start_msf[0]);
-      sony_toc.lead_out_start_msf[1] = bcd_to_int(single_toc.lead_out_start_msf[1]);
-      sony_toc.lead_out_start_msf[2] = bcd_to_int(single_toc.lead_out_start_msf[2]);
-      sony_toc.lead_out_start_lba = single_toc.lead_out_start_lba =
-                    msf_to_log(sony_toc.lead_out_start_msf);
-
-      /* For points that do not exist, move the data over them
-	 to the right location. */
-      if (single_toc.pointb0 != 0xb0)
-      {
-	 memmove(((char *) &single_toc) + 27,
-		 ((char *) &single_toc) + 18,
-		 res_size - 18);
-	 res_size += 9;
-      }
-      else if (res_size > 18) {
-        sony_toc.lead_out_start_msf[0] = bcd_to_int(single_toc.max_start_outer_leadout_msf[0]);
-        sony_toc.lead_out_start_msf[1] = bcd_to_int(single_toc.max_start_outer_leadout_msf[1]);
-        sony_toc.lead_out_start_msf[2] = bcd_to_int(single_toc.max_start_outer_leadout_msf[2]);
-        sony_toc.lead_out_start_lba = msf_to_log(sony_toc.lead_out_start_msf);
-      }
-      if (single_toc.pointb1 != 0xb1)
-      {
-	 memmove(((char *) &single_toc) + 36,
-		((char *) &single_toc) + 27,
-		res_size - 27);
-	 res_size += 9;
-      }
-      if (single_toc.pointb2 != 0xb2)
-      {
-	 memmove(((char *) &single_toc) + 45,
-		((char *) &single_toc) + 36,
-		res_size - 36);
-	 res_size += 9;
-      }
-      if (single_toc.pointb3 != 0xb3)
-      {
-	 memmove(((char *) &single_toc) + 54,
-		((char *) &single_toc) + 45,
-		res_size - 45);
-	 res_size += 9;
-      }
-      if (single_toc.pointb4 != 0xb4)
-      {
-	 memmove(((char *) &single_toc) + 63,
-		((char *) &single_toc) + 54,
-		res_size - 54);
-	 res_size += 9;
-      }
-      if (single_toc.pointc0 != 0xc0)
-      {
-	 memmove(((char *) &single_toc) + 72,
-		((char *) &single_toc) + 63,
-		res_size - 63);
-	 res_size += 9;
-      }
-
-#if DEBUG
-      printk("start track lba %u,  leadout start lba %u\n",
-              single_toc.start_track_lba, single_toc.lead_out_start_lba);
-      { int i;
-        for (i = 0; i < 1 + bcd_to_int(single_toc.last_track_num)
-                          - bcd_to_int(single_toc.first_track_num); i++) {
-          printk("trk %02d: add 0x%01x, con 0x%01x,  track %02d, start min %02d, sec %02d, frame %02d\n",
-                 i, single_toc.tracks[i].address, single_toc.tracks[i].control,
-                 bcd_to_int(single_toc.tracks[i].track),
-                 bcd_to_int(single_toc.tracks[i].track_start_msf[0]),
-                 bcd_to_int(single_toc.tracks[i].track_start_msf[1]),
-                 bcd_to_int(single_toc.tracks[i].track_start_msf[2]));
-          if (mint > bcd_to_int(single_toc.tracks[i].track))
-            mint = bcd_to_int(single_toc.tracks[i].track);
-          if (maxt < bcd_to_int(single_toc.tracks[i].track))
-            maxt = bcd_to_int(single_toc.tracks[i].track);
-        }
-        printk("min track number %d,   max track number %d\n", mint, maxt);
-      }
-#endif
-
-         /* prepare a special table of contents for a CD-I disc. They don't have one. */
-         if (single_toc.disk_type == 0x10 &&
-             single_toc.first_track_num == 2 &&
-             single_toc.last_track_num == 2 /* CD-I */)
-         {
-            sony_toc.tracks[totaltracks].address = 1;
-	    sony_toc.tracks[totaltracks].control = 4; /* force data tracks */
-            sony_toc.tracks[totaltracks].track = 1;
-            sony_toc.tracks[totaltracks].track_start_msf[0] = 0;
-            sony_toc.tracks[totaltracks].track_start_msf[1] = 2;
-            sony_toc.tracks[totaltracks].track_start_msf[2] = 0;
-            mint = maxt = 1;
-            totaltracks++;
-         } else
-         /* gather track entries from this session */
-         { int i;
-	   for (i = 0; i < 1 + bcd_to_int(single_toc.last_track_num)
-                          - bcd_to_int(single_toc.first_track_num); i++, totaltracks++) {
-             sony_toc.tracks[totaltracks].address = single_toc.tracks[i].address;
-             sony_toc.tracks[totaltracks].control = single_toc.tracks[i].control;
-             sony_toc.tracks[totaltracks].track = bcd_to_int(single_toc.tracks[i].track);
-             sony_toc.tracks[totaltracks].track_start_msf[0] = 
-                  bcd_to_int(single_toc.tracks[i].track_start_msf[0]);
-             sony_toc.tracks[totaltracks].track_start_msf[1] = 
-                  bcd_to_int(single_toc.tracks[i].track_start_msf[1]);
-             sony_toc.tracks[totaltracks].track_start_msf[2] = 
-                  bcd_to_int(single_toc.tracks[i].track_start_msf[2]);
-             if (i == 0)
-               single_toc.start_track_lba = msf_to_log(sony_toc.tracks[totaltracks].track_start_msf);
-             if (mint > sony_toc.tracks[totaltracks].track)
-               mint = sony_toc.tracks[totaltracks].track;
-             if (maxt < sony_toc.tracks[totaltracks].track)
-               maxt = sony_toc.tracks[totaltracks].track;
-           }
-         }
-         sony_toc.first_track_num = mint;
-         sony_toc.last_track_num = maxt;
-         /* Disk type of last session wins. For example:
-            CD-Extra has disk type 0 for the first session, so
-            a dumb HiFi CD player thinks it is a plain audio CD.
-	    We are interested in the disk type of the last session,
-            which is 0x20 (XA) for CD-Extra, so we can access the
-            data track ... */
-         sony_toc.disk_type = single_toc.disk_type;
-         sony_toc.sessions = session;
-
-         /* don't believe everything :-) */
-         if (session == 1)
-            single_toc.start_track_lba = 0;
-         sony_toc.start_track_lba = single_toc.start_track_lba;
-
-         if (session > 1 && single_toc.pointb0 == 0xb0 &&
-             sony_toc.lead_out_start_lba == single_toc.lead_out_start_lba)
-	 {
-            break;
-         }
-
-         /* Let's not get carried away... */
-         if (session > 40)
-         {
-            printk("cdu31a: too many sessions: %d\n", session);
-            break;
-         }
-         session++;
-      }
-      sony_toc.track_entries = totaltracks;
-      /* add one entry for the LAST track with track number CDROM_LEADOUT */ 
-      sony_toc.tracks[totaltracks].address = single_toc.address2;
-      sony_toc.tracks[totaltracks].control = single_toc.control2;
-      sony_toc.tracks[totaltracks].track = CDROM_LEADOUT;
-      sony_toc.tracks[totaltracks].track_start_msf[0] = 
-             sony_toc.lead_out_start_msf[0];
-      sony_toc.tracks[totaltracks].track_start_msf[1] = 
-             sony_toc.lead_out_start_msf[1];
-      sony_toc.tracks[totaltracks].track_start_msf[2] = 
-             sony_toc.lead_out_start_msf[2];
+			sony_toc.lead_out_start_msf[0] =
+			    bcd_to_int(single_toc.lead_out_start_msf[0]);
+			sony_toc.lead_out_start_msf[1] =
+			    bcd_to_int(single_toc.lead_out_start_msf[1]);
+			sony_toc.lead_out_start_msf[2] =
+			    bcd_to_int(single_toc.lead_out_start_msf[2]);
+			sony_toc.lead_out_start_lba =
+			    single_toc.lead_out_start_lba =
+			    msf_to_log(sony_toc.lead_out_start_msf);
+
+			/* For points that do not exist, move the data over them
+			   to the right location. */
+			if (single_toc.pointb0 != 0xb0) {
+				memmove(((char *) &single_toc) + 27,
+					((char *) &single_toc) + 18,
+					res_size - 18);
+				res_size += 9;
+			} else if (res_size > 18) {
+				sony_toc.lead_out_start_msf[0] =
+				    bcd_to_int(single_toc.
+					       max_start_outer_leadout_msf
+					       [0]);
+				sony_toc.lead_out_start_msf[1] =
+				    bcd_to_int(single_toc.
+					       max_start_outer_leadout_msf
+					       [1]);
+				sony_toc.lead_out_start_msf[2] =
+				    bcd_to_int(single_toc.
+					       max_start_outer_leadout_msf
+					       [2]);
+				sony_toc.lead_out_start_lba =
+				    msf_to_log(sony_toc.
+					       lead_out_start_msf);
+			}
+			if (single_toc.pointb1 != 0xb1) {
+				memmove(((char *) &single_toc) + 36,
+					((char *) &single_toc) + 27,
+					res_size - 27);
+				res_size += 9;
+			}
+			if (single_toc.pointb2 != 0xb2) {
+				memmove(((char *) &single_toc) + 45,
+					((char *) &single_toc) + 36,
+					res_size - 36);
+				res_size += 9;
+			}
+			if (single_toc.pointb3 != 0xb3) {
+				memmove(((char *) &single_toc) + 54,
+					((char *) &single_toc) + 45,
+					res_size - 45);
+				res_size += 9;
+			}
+			if (single_toc.pointb4 != 0xb4) {
+				memmove(((char *) &single_toc) + 63,
+					((char *) &single_toc) + 54,
+					res_size - 54);
+				res_size += 9;
+			}
+			if (single_toc.pointc0 != 0xc0) {
+				memmove(((char *) &single_toc) + 72,
+					((char *) &single_toc) + 63,
+					res_size - 63);
+				res_size += 9;
+			}
+#if DEBUG
+			printk
+			    ("start track lba %u,  leadout start lba %u\n",
+			     single_toc.start_track_lba,
+			     single_toc.lead_out_start_lba);
+			{
+				int i;
+				for (i = 0;
+				     i <
+				     1 +
+				     bcd_to_int(single_toc.last_track_num)
+				     -
+				     bcd_to_int(single_toc.
+						first_track_num); i++) {
+					printk
+					    ("trk %02d: add 0x%01x, con 0x%01x,  track %02d, start min %02d, sec %02d, frame %02d\n",
+					     i,
+					     single_toc.tracks[i].address,
+					     single_toc.tracks[i].control,
+					     bcd_to_int(single_toc.
+							tracks[i].track),
+					     bcd_to_int(single_toc.
+							tracks[i].
+							track_start_msf
+							[0]),
+					     bcd_to_int(single_toc.
+							tracks[i].
+							track_start_msf
+							[1]),
+					     bcd_to_int(single_toc.
+							tracks[i].
+							track_start_msf
+							[2]));
+					if (mint >
+					    bcd_to_int(single_toc.
+						       tracks[i].track))
+						mint =
+						    bcd_to_int(single_toc.
+							       tracks[i].
+							       track);
+					if (maxt <
+					    bcd_to_int(single_toc.
+						       tracks[i].track))
+						maxt =
+						    bcd_to_int(single_toc.
+							       tracks[i].
+							       track);
+				}
+				printk
+				    ("min track number %d,   max track number %d\n",
+				     mint, maxt);
+			}
+#endif
+
+			/* prepare a special table of contents for a CD-I disc. They don't have one. */
+			if (single_toc.disk_type == 0x10 &&
+			    single_toc.first_track_num == 2 &&
+			    single_toc.last_track_num == 2 /* CD-I */ ) {
+				sony_toc.tracks[totaltracks].address = 1;
+				sony_toc.tracks[totaltracks].control = 4;	/* force data tracks */
+				sony_toc.tracks[totaltracks].track = 1;
+				sony_toc.tracks[totaltracks].
+				    track_start_msf[0] = 0;
+				sony_toc.tracks[totaltracks].
+				    track_start_msf[1] = 2;
+				sony_toc.tracks[totaltracks].
+				    track_start_msf[2] = 0;
+				mint = maxt = 1;
+				totaltracks++;
+			} else
+				/* gather track entries from this session */
+			{
+				int i;
+				for (i = 0;
+				     i <
+				     1 +
+				     bcd_to_int(single_toc.last_track_num)
+				     -
+				     bcd_to_int(single_toc.
+						first_track_num);
+				     i++, totaltracks++) {
+					sony_toc.tracks[totaltracks].
+					    address =
+					    single_toc.tracks[i].address;
+					sony_toc.tracks[totaltracks].
+					    control =
+					    single_toc.tracks[i].control;
+					sony_toc.tracks[totaltracks].
+					    track =
+					    bcd_to_int(single_toc.
+						       tracks[i].track);
+					sony_toc.tracks[totaltracks].
+					    track_start_msf[0] =
+					    bcd_to_int(single_toc.
+						       tracks[i].
+						       track_start_msf[0]);
+					sony_toc.tracks[totaltracks].
+					    track_start_msf[1] =
+					    bcd_to_int(single_toc.
+						       tracks[i].
+						       track_start_msf[1]);
+					sony_toc.tracks[totaltracks].
+					    track_start_msf[2] =
+					    bcd_to_int(single_toc.
+						       tracks[i].
+						       track_start_msf[2]);
+					if (i == 0)
+						single_toc.
+						    start_track_lba =
+						    msf_to_log(sony_toc.
+							       tracks
+							       [totaltracks].
+							       track_start_msf);
+					if (mint >
+					    sony_toc.tracks[totaltracks].
+					    track)
+						mint =
+						    sony_toc.
+						    tracks[totaltracks].
+						    track;
+					if (maxt <
+					    sony_toc.tracks[totaltracks].
+					    track)
+						maxt =
+						    sony_toc.
+						    tracks[totaltracks].
+						    track;
+				}
+			}
+			sony_toc.first_track_num = mint;
+			sony_toc.last_track_num = maxt;
+			/* Disk type of last session wins. For example:
+			   CD-Extra has disk type 0 for the first session, so
+			   a dumb HiFi CD player thinks it is a plain audio CD.
+			   We are interested in the disk type of the last session,
+			   which is 0x20 (XA) for CD-Extra, so we can access the
+			   data track ... */
+			sony_toc.disk_type = single_toc.disk_type;
+			sony_toc.sessions = session;
+
+			/* don't believe everything :-) */
+			if (session == 1)
+				single_toc.start_track_lba = 0;
+			sony_toc.start_track_lba =
+			    single_toc.start_track_lba;
+
+			if (session > 1 && single_toc.pointb0 == 0xb0 &&
+			    sony_toc.lead_out_start_lba ==
+			    single_toc.lead_out_start_lba) {
+				break;
+			}
+
+			/* Let's not get carried away... */
+			if (session > 40) {
+				printk("cdu31a: too many sessions: %d\n",
+				       session);
+				break;
+			}
+			session++;
+		}
+		sony_toc.track_entries = totaltracks;
+		/* add one entry for the LAST track with track number CDROM_LEADOUT */
+		sony_toc.tracks[totaltracks].address = single_toc.address2;
+		sony_toc.tracks[totaltracks].control = single_toc.control2;
+		sony_toc.tracks[totaltracks].track = CDROM_LEADOUT;
+		sony_toc.tracks[totaltracks].track_start_msf[0] =
+		    sony_toc.lead_out_start_msf[0];
+		sony_toc.tracks[totaltracks].track_start_msf[1] =
+		    sony_toc.lead_out_start_msf[1];
+		sony_toc.tracks[totaltracks].track_start_msf[2] =
+		    sony_toc.lead_out_start_msf[2];
 
-      sony_toc_read = 1;
+		sony_toc_read = 1;
 #undef DEBUG
 #if DEBUG
-   printk("Disk session %d, start track: %d, stop track: %d\n",
-	  session,
-	  single_toc.start_track_lba,
-	  single_toc.lead_out_start_lba);
+		printk
+		    ("Disk session %d, start track: %d, stop track: %d\n",
+		     session, single_toc.start_track_lba,
+		     single_toc.lead_out_start_lba);
 #endif
-   }
+	}
 #if DEBUG
-   printk("Leaving sony_get_toc\n");
+	printk("Leaving sony_get_toc\n");
 #endif
 }
 
@@ -2236,74 +2230,76 @@
  * Uniform cdrom interface function
  * return multisession offset and sector information
  */
-static int scd_get_last_session(struct cdrom_device_info *cdi, 
-                                struct cdrom_multisession *ms_info)
+static int scd_get_last_session(struct cdrom_device_info *cdi,
+				struct cdrom_multisession *ms_info)
 {
-   if (ms_info == NULL)
-      return 1;
+	if (ms_info == NULL)
+		return 1;
 
-   if (!sony_toc_read)
-      sony_get_toc();
+	if (!sony_toc_read)
+		sony_get_toc();
 
-   ms_info->addr_format = CDROM_LBA;
-   ms_info->addr.lba    = sony_toc.start_track_lba;
-   ms_info->xa_flag     = sony_toc.disk_type == SONY_XA_DISK_TYPE ||
-                          sony_toc.disk_type == 0x10 /* CDI */;
+	ms_info->addr_format = CDROM_LBA;
+	ms_info->addr.lba = sony_toc.start_track_lba;
+	ms_info->xa_flag = sony_toc.disk_type == SONY_XA_DISK_TYPE ||
+	    sony_toc.disk_type == 0x10 /* CDI */ ;
 
-   return 0;
+	return 0;
 }
 
 /*
  * Search for a specific track in the table of contents.
  */
-static int
-find_track(int track)
+static int find_track(int track)
 {
-   int i;
+	int i;
 
-   for (i = 0; i <= sony_toc.track_entries; i++)
-   {
-      if (sony_toc.tracks[i].track == track)
-      {
-         return i;
-      }
-   }
+	for (i = 0; i <= sony_toc.track_entries; i++) {
+		if (sony_toc.tracks[i].track == track) {
+			return i;
+		}
+	}
 
-   return -1;
+	return -1;
 }
 
 
 /*
  * Read the subcode and put it in last_sony_subcode for future use.
  */
-static int
-read_subcode(void)
+static int read_subcode(void)
 {
-   unsigned int res_size;
+	unsigned int res_size;
 
 
-   do_sony_cd_cmd(SONY_REQ_SUBCODE_ADDRESS_CMD,
-                  NULL,
-                  0, 
-                  (unsigned char *) &last_sony_subcode, 
-                  &res_size);
-   if ((res_size < 2) || ((last_sony_subcode.exec_status[0] & 0xf0) == 0x20))
-   {
-      printk("Sony CDROM error %s (read_subcode)\n",
-             translate_error(last_sony_subcode.exec_status[1]));
-      return -EIO;
-   }
-
-   last_sony_subcode.track_num = bcd_to_int(last_sony_subcode.track_num);
-   last_sony_subcode.index_num = bcd_to_int(last_sony_subcode.index_num);
-   last_sony_subcode.abs_msf[0] = bcd_to_int(last_sony_subcode.abs_msf[0]);
-   last_sony_subcode.abs_msf[1] = bcd_to_int(last_sony_subcode.abs_msf[1]);
-   last_sony_subcode.abs_msf[2] = bcd_to_int(last_sony_subcode.abs_msf[2]);
-
-   last_sony_subcode.rel_msf[0] = bcd_to_int(last_sony_subcode.rel_msf[0]);
-   last_sony_subcode.rel_msf[1] = bcd_to_int(last_sony_subcode.rel_msf[1]);
-   last_sony_subcode.rel_msf[2] = bcd_to_int(last_sony_subcode.rel_msf[2]);
-   return 0;
+	do_sony_cd_cmd(SONY_REQ_SUBCODE_ADDRESS_CMD,
+		       NULL,
+		       0, (unsigned char *) &last_sony_subcode, &res_size);
+	if ((res_size < 2)
+	    || ((last_sony_subcode.exec_status[0] & 0xf0) == 0x20)) {
+		printk("Sony CDROM error %s (read_subcode)\n",
+		       translate_error(last_sony_subcode.exec_status[1]));
+		return -EIO;
+	}
+
+	last_sony_subcode.track_num =
+	    bcd_to_int(last_sony_subcode.track_num);
+	last_sony_subcode.index_num =
+	    bcd_to_int(last_sony_subcode.index_num);
+	last_sony_subcode.abs_msf[0] =
+	    bcd_to_int(last_sony_subcode.abs_msf[0]);
+	last_sony_subcode.abs_msf[1] =
+	    bcd_to_int(last_sony_subcode.abs_msf[1]);
+	last_sony_subcode.abs_msf[2] =
+	    bcd_to_int(last_sony_subcode.abs_msf[2]);
+
+	last_sony_subcode.rel_msf[0] =
+	    bcd_to_int(last_sony_subcode.rel_msf[0]);
+	last_sony_subcode.rel_msf[1] =
+	    bcd_to_int(last_sony_subcode.rel_msf[1]);
+	last_sony_subcode.rel_msf[2] =
+	    bcd_to_int(last_sony_subcode.rel_msf[2]);
+	return 0;
 }
 
 /*
@@ -2313,37 +2309,33 @@
 static int
 scd_get_mcn(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn)
 {
-   unsigned char resbuffer[2 + 14];
-   unsigned char *mcnp = mcn->medium_catalog_number;
-   unsigned char *resp = resbuffer + 3;
-   unsigned int res_size;
-
-   memset(mcn->medium_catalog_number, 0, 14);
-   do_sony_cd_cmd(SONY_REQ_UPC_EAN_CMD,
-                  NULL,
-                  0, 
-                  resbuffer,
-                  &res_size);
-   if ((res_size < 2) || ((resbuffer[0] & 0xf0) == 0x20))
-     ;
-   else {
-     /* packed bcd to single ASCII digits */
-     *mcnp++ = (*resp >> 4)     + '0'; 
-     *mcnp++ = (*resp++ & 0x0f) + '0'; 
-     *mcnp++ = (*resp >> 4)     + '0'; 
-     *mcnp++ = (*resp++ & 0x0f) + '0'; 
-     *mcnp++ = (*resp >> 4)     + '0'; 
-     *mcnp++ = (*resp++ & 0x0f) + '0'; 
-     *mcnp++ = (*resp >> 4)     + '0'; 
-     *mcnp++ = (*resp++ & 0x0f) + '0'; 
-     *mcnp++ = (*resp >> 4)     + '0'; 
-     *mcnp++ = (*resp++ & 0x0f) + '0'; 
-     *mcnp++ = (*resp >> 4)     + '0'; 
-     *mcnp++ = (*resp++ & 0x0f) + '0'; 
-     *mcnp++ = (*resp >> 4)     + '0'; 
-   }
-   *mcnp = '\0';
-   return 0;
+	unsigned char resbuffer[2 + 14];
+	unsigned char *mcnp = mcn->medium_catalog_number;
+	unsigned char *resp = resbuffer + 3;
+	unsigned int res_size;
+
+	memset(mcn->medium_catalog_number, 0, 14);
+	do_sony_cd_cmd(SONY_REQ_UPC_EAN_CMD,
+		       NULL, 0, resbuffer, &res_size);
+	if ((res_size < 2) || ((resbuffer[0] & 0xf0) == 0x20));
+	else {
+		/* packed bcd to single ASCII digits */
+		*mcnp++ = (*resp >> 4) + '0';
+		*mcnp++ = (*resp++ & 0x0f) + '0';
+		*mcnp++ = (*resp >> 4) + '0';
+		*mcnp++ = (*resp++ & 0x0f) + '0';
+		*mcnp++ = (*resp >> 4) + '0';
+		*mcnp++ = (*resp++ & 0x0f) + '0';
+		*mcnp++ = (*resp >> 4) + '0';
+		*mcnp++ = (*resp++ & 0x0f) + '0';
+		*mcnp++ = (*resp >> 4) + '0';
+		*mcnp++ = (*resp++ & 0x0f) + '0';
+		*mcnp++ = (*resp >> 4) + '0';
+		*mcnp++ = (*resp++ & 0x0f) + '0';
+		*mcnp++ = (*resp >> 4) + '0';
+	}
+	*mcnp = '\0';
+	return 0;
 }
 
 
@@ -2354,67 +2346,67 @@
  * already been stored, just use that.  The ioctl call wants things in decimal
  * (not BCD), so all the conversions are done.
  */
-static int
-sony_get_subchnl_info(struct cdrom_subchnl *schi)
+static int sony_get_subchnl_info(struct cdrom_subchnl *schi)
 {
-   /* Get attention stuff */
-   while (handle_sony_cd_attention())
-      ;
-
-   sony_get_toc();
-   if (!sony_toc_read)
-   {
-      return -EIO;
-   }
-
-   switch (sony_audio_status)
-   {
-   case CDROM_AUDIO_NO_STATUS:
-   case CDROM_AUDIO_PLAY:
-      if (read_subcode() < 0)
-      {
-         return -EIO;
-      }
-      break;
-
-   case CDROM_AUDIO_PAUSED:
-   case CDROM_AUDIO_COMPLETED:
-      break;
+	/* Get attention stuff */
+	while (handle_sony_cd_attention());
+
+	sony_get_toc();
+	if (!sony_toc_read) {
+		return -EIO;
+	}
+
+	switch (sony_audio_status) {
+	case CDROM_AUDIO_NO_STATUS:
+	case CDROM_AUDIO_PLAY:
+		if (read_subcode() < 0) {
+			return -EIO;
+		}
+		break;
+
+	case CDROM_AUDIO_PAUSED:
+	case CDROM_AUDIO_COMPLETED:
+		break;
 
 #if 0
-   case CDROM_AUDIO_NO_STATUS:
-      schi->cdsc_audiostatus = sony_audio_status;
-      return 0;
-      break;
-#endif
-   case CDROM_AUDIO_INVALID:
-   case CDROM_AUDIO_ERROR:
-   default:
-      return -EIO;
-   }
-
-   schi->cdsc_audiostatus = sony_audio_status;
-   schi->cdsc_adr = last_sony_subcode.address;
-   schi->cdsc_ctrl = last_sony_subcode.control;
-   schi->cdsc_trk = last_sony_subcode.track_num;
-   schi->cdsc_ind = last_sony_subcode.index_num;
-   if (schi->cdsc_format == CDROM_MSF)
-   {
-      schi->cdsc_absaddr.msf.minute = last_sony_subcode.abs_msf[0];
-      schi->cdsc_absaddr.msf.second = last_sony_subcode.abs_msf[1];
-      schi->cdsc_absaddr.msf.frame = last_sony_subcode.abs_msf[2];
-
-      schi->cdsc_reladdr.msf.minute = last_sony_subcode.rel_msf[0];
-      schi->cdsc_reladdr.msf.second = last_sony_subcode.rel_msf[1];
-      schi->cdsc_reladdr.msf.frame = last_sony_subcode.rel_msf[2];
-   }
-   else if (schi->cdsc_format == CDROM_LBA)
-   {
-      schi->cdsc_absaddr.lba = msf_to_log(last_sony_subcode.abs_msf);
-      schi->cdsc_reladdr.lba = msf_to_log(last_sony_subcode.rel_msf);
-   }
-   
-   return 0;
+	case CDROM_AUDIO_NO_STATUS:
+		schi->cdsc_audiostatus = sony_audio_status;
+		return 0;
+		break;
+#endif
+	case CDROM_AUDIO_INVALID:
+	case CDROM_AUDIO_ERROR:
+	default:
+		return -EIO;
+	}
+
+	schi->cdsc_audiostatus = sony_audio_status;
+	schi->cdsc_adr = last_sony_subcode.address;
+	schi->cdsc_ctrl = last_sony_subcode.control;
+	schi->cdsc_trk = last_sony_subcode.track_num;
+	schi->cdsc_ind = last_sony_subcode.index_num;
+	if (schi->cdsc_format == CDROM_MSF) {
+		schi->cdsc_absaddr.msf.minute =
+		    last_sony_subcode.abs_msf[0];
+		schi->cdsc_absaddr.msf.second =
+		    last_sony_subcode.abs_msf[1];
+		schi->cdsc_absaddr.msf.frame =
+		    last_sony_subcode.abs_msf[2];
+
+		schi->cdsc_reladdr.msf.minute =
+		    last_sony_subcode.rel_msf[0];
+		schi->cdsc_reladdr.msf.second =
+		    last_sony_subcode.rel_msf[1];
+		schi->cdsc_reladdr.msf.frame =
+		    last_sony_subcode.rel_msf[2];
+	} else if (schi->cdsc_format == CDROM_LBA) {
+		schi->cdsc_absaddr.lba =
+		    msf_to_log(last_sony_subcode.abs_msf);
+		schi->cdsc_reladdr.lba =
+		    msf_to_log(last_sony_subcode.rel_msf);
+	}
+
+	return 0;
 }
 
 /* Get audio data from the drive.  This is fairly complex because I
@@ -2422,782 +2414,756 @@
    then I just look for data.  I need to get the status immediately so
    the switch from audio to data tracks will happen quickly. */
 static void
-read_audio_data(char          *buffer,
-                unsigned char res_reg[],
-                int           *res_size)
-{
-   unsigned int retry_count;
-   int result_read;
-
-
-   res_reg[0] = 0;
-   res_reg[1] = 0;
-   *res_size = 0;
-   result_read = 0;
-
-   /* Wait for the drive to tell us we have something */
-   retry_count = jiffies + SONY_JIFFIES_TIMEOUT;
-continue_read_audio_wait:
-   while (time_before(jiffies, retry_count) && !(is_data_ready())
-          && !(is_result_ready() || result_read))
-   {
-      while (handle_sony_cd_attention())
-         ;
-
-      sony_sleep();
-   }
-   if (!(is_data_ready()))
-   {
-      if (is_result_ready() && !result_read)
-      {
-         get_result(res_reg, res_size);
-
-         /* Read block status and continue waiting for data. */
-         if ((res_reg[0] & 0xf0) == 0x50)
-         {
-            result_read = 1;
-            goto continue_read_audio_wait;
-         }
-         /* Invalid data from the drive.  Shut down the operation. */
-         else if ((res_reg[0] & 0xf0) != 0x20)
-         {
-            printk("CDU31A: Got result that should have been error: %d\n",
-                   res_reg[0]);
-            res_reg[0] = 0x20;
-            res_reg[1] = SONY_BAD_DATA_ERR;
-            *res_size = 2;
-         }
-         abort_read();
-      }
-      else
-      {
-#if DEBUG
-         printk("CDU31A timeout out %d\n", __LINE__);
-#endif
-         res_reg[0] = 0x20;
-         res_reg[1] = SONY_TIMEOUT_OP_ERR;
-         *res_size = 2;
-         abort_read();
-      }
-   }
-   else
-   {
-      clear_data_ready();
-
-      /* If data block, then get 2340 bytes offset by 12. */
-      if (sony_raw_data_mode)
-      {
-         insb(sony_cd_read_reg, buffer + CD_XA_HEAD, CD_FRAMESIZE_RAW1);
-      }
-      else
-      {
-         /* Audio gets the whole 2352 bytes. */
-         insb(sony_cd_read_reg, buffer, CD_FRAMESIZE_RAW);
-      }
-
-      /* If I haven't already gotten the result, get it now. */
-      if (!result_read)
-      {
-         /* Wait for the drive to tell us we have something */
-         retry_count = jiffies + SONY_JIFFIES_TIMEOUT;
-         while (time_before(jiffies, retry_count) && !(is_result_ready()))
-         {
-            while (handle_sony_cd_attention())
-               ;
-
-            sony_sleep();
-         }
-
-         if (!is_result_ready())
-         {
-#if DEBUG
-            printk("CDU31A timeout out %d\n", __LINE__);
-#endif
-            res_reg[0] = 0x20;
-            res_reg[1] = SONY_TIMEOUT_OP_ERR;
-            *res_size = 2;
-            abort_read();
-            return;
-         }
-         else
-         {
-            get_result(res_reg, res_size);
-         }
-      }
-
-      if ((res_reg[0] & 0xf0) == 0x50)
-      {
-         if (   (res_reg[0] == SONY_NO_CIRC_ERR_BLK_STAT)
-             || (res_reg[0] == SONY_NO_LECC_ERR_BLK_STAT)
-             || (res_reg[0] == SONY_RECOV_LECC_ERR_BLK_STAT)
-             || (res_reg[0] == SONY_NO_ERR_DETECTION_STAT))
-         {
-            /* Ok, nothing to do. */
-         }
-         else
-         {
-            printk("CDU31A: Data block error: 0x%x\n", res_reg[0]);
-            res_reg[0] = 0x20;
-            res_reg[1] = SONY_BAD_DATA_ERR;
-            *res_size = 2;
-         }
-      }
-      else if ((res_reg[0] & 0xf0) != 0x20)
-      {
-         /* The drive gave me bad status, I don't know what to do.
-            Reset the driver and return an error. */
-         printk("CDU31A: Invalid block status: 0x%x\n", res_reg[0]);
-         restart_on_error();
-         res_reg[0] = 0x20;
-         res_reg[1] = SONY_BAD_DATA_ERR;
-         *res_size = 2;
-      }
-   }
+read_audio_data(char *buffer, unsigned char res_reg[], int *res_size)
+{
+	unsigned int retry_count;
+	int result_read;
+
+
+	res_reg[0] = 0;
+	res_reg[1] = 0;
+	*res_size = 0;
+	result_read = 0;
+
+	/* Wait for the drive to tell us we have something */
+	retry_count = jiffies + SONY_JIFFIES_TIMEOUT;
+      continue_read_audio_wait:
+	while (time_before(jiffies, retry_count) && !(is_data_ready())
+	       && !(is_result_ready() || result_read)) {
+		while (handle_sony_cd_attention());
+
+		sony_sleep();
+	}
+	if (!(is_data_ready())) {
+		if (is_result_ready() && !result_read) {
+			get_result(res_reg, res_size);
+
+			/* Read block status and continue waiting for data. */
+			if ((res_reg[0] & 0xf0) == 0x50) {
+				result_read = 1;
+				goto continue_read_audio_wait;
+			}
+			/* Invalid data from the drive.  Shut down the operation. */
+			else if ((res_reg[0] & 0xf0) != 0x20) {
+				printk
+				    ("CDU31A: Got result that should have been error: %d\n",
+				     res_reg[0]);
+				res_reg[0] = 0x20;
+				res_reg[1] = SONY_BAD_DATA_ERR;
+				*res_size = 2;
+			}
+			abort_read();
+		} else {
+#if DEBUG
+			printk("CDU31A timeout out %d\n", __LINE__);
+#endif
+			res_reg[0] = 0x20;
+			res_reg[1] = SONY_TIMEOUT_OP_ERR;
+			*res_size = 2;
+			abort_read();
+		}
+	} else {
+		clear_data_ready();
+
+		/* If data block, then get 2340 bytes offset by 12. */
+		if (sony_raw_data_mode) {
+			insb(sony_cd_read_reg, buffer + CD_XA_HEAD,
+			     CD_FRAMESIZE_RAW1);
+		} else {
+			/* Audio gets the whole 2352 bytes. */
+			insb(sony_cd_read_reg, buffer, CD_FRAMESIZE_RAW);
+		}
+
+		/* If I haven't already gotten the result, get it now. */
+		if (!result_read) {
+			/* Wait for the drive to tell us we have something */
+			retry_count = jiffies + SONY_JIFFIES_TIMEOUT;
+			while (time_before(jiffies, retry_count)
+			       && !(is_result_ready())) {
+				while (handle_sony_cd_attention());
+
+				sony_sleep();
+			}
+
+			if (!is_result_ready()) {
+#if DEBUG
+				printk("CDU31A timeout out %d\n",
+				       __LINE__);
+#endif
+				res_reg[0] = 0x20;
+				res_reg[1] = SONY_TIMEOUT_OP_ERR;
+				*res_size = 2;
+				abort_read();
+				return;
+			} else {
+				get_result(res_reg, res_size);
+			}
+		}
+
+		if ((res_reg[0] & 0xf0) == 0x50) {
+			if ((res_reg[0] == SONY_NO_CIRC_ERR_BLK_STAT)
+			    || (res_reg[0] == SONY_NO_LECC_ERR_BLK_STAT)
+			    || (res_reg[0] == SONY_RECOV_LECC_ERR_BLK_STAT)
+			    || (res_reg[0] == SONY_NO_ERR_DETECTION_STAT)) {
+				/* Ok, nothing to do. */
+			} else {
+				printk("CDU31A: Data block error: 0x%x\n",
+				       res_reg[0]);
+				res_reg[0] = 0x20;
+				res_reg[1] = SONY_BAD_DATA_ERR;
+				*res_size = 2;
+			}
+		} else if ((res_reg[0] & 0xf0) != 0x20) {
+			/* The drive gave me bad status, I don't know what to do.
+			   Reset the driver and return an error. */
+			printk("CDU31A: Invalid block status: 0x%x\n",
+			       res_reg[0]);
+			restart_on_error();
+			res_reg[0] = 0x20;
+			res_reg[1] = SONY_BAD_DATA_ERR;
+			*res_size = 2;
+		}
+	}
 }
 
 /* Perform a raw data read.  This will automatically detect the
    track type and read the proper data (audio or data). */
-static int
-read_audio(struct cdrom_read_audio *ra)
+static int read_audio(struct cdrom_read_audio *ra)
 {
-   int retval;
-   unsigned char params[2];
-   unsigned char res_reg[12];
-   unsigned int res_size;
-   unsigned int cframe;
-   unsigned long flags;
-
-   /* 
-    * Make sure no one else is using the driver; wait for them
-    * to finish if it is so.
-    */
-   save_flags(flags);
-   cli();
-   while (sony_inuse)
-   {
-      interruptible_sleep_on(&sony_wait);
-      if (signal_pending(current))
-      {
-         restore_flags(flags);
-         return -EAGAIN;
-      }
-   }
-   sony_inuse = 1;
-   has_cd_task = current;
-   restore_flags(flags);
-
-   if (!sony_spun_up)
-   {
-     scd_spinup();
-   }
-
-   /* Set the drive to do raw operations. */
-   params[0] = SONY_SD_DECODE_PARAM;
-   params[1] = 0x06 | sony_raw_data_mode;
-   do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD,
-                  params,
-                  2,
-                  res_reg,
-                  &res_size);
-   if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20))
-   {
-      printk("CDU31A: Unable to set decode params: 0x%2.2x\n", res_reg[1]);
-      return -EIO;
-   }
-
-   /* From here down, we have to goto exit_read_audio instead of returning
-      because the drive parameters have to be set back to data before
-      return. */
-
-   retval = 0;
-   /* start_request clears out any readahead data, so it should be safe. */
-   if (start_request(ra->addr.lba, ra->nframes, 1))
-   {
-      retval = -EIO;
-      goto exit_read_audio;
-   }
-
-   /* For every requested frame. */
-   cframe = 0;
-   while (cframe < ra->nframes)
-   {
-      read_audio_data(readahead_buffer, res_reg, &res_size);
-      if ((res_reg[0] & 0xf0) == 0x20)
-      {
-         if (res_reg[1] == SONY_BAD_DATA_ERR)
-         {
-            printk("CDU31A: Data error on audio sector %d\n",
-                   ra->addr.lba + cframe);
-         }
-         else if (res_reg[1] == SONY_ILL_TRACK_R_ERR)
-         {
-            /* Illegal track type, change track types and start over. */
-            sony_raw_data_mode = (sony_raw_data_mode) ? 0 : 1;
-
-            /* Set the drive mode. */
-            params[0] = SONY_SD_DECODE_PARAM;
-            params[1] = 0x06 | sony_raw_data_mode;
-            do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD,
-                           params,
-                           2,
-                           res_reg,
-                           &res_size);
-            if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20))
-            {
-               printk("CDU31A: Unable to set decode params: 0x%2.2x\n", res_reg[1]);
-               retval = -EIO;
-               goto exit_read_audio;
-            }
-
-            /* Restart the request on the current frame. */
-            if (start_request(ra->addr.lba + cframe, ra->nframes - cframe, 1))
-            {
-               retval = -EIO;
-               goto exit_read_audio;
-            }
-
-            /* Don't go back to the top because don't want to get into
-               and infinite loop.  A lot of code gets duplicated, but
-               that's no big deal, I don't guess. */
-            read_audio_data(readahead_buffer, res_reg, &res_size);
-            if ((res_reg[0] & 0xf0) == 0x20)
-            {
-               if (res_reg[1] == SONY_BAD_DATA_ERR)
-               {
-                  printk("CDU31A: Data error on audio sector %d\n",
-                         ra->addr.lba + cframe);
-               }
-               else
-               {
-                  printk("CDU31A: Error reading audio data on sector %d: %s\n",
-                         ra->addr.lba + cframe,
-                         translate_error(res_reg[1]));
-                  retval = -EIO;
-                  goto exit_read_audio;
-               }
-            }
-            else
-            {
-               copy_to_user((char *) (ra->buf + (CD_FRAMESIZE_RAW * cframe)),
-                           (char *) readahead_buffer,
-                           CD_FRAMESIZE_RAW);
-            }
-         }
-         else
-         {
-            printk("CDU31A: Error reading audio data on sector %d: %s\n",
-                   ra->addr.lba + cframe,
-                   translate_error(res_reg[1]));
-            retval = -EIO;
-            goto exit_read_audio;
-         }
-      }
-      else
-      {
-         copy_to_user((char *) (ra->buf + (CD_FRAMESIZE_RAW * cframe)),
-                     (char *) readahead_buffer,
-                     CD_FRAMESIZE_RAW);
-      }
-
-      cframe++;
-   }
-
-   get_result(res_reg, &res_size);
-   if ((res_reg[0] & 0xf0) == 0x20)
-   {
-      printk("CDU31A: Error return from audio read: %s\n",
-             translate_error(res_reg[1]));
-      retval = -EIO;
-      goto exit_read_audio;
-   }
-
-exit_read_audio:
-
-   /* Set the drive mode back to the proper one for the disk. */
-   params[0] = SONY_SD_DECODE_PARAM;
-   if (!sony_xa_mode)
-   {
-      params[1] = 0x0f;
-   }
-   else
-   {
-      params[1] = 0x07;
-   }
-   do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD,
-                  params,
-                  2,
-                  res_reg,
-                  &res_size);
-   if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20))
-   {
-      printk("CDU31A: Unable to reset decode params: 0x%2.2x\n", res_reg[1]);
-      return -EIO;
-   }
-
-   has_cd_task = NULL;
-   sony_inuse = 0;
-   wake_up_interruptible(&sony_wait);
+	int retval;
+	unsigned char params[2];
+	unsigned char res_reg[12];
+	unsigned int res_size;
+	unsigned int cframe;
+	unsigned long flags;
+
+	/* 
+	 * Make sure no one else is using the driver; wait for them
+	 * to finish if it is so.
+	 */
+	save_flags(flags);
+	cli();
+	while (sony_inuse) {
+		interruptible_sleep_on(&sony_wait);
+		if (signal_pending(current)) {
+			restore_flags(flags);
+			return -EAGAIN;
+		}
+	}
+	sony_inuse = 1;
+	has_cd_task = current;
+	restore_flags(flags);
+
+	if (!sony_spun_up) {
+		scd_spinup();
+	}
+
+	/* Set the drive to do raw operations. */
+	params[0] = SONY_SD_DECODE_PARAM;
+	params[1] = 0x06 | sony_raw_data_mode;
+	do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD,
+		       params, 2, res_reg, &res_size);
+	if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20)) {
+		printk("CDU31A: Unable to set decode params: 0x%2.2x\n",
+		       res_reg[1]);
+		return -EIO;
+	}
+
+	/* From here down, we have to goto exit_read_audio instead of returning
+	   because the drive parameters have to be set back to data before
+	   return. */
+
+	retval = 0;
+	/* start_request clears out any readahead data, so it should be safe. */
+	if (start_request(ra->addr.lba, ra->nframes, 1)) {
+		retval = -EIO;
+		goto exit_read_audio;
+	}
+
+	/* For every requested frame. */
+	cframe = 0;
+	while (cframe < ra->nframes) {
+		read_audio_data(readahead_buffer, res_reg, &res_size);
+		if ((res_reg[0] & 0xf0) == 0x20) {
+			if (res_reg[1] == SONY_BAD_DATA_ERR) {
+				printk
+				    ("CDU31A: Data error on audio sector %d\n",
+				     ra->addr.lba + cframe);
+			} else if (res_reg[1] == SONY_ILL_TRACK_R_ERR) {
+				/* Illegal track type, change track types and start over. */
+				sony_raw_data_mode =
+				    (sony_raw_data_mode) ? 0 : 1;
+
+				/* Set the drive mode. */
+				params[0] = SONY_SD_DECODE_PARAM;
+				params[1] = 0x06 | sony_raw_data_mode;
+				do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD,
+					       params,
+					       2, res_reg, &res_size);
+				if ((res_size < 2)
+				    || ((res_reg[0] & 0xf0) == 0x20)) {
+					printk
+					    ("CDU31A: Unable to set decode params: 0x%2.2x\n",
+					     res_reg[1]);
+					retval = -EIO;
+					goto exit_read_audio;
+				}
+
+				/* Restart the request on the current frame. */
+				if (start_request
+				    (ra->addr.lba + cframe,
+				     ra->nframes - cframe, 1)) {
+					retval = -EIO;
+					goto exit_read_audio;
+				}
+
+				/* Don't go back to the top because don't want to get into
+				   and infinite loop.  A lot of code gets duplicated, but
+				   that's no big deal, I don't guess. */
+				read_audio_data(readahead_buffer, res_reg,
+						&res_size);
+				if ((res_reg[0] & 0xf0) == 0x20) {
+					if (res_reg[1] ==
+					    SONY_BAD_DATA_ERR) {
+						printk
+						    ("CDU31A: Data error on audio sector %d\n",
+						     ra->addr.lba +
+						     cframe);
+					} else {
+						printk
+						    ("CDU31A: Error reading audio data on sector %d: %s\n",
+						     ra->addr.lba + cframe,
+						     translate_error
+						     (res_reg[1]));
+						retval = -EIO;
+						goto exit_read_audio;
+					}
+				} else {
+					copy_to_user((char *) (ra->buf +
+							       (CD_FRAMESIZE_RAW
+								* cframe)),
+						     (char *)
+						     readahead_buffer,
+						     CD_FRAMESIZE_RAW);
+				}
+			} else {
+				printk
+				    ("CDU31A: Error reading audio data on sector %d: %s\n",
+				     ra->addr.lba + cframe,
+				     translate_error(res_reg[1]));
+				retval = -EIO;
+				goto exit_read_audio;
+			}
+		} else {
+			copy_to_user((char *) (ra->buf +
+					       (CD_FRAMESIZE_RAW *
+						cframe)),
+				     (char *) readahead_buffer,
+				     CD_FRAMESIZE_RAW);
+		}
+
+		cframe++;
+	}
+
+	get_result(res_reg, &res_size);
+	if ((res_reg[0] & 0xf0) == 0x20) {
+		printk("CDU31A: Error return from audio read: %s\n",
+		       translate_error(res_reg[1]));
+		retval = -EIO;
+		goto exit_read_audio;
+	}
+
+      exit_read_audio:
+
+	/* Set the drive mode back to the proper one for the disk. */
+	params[0] = SONY_SD_DECODE_PARAM;
+	if (!sony_xa_mode) {
+		params[1] = 0x0f;
+	} else {
+		params[1] = 0x07;
+	}
+	do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD,
+		       params, 2, res_reg, &res_size);
+	if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20)) {
+		printk("CDU31A: Unable to reset decode params: 0x%2.2x\n",
+		       res_reg[1]);
+		return -EIO;
+	}
+
+	has_cd_task = NULL;
+	sony_inuse = 0;
+	wake_up_interruptible(&sony_wait);
 
-   return(retval);
+	return (retval);
 }
 
 static int
 do_sony_cd_cmd_chk(const char *name,
-                   unsigned char cmd,
-                   unsigned char *params,
-                   unsigned int num_params,
-		   unsigned char *result_buffer,
-                   unsigned int *result_size)
-{      
-      do_sony_cd_cmd(cmd, params, num_params, result_buffer, result_size);
-      if ((*result_size < 2) || ((result_buffer[0] & 0xf0) == 0x20))
-      {
-         printk("Sony CDROM error %s (CDROM%s)\n", translate_error(result_buffer[1]), name);
-         return -EIO;
-      }
-      return 0;
+		   unsigned char cmd,
+		   unsigned char *params,
+		   unsigned int num_params,
+		   unsigned char *result_buffer, unsigned int *result_size)
+{
+	do_sony_cd_cmd(cmd, params, num_params, result_buffer,
+		       result_size);
+	if ((*result_size < 2) || ((result_buffer[0] & 0xf0) == 0x20)) {
+		printk("Sony CDROM error %s (CDROM%s)\n",
+		       translate_error(result_buffer[1]), name);
+		return -EIO;
+	}
+	return 0;
 }
- 
+
 /*
  * Uniform cdrom interface function
  * open the tray
  */
 static int scd_tray_move(struct cdrom_device_info *cdi, int position)
 {
-  if (position == 1 /* open tray */)
-  {
-    unsigned char res_reg[12];
-    unsigned int res_size;
-
-    do_sony_cd_cmd(SONY_AUDIO_STOP_CMD, NULL, 0, res_reg, &res_size);
-    do_sony_cd_cmd(SONY_SPIN_DOWN_CMD, NULL, 0, res_reg, &res_size);
-
-    sony_audio_status = CDROM_AUDIO_INVALID;
-    return do_sony_cd_cmd_chk("EJECT",SONY_EJECT_CMD, NULL, 0, res_reg, &res_size);
-  } else {
-    if (0 == scd_spinup())
-      sony_spun_up = 1;
-    return 0;
-  }
+	if (position == 1 /* open tray */ ) {
+		unsigned char res_reg[12];
+		unsigned int res_size;
+
+		do_sony_cd_cmd(SONY_AUDIO_STOP_CMD, NULL, 0, res_reg,
+			       &res_size);
+		do_sony_cd_cmd(SONY_SPIN_DOWN_CMD, NULL, 0, res_reg,
+			       &res_size);
+
+		sony_audio_status = CDROM_AUDIO_INVALID;
+		return do_sony_cd_cmd_chk("EJECT", SONY_EJECT_CMD, NULL, 0,
+					  res_reg, &res_size);
+	} else {
+		if (0 == scd_spinup())
+			sony_spun_up = 1;
+		return 0;
+	}
 }
 
 /*
  * The big ugly ioctl handler.
  */
 static int scd_audio_ioctl(struct cdrom_device_info *cdi,
-          unsigned int  cmd,
-          void * arg)
+			   unsigned int cmd, void *arg)
 {
-   unsigned char res_reg[12];
-   unsigned int res_size;
-   unsigned char params[7];
-   int i;
-
-
-   switch (cmd)
-   {
-   case CDROMSTART:     /* Spin up the drive */
-      return do_sony_cd_cmd_chk("START",SONY_SPIN_UP_CMD, NULL, 0, res_reg, &res_size);
-      break;
-      
-   case CDROMSTOP:      /* Spin down the drive */
-      do_sony_cd_cmd(SONY_AUDIO_STOP_CMD, NULL, 0, res_reg, &res_size);
-
-      /*
-       * Spin the drive down, ignoring the error if the disk was
-       * already not spinning.
-       */
-      sony_audio_status = CDROM_AUDIO_NO_STATUS;
-      return do_sony_cd_cmd_chk("STOP",SONY_SPIN_DOWN_CMD, NULL, 0, res_reg, &res_size);
-
-   case CDROMPAUSE:     /* Pause the drive */
-      if(do_sony_cd_cmd_chk("PAUSE", SONY_AUDIO_STOP_CMD, NULL, 0, res_reg, &res_size))
-      	return -EIO;
-      /* Get the current position and save it for resuming */
-      if (read_subcode() < 0)
-      {
-         return -EIO;
-      }
-      cur_pos_msf[0] = last_sony_subcode.abs_msf[0];
-      cur_pos_msf[1] = last_sony_subcode.abs_msf[1];
-      cur_pos_msf[2] = last_sony_subcode.abs_msf[2];
-      sony_audio_status = CDROM_AUDIO_PAUSED;
-      return 0;
-      break;
-
-   case CDROMRESUME:    /* Start the drive after being paused */
-      if (sony_audio_status != CDROM_AUDIO_PAUSED)
-      {
-         return -EINVAL;
-      }
-      
-      do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, &res_size);
-      
-      /* Start the drive at the saved position. */
-      params[1] = int_to_bcd(cur_pos_msf[0]);
-      params[2] = int_to_bcd(cur_pos_msf[1]);
-      params[3] = int_to_bcd(cur_pos_msf[2]);
-      params[4] = int_to_bcd(final_pos_msf[0]);
-      params[5] = int_to_bcd(final_pos_msf[1]);
-      params[6] = int_to_bcd(final_pos_msf[2]);
-      params[0] = 0x03;
-      if(do_sony_cd_cmd_chk("RESUME",SONY_AUDIO_PLAYBACK_CMD, params, 7, res_reg, &res_size)<0)
-      	return -EIO;
-      sony_audio_status = CDROM_AUDIO_PLAY;
-      return 0;
-
-   case CDROMPLAYMSF:   /* Play starting at the given MSF address. */
-      do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, &res_size);
-      
-      /* The parameters are given in int, must be converted */
-      for (i=1; i<7; i++)
-      {
-         params[i] = int_to_bcd(((unsigned char *)arg)[i-1]);
-      }
-      params[0] = 0x03;
-      if(do_sony_cd_cmd_chk("PLAYMSF",SONY_AUDIO_PLAYBACK_CMD, params, 7, res_reg, &res_size)<0)
-      	return -EIO;
-      
-      /* Save the final position for pauses and resumes */
-      final_pos_msf[0] = bcd_to_int(params[4]);
-      final_pos_msf[1] = bcd_to_int(params[5]);
-      final_pos_msf[2] = bcd_to_int(params[6]);
-      sony_audio_status = CDROM_AUDIO_PLAY;
-      return 0;
-
-   case CDROMREADTOCHDR:        /* Read the table of contents header */
-      {
-         struct cdrom_tochdr *hdr;
-         
-         sony_get_toc();
-         if (!sony_toc_read)
-         {
-            return -EIO;
-         }
-         
-         hdr = (struct cdrom_tochdr *) arg;
-         hdr->cdth_trk0 = sony_toc.first_track_num;
-         hdr->cdth_trk1 = sony_toc.last_track_num;
-      }
-      return 0;
-
-   case CDROMREADTOCENTRY:      /* Read a given table of contents entry */
-      {
-         struct cdrom_tocentry *entry;
-         int track_idx;
-         unsigned char *msf_val = NULL;
-         
-         sony_get_toc();
-         if (!sony_toc_read)
-         {
-            return -EIO;
-         }
-         
-         entry = (struct cdrom_tocentry *) arg;
-         
-         track_idx = find_track(entry->cdte_track);
-         if (track_idx < 0)
-         {
-            return -EINVAL;
-         }
-            
-         entry->cdte_adr = sony_toc.tracks[track_idx].address;
-         entry->cdte_ctrl = sony_toc.tracks[track_idx].control;
-         msf_val = sony_toc.tracks[track_idx].track_start_msf;
-         
-         /* Logical buffer address or MSF format requested? */
-         if (entry->cdte_format == CDROM_LBA)
-         {
-            entry->cdte_addr.lba = msf_to_log(msf_val);
-         }
-         else if (entry->cdte_format == CDROM_MSF)
-         {
-            entry->cdte_addr.msf.minute = *msf_val;
-            entry->cdte_addr.msf.second = *(msf_val+1);
-            entry->cdte_addr.msf.frame = *(msf_val+2);
-         }
-      }
-      return 0;
-      break;
-
-   case CDROMPLAYTRKIND:     /* Play a track.  This currently ignores index. */
-      {
-         struct cdrom_ti *ti = (struct cdrom_ti *) arg;
-         int track_idx;
-         
-         sony_get_toc();
-         if (!sony_toc_read)
-         {
-            return -EIO;
-         }
-         
-         if (   (ti->cdti_trk0 < sony_toc.first_track_num)
-             || (ti->cdti_trk0 > sony_toc.last_track_num)
-             || (ti->cdti_trk1 < ti->cdti_trk0))
-         {
-            return -EINVAL;
-         }
-         
-         track_idx = find_track(ti->cdti_trk0);
-         if (track_idx < 0)
-         {
-            return -EINVAL;
-         }
-         params[1] = int_to_bcd(sony_toc.tracks[track_idx].track_start_msf[0]);
-         params[2] = int_to_bcd(sony_toc.tracks[track_idx].track_start_msf[1]);
-         params[3] = int_to_bcd(sony_toc.tracks[track_idx].track_start_msf[2]);
-         
-         /*
-          * If we want to stop after the last track, use the lead-out
-          * MSF to do that.
-          */
-         if (ti->cdti_trk1 >= sony_toc.last_track_num)
-         {
-            track_idx = find_track(CDROM_LEADOUT);
-         }
-         else
-         {
-            track_idx = find_track(ti->cdti_trk1+1);
-         }
-         if (track_idx < 0)
-         {
-            return -EINVAL;
-         }
-         params[4] = int_to_bcd(sony_toc.tracks[track_idx].track_start_msf[0]);
-         params[5] = int_to_bcd(sony_toc.tracks[track_idx].track_start_msf[1]);
-         params[6] = int_to_bcd(sony_toc.tracks[track_idx].track_start_msf[2]);
-         params[0] = 0x03;
-         
-         do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, &res_size);
-         
-         do_sony_cd_cmd(SONY_AUDIO_PLAYBACK_CMD, params, 7, res_reg, &res_size);
-         
-         if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20))
-         {
-            printk("Params: %x %x %x %x %x %x %x\n", params[0], params[1],
-                   params[2], params[3], params[4], params[5], params[6]);
-            printk("Sony CDROM error %s (CDROMPLAYTRKIND)\n", translate_error(res_reg[1]));
-            return -EIO;
-         }
-         
-         /* Save the final position for pauses and resumes */
-         final_pos_msf[0] = bcd_to_int(params[4]);
-         final_pos_msf[1] = bcd_to_int(params[5]);
-         final_pos_msf[2] = bcd_to_int(params[6]);
-         sony_audio_status = CDROM_AUDIO_PLAY;
-         return 0;
-      }
-     
-   case CDROMVOLCTRL:   /* Volume control.  What volume does this change, anyway? */
-      {
-         struct cdrom_volctrl *volctrl = (struct cdrom_volctrl *) arg;
-         
-         params[0] = SONY_SD_AUDIO_VOLUME;
-         params[1] = volctrl->channel0;
-         params[2] = volctrl->channel1;
-         return do_sony_cd_cmd_chk("VOLCTRL",SONY_SET_DRIVE_PARAM_CMD, params, 3, res_reg, &res_size);
-      }
-   case CDROMSUBCHNL:   /* Get subchannel info */
-      return sony_get_subchnl_info((struct cdrom_subchnl *)arg);
-
-   default:
-      return -EINVAL;
-   }
+	unsigned char res_reg[12];
+	unsigned int res_size;
+	unsigned char params[7];
+	int i;
+
+
+	switch (cmd) {
+	case CDROMSTART:	/* Spin up the drive */
+		return do_sony_cd_cmd_chk("START", SONY_SPIN_UP_CMD, NULL,
+					  0, res_reg, &res_size);
+		break;
+
+	case CDROMSTOP:	/* Spin down the drive */
+		do_sony_cd_cmd(SONY_AUDIO_STOP_CMD, NULL, 0, res_reg,
+			       &res_size);
+
+		/*
+		 * Spin the drive down, ignoring the error if the disk was
+		 * already not spinning.
+		 */
+		sony_audio_status = CDROM_AUDIO_NO_STATUS;
+		return do_sony_cd_cmd_chk("STOP", SONY_SPIN_DOWN_CMD, NULL,
+					  0, res_reg, &res_size);
+
+	case CDROMPAUSE:	/* Pause the drive */
+		if (do_sony_cd_cmd_chk
+		    ("PAUSE", SONY_AUDIO_STOP_CMD, NULL, 0, res_reg,
+		     &res_size))
+			return -EIO;
+		/* Get the current position and save it for resuming */
+		if (read_subcode() < 0) {
+			return -EIO;
+		}
+		cur_pos_msf[0] = last_sony_subcode.abs_msf[0];
+		cur_pos_msf[1] = last_sony_subcode.abs_msf[1];
+		cur_pos_msf[2] = last_sony_subcode.abs_msf[2];
+		sony_audio_status = CDROM_AUDIO_PAUSED;
+		return 0;
+		break;
+
+	case CDROMRESUME:	/* Start the drive after being paused */
+		if (sony_audio_status != CDROM_AUDIO_PAUSED) {
+			return -EINVAL;
+		}
+
+		do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg,
+			       &res_size);
+
+		/* Start the drive at the saved position. */
+		params[1] = int_to_bcd(cur_pos_msf[0]);
+		params[2] = int_to_bcd(cur_pos_msf[1]);
+		params[3] = int_to_bcd(cur_pos_msf[2]);
+		params[4] = int_to_bcd(final_pos_msf[0]);
+		params[5] = int_to_bcd(final_pos_msf[1]);
+		params[6] = int_to_bcd(final_pos_msf[2]);
+		params[0] = 0x03;
+		if (do_sony_cd_cmd_chk
+		    ("RESUME", SONY_AUDIO_PLAYBACK_CMD, params, 7, res_reg,
+		     &res_size) < 0)
+			return -EIO;
+		sony_audio_status = CDROM_AUDIO_PLAY;
+		return 0;
+
+	case CDROMPLAYMSF:	/* Play starting at the given MSF address. */
+		do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg,
+			       &res_size);
+
+		/* The parameters are given in int, must be converted */
+		for (i = 1; i < 7; i++) {
+			params[i] =
+			    int_to_bcd(((unsigned char *) arg)[i - 1]);
+		}
+		params[0] = 0x03;
+		if (do_sony_cd_cmd_chk
+		    ("PLAYMSF", SONY_AUDIO_PLAYBACK_CMD, params, 7,
+		     res_reg, &res_size) < 0)
+			return -EIO;
+
+		/* Save the final position for pauses and resumes */
+		final_pos_msf[0] = bcd_to_int(params[4]);
+		final_pos_msf[1] = bcd_to_int(params[5]);
+		final_pos_msf[2] = bcd_to_int(params[6]);
+		sony_audio_status = CDROM_AUDIO_PLAY;
+		return 0;
+
+	case CDROMREADTOCHDR:	/* Read the table of contents header */
+		{
+			struct cdrom_tochdr *hdr;
+
+			sony_get_toc();
+			if (!sony_toc_read) {
+				return -EIO;
+			}
+
+			hdr = (struct cdrom_tochdr *) arg;
+			hdr->cdth_trk0 = sony_toc.first_track_num;
+			hdr->cdth_trk1 = sony_toc.last_track_num;
+		}
+		return 0;
+
+	case CDROMREADTOCENTRY:	/* Read a given table of contents entry */
+		{
+			struct cdrom_tocentry *entry;
+			int track_idx;
+			unsigned char *msf_val = NULL;
+
+			sony_get_toc();
+			if (!sony_toc_read) {
+				return -EIO;
+			}
+
+			entry = (struct cdrom_tocentry *) arg;
+
+			track_idx = find_track(entry->cdte_track);
+			if (track_idx < 0) {
+				return -EINVAL;
+			}
+
+			entry->cdte_adr =
+			    sony_toc.tracks[track_idx].address;
+			entry->cdte_ctrl =
+			    sony_toc.tracks[track_idx].control;
+			msf_val =
+			    sony_toc.tracks[track_idx].track_start_msf;
+
+			/* Logical buffer address or MSF format requested? */
+			if (entry->cdte_format == CDROM_LBA) {
+				entry->cdte_addr.lba = msf_to_log(msf_val);
+			} else if (entry->cdte_format == CDROM_MSF) {
+				entry->cdte_addr.msf.minute = *msf_val;
+				entry->cdte_addr.msf.second =
+				    *(msf_val + 1);
+				entry->cdte_addr.msf.frame =
+				    *(msf_val + 2);
+			}
+		}
+		return 0;
+		break;
+
+	case CDROMPLAYTRKIND:	/* Play a track.  This currently ignores index. */
+		{
+			struct cdrom_ti *ti = (struct cdrom_ti *) arg;
+			int track_idx;
+
+			sony_get_toc();
+			if (!sony_toc_read) {
+				return -EIO;
+			}
+
+			if ((ti->cdti_trk0 < sony_toc.first_track_num)
+			    || (ti->cdti_trk0 > sony_toc.last_track_num)
+			    || (ti->cdti_trk1 < ti->cdti_trk0)) {
+				return -EINVAL;
+			}
+
+			track_idx = find_track(ti->cdti_trk0);
+			if (track_idx < 0) {
+				return -EINVAL;
+			}
+			params[1] =
+			    int_to_bcd(sony_toc.tracks[track_idx].
+				       track_start_msf[0]);
+			params[2] =
+			    int_to_bcd(sony_toc.tracks[track_idx].
+				       track_start_msf[1]);
+			params[3] =
+			    int_to_bcd(sony_toc.tracks[track_idx].
+				       track_start_msf[2]);
+
+			/*
+			 * If we want to stop after the last track, use the lead-out
+			 * MSF to do that.
+			 */
+			if (ti->cdti_trk1 >= sony_toc.last_track_num) {
+				track_idx = find_track(CDROM_LEADOUT);
+			} else {
+				track_idx = find_track(ti->cdti_trk1 + 1);
+			}
+			if (track_idx < 0) {
+				return -EINVAL;
+			}
+			params[4] =
+			    int_to_bcd(sony_toc.tracks[track_idx].
+				       track_start_msf[0]);
+			params[5] =
+			    int_to_bcd(sony_toc.tracks[track_idx].
+				       track_start_msf[1]);
+			params[6] =
+			    int_to_bcd(sony_toc.tracks[track_idx].
+				       track_start_msf[2]);
+			params[0] = 0x03;
+
+			do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg,
+				       &res_size);
+
+			do_sony_cd_cmd(SONY_AUDIO_PLAYBACK_CMD, params, 7,
+				       res_reg, &res_size);
+
+			if ((res_size < 2)
+			    || ((res_reg[0] & 0xf0) == 0x20)) {
+				printk("Params: %x %x %x %x %x %x %x\n",
+				       params[0], params[1], params[2],
+				       params[3], params[4], params[5],
+				       params[6]);
+				printk
+				    ("Sony CDROM error %s (CDROMPLAYTRKIND)\n",
+				     translate_error(res_reg[1]));
+				return -EIO;
+			}
+
+			/* Save the final position for pauses and resumes */
+			final_pos_msf[0] = bcd_to_int(params[4]);
+			final_pos_msf[1] = bcd_to_int(params[5]);
+			final_pos_msf[2] = bcd_to_int(params[6]);
+			sony_audio_status = CDROM_AUDIO_PLAY;
+			return 0;
+		}
+
+	case CDROMVOLCTRL:	/* Volume control.  What volume does this change, anyway? */
+		{
+			struct cdrom_volctrl *volctrl =
+			    (struct cdrom_volctrl *) arg;
+
+			params[0] = SONY_SD_AUDIO_VOLUME;
+			params[1] = volctrl->channel0;
+			params[2] = volctrl->channel1;
+			return do_sony_cd_cmd_chk("VOLCTRL",
+						  SONY_SET_DRIVE_PARAM_CMD,
+						  params, 3, res_reg,
+						  &res_size);
+		}
+	case CDROMSUBCHNL:	/* Get subchannel info */
+		return sony_get_subchnl_info((struct cdrom_subchnl *) arg);
+
+	default:
+		return -EINVAL;
+	}
 }
 
 static int scd_dev_ioctl(struct cdrom_device_info *cdi,
-          unsigned int  cmd,
-          unsigned long arg)
+			 unsigned int cmd, unsigned long arg)
 {
-   int i;
+	int i;
 
-   switch (cmd)
-   {
-   case CDROMREADAUDIO:      /* Read 2352 byte audio tracks and 2340 byte
-				 raw data tracks. */
-      {
-         struct cdrom_read_audio ra;
-
-
-         sony_get_toc();
-         if (!sony_toc_read)
-         {
-         	return -EIO;
-         }
-
-	 if(copy_from_user(&ra, (char *) arg, sizeof(ra)))
-	 	return -EFAULT;
-
-         if (ra.nframes == 0)
-         {
-         	return 0;
-         }
-
-         i=verify_area(VERIFY_WRITE, ra.buf, CD_FRAMESIZE_RAW * ra.nframes);
-         if(i<0)
-         	return i;
-
-         if (ra.addr_format == CDROM_LBA)
-         {
-            if (   (ra.addr.lba >= sony_toc.lead_out_start_lba)
-                || (ra.addr.lba + ra.nframes >= sony_toc.lead_out_start_lba))
-            {
-               return -EINVAL;
-            }
-         }
-         else if (ra.addr_format == CDROM_MSF)
-         {
-            if (   (ra.addr.msf.minute >= 75)
-                || (ra.addr.msf.second >= 60)
-                || (ra.addr.msf.frame >= 75))
-            {
-               return -EINVAL;
-            }
-
-            ra.addr.lba = (  (ra.addr.msf.minute * 4500)
-                           + (ra.addr.msf.second * 75)
-                           + ra.addr.msf.frame);
-            if (   (ra.addr.lba >= sony_toc.lead_out_start_lba)
-                || (ra.addr.lba + ra.nframes >= sony_toc.lead_out_start_lba))
-            {
-               return -EINVAL;
-            }
-
-            /* I know, this can go negative on an unsigned.  However,
-               the first thing done to the data is to add this value,
-               so this should compensate and allow direct msf access. */
-            ra.addr.lba -= LOG_START_OFFSET;
-         }
-         else
-         {
-            return -EINVAL;
-         }
-
-         return(read_audio(&ra));
-      }
-      return 0;
-      break;
-
-   default:
-      return -EINVAL;
-   }
+	switch (cmd) {
+	case CDROMREADAUDIO:	/* Read 2352 byte audio tracks and 2340 byte
+				   raw data tracks. */
+		{
+			struct cdrom_read_audio ra;
+
+
+			sony_get_toc();
+			if (!sony_toc_read) {
+				return -EIO;
+			}
+
+			if (copy_from_user(&ra, (char *) arg, sizeof(ra)))
+				return -EFAULT;
+
+			if (ra.nframes == 0) {
+				return 0;
+			}
+
+			i = verify_area(VERIFY_WRITE, ra.buf,
+					CD_FRAMESIZE_RAW * ra.nframes);
+			if (i < 0)
+				return i;
+
+			if (ra.addr_format == CDROM_LBA) {
+				if ((ra.addr.lba >=
+				     sony_toc.lead_out_start_lba)
+				    || (ra.addr.lba + ra.nframes >=
+					sony_toc.lead_out_start_lba)) {
+					return -EINVAL;
+				}
+			} else if (ra.addr_format == CDROM_MSF) {
+				if ((ra.addr.msf.minute >= 75)
+				    || (ra.addr.msf.second >= 60)
+				    || (ra.addr.msf.frame >= 75)) {
+					return -EINVAL;
+				}
+
+				ra.addr.lba = ((ra.addr.msf.minute * 4500)
+					       + (ra.addr.msf.second * 75)
+					       + ra.addr.msf.frame);
+				if ((ra.addr.lba >=
+				     sony_toc.lead_out_start_lba)
+				    || (ra.addr.lba + ra.nframes >=
+					sony_toc.lead_out_start_lba)) {
+					return -EINVAL;
+				}
+
+				/* I know, this can go negative on an unsigned.  However,
+				   the first thing done to the data is to add this value,
+				   so this should compensate and allow direct msf access. */
+				ra.addr.lba -= LOG_START_OFFSET;
+			} else {
+				return -EINVAL;
+			}
+
+			return (read_audio(&ra));
+		}
+		return 0;
+		break;
+
+	default:
+		return -EINVAL;
+	}
 }
 
 static int scd_spinup(void)
 {
-   unsigned char res_reg[12];
-   unsigned int res_size;
-   int num_spin_ups;
-
-   num_spin_ups = 0;
-
-respinup_on_open:
-   do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, &res_size);
-
-   /* The drive sometimes returns error 0.  I don't know why, but ignore
-      it.  It seems to mean the drive has already done the operation. */
-   if ((res_size < 2) || ((res_reg[0] != 0) && (res_reg[1] != 0)))
-   {
-      printk("Sony CDROM %s error (scd_open, spin up)\n", translate_error(res_reg[1]));
-      return 1;
-   }
-      
-   do_sony_cd_cmd(SONY_READ_TOC_CMD, NULL, 0, res_reg, &res_size);
-
-   /* The drive sometimes returns error 0.  I don't know why, but ignore
-      it.  It seems to mean the drive has already done the operation. */
-   if ((res_size < 2) || ((res_reg[0] != 0) && (res_reg[1] != 0)))
-   {
-      /* If the drive is already playing, it's ok.  */
-      if ((res_reg[1] == SONY_AUDIO_PLAYING_ERR) || (res_reg[1] == 0))
-      {
-         return 0;
-      }
-
-      /* If the drive says it is not spun up (even though we just did it!)
-         then retry the operation at least a few times. */
-      if (   (res_reg[1] == SONY_NOT_SPIN_ERR)
-          && (num_spin_ups < MAX_CDU31A_RETRIES))
-      {
-         num_spin_ups++;
-         goto respinup_on_open;
-      }
-
-      printk("Sony CDROM error %s (scd_open, read toc)\n", translate_error(res_reg[1]));
-      do_sony_cd_cmd(SONY_SPIN_DOWN_CMD, NULL, 0, res_reg, &res_size);
-      return 1;  
-   }
-   return 0;
+	unsigned char res_reg[12];
+	unsigned int res_size;
+	int num_spin_ups;
+
+	num_spin_ups = 0;
+
+      respinup_on_open:
+	do_sony_cd_cmd(SONY_SPIN_UP_CMD, NULL, 0, res_reg, &res_size);
+
+	/* The drive sometimes returns error 0.  I don't know why, but ignore
+	   it.  It seems to mean the drive has already done the operation. */
+	if ((res_size < 2) || ((res_reg[0] != 0) && (res_reg[1] != 0))) {
+		printk("Sony CDROM %s error (scd_open, spin up)\n",
+		       translate_error(res_reg[1]));
+		return 1;
+	}
+
+	do_sony_cd_cmd(SONY_READ_TOC_CMD, NULL, 0, res_reg, &res_size);
+
+	/* The drive sometimes returns error 0.  I don't know why, but ignore
+	   it.  It seems to mean the drive has already done the operation. */
+	if ((res_size < 2) || ((res_reg[0] != 0) && (res_reg[1] != 0))) {
+		/* If the drive is already playing, it's ok.  */
+		if ((res_reg[1] == SONY_AUDIO_PLAYING_ERR)
+		    || (res_reg[1] == 0)) {
+			return 0;
+		}
+
+		/* If the drive says it is not spun up (even though we just did it!)
+		   then retry the operation at least a few times. */
+		if ((res_reg[1] == SONY_NOT_SPIN_ERR)
+		    && (num_spin_ups < MAX_CDU31A_RETRIES)) {
+			num_spin_ups++;
+			goto respinup_on_open;
+		}
+
+		printk("Sony CDROM error %s (scd_open, read toc)\n",
+		       translate_error(res_reg[1]));
+		do_sony_cd_cmd(SONY_SPIN_DOWN_CMD, NULL, 0, res_reg,
+			       &res_size);
+		return 1;
+	}
+	return 0;
 }
 
 /*
  * Open the drive for operations.  Spin the drive up and read the table of
  * contents if these have not already been done.
  */
-static int
-scd_open(struct cdrom_device_info *cdi, int openmode)
+static int scd_open(struct cdrom_device_info *cdi, int openmode)
 {
-   unsigned char res_reg[12];
-   unsigned int res_size;
-   unsigned char params[2];
-
-   MOD_INC_USE_COUNT;
-   if (sony_usage == 0)
-   {
-      if (scd_spinup() != 0) {
-         MOD_DEC_USE_COUNT;
-         return -EIO;
-      }
-      sony_get_toc();
-      if (!sony_toc_read)
-      {
-         do_sony_cd_cmd(SONY_SPIN_DOWN_CMD, NULL, 0, res_reg, &res_size);
-         MOD_DEC_USE_COUNT;
-         return -EIO;
-      }
-
-      /* For XA on the CDU31A only, we have to do special reads.
-         The CDU33A handles XA automagically. */
-      /* if (   (sony_toc.disk_type == SONY_XA_DISK_TYPE) */
-      if (   (sony_toc.disk_type != 0x00)
-          && (!is_double_speed))
-      {
-         params[0] = SONY_SD_DECODE_PARAM;
-         params[1] = 0x07;
-         do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD,
-                        params,
-                        2,
-                        res_reg,
-                        &res_size);
-         if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20))
-         {
-            printk("CDU31A: Unable to set XA params: 0x%2.2x\n", res_reg[1]);
-         }
-         sony_xa_mode = 1;
-      }
-      /* A non-XA disk.  Set the parms back if necessary. */
-      else if (sony_xa_mode)
-      {
-         params[0] = SONY_SD_DECODE_PARAM;
-         params[1] = 0x0f;
-         do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD,
-                        params,
-                        2,
-                        res_reg,
-                        &res_size);
-         if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20))
-         {
-            printk("CDU31A: Unable to reset XA params: 0x%2.2x\n", res_reg[1]);
-         }
-         sony_xa_mode = 0;
-      }
+	unsigned char res_reg[12];
+	unsigned int res_size;
+	unsigned char params[2];
+
+	MOD_INC_USE_COUNT;
+	if (sony_usage == 0) {
+		if (scd_spinup() != 0) {
+			MOD_DEC_USE_COUNT;
+			return -EIO;
+		}
+		sony_get_toc();
+		if (!sony_toc_read) {
+			do_sony_cd_cmd(SONY_SPIN_DOWN_CMD, NULL, 0,
+				       res_reg, &res_size);
+			MOD_DEC_USE_COUNT;
+			return -EIO;
+		}
+
+		/* For XA on the CDU31A only, we have to do special reads.
+		   The CDU33A handles XA automagically. */
+		/* if (   (sony_toc.disk_type == SONY_XA_DISK_TYPE) */
+		if ((sony_toc.disk_type != 0x00)
+		    && (!is_double_speed)) {
+			params[0] = SONY_SD_DECODE_PARAM;
+			params[1] = 0x07;
+			do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD,
+				       params, 2, res_reg, &res_size);
+			if ((res_size < 2)
+			    || ((res_reg[0] & 0xf0) == 0x20)) {
+				printk
+				    ("CDU31A: Unable to set XA params: 0x%2.2x\n",
+				     res_reg[1]);
+			}
+			sony_xa_mode = 1;
+		}
+		/* A non-XA disk.  Set the parms back if necessary. */
+		else if (sony_xa_mode) {
+			params[0] = SONY_SD_DECODE_PARAM;
+			params[1] = 0x0f;
+			do_sony_cd_cmd(SONY_SET_DRIVE_PARAM_CMD,
+				       params, 2, res_reg, &res_size);
+			if ((res_size < 2)
+			    || ((res_reg[0] & 0xf0) == 0x20)) {
+				printk
+				    ("CDU31A: Unable to reset XA params: 0x%2.2x\n",
+				     res_reg[1]);
+			}
+			sony_xa_mode = 0;
+		}
 
-      sony_spun_up = 1;
-   }
+		sony_spun_up = 1;
+	}
 
-   sony_usage++;
+	sony_usage++;
 
-   return 0;
+	return 0;
 }
 
 
@@ -3205,114 +3171,109 @@
  * Close the drive.  Spin it down if no task is using it.  The spin
  * down will fail if playing audio, so audio play is OK.
  */
-static void
-scd_release(struct cdrom_device_info *cdi)
+static void scd_release(struct cdrom_device_info *cdi)
 {
-   if (sony_usage == 1)
-   {
-      unsigned char res_reg[12];
-      unsigned int  res_size;
-
-      do_sony_cd_cmd(SONY_SPIN_DOWN_CMD, NULL, 0, res_reg, &res_size);
-
-      sony_spun_up = 0;
-   }
-   sony_usage--;
-   MOD_DEC_USE_COUNT;
+	if (sony_usage == 1) {
+		unsigned char res_reg[12];
+		unsigned int res_size;
+
+		do_sony_cd_cmd(SONY_SPIN_DOWN_CMD, NULL, 0, res_reg,
+			       &res_size);
+
+		sony_spun_up = 0;
+	}
+	sony_usage--;
+	MOD_DEC_USE_COUNT;
 }
 
 static struct cdrom_device_ops scd_dops = {
-	open:			scd_open,
-	release:		scd_release,
-	drive_status:		scd_drive_status,
-	media_changed:		scd_media_changed,
-	tray_move:		scd_tray_move,
-	lock_door:		scd_lock_door,
-	select_speed:		scd_select_speed,
-	get_last_session:	scd_get_last_session,
-	get_mcn:		scd_get_mcn,
-	reset:			scd_reset,
-	audio_ioctl:		scd_audio_ioctl,
-	dev_ioctl:		scd_dev_ioctl,
-	capability:		CDC_OPEN_TRAY | CDC_CLOSE_TRAY | CDC_LOCK |
-				CDC_SELECT_SPEED | CDC_MULTI_SESSION | 
-				CDC_MULTI_SESSION | CDC_MCN |
-				CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO |
-				CDC_RESET | CDC_IOCTLS | CDC_DRIVE_STATUS,
-	n_minors:		1,
+	open:scd_open,
+	release:scd_release,
+	drive_status:scd_drive_status,
+	media_changed:scd_media_changed,
+	tray_move:scd_tray_move,
+	lock_door:scd_lock_door,
+	select_speed:scd_select_speed,
+	get_last_session:scd_get_last_session,
+	get_mcn:scd_get_mcn,
+	reset:scd_reset,
+	audio_ioctl:scd_audio_ioctl,
+	dev_ioctl:scd_dev_ioctl,
+	capability:CDC_OPEN_TRAY | CDC_CLOSE_TRAY | CDC_LOCK |
+	    CDC_SELECT_SPEED | CDC_MULTI_SESSION |
+	    CDC_MULTI_SESSION | CDC_MCN |
+	    CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO |
+	    CDC_RESET | CDC_IOCTLS | CDC_DRIVE_STATUS,
+	n_minors:1,
 };
 
 static struct cdrom_device_info scd_info = {
-	ops:		&scd_dops,
-	speed:		2,
-	capacity:	1,
-	name:		"cdu31a"
+	ops:&scd_dops,
+	speed:2,
+	capacity:1,
+	name:"cdu31a"
 };
 
 /* The different types of disc loading mechanisms supported */
-static const char *load_mech[] __initdata = { "caddy", "tray", "pop-up", "unknown" };
+static char *load_mech[] __initdata =
+    { "caddy", "tray", "pop-up", "unknown" };
 
-static void __init 
+static void __init
 get_drive_configuration(unsigned short base_io,
-                        unsigned char res_reg[],
-                        unsigned int *res_size)
+			unsigned char res_reg[], unsigned int *res_size)
 {
-   int retry_count;
+	int retry_count;
 
 
-   /* Set the base address */
-   cdu31a_port = base_io;
+	/* Set the base address */
+	cdu31a_port = base_io;
 
-   /* Set up all the register locations */
-   sony_cd_cmd_reg = cdu31a_port + SONY_CMD_REG_OFFSET;
-   sony_cd_param_reg = cdu31a_port + SONY_PARAM_REG_OFFSET;
-   sony_cd_write_reg = cdu31a_port + SONY_WRITE_REG_OFFSET;
-   sony_cd_control_reg = cdu31a_port + SONY_CONTROL_REG_OFFSET;
-   sony_cd_status_reg = cdu31a_port + SONY_STATUS_REG_OFFSET;
-   sony_cd_result_reg = cdu31a_port + SONY_RESULT_REG_OFFSET;
-   sony_cd_read_reg = cdu31a_port + SONY_READ_REG_OFFSET;
-   sony_cd_fifost_reg = cdu31a_port + SONY_FIFOST_REG_OFFSET;
-
-   /*
-    * Check to see if anything exists at the status register location.
-    * I don't know if this is a good way to check, but it seems to work
-    * ok for me.
-    */
-   if (read_status_register() != 0xff)
-   {
-      /*
-       * Reset the drive and wait for attention from it (to say it's reset).
-       * If you don't wait, the next operation will probably fail.
-       */
-      reset_drive();
-      retry_count = jiffies + SONY_RESET_TIMEOUT;
-      while (time_before(jiffies, retry_count) && (!is_attention()))
-      {
-         sony_sleep();
-      }
+	/* Set up all the register locations */
+	sony_cd_cmd_reg = cdu31a_port + SONY_CMD_REG_OFFSET;
+	sony_cd_param_reg = cdu31a_port + SONY_PARAM_REG_OFFSET;
+	sony_cd_write_reg = cdu31a_port + SONY_WRITE_REG_OFFSET;
+	sony_cd_control_reg = cdu31a_port + SONY_CONTROL_REG_OFFSET;
+	sony_cd_status_reg = cdu31a_port + SONY_STATUS_REG_OFFSET;
+	sony_cd_result_reg = cdu31a_port + SONY_RESULT_REG_OFFSET;
+	sony_cd_read_reg = cdu31a_port + SONY_READ_REG_OFFSET;
+	sony_cd_fifost_reg = cdu31a_port + SONY_FIFOST_REG_OFFSET;
+
+	/*
+	 * Check to see if anything exists at the status register location.
+	 * I don't know if this is a good way to check, but it seems to work
+	 * ok for me.
+	 */
+	if (read_status_register() != 0xff) {
+		/*
+		 * Reset the drive and wait for attention from it (to say it's reset).
+		 * If you don't wait, the next operation will probably fail.
+		 */
+		reset_drive();
+		retry_count = jiffies + SONY_RESET_TIMEOUT;
+		while (time_before(jiffies, retry_count)
+		       && (!is_attention())) {
+			sony_sleep();
+		}
 
 #if 0
-      /* If attention is never seen probably not a CDU31a present */
-      if (!is_attention())
-      {
-         res_reg[0] = 0x20;
-         return;
-      }
-#endif
-
-      /*
-       * Get the drive configuration.
-       */
-      do_sony_cd_cmd(SONY_REQ_DRIVE_CONFIG_CMD,
-                     NULL,
-                     0,
-                     (unsigned char *) res_reg,
-                     res_size);
-      return;
-   }
+		/* If attention is never seen probably not a CDU31a present */
+		if (!is_attention()) {
+			res_reg[0] = 0x20;
+			return;
+		}
+#endif
+
+		/*
+		 * Get the drive configuration.
+		 */
+		do_sony_cd_cmd(SONY_REQ_DRIVE_CONFIG_CMD,
+			       NULL,
+			       0, (unsigned char *) res_reg, res_size);
+		return;
+	}
 
-   /* Return an error */
-   res_reg[0] = 0x20;
+	/* Return an error */
+	res_reg[0] = 0x20;
 }
 
 #ifndef MODULE
@@ -3321,33 +3282,28 @@
  
  */
 
-static int __init cdu31a_setup(char *strings)	     
+static int __init cdu31a_setup(char *strings)
 {
-    int ints[4];
-    
-    (void)get_options(strings, ARRAY_SIZE(ints), ints);
-
-   if (ints[0] > 0)
-   {
-      cdu31a_port = ints[1];
-   }
-   if (ints[0] > 1)
-   {
-      cdu31a_irq = ints[2];
-   }
-   if ((strings != NULL) && (*strings != '\0'))
-   {
-      if (strcmp(strings, "PAS") == 0)
-      {
-	 sony_pas_init = 1;
-      }
-      else
-      {
-	 printk("CDU31A: Unknown interface type: %s\n", strings);
-      }
-   }
-   
-   return 1;
+	int ints[4];
+
+	(void) get_options(strings, ARRAY_SIZE(ints), ints);
+
+	if (ints[0] > 0) {
+		cdu31a_port = ints[1];
+	}
+	if (ints[0] > 1) {
+		cdu31a_irq = ints[2];
+	}
+	if ((strings != NULL) && (*strings != '\0')) {
+		if (strcmp(strings, "PAS") == 0) {
+			sony_pas_init = 1;
+		} else {
+			printk("CDU31A: Unknown interface type: %s\n",
+			       strings);
+		}
+	}
+
+	return 1;
 }
 
 __setup("cdu31a=", cdu31a_setup);
@@ -3359,223 +3315,204 @@
 /*
  * Initialize the driver.
  */
-int __init 
-cdu31a_init(void)
+int __init cdu31a_init(void)
 {
-   struct s_sony_drive_config drive_config;
-   unsigned int res_size;
-   char msg[255];
-   char buf[40];
-   int i;
-   int drive_found;
-   int tmp_irq;
-
-
-   /*
-    * According to Alex Freed (freed@europa.orion.adobe.com), this is
-    * required for the Fusion CD-16 package.  If the sound driver is
-    * loaded, it should work fine, but just in case...
-    *
-    * The following turn on the CD-ROM interface for a Fusion CD-16.
-    */
-   if (sony_pas_init)
-   {
-      outb(0xbc, 0x9a01);
-      outb(0xe2, 0x9a01);
-   }
-
-   drive_found = 0;
-
-   /* Setting the base I/O address to 0xffff will disable it. */
-   if (cdu31a_port == 0xffff)
-   {
-   }
-   else if (cdu31a_port != 0)
-   {
-      tmp_irq = cdu31a_irq; /* Need IRQ 0 because we can't sleep here. */
-      cdu31a_irq = 0;
-
-      get_drive_configuration(cdu31a_port,
-			      drive_config.exec_status,
-			      &res_size);
-      if ((res_size > 2) && ((drive_config.exec_status[0] & 0xf0) == 0x00))
-      {
-	 drive_found = 1;
-      }
-
-      cdu31a_irq = tmp_irq;
-   }
-   else
-   {
-      cdu31a_irq = 0;
-      i = 0;
-      while (   (cdu31a_addresses[i].base != 0)
-	     && (!drive_found))
-      {
-	 if (check_region(cdu31a_addresses[i].base, 4)) {
-	    i++;
-	    continue;
-	 }
-	 get_drive_configuration(cdu31a_addresses[i].base,
-				 drive_config.exec_status,
-				 &res_size);
-	 if ((res_size > 2) && ((drive_config.exec_status[0] & 0xf0) == 0x00))
-	 {
-	    drive_found = 1;
-	    cdu31a_irq = cdu31a_addresses[i].int_num;
-	 }
-	 else
-	 {
-	    i++;
-	 }
-      }
-   }
-
-   if (drive_found)
-   {
-      int deficiency=0;
-
-      request_region(cdu31a_port, 4,"cdu31a");
-      
-      if (devfs_register_blkdev(MAJOR_NR,"cdu31a",&cdrom_fops))
-      {
-	 printk("Unable to get major %d for CDU-31a\n", MAJOR_NR);
-         goto errout2;
-      }
-
-      if (SONY_HWC_DOUBLE_SPEED(drive_config))
-      {
-	 is_double_speed = 1;
-      }
-
-      tmp_irq = cdu31a_irq; /* Need IRQ 0 because we can't sleep here. */
-      cdu31a_irq = 0;
-
-      set_drive_params(sony_speed);
-
-      cdu31a_irq = tmp_irq;
-      
-      if (cdu31a_irq > 0)
-      {
-	 if (request_irq(cdu31a_irq, cdu31a_interrupt, SA_INTERRUPT, "cdu31a", NULL))
-	 {
-	    printk("Unable to grab IRQ%d for the CDU31A driver\n", cdu31a_irq);
-	    cdu31a_irq = 0;
-	 }
-      }
-      
-      sprintf(msg, "Sony I/F CDROM : %8.8s %16.16s %8.8s\n",
-	     drive_config.vendor_id,
-	     drive_config.product_id,
-	     drive_config.product_rev_level);
-      sprintf(buf, "  Capabilities: %s",
-	     load_mech[SONY_HWC_GET_LOAD_MECH(drive_config)]);
-      strcat(msg, buf);
-      if (SONY_HWC_AUDIO_PLAYBACK(drive_config))
-      {
-         strcat(msg, ", audio");
-      } else
-	 deficiency |= CDC_PLAY_AUDIO;
-      if (SONY_HWC_EJECT(drive_config))
-      {
-         strcat(msg, ", eject");
-      } else
-	 deficiency |= CDC_OPEN_TRAY;
-      if (SONY_HWC_LED_SUPPORT(drive_config))
-      {
-         strcat(msg, ", LED");
-      }
-      if (SONY_HWC_ELECTRIC_VOLUME(drive_config))
-      {
-         strcat(msg, ", elec. Vol");
-      }
-      if (SONY_HWC_ELECTRIC_VOLUME_CTL(drive_config))
-      {
-         strcat(msg, ", sep. Vol");
-      }
-      if (is_double_speed)
-      {
-         strcat(msg, ", double speed");
-      } else
-	 deficiency |= CDC_SELECT_SPEED;
-      if (cdu31a_irq > 0)
-      {
-	 sprintf(buf, ", irq %d", cdu31a_irq);
-         strcat(msg, buf);
-      }
-      strcat(msg, "\n");
-
-      is_a_cdu31a = strcmp("CD-ROM CDU31A", drive_config.product_id) == 0;
-
-      blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST);
-      read_ahead[MAJOR_NR] = CDU31A_READAHEAD;
-      cdu31a_block_size = 1024; /* 1kB default block size */
-      /* use 'mount -o block=2048' */
-      blksize_size[MAJOR_NR] = &cdu31a_block_size;
-      
-      init_timer(&cdu31a_abort_timer);
-      cdu31a_abort_timer.function = handle_abort_timeout;
-
-      scd_info.dev = MKDEV(MAJOR_NR,0);
-      scd_info.mask = deficiency;
-      strncpy(scd_info.name, "cdu31a", sizeof(scd_info.name));
-
-      if (register_cdrom(&scd_info))
-      {
-         goto errout0;
-      }
-   }
-
-
-   disk_changed = 1;
-   
-   if (drive_found)
-   {
-      return(0);
-   }
-   else
-   {
-      goto errout3;
-   }
-errout0:
-   printk("Unable to register CDU-31a with Uniform cdrom driver\n");
-   blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
-   if (devfs_unregister_blkdev(MAJOR_NR, "cdu31a"))    
-   {
-      printk("Can't unregister block device for cdu31a\n");
-   }
-errout2:
-   release_region(cdu31a_port,4);
-errout3:
-   return -EIO;
-}
-
-
-void __exit
-cdu31a_exit(void)
-{
-   if (unregister_cdrom(&scd_info))    
-   {
-      printk("Can't unregister cdu31a from Uniform cdrom driver\n");
-      return;
-   }
-   if ((devfs_unregister_blkdev(MAJOR_NR, "cdu31a") == -EINVAL))    
-   {
-      printk("Can't unregister cdu31a\n");
-      return;
-   }
-
-   blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
-
-   if (cdu31a_irq > 0)
-      free_irq(cdu31a_irq, NULL);
-
-   release_region(cdu31a_port,4);
-   printk(KERN_INFO "cdu31a module released.\n");
-}   
+	struct s_sony_drive_config drive_config;
+	unsigned int res_size;
+	char msg[255];
+	char buf[40];
+	int i;
+	int drive_found;
+	int tmp_irq;
+
+
+	/*
+	 * According to Alex Freed (freed@europa.orion.adobe.com), this is
+	 * required for the Fusion CD-16 package.  If the sound driver is
+	 * loaded, it should work fine, but just in case...
+	 *
+	 * The following turn on the CD-ROM interface for a Fusion CD-16.
+	 */
+	if (sony_pas_init) {
+		outb(0xbc, 0x9a01);
+		outb(0xe2, 0x9a01);
+	}
+
+	drive_found = 0;
+
+	/* Setting the base I/O address to 0xffff will disable it. */
+	if (cdu31a_port == 0xffff) {
+	} else if (cdu31a_port != 0) {
+		tmp_irq = cdu31a_irq;	/* Need IRQ 0 because we can't sleep here. */
+		cdu31a_irq = 0;
+
+		get_drive_configuration(cdu31a_port,
+					drive_config.exec_status,
+					&res_size);
+		if ((res_size > 2)
+		    && ((drive_config.exec_status[0] & 0xf0) == 0x00)) {
+			drive_found = 1;
+		}
+
+		cdu31a_irq = tmp_irq;
+	} else {
+		cdu31a_irq = 0;
+		i = 0;
+		while ((cdu31a_addresses[i].base != 0)
+		       && (!drive_found)) {
+			if (check_region(cdu31a_addresses[i].base, 4)) {
+				i++;
+				continue;
+			}
+			get_drive_configuration(cdu31a_addresses[i].base,
+						drive_config.exec_status,
+						&res_size);
+			if ((res_size > 2)
+			    && ((drive_config.exec_status[0] & 0xf0) ==
+				0x00)) {
+				drive_found = 1;
+				cdu31a_irq = cdu31a_addresses[i].int_num;
+			} else {
+				i++;
+			}
+		}
+	}
+
+	if (drive_found) {
+		int deficiency = 0;
+
+		request_region(cdu31a_port, 4, "cdu31a");
+
+		if (devfs_register_blkdev(MAJOR_NR, "cdu31a", &cdrom_fops)) {
+			printk("Unable to get major %d for CDU-31a\n",
+			       MAJOR_NR);
+			goto errout2;
+		}
+
+		if (SONY_HWC_DOUBLE_SPEED(drive_config)) {
+			is_double_speed = 1;
+		}
+
+		tmp_irq = cdu31a_irq;	/* Need IRQ 0 because we can't sleep here. */
+		cdu31a_irq = 0;
+
+		set_drive_params(sony_speed);
+
+		cdu31a_irq = tmp_irq;
+
+		if (cdu31a_irq > 0) {
+			if (request_irq
+			    (cdu31a_irq, cdu31a_interrupt, SA_INTERRUPT,
+			     "cdu31a", NULL)) {
+				printk
+				    ("Unable to grab IRQ%d for the CDU31A driver\n",
+				     cdu31a_irq);
+				cdu31a_irq = 0;
+			}
+		}
+
+		sprintf(msg, "Sony I/F CDROM : %8.8s %16.16s %8.8s\n",
+			drive_config.vendor_id,
+			drive_config.product_id,
+			drive_config.product_rev_level);
+		sprintf(buf, "  Capabilities: %s",
+			load_mech[SONY_HWC_GET_LOAD_MECH(drive_config)]);
+		strcat(msg, buf);
+		if (SONY_HWC_AUDIO_PLAYBACK(drive_config)) {
+			strcat(msg, ", audio");
+		} else
+			deficiency |= CDC_PLAY_AUDIO;
+		if (SONY_HWC_EJECT(drive_config)) {
+			strcat(msg, ", eject");
+		} else
+			deficiency |= CDC_OPEN_TRAY;
+		if (SONY_HWC_LED_SUPPORT(drive_config)) {
+			strcat(msg, ", LED");
+		}
+		if (SONY_HWC_ELECTRIC_VOLUME(drive_config)) {
+			strcat(msg, ", elec. Vol");
+		}
+		if (SONY_HWC_ELECTRIC_VOLUME_CTL(drive_config)) {
+			strcat(msg, ", sep. Vol");
+		}
+		if (is_double_speed) {
+			strcat(msg, ", double speed");
+		} else
+			deficiency |= CDC_SELECT_SPEED;
+		if (cdu31a_irq > 0) {
+			sprintf(buf, ", irq %d", cdu31a_irq);
+			strcat(msg, buf);
+		}
+		strcat(msg, "\n");
+
+		is_a_cdu31a =
+		    strcmp("CD-ROM CDU31A", drive_config.product_id) == 0;
+
+		blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR),
+			       DEVICE_REQUEST);
+		read_ahead[MAJOR_NR] = CDU31A_READAHEAD;
+		cdu31a_block_size = 1024;	/* 1kB default block size */
+		/* use 'mount -o block=2048' */
+		blksize_size[MAJOR_NR] = &cdu31a_block_size;
+
+		init_timer(&cdu31a_abort_timer);
+		cdu31a_abort_timer.function = handle_abort_timeout;
+
+		scd_info.dev = MKDEV(MAJOR_NR, 0);
+		scd_info.mask = deficiency;
+		strncpy(scd_info.name, "cdu31a", sizeof(scd_info.name));
+
+		if (register_cdrom(&scd_info)) {
+			goto errout0;
+		}
+	}
+
+
+	disk_changed = 1;
+
+	if (drive_found) {
+		return (0);
+	} else {
+		goto errout3;
+	}
+      errout0:
+	printk("Unable to register CDU-31a with Uniform cdrom driver\n");
+	blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
+	if (devfs_unregister_blkdev(MAJOR_NR, "cdu31a")) {
+		printk("Can't unregister block device for cdu31a\n");
+	}
+      errout2:
+	release_region(cdu31a_port, 4);
+      errout3:
+	return -EIO;
+}
+
+
+void __exit cdu31a_exit(void)
+{
+	if (unregister_cdrom(&scd_info)) {
+		printk
+		    ("Can't unregister cdu31a from Uniform cdrom driver\n");
+		return;
+	}
+	if ((devfs_unregister_blkdev(MAJOR_NR, "cdu31a") == -EINVAL)) {
+		printk("Can't unregister cdu31a\n");
+		return;
+	}
+
+	blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
+
+	if (cdu31a_irq > 0)
+		free_irq(cdu31a_irq, NULL);
+
+	release_region(cdu31a_port, 4);
+	printk(KERN_INFO "cdu31a module released.\n");
+}
 
 #ifdef MODULE
 module_init(cdu31a_init);
 #endif
 module_exit(cdu31a_exit);
 
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/cdrom/cm206.c linux/drivers/cdrom/cm206.c
--- v2.4.9/linux/drivers/cdrom/cm206.c	Fri Feb  9 11:30:22 2001
+++ linux/drivers/cdrom/cm206.c	Fri Sep  7 09:28:38 2001
@@ -178,7 +178,7 @@
  * David van Leeuwen, david@tm.tno.nl.  */
 #define REVISION "$Revision: 1.5 $"
 
-#include <linux/module.h>	
+#include <linux/module.h>
 
 #include <linux/errno.h>	/* These include what we really need */
 #include <linux/delay.h>
@@ -211,16 +211,19 @@
    address and interrupt request. It can be overridden by the boot 
    parameter `auto'.
 */
-static int auto_probe=1;	/* Yes, why not? */
+static int auto_probe = 1;	/* Yes, why not? */
 
 static int cm206_base = CM206_BASE;
-static int cm206_irq = CM206_IRQ; 
-static int cm206[2] = {0,0};	/* for compatible `insmod' parameter passing */
+static int cm206_irq = CM206_IRQ;
+#ifdef MODULE
+static int cm206[2] = { 0, 0 };	/* for compatible `insmod' parameter passing */
+#endif
 
 MODULE_PARM(cm206_base, "i");	/* base */
 MODULE_PARM(cm206_irq, "i");	/* irq */
 MODULE_PARM(cm206, "1-2i");	/* base,irq or irq,base */
 MODULE_PARM(auto_probe, "i");	/* auto probe base and irq */
+MODULE_LICENSE("GPL");
 
 #define POLLOOP 100		/* milliseconds */
 #define READ_AHEAD 1		/* defines private buffer, waste! */
@@ -233,7 +236,7 @@
 #define LINUX_BLOCK_SIZE 512	/* WHERE is this defined? */
 #define RAW_SECTOR_SIZE 2352	/* ok, is also defined in cdrom.h */
 #define ISO_SECTOR_SIZE 2048
-#define BLOCKS_ISO (ISO_SECTOR_SIZE/LINUX_BLOCK_SIZE) /* 4 */
+#define BLOCKS_ISO (ISO_SECTOR_SIZE/LINUX_BLOCK_SIZE)	/* 4 */
 #define CD_SYNC_HEAD 16		/* CD_SYNC + CD_HEAD */
 
 #ifdef STATISTICS		/* keep track of errors in counters */
@@ -254,88 +257,91 @@
 typedef unsigned char uch;	/* 8-bits */
 typedef unsigned short ush;	/* 16-bits */
 
-struct toc_struct{		/* private copy of Table of Contents */
-  uch track, fsm[3], q0;
+struct toc_struct {		/* private copy of Table of Contents */
+	uch track, fsm[3], q0;
 };
 
 static int cm206_blocksizes[1] = { 2048 };
 
 struct cm206_struct {
-  volatile ush intr_ds;		/* data status read on last interrupt */
-  volatile ush intr_ls;		/* uart line status read on last interrupt*/
-  volatile uch ur[UR_SIZE];	/* uart receive buffer fifo */
-  volatile uch ur_w, ur_r;	/* write/read buffer index */
-  volatile uch dsb, cc;	 /* drive status byte and condition (error) code */
-  int command;			/* command to be written to the uart */
-  int openfiles;
-  ush sector[READ_AHEAD*RAW_SECTOR_SIZE/2]; /* buffered cd-sector */
-  int sector_first, sector_last; /* range of these sectors */
-  wait_queue_head_t uart;	/* wait queues for interrupt */
-  wait_queue_head_t data;
-  struct timer_list timer;	/* time-out */
-  char timed_out;
-  signed char max_sectors;	/* number of sectors that fit in adapter mem */
-  char wait_back;		/* we're waiting for a background-read */
-  char background;		/* is a read going on in the background? */
-  int adapter_first;		/* if so, that's the starting sector */
-  int adapter_last;
-  char fifo_overflowed;
-  uch disc_status[7];		/* result of get_disc_status command */
+	volatile ush intr_ds;	/* data status read on last interrupt */
+	volatile ush intr_ls;	/* uart line status read on last interrupt */
+	volatile uch ur[UR_SIZE];	/* uart receive buffer fifo */
+	volatile uch ur_w, ur_r;	/* write/read buffer index */
+	volatile uch dsb, cc;	/* drive status byte and condition (error) code */
+	int command;		/* command to be written to the uart */
+	int openfiles;
+	ush sector[READ_AHEAD * RAW_SECTOR_SIZE / 2];	/* buffered cd-sector */
+	int sector_first, sector_last;	/* range of these sectors */
+	wait_queue_head_t uart;	/* wait queues for interrupt */
+	wait_queue_head_t data;
+	struct timer_list timer;	/* time-out */
+	char timed_out;
+	signed char max_sectors;	/* number of sectors that fit in adapter mem */
+	char wait_back;		/* we're waiting for a background-read */
+	char background;	/* is a read going on in the background? */
+	int adapter_first;	/* if so, that's the starting sector */
+	int adapter_last;
+	char fifo_overflowed;
+	uch disc_status[7];	/* result of get_disc_status command */
 #ifdef STATISTICS
-  int stats[NR_STATS];
-  int last_stat[NR_STATS];	/* `time' at which stat was stat */
-  int stat_counter;
-#endif  
-  struct toc_struct toc[101];	/* The whole table of contents + lead-out */
-  uch q[10];			/* Last read q-channel info */
-  uch audio_status[5];		/* last read position on pause */
-  uch media_changed;		/* record if media changed */
+	int stats[NR_STATS];
+	int last_stat[NR_STATS];	/* `time' at which stat was stat */
+	int stat_counter;
+#endif
+	struct toc_struct toc[101];	/* The whole table of contents + lead-out */
+	uch q[10];		/* Last read q-channel info */
+	uch audio_status[5];	/* last read position on pause */
+	uch media_changed;	/* record if media changed */
 };
 
 #define DISC_STATUS cd->disc_status[0]
 #define FIRST_TRACK cd->disc_status[1]
 #define LAST_TRACK cd->disc_status[2]
-#define PAUSED cd->audio_status[0] /* misuse this memory byte! */
+#define PAUSED cd->audio_status[0]	/* misuse this memory byte! */
 #define PLAY_TO cd->toc[0]	/* toc[0] records end-time in play */
 
-static struct cm206_struct * cd; /* the main memory structure */
+static struct cm206_struct *cd;	/* the main memory structure */
 
 /* First, we define some polling functions. These are actually
    only being used in the initialization. */
 
 void send_command_polled(int command)
 {
-  int loop=POLLOOP;
-  while (!(inw(r_line_status) & ls_transmitter_buffer_empty) && loop>0) {
-    mdelay(1);		/* one millisec delay */
-    --loop;
-  }
-  outw(command, r_uart_transmit);
+	int loop = POLLOOP;
+	while (!(inw(r_line_status) & ls_transmitter_buffer_empty)
+	       && loop > 0) {
+		mdelay(1);	/* one millisec delay */
+		--loop;
+	}
+	outw(command, r_uart_transmit);
 }
 
 uch receive_echo_polled(void)
 {
-  int loop=POLLOOP;
-  while (!(inw(r_line_status) & ls_receive_buffer_full) && loop>0) {
-    mdelay(1);
-    --loop;
-  }
-  return ((uch) inw(r_uart_receive));
+	int loop = POLLOOP;
+	while (!(inw(r_line_status) & ls_receive_buffer_full) && loop > 0) {
+		mdelay(1);
+		--loop;
+	}
+	return ((uch) inw(r_uart_receive));
 }
 
 uch send_receive_polled(int command)
 {
-  send_command_polled(command);
-  return receive_echo_polled();
+	send_command_polled(command);
+	return receive_echo_polled();
 }
 
-inline void clear_ur(void) {
-  if (cd->ur_r != cd->ur_w) {
-    debug(("Deleting bytes from fifo:"));
-    for(;cd->ur_r != cd->ur_w; cd->ur_r++, cd->ur_r %= UR_SIZE)
-      debug((" 0x%x", cd->ur[cd->ur_r]));
-    debug(("\n"));
-  }
+inline void clear_ur(void)
+{
+	if (cd->ur_r != cd->ur_w) {
+		debug(("Deleting bytes from fifo:"));
+		for (; cd->ur_r != cd->ur_w;
+		     cd->ur_r++, cd->ur_r %= UR_SIZE)
+			debug((" 0x%x", cd->ur[cd->ur_r]));
+		debug(("\n"));
+	}
 }
 
 /* The interrupt handler. When the cm260 generates an interrupt, very
@@ -351,252 +357,269 @@
    as there seems so reason for this to happen.
 */
 
-static void cm206_interrupt(int sig, void *dev_id, struct pt_regs * regs) 
+static void cm206_interrupt(int sig, void *dev_id, struct pt_regs *regs)
 /* you rang? */
 {
-  volatile ush fool;
-  cd->intr_ds = inw(r_data_status); /* resets data_ready, data_error,
-				       crc_error, sync_error, toc_ready 
-				       interrupts */
-  cd->intr_ls = inw(r_line_status); /* resets overrun bit */
-  debug(("Intr, 0x%x 0x%x, %d\n", cd->intr_ds, cd->intr_ls, cd->background));
-  if (cd->intr_ls & ls_attention) stats(attention);
-  /* receive buffer full? */
-  if (cd->intr_ls & ls_receive_buffer_full) {	
-    cd->ur[cd->ur_w] = inb(r_uart_receive); /* get order right! */
-    cd->intr_ls = inw(r_line_status); /* resets rbf interrupt */
-    debug(("receiving #%d: 0x%x\n", cd->ur_w, cd->ur[cd->ur_w]));
-    cd->ur_w++; cd->ur_w %= UR_SIZE;
-    if (cd->ur_w == cd->ur_r) debug(("cd->ur overflow!\n"));
-    if (waitqueue_active(&cd->uart) && cd->background < 2) { 
-      del_timer(&cd->timer);
-      wake_up_interruptible(&cd->uart);
-    }
-  }
-  /* data ready in fifo? */
-  else if (cd->intr_ds & ds_data_ready) { 
-    if (cd->background) ++cd->adapter_last;
-    if (waitqueue_active(&cd->data) && (cd->wait_back || !cd->background)) {
-      del_timer(&cd->timer);
-      wake_up_interruptible(&cd->data);
-    }
-    stats(data_ready);
-  }
-  /* ready to issue a write command? */
-  else if (cd->command && cd->intr_ls & ls_transmitter_buffer_empty) {
-    outw(dc_normal | (inw(r_data_status) & 0x7f), r_data_control);
-    outw(cd->command, r_uart_transmit);
-    cd->command=0;
-    if (!cd->background) wake_up_interruptible(&cd->uart);
-  }
-  /* now treat errors (at least, identify them for debugging) */
-  else if (cd->intr_ds & ds_fifo_overflow) {
-    debug(("Fifo overflow at sectors 0x%x\n", cd->sector_first));
-    fool = inw(r_fifo_output_buffer);	/* de-assert the interrupt */
-    cd->fifo_overflowed=1;	/* signal one word less should be read */
-    stats(fifo_overflow);
-  }
-  else if (cd->intr_ds & ds_data_error) {
-    debug(("Data error at sector 0x%x\n", cd->sector_first));
-    stats(data_error);
-  }
-  else if (cd->intr_ds & ds_crc_error) {
-    debug(("CRC error at sector 0x%x\n", cd->sector_first));
-    stats(crc_error);
-  }
-  else if (cd->intr_ds & ds_sync_error) {
-    debug(("Sync at sector 0x%x\n", cd->sector_first));
-    stats(sync_error);
-  }
-  else if (cd->intr_ds & ds_toc_ready) {
-    /* do something appropriate */
-  }
-  /* couldn't see why this interrupt, maybe due to init */
-  else {			
-    outw(dc_normal | READ_AHEAD, r_data_control);
-    stats(lost_intr);
-  }
-  if (cd->background && (cd->adapter_last-cd->adapter_first == cd->max_sectors
-			 || cd->fifo_overflowed))
-    mark_bh(CM206_BH);	/* issue a stop read command */
-  stats(interrupt);
+	volatile ush fool;
+	cd->intr_ds = inw(r_data_status);	/* resets data_ready, data_error,
+						   crc_error, sync_error, toc_ready 
+						   interrupts */
+	cd->intr_ls = inw(r_line_status);	/* resets overrun bit */
+	debug(("Intr, 0x%x 0x%x, %d\n", cd->intr_ds, cd->intr_ls,
+	       cd->background));
+	if (cd->intr_ls & ls_attention)
+		stats(attention);
+	/* receive buffer full? */
+	if (cd->intr_ls & ls_receive_buffer_full) {
+		cd->ur[cd->ur_w] = inb(r_uart_receive);	/* get order right! */
+		cd->intr_ls = inw(r_line_status);	/* resets rbf interrupt */
+		debug(("receiving #%d: 0x%x\n", cd->ur_w,
+		       cd->ur[cd->ur_w]));
+		cd->ur_w++;
+		cd->ur_w %= UR_SIZE;
+		if (cd->ur_w == cd->ur_r)
+			debug(("cd->ur overflow!\n"));
+		if (waitqueue_active(&cd->uart) && cd->background < 2) {
+			del_timer(&cd->timer);
+			wake_up_interruptible(&cd->uart);
+		}
+	}
+	/* data ready in fifo? */
+	else if (cd->intr_ds & ds_data_ready) {
+		if (cd->background)
+			++cd->adapter_last;
+		if (waitqueue_active(&cd->data)
+		    && (cd->wait_back || !cd->background)) {
+			del_timer(&cd->timer);
+			wake_up_interruptible(&cd->data);
+		}
+		stats(data_ready);
+	}
+	/* ready to issue a write command? */
+	else if (cd->command && cd->intr_ls & ls_transmitter_buffer_empty) {
+		outw(dc_normal | (inw(r_data_status) & 0x7f),
+		     r_data_control);
+		outw(cd->command, r_uart_transmit);
+		cd->command = 0;
+		if (!cd->background)
+			wake_up_interruptible(&cd->uart);
+	}
+	/* now treat errors (at least, identify them for debugging) */
+	else if (cd->intr_ds & ds_fifo_overflow) {
+		debug(("Fifo overflow at sectors 0x%x\n",
+		       cd->sector_first));
+		fool = inw(r_fifo_output_buffer);	/* de-assert the interrupt */
+		cd->fifo_overflowed = 1;	/* signal one word less should be read */
+		stats(fifo_overflow);
+	} else if (cd->intr_ds & ds_data_error) {
+		debug(("Data error at sector 0x%x\n", cd->sector_first));
+		stats(data_error);
+	} else if (cd->intr_ds & ds_crc_error) {
+		debug(("CRC error at sector 0x%x\n", cd->sector_first));
+		stats(crc_error);
+	} else if (cd->intr_ds & ds_sync_error) {
+		debug(("Sync at sector 0x%x\n", cd->sector_first));
+		stats(sync_error);
+	} else if (cd->intr_ds & ds_toc_ready) {
+		/* do something appropriate */
+	}
+	/* couldn't see why this interrupt, maybe due to init */
+	else {
+		outw(dc_normal | READ_AHEAD, r_data_control);
+		stats(lost_intr);
+	}
+	if (cd->background
+	    && (cd->adapter_last - cd->adapter_first == cd->max_sectors
+		|| cd->fifo_overflowed))
+		mark_bh(CM206_BH);	/* issue a stop read command */
+	stats(interrupt);
 }
 
 /* we have put the address of the wait queue in who */
 void cm206_timeout(unsigned long who)
 {
-  cd->timed_out = 1;
-  debug(("Timing out\n"));
-  wake_up_interruptible((wait_queue_head_t *)who);
+	cd->timed_out = 1;
+	debug(("Timing out\n"));
+	wake_up_interruptible((wait_queue_head_t *) who);
 }
 
 /* This function returns 1 if a timeout occurred, 0 if an interrupt
    happened */
-int sleep_or_timeout(wait_queue_head_t *wait, int timeout)
+int sleep_or_timeout(wait_queue_head_t * wait, int timeout)
 {
-  cd->timed_out=0;
-  cd->timer.data=(unsigned long) wait;
-  cd->timer.expires = jiffies + timeout;
-  add_timer(&cd->timer);
-  debug(("going to sleep\n"));
-  interruptible_sleep_on(wait);
-  del_timer(&cd->timer);
-  if (cd->timed_out) {
-    cd->timed_out = 0;
-    return 1;
-  }
-  else return 0;
+	cd->timed_out = 0;
+	cd->timer.data = (unsigned long) wait;
+	cd->timer.expires = jiffies + timeout;
+	add_timer(&cd->timer);
+	debug(("going to sleep\n"));
+	interruptible_sleep_on(wait);
+	del_timer(&cd->timer);
+	if (cd->timed_out) {
+		cd->timed_out = 0;
+		return 1;
+	} else
+		return 0;
 }
 
-void cm206_delay(int nr_jiffies) 
+void cm206_delay(int nr_jiffies)
 {
-  DECLARE_WAIT_QUEUE_HEAD(wait);
-  sleep_or_timeout(&wait, nr_jiffies);
+	DECLARE_WAIT_QUEUE_HEAD(wait);
+	sleep_or_timeout(&wait, nr_jiffies);
 }
 
 void send_command(int command)
 {
-  debug(("Sending 0x%x\n", command));
-  if (!(inw(r_line_status) & ls_transmitter_buffer_empty)) {
-    cd->command = command;
-    cli();			/* don't interrupt before sleep */
-    outw(dc_mask_sync_error | dc_no_stop_on_error | 
-	 (inw(r_data_status) & 0x7f), r_data_control);
-    /* interrupt routine sends command */
-    if (sleep_or_timeout(&cd->uart, UART_TIMEOUT)) {
-      debug(("Time out on write-buffer\n"));
-      stats(write_timeout);
-      outw(command, r_uart_transmit);
-    }
-    debug(("Write commmand delayed\n"));
-  }
-  else outw(command, r_uart_transmit);
+	debug(("Sending 0x%x\n", command));
+	if (!(inw(r_line_status) & ls_transmitter_buffer_empty)) {
+		cd->command = command;
+		cli();		/* don't interrupt before sleep */
+		outw(dc_mask_sync_error | dc_no_stop_on_error |
+		     (inw(r_data_status) & 0x7f), r_data_control);
+		/* interrupt routine sends command */
+		if (sleep_or_timeout(&cd->uart, UART_TIMEOUT)) {
+			debug(("Time out on write-buffer\n"));
+			stats(write_timeout);
+			outw(command, r_uart_transmit);
+		}
+		debug(("Write commmand delayed\n"));
+	} else
+		outw(command, r_uart_transmit);
 }
 
 uch receive_byte(int timeout)
 {
-  uch ret;
-  cli();
-  debug(("cli\n"));
-  ret = cd->ur[cd->ur_r];
-  if (cd->ur_r != cd->ur_w) {
-    sti();
-    debug(("returning #%d: 0x%x\n", cd->ur_r, cd->ur[cd->ur_r]));
-    cd->ur_r++; cd->ur_r %= UR_SIZE;
-    return ret;
-  } 
-  else if (sleep_or_timeout(&cd->uart, timeout)) { /* does sti() */
-    debug(("Time out on receive-buffer\n"));
+	uch ret;
+	cli();
+	debug(("cli\n"));
+	ret = cd->ur[cd->ur_r];
+	if (cd->ur_r != cd->ur_w) {
+		sti();
+		debug(("returning #%d: 0x%x\n", cd->ur_r,
+		       cd->ur[cd->ur_r]));
+		cd->ur_r++;
+		cd->ur_r %= UR_SIZE;
+		return ret;
+	} else if (sleep_or_timeout(&cd->uart, timeout)) {	/* does sti() */
+		debug(("Time out on receive-buffer\n"));
 #ifdef STATISTICS
-    if (timeout==UART_TIMEOUT) stats(receive_timeout) /* no `;'! */
-    else stats(dsb_timeout);
+		if (timeout == UART_TIMEOUT)
+			stats(receive_timeout)	/* no `;'! */
+			    else
+			stats(dsb_timeout);
 #endif
-    return 0xda;
-  }
-  ret = cd->ur[cd->ur_r];  
-  debug(("slept; returning #%d: 0x%x\n", cd->ur_r, cd->ur[cd->ur_r]));
-  cd->ur_r++; cd->ur_r %= UR_SIZE;
-  return ret;
+		return 0xda;
+	}
+	ret = cd->ur[cd->ur_r];
+	debug(("slept; returning #%d: 0x%x\n", cd->ur_r,
+	       cd->ur[cd->ur_r]));
+	cd->ur_r++;
+	cd->ur_r %= UR_SIZE;
+	return ret;
 }
 
 inline uch receive_echo(void)
 {
-  return receive_byte(UART_TIMEOUT);
+	return receive_byte(UART_TIMEOUT);
 }
 
 inline uch send_receive(int command)
 {
-  send_command(command);
-  return receive_echo();
+	send_command(command);
+	return receive_echo();
 }
 
 inline uch wait_dsb(void)
 {
-  return receive_byte(DSB_TIMEOUT);
+	return receive_byte(DSB_TIMEOUT);
 }
 
 int type_0_command(int command, int expect_dsb)
 {
-  int e;
-  clear_ur();
-  if (command != (e=send_receive(command))) {
-    debug(("command 0x%x echoed as 0x%x\n", command, e));
-    stats(echo);
-    return -1;
-  }
-  if (expect_dsb) {
-    cd->dsb = wait_dsb();	/* wait for command to finish */
-  }
-  return 0;
-}
-
-int type_1_command(int command, int bytes, uch * status) /* returns info */
-{
-  int i;
-  if (type_0_command(command,0)) return -1;
-  for(i=0; i<bytes; i++) 
-    status[i] = send_receive(c_gimme);
-  return 0;
-}  
+	int e;
+	clear_ur();
+	if (command != (e = send_receive(command))) {
+		debug(("command 0x%x echoed as 0x%x\n", command, e));
+		stats(echo);
+		return -1;
+	}
+	if (expect_dsb) {
+		cd->dsb = wait_dsb();	/* wait for command to finish */
+	}
+	return 0;
+}
+
+int type_1_command(int command, int bytes, uch * status)
+{				/* returns info */
+	int i;
+	if (type_0_command(command, 0))
+		return -1;
+	for (i = 0; i < bytes; i++)
+		status[i] = send_receive(c_gimme);
+	return 0;
+}
 
 /* This function resets the adapter card. We'd better not do this too
  * often, because it tends to generate `lost interrupts.' */
 void reset_cm260(void)
 {
-  outw(dc_normal | dc_initialize | READ_AHEAD, r_data_control);
-  udelay(10);			/* 3.3 mu sec minimum */
-  outw(dc_normal | READ_AHEAD, r_data_control);
+	outw(dc_normal | dc_initialize | READ_AHEAD, r_data_control);
+	udelay(10);		/* 3.3 mu sec minimum */
+	outw(dc_normal | READ_AHEAD, r_data_control);
 }
 
 /* fsm: frame-sec-min from linear address; one of many */
-void fsm(int lba, uch * fsm) 
+void fsm(int lba, uch * fsm)
 {
-  fsm[0] = lba % 75;
-  lba /= 75; lba += 2;
-  fsm[1] = lba % 60; fsm[2] = lba / 60;
+	fsm[0] = lba % 75;
+	lba /= 75;
+	lba += 2;
+	fsm[1] = lba % 60;
+	fsm[2] = lba / 60;
 }
 
-inline int fsm2lba(uch * fsm) 
+inline int fsm2lba(uch * fsm)
 {
-  return fsm[0] + 75*(fsm[1]-2 + 60*fsm[2]);
+	return fsm[0] + 75 * (fsm[1] - 2 + 60 * fsm[2]);
 }
 
 inline int f_s_m2lba(uch f, uch s, uch m)
 {
-  return f + 75*(s-2 + 60*m);
+	return f + 75 * (s - 2 + 60 * m);
 }
 
-int start_read(int start) 
+int start_read(int start)
 {
-  uch read_sector[4] = {c_read_data, };
-  int i, e;
+	uch read_sector[4] = { c_read_data, };
+	int i, e;
 
-  fsm(start, &read_sector[1]);
-  clear_ur();
-  for (i=0; i<4; i++) 
-    if (read_sector[i] != (e=send_receive(read_sector[i]))) {
-      debug(("read_sector: %x echoes %x\n", read_sector[i], e));
-      stats(echo);
-      if (e==0xff) {		/* this seems to happen often */
-	e = receive_echo();
-	debug(("Second try %x\n", e));
-	if (e!=read_sector[i]) return -1;
-      }
-    }
-  return 0;
+	fsm(start, &read_sector[1]);
+	clear_ur();
+	for (i = 0; i < 4; i++)
+		if (read_sector[i] != (e = send_receive(read_sector[i]))) {
+			debug(("read_sector: %x echoes %x\n",
+			       read_sector[i], e));
+			stats(echo);
+			if (e == 0xff) {	/* this seems to happen often */
+				e = receive_echo();
+				debug(("Second try %x\n", e));
+				if (e != read_sector[i])
+					return -1;
+			}
+		}
+	return 0;
 }
 
 int stop_read(void)
 {
-  int e;
-  type_0_command(c_stop,0);
-  if((e=receive_echo()) != 0xff) {
-    debug(("c_stop didn't send 0xff, but 0x%x\n", e));
-    stats(stop_0xff);
-    return -1;
-  }
-  return 0;
-}  
+	int e;
+	type_0_command(c_stop, 0);
+	if ((e = receive_echo()) != 0xff) {
+		debug(("c_stop didn't send 0xff, but 0x%x\n", e));
+		stats(stop_0xff);
+		return -1;
+	}
+	return 0;
+}
 
 /* This function starts to read sectors in adapter memory, the
    interrupt routine should stop the read. In fact, the bottom_half
@@ -605,12 +628,14 @@
 
 int read_background(int start, int reading)
 {
-  if (cd->background) return -1; /* can't do twice */
-  outw(dc_normal | BACK_AHEAD, r_data_control);
-  if (!reading && start_read(start)) return -2;
-  cd->adapter_first = cd->adapter_last = start; 
-  cd->background = 1;		/* flag a read is going on */
-  return 0;
+	if (cd->background)
+		return -1;	/* can't do twice */
+	outw(dc_normal | BACK_AHEAD, r_data_control);
+	if (!reading && start_read(start))
+		return -2;
+	cd->adapter_first = cd->adapter_last = start;
+	cd->background = 1;	/* flag a read is going on */
+	return 0;
 }
 
 #ifdef USE_INSW
@@ -618,12 +643,12 @@
 #else
 /* this routine implements insw(,,). There was a time i had the
    impression that there would be any difference in error-behaviour. */
-void transport_data(int port, ush * dest, int count) 
+void transport_data(int port, ush * dest, int count)
 {
-  int i;
-  ush * d;
-  for (i=0, d=dest; i<count; i++, d++) 
-    *d = inw(port);
+	int i;
+	ush *d;
+	for (i = 0, d = dest; i < count; i++, d++)
+		*d = inw(port);
 }
 #endif
 
@@ -631,33 +656,38 @@
 #define MAX_TRIES 100
 int read_sector(int start)
 {
-  int tries=0;
-  if (cd->background) {
-    cd->background=0;
-    cd->adapter_last = -1;	/* invalidate adapter memory */
-    stop_read();
-  }
-  cd->fifo_overflowed=0;
-  reset_cm260();		/* empty fifo etc. */
-  if (start_read(start)) return -1;
-  do {
-    if (sleep_or_timeout(&cd->data, DATA_TIMEOUT)) {
-      debug(("Read timed out sector 0x%x\n", start));
-      stats(read_timeout);
-      stop_read();
-      return -3;		
-    } 
-    tries++;
-  } while (cd->intr_ds & ds_fifo_empty && tries < MAX_TRIES);
-  if (tries>1) debug(("Took me some tries\n"))
-  else if (tries == MAX_TRIES) 
-    debug(("MAX_TRIES tries for read sector\n"));
-  transport_data(r_fifo_output_buffer, cd->sector, 
-		 READ_AHEAD*RAW_SECTOR_SIZE/2);
-  if (read_background(start+READ_AHEAD,1)) stats(read_background);
-  cd->sector_first = start; cd->sector_last = start+READ_AHEAD;
-  stats(read_restarted);
-  return 0;
+	int tries = 0;
+	if (cd->background) {
+		cd->background = 0;
+		cd->adapter_last = -1;	/* invalidate adapter memory */
+		stop_read();
+	}
+	cd->fifo_overflowed = 0;
+	reset_cm260();		/* empty fifo etc. */
+	if (start_read(start))
+		return -1;
+	do {
+		if (sleep_or_timeout(&cd->data, DATA_TIMEOUT)) {
+			debug(("Read timed out sector 0x%x\n", start));
+			stats(read_timeout);
+			stop_read();
+			return -3;
+		}
+		tries++;
+	} while (cd->intr_ds & ds_fifo_empty && tries < MAX_TRIES);
+	if (tries > 1)
+		debug(("Took me some tries\n"))
+		    else
+	if (tries == MAX_TRIES)
+		debug(("MAX_TRIES tries for read sector\n"));
+	transport_data(r_fifo_output_buffer, cd->sector,
+		       READ_AHEAD * RAW_SECTOR_SIZE / 2);
+	if (read_background(start + READ_AHEAD, 1))
+		stats(read_background);
+	cd->sector_first = start;
+	cd->sector_last = start + READ_AHEAD;
+	stats(read_restarted);
+	return 0;
 }
 
 /* The function of bottom-half is to send a stop command to the drive
@@ -672,43 +702,46 @@
 
 void cm206_bh(void)
 {
-  debug(("bh: %d\n", cd->background));
-  switch (cd->background) {
-  case 1:
-    stats(bh);
-    if (!(cd->intr_ls & ls_transmitter_buffer_empty)) {
-      cd->command = c_stop;
-      outw(dc_mask_sync_error | dc_no_stop_on_error | 
-	   (inw(r_data_status) & 0x7f), r_data_control);
-      cd->background=2;
-      break;			/* we'd better not time-out here! */
-    }
-    else outw(c_stop, r_uart_transmit);
-    /* fall into case 2: */
-  case 2:			
-    /* the write has been satisfied by interrupt routine */
-    cd->background=3;
-    break;
-  case 3:
-    if (cd->ur_r != cd->ur_w) {
-      if (cd->ur[cd->ur_r] != c_stop) {
-	debug(("cm206_bh: c_stop echoed 0x%x\n", cd->ur[cd->ur_r]));
-	stats(echo);
-      }
-      cd->ur_r++; cd->ur_r %= UR_SIZE;
-    }
-    cd->background++;
-    break;
-  case 4:
-    if (cd->ur_r != cd->ur_w) {
-      if (cd->ur[cd->ur_r] != 0xff) {
-	debug(("cm206_bh: c_stop reacted with 0x%x\n", cd->ur[cd->ur_r]));
-	stats(stop_0xff);
-      }
-      cd->ur_r++; cd->ur_r %= UR_SIZE;
-    }
-    cd->background=0;
-  }
+	debug(("bh: %d\n", cd->background));
+	switch (cd->background) {
+	case 1:
+		stats(bh);
+		if (!(cd->intr_ls & ls_transmitter_buffer_empty)) {
+			cd->command = c_stop;
+			outw(dc_mask_sync_error | dc_no_stop_on_error |
+			     (inw(r_data_status) & 0x7f), r_data_control);
+			cd->background = 2;
+			break;	/* we'd better not time-out here! */
+		} else
+			outw(c_stop, r_uart_transmit);
+		/* fall into case 2: */
+	case 2:
+		/* the write has been satisfied by interrupt routine */
+		cd->background = 3;
+		break;
+	case 3:
+		if (cd->ur_r != cd->ur_w) {
+			if (cd->ur[cd->ur_r] != c_stop) {
+				debug(("cm206_bh: c_stop echoed 0x%x\n",
+				       cd->ur[cd->ur_r]));
+				stats(echo);
+			}
+			cd->ur_r++;
+			cd->ur_r %= UR_SIZE;
+		}
+		cd->background++;
+		break;
+	case 4:
+		if (cd->ur_r != cd->ur_w) {
+			if (cd->ur[cd->ur_r] != 0xff) {
+				debug(("cm206_bh: c_stop reacted with 0x%x\n", cd->ur[cd->ur_r]));
+				stats(stop_0xff);
+			}
+			cd->ur_r++;
+			cd->ur_r %= UR_SIZE;
+		}
+		cd->background = 0;
+	}
 }
 
 /* This command clears the dsb_possible_media_change flag, so we must 
@@ -716,66 +749,67 @@
  */
 void get_drive_status(void)
 {
-  uch status[2];
-  type_1_command(c_drive_status, 2, status); /* this might be done faster */
-  cd->dsb=status[0];
-  cd->cc=status[1];
-  cd->media_changed |= 
-    !!(cd->dsb & (dsb_possible_media_change | 
-		  dsb_drive_not_ready | dsb_tray_not_closed));
+	uch status[2];
+	type_1_command(c_drive_status, 2, status);	/* this might be done faster */
+	cd->dsb = status[0];
+	cd->cc = status[1];
+	cd->media_changed |=
+	    !!(cd->dsb & (dsb_possible_media_change |
+			  dsb_drive_not_ready | dsb_tray_not_closed));
 }
 
 void get_disc_status(void)
 {
-  if (type_1_command(c_disc_status, 7, cd->disc_status)) {
-    debug(("get_disc_status: error\n"));
-  }
+	if (type_1_command(c_disc_status, 7, cd->disc_status)) {
+		debug(("get_disc_status: error\n"));
+	}
 }
 
 /* The new open. The real opening strategy is defined in cdrom.c. */
 
-static int cm206_open(struct cdrom_device_info * cdi, int purpose) 
+static int cm206_open(struct cdrom_device_info *cdi, int purpose)
 {
-  MOD_INC_USE_COUNT;
-  if (!cd->openfiles) {		/* reset only first time */
-    cd->background=0;
-    reset_cm260();
-    cd->adapter_last = -1;	/* invalidate adapter memory */
-    cd->sector_last = -1;
-  }
-  ++cd->openfiles;
-  stats(open);
-  return 0;
-}
-
-static void cm206_release(struct cdrom_device_info * cdi)
-{
-  if (cd->openfiles==1) {
-    if (cd->background) {
-      cd->background=0;
-      stop_read();
-    }
-    cd->sector_last = -1;	/* Make our internal buffer invalid */
-    FIRST_TRACK = 0;		/* No valid disc status */
-  }
-  --cd->openfiles;
-  MOD_DEC_USE_COUNT;
+	MOD_INC_USE_COUNT;
+	if (!cd->openfiles) {	/* reset only first time */
+		cd->background = 0;
+		reset_cm260();
+		cd->adapter_last = -1;	/* invalidate adapter memory */
+		cd->sector_last = -1;
+	}
+	++cd->openfiles;
+	stats(open);
+	return 0;
+}
+
+static void cm206_release(struct cdrom_device_info *cdi)
+{
+	if (cd->openfiles == 1) {
+		if (cd->background) {
+			cd->background = 0;
+			stop_read();
+		}
+		cd->sector_last = -1;	/* Make our internal buffer invalid */
+		FIRST_TRACK = 0;	/* No valid disc status */
+	}
+	--cd->openfiles;
+	MOD_DEC_USE_COUNT;
 }
 
 /* Empty buffer empties $sectors$ sectors of the adapter card buffer,
  * and then reads a sector in kernel memory.  */
-void empty_buffer(int sectors) 
+void empty_buffer(int sectors)
 {
-  while (sectors>=0) {
-    transport_data(r_fifo_output_buffer, cd->sector + cd->fifo_overflowed, 
-	 RAW_SECTOR_SIZE/2 - cd->fifo_overflowed);
-    --sectors;
-    ++cd->adapter_first;	/* update the current adapter sector */
-    cd->fifo_overflowed=0;	/* reset overflow bit */
-    stats(sector_transferred);
-  } 
-  cd->sector_first=cd->adapter_first-1;
-  cd->sector_last=cd->adapter_first; /* update the buffer sector */
+	while (sectors >= 0) {
+		transport_data(r_fifo_output_buffer,
+			       cd->sector + cd->fifo_overflowed,
+			       RAW_SECTOR_SIZE / 2 - cd->fifo_overflowed);
+		--sectors;
+		++cd->adapter_first;	/* update the current adapter sector */
+		cd->fifo_overflowed = 0;	/* reset overflow bit */
+		stats(sector_transferred);
+	}
+	cd->sector_first = cd->adapter_first - 1;
+	cd->sector_last = cd->adapter_first;	/* update the buffer sector */
 }
 
 /* try_adapter. This function determines if the requested sector is
@@ -783,29 +817,27 @@
    success */
 int try_adapter(int sector)
 {
-  if (cd->adapter_first <= sector && sector < cd->adapter_last) { 
-    /* sector is in adapter memory */
-    empty_buffer(sector - cd->adapter_first);
-    return 0;
-  }
-  else if (cd->background==1 && cd->adapter_first <= sector
-	   && sector < cd->adapter_first+cd->max_sectors) {
-    /* a read is going on, we can wait for it */
-    cd->wait_back=1;
-    while (sector >= cd->adapter_last) {
-      if (sleep_or_timeout(&cd->data, DATA_TIMEOUT)) {
-	debug(("Timed out during background wait: %d %d %d %d\n", sector, 
-	       cd->adapter_last, cd->adapter_first, cd->background));
-	stats(back_read_timeout);
-	cd->wait_back=0;
-	return -1;
-      }
-    }
-    cd->wait_back=0;
-    empty_buffer(sector - cd->adapter_first);
-    return 0;
-  }
-  else return -2;
+	if (cd->adapter_first <= sector && sector < cd->adapter_last) {
+		/* sector is in adapter memory */
+		empty_buffer(sector - cd->adapter_first);
+		return 0;
+	} else if (cd->background == 1 && cd->adapter_first <= sector
+		   && sector < cd->adapter_first + cd->max_sectors) {
+		/* a read is going on, we can wait for it */
+		cd->wait_back = 1;
+		while (sector >= cd->adapter_last) {
+			if (sleep_or_timeout(&cd->data, DATA_TIMEOUT)) {
+				debug(("Timed out during background wait: %d %d %d %d\n", sector, cd->adapter_last, cd->adapter_first, cd->background));
+				stats(back_read_timeout);
+				cd->wait_back = 0;
+				return -1;
+			}
+		}
+		cd->wait_back = 0;
+		empty_buffer(sector - cd->adapter_first);
+		return 0;
+	} else
+		return -2;
 }
 
 /* This is not a very smart implementation. We could optimize for 
@@ -813,45 +845,50 @@
    bring down the processor load. */
 static void do_cm206_request(request_queue_t * q)
 {
-  long int i, cd_sec_no;
-  int quarter, error; 
-  uch * source, * dest;
-  
-  while(1) {	 /* repeat until all requests have been satisfied */
-    INIT_REQUEST;
-    if (QUEUE_EMPTY || CURRENT->rq_status == RQ_INACTIVE)
-      return;
-    if (CURRENT->cmd != READ) {
-      debug(("Non-read command %d on cdrom\n", CURRENT->cmd));
-      end_request(0);
-      continue;
-    }
-    spin_unlock_irq(&io_request_lock);
-    error=0;
-    for (i=0; i<CURRENT->nr_sectors; i++) {
-      int e1, e2;
-      cd_sec_no = (CURRENT->sector+i)/BLOCKS_ISO; /* 4 times 512 bytes */
-      quarter = (CURRENT->sector+i) % BLOCKS_ISO; 
-      dest = CURRENT->buffer + i*LINUX_BLOCK_SIZE;
-      /* is already in buffer memory? */
-      if (cd->sector_first <= cd_sec_no && cd_sec_no < cd->sector_last) {
-	source = ((uch *) cd->sector) + 16 + quarter*LINUX_BLOCK_SIZE 
-	  + (cd_sec_no-cd->sector_first)*RAW_SECTOR_SIZE;
- 	memcpy(dest, source, LINUX_BLOCK_SIZE); 
-      }
-      else if (!(e1=try_adapter(cd_sec_no)) || 
-	       !(e2=read_sector(cd_sec_no))) {
-	source =  ((uch *) cd->sector)+16+quarter*LINUX_BLOCK_SIZE;
-	memcpy(dest, source, LINUX_BLOCK_SIZE); 
-      }
-      else {
-	error=1;
-	debug(("cm206_request: %d %d\n", e1, e2));
-      }
-    }
-    spin_lock_irq(&io_request_lock);
-    end_request(!error);
-  }
+	long int i, cd_sec_no;
+	int quarter, error;
+	uch *source, *dest;
+
+	while (1) {		/* repeat until all requests have been satisfied */
+		INIT_REQUEST;
+		if (QUEUE_EMPTY || CURRENT->rq_status == RQ_INACTIVE)
+			return;
+		if (CURRENT->cmd != READ) {
+			debug(("Non-read command %d on cdrom\n",
+			       CURRENT->cmd));
+			end_request(0);
+			continue;
+		}
+		spin_unlock_irq(&io_request_lock);
+		error = 0;
+		for (i = 0; i < CURRENT->nr_sectors; i++) {
+			int e1, e2;
+			cd_sec_no = (CURRENT->sector + i) / BLOCKS_ISO;	/* 4 times 512 bytes */
+			quarter = (CURRENT->sector + i) % BLOCKS_ISO;
+			dest = CURRENT->buffer + i * LINUX_BLOCK_SIZE;
+			/* is already in buffer memory? */
+			if (cd->sector_first <= cd_sec_no
+			    && cd_sec_no < cd->sector_last) {
+				source =
+				    ((uch *) cd->sector) + 16 +
+				    quarter * LINUX_BLOCK_SIZE +
+				    (cd_sec_no -
+				     cd->sector_first) * RAW_SECTOR_SIZE;
+				memcpy(dest, source, LINUX_BLOCK_SIZE);
+			} else if (!(e1 = try_adapter(cd_sec_no)) ||
+				   !(e2 = read_sector(cd_sec_no))) {
+				source =
+				    ((uch *) cd->sector) + 16 +
+				    quarter * LINUX_BLOCK_SIZE;
+				memcpy(dest, source, LINUX_BLOCK_SIZE);
+			} else {
+				error = 1;
+				debug(("cm206_request: %d %d\n", e1, e2));
+			}
+		}
+		spin_lock_irq(&io_request_lock);
+		end_request(!error);
+	}
 }
 
 /* Audio support. I've tried very hard, but the cm206 drive doesn't 
@@ -870,24 +907,27 @@
 /* seek seeks to address lba. It does wait to arrive there. */
 void seek(int lba)
 {
-  int i;
-  uch seek_command[4]={c_seek, };
-  
-  fsm(lba, &seek_command[1]);
-  for (i=0; i<4; i++) type_0_command(seek_command[i], 0);
-  cd->dsb = wait_dsb();
+	int i;
+	uch seek_command[4] = { c_seek, };
+
+	fsm(lba, &seek_command[1]);
+	for (i = 0; i < 4; i++)
+		type_0_command(seek_command[i], 0);
+	cd->dsb = wait_dsb();
 }
 
-uch bcdbin(unsigned char bcd)	/* stolen from mcd.c! */
-{
-  return (bcd >> 4)*10 + (bcd & 0xf);
-} 
+uch bcdbin(unsigned char bcd)
+{				/* stolen from mcd.c! */
+	return (bcd >> 4) * 10 + (bcd & 0xf);
+}
 
-inline uch normalize_track(uch track) 
+inline uch normalize_track(uch track)
 {
-  if (track<1) return 1;
-  if (track>LAST_TRACK) return LAST_TRACK+1;
-  return track;
+	if (track < 1)
+		return 1;
+	if (track > LAST_TRACK)
+		return LAST_TRACK + 1;
+	return track;
 }
 
 /* This function does a binary search for track start. It records all
@@ -896,150 +936,175 @@
  */
 int get_toc_lba(uch track)
 {
-  int max=74*60*75-150, min=fsm2lba(cd->toc[1].fsm);
-  int i, lba, l, old_lba=0;
-  uch * q = cd->q;
-  uch ct;			/* current track */
-  int binary=0;
-  const int skip = 3*60*75;		/* 3 minutes */
-
-  for (i=track; i>0; i--) if (cd->toc[i].track) {
-    min = fsm2lba(cd->toc[i].fsm);
-    break;
-  }
-  lba = min + skip;
-  do {
-    seek(lba); 
-    type_1_command(c_read_current_q, 10, q);
-    ct = normalize_track(q[1]);
-    if (!cd->toc[ct].track) {
-      l = q[9]-bcdbin(q[5]) + 75*(q[8]-bcdbin(q[4])-2 + 
-				  60*(q[7]-bcdbin(q[3])));
-      cd->toc[ct].track=q[1];	/* lead out still 0xaa */
-      fsm(l, cd->toc[ct].fsm);
-      cd->toc[ct].q0 = q[0];	/* contains adr and ctrl info */
-      if (ct==track) return l;
-    }
-    old_lba=lba;
-    if (binary) {
-      if (ct < track) min = lba; else max = lba;
-      lba = (min+max)/2; 
-    } else {
-      if(ct < track) lba += skip;
-      else {
-	binary=1;
-	max = lba; min = lba - skip;
-	lba = (min+max)/2;
-      }
-    }
-  } while (lba!=old_lba);
-  return lba;
+	int max = 74 * 60 * 75 - 150, min = fsm2lba(cd->toc[1].fsm);
+	int i, lba, l, old_lba = 0;
+	uch *q = cd->q;
+	uch ct;			/* current track */
+	int binary = 0;
+	const int skip = 3 * 60 * 75;	/* 3 minutes */
+
+	for (i = track; i > 0; i--)
+		if (cd->toc[i].track) {
+			min = fsm2lba(cd->toc[i].fsm);
+			break;
+		}
+	lba = min + skip;
+	do {
+		seek(lba);
+		type_1_command(c_read_current_q, 10, q);
+		ct = normalize_track(q[1]);
+		if (!cd->toc[ct].track) {
+			l = q[9] - bcdbin(q[5]) + 75 * (q[8] -
+							bcdbin(q[4]) - 2 +
+							60 * (q[7] -
+							      bcdbin(q
+								     [3])));
+			cd->toc[ct].track = q[1];	/* lead out still 0xaa */
+			fsm(l, cd->toc[ct].fsm);
+			cd->toc[ct].q0 = q[0];	/* contains adr and ctrl info */
+			if (ct == track)
+				return l;
+		}
+		old_lba = lba;
+		if (binary) {
+			if (ct < track)
+				min = lba;
+			else
+				max = lba;
+			lba = (min + max) / 2;
+		} else {
+			if (ct < track)
+				lba += skip;
+			else {
+				binary = 1;
+				max = lba;
+				min = lba - skip;
+				lba = (min + max) / 2;
+			}
+		}
+	} while (lba != old_lba);
+	return lba;
+}
+
+void update_toc_entry(uch track)
+{
+	track = normalize_track(track);
+	if (!cd->toc[track].track)
+		get_toc_lba(track);
 }
 
-void update_toc_entry(uch track) 
+/* return 0 upon success */
+int read_toc_header(struct cdrom_tochdr *hp)
 {
-  track = normalize_track(track);
-  if (!cd->toc[track].track) get_toc_lba(track);
+	if (!FIRST_TRACK)
+		get_disc_status();
+	if (hp) {
+		int i;
+		hp->cdth_trk0 = FIRST_TRACK;
+		hp->cdth_trk1 = LAST_TRACK;
+		/* fill in first track position */
+		for (i = 0; i < 3; i++)
+			cd->toc[1].fsm[i] = cd->disc_status[3 + i];
+		update_toc_entry(LAST_TRACK + 1);	/* find most entries */
+		return 0;
+	}
+	return -1;
 }
 
-/* return 0 upon success */
-int read_toc_header(struct cdrom_tochdr * hp)
+void play_from_to_msf(struct cdrom_msf *msfp)
 {
-  if (!FIRST_TRACK) get_disc_status();
-  if (hp) { 
-    int i;
-    hp->cdth_trk0 = FIRST_TRACK;
-    hp->cdth_trk1 = LAST_TRACK; 
-				/* fill in first track position */
-    for (i=0; i<3; i++) cd->toc[1].fsm[i] = cd->disc_status[3+i];
-    update_toc_entry(LAST_TRACK+1);		/* find most entries */
-    return 0;
-  }
-  return -1;
-}  
-
-void play_from_to_msf(struct cdrom_msf* msfp)
-{
-  uch play_command[] = {c_play, 
-	   msfp->cdmsf_frame0, msfp->cdmsf_sec0, msfp->cdmsf_min0,
-	   msfp->cdmsf_frame1, msfp->cdmsf_sec1, msfp->cdmsf_min1, 2, 2};
-  int i;
-  for (i=0; i<9; i++) type_0_command(play_command[i], 0);
-  for (i=0; i<3; i++) 
-    PLAY_TO.fsm[i] = play_command[i+4];
-  PLAY_TO.track = 0;		/* say no track end */
-  cd->dsb = wait_dsb();
-}  
+	uch play_command[] = { c_play,
+		msfp->cdmsf_frame0, msfp->cdmsf_sec0, msfp->cdmsf_min0,
+		msfp->cdmsf_frame1, msfp->cdmsf_sec1, msfp->cdmsf_min1, 2,
+		    2
+	};
+	int i;
+	for (i = 0; i < 9; i++)
+		type_0_command(play_command[i], 0);
+	for (i = 0; i < 3; i++)
+		PLAY_TO.fsm[i] = play_command[i + 4];
+	PLAY_TO.track = 0;	/* say no track end */
+	cd->dsb = wait_dsb();
+}
 
 void play_from_to_track(int from, int to)
 {
-  uch play_command[8] = {c_play, };
-  int i;
+	uch play_command[8] = { c_play, };
+	int i;
 
-  if (from==0) {		/* continue paused play */
-    for (i=0; i<3; i++) { 
-      play_command[i+1] = cd->audio_status[i+2];
-      play_command[i+4] = PLAY_TO.fsm[i];
-    }
-  } else {
-    update_toc_entry(from); update_toc_entry(to+1);
-    for (i=0; i<3; i++) {
-      play_command[i+1] = cd->toc[from].fsm[i];
-      PLAY_TO.fsm[i] = play_command[i+4] = cd->toc[to+1].fsm[i];
-    }
-    PLAY_TO.track = to; 
-  }
-  for (i=0; i<7; i++) type_0_command(play_command[i],0);
-  for (i=0; i<2; i++) type_0_command(0x2, 0); /* volume */
-  cd->dsb = wait_dsb();
-}
-
-int get_current_q(struct cdrom_subchnl * qp)
-{
-  int i;
-  uch * q = cd->q;
-  if (type_1_command(c_read_current_q, 10, q)) return 0;
+	if (from == 0) {	/* continue paused play */
+		for (i = 0; i < 3; i++) {
+			play_command[i + 1] = cd->audio_status[i + 2];
+			play_command[i + 4] = PLAY_TO.fsm[i];
+		}
+	} else {
+		update_toc_entry(from);
+		update_toc_entry(to + 1);
+		for (i = 0; i < 3; i++) {
+			play_command[i + 1] = cd->toc[from].fsm[i];
+			PLAY_TO.fsm[i] = play_command[i + 4] =
+			    cd->toc[to + 1].fsm[i];
+		}
+		PLAY_TO.track = to;
+	}
+	for (i = 0; i < 7; i++)
+		type_0_command(play_command[i], 0);
+	for (i = 0; i < 2; i++)
+		type_0_command(0x2, 0);	/* volume */
+	cd->dsb = wait_dsb();
+}
+
+int get_current_q(struct cdrom_subchnl *qp)
+{
+	int i;
+	uch *q = cd->q;
+	if (type_1_command(c_read_current_q, 10, q))
+		return 0;
 /*  q[0] = bcdbin(q[0]); Don't think so! */
-  for (i=2; i<6; i++) q[i]=bcdbin(q[i]); 
-  qp->cdsc_adr = q[0] & 0xf; qp->cdsc_ctrl = q[0] >> 4;	/* from mcd.c */
-  qp->cdsc_trk = q[1];  qp->cdsc_ind = q[2];
-  if (qp->cdsc_format == CDROM_MSF) {
-    qp->cdsc_reladdr.msf.minute = q[3];
-    qp->cdsc_reladdr.msf.second = q[4];
-    qp->cdsc_reladdr.msf.frame = q[5];
-    qp->cdsc_absaddr.msf.minute = q[7];
-    qp->cdsc_absaddr.msf.second = q[8];
-    qp->cdsc_absaddr.msf.frame = q[9];
-  } else {
-    qp->cdsc_reladdr.lba = f_s_m2lba(q[5], q[4], q[3]);
-    qp->cdsc_absaddr.lba = f_s_m2lba(q[9], q[8], q[7]);
-  }
-  get_drive_status();
-  if (cd->dsb & dsb_play_in_progress) 
-    qp->cdsc_audiostatus = CDROM_AUDIO_PLAY ;
-  else if (PAUSED) 
-    qp->cdsc_audiostatus = CDROM_AUDIO_PAUSED;
-  else qp->cdsc_audiostatus = CDROM_AUDIO_NO_STATUS;
-  return 0;
+	for (i = 2; i < 6; i++)
+		q[i] = bcdbin(q[i]);
+	qp->cdsc_adr = q[0] & 0xf;
+	qp->cdsc_ctrl = q[0] >> 4;	/* from mcd.c */
+	qp->cdsc_trk = q[1];
+	qp->cdsc_ind = q[2];
+	if (qp->cdsc_format == CDROM_MSF) {
+		qp->cdsc_reladdr.msf.minute = q[3];
+		qp->cdsc_reladdr.msf.second = q[4];
+		qp->cdsc_reladdr.msf.frame = q[5];
+		qp->cdsc_absaddr.msf.minute = q[7];
+		qp->cdsc_absaddr.msf.second = q[8];
+		qp->cdsc_absaddr.msf.frame = q[9];
+	} else {
+		qp->cdsc_reladdr.lba = f_s_m2lba(q[5], q[4], q[3]);
+		qp->cdsc_absaddr.lba = f_s_m2lba(q[9], q[8], q[7]);
+	}
+	get_drive_status();
+	if (cd->dsb & dsb_play_in_progress)
+		qp->cdsc_audiostatus = CDROM_AUDIO_PLAY;
+	else if (PAUSED)
+		qp->cdsc_audiostatus = CDROM_AUDIO_PAUSED;
+	else
+		qp->cdsc_audiostatus = CDROM_AUDIO_NO_STATUS;
+	return 0;
 }
 
 void invalidate_toc(void)
 {
-  memset(cd->toc, 0, sizeof(cd->toc));
-  memset(cd->disc_status, 0, sizeof(cd->disc_status));
+	memset(cd->toc, 0, sizeof(cd->toc));
+	memset(cd->disc_status, 0, sizeof(cd->disc_status));
 }
 
 /* cdrom.c guarantees that cdte_format == CDROM_MSF */
-void get_toc_entry(struct cdrom_tocentry * ep)
+void get_toc_entry(struct cdrom_tocentry *ep)
 {
-  uch track = normalize_track(ep->cdte_track);
-  update_toc_entry(track);
-  ep->cdte_addr.msf.frame = cd->toc[track].fsm[0];
-  ep->cdte_addr.msf.second = cd->toc[track].fsm[1];
-  ep->cdte_addr.msf.minute = cd->toc[track].fsm[2];
-  ep->cdte_adr = cd->toc[track].q0 & 0xf; 
-  ep->cdte_ctrl = cd->toc[track].q0 >> 4;
-  ep->cdte_datamode=0;
+	uch track = normalize_track(ep->cdte_track);
+	update_toc_entry(track);
+	ep->cdte_addr.msf.frame = cd->toc[track].fsm[0];
+	ep->cdte_addr.msf.second = cd->toc[track].fsm[1];
+	ep->cdte_addr.msf.minute = cd->toc[track].fsm[2];
+	ep->cdte_adr = cd->toc[track].q0 & 0xf;
+	ep->cdte_ctrl = cd->toc[track].q0 >> 4;
+	ep->cdte_datamode = 0;
 }
 
 /* Audio ioctl.  Ioctl commands connected to audio are in such an
@@ -1047,244 +1112,262 @@
  * upon success. Memory checking has been done by cdrom_ioctl(), the
  * calling function, as well as LBA/MSF sanitization.
 */
-int cm206_audio_ioctl(struct cdrom_device_info * cdi, unsigned int cmd, 
-		      void * arg)  
+int cm206_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
+		      void *arg)
 {
-  switch (cmd) {
-  case CDROMREADTOCHDR: 
-    return read_toc_header((struct cdrom_tochdr *) arg);
-  case CDROMREADTOCENTRY: 	
-    get_toc_entry((struct cdrom_tocentry *) arg);
-    return 0;
-  case CDROMPLAYMSF: 
-    play_from_to_msf((struct cdrom_msf *) arg);
-    return 0;
-  case CDROMPLAYTRKIND:		/* admittedly, not particularly beautiful */
-    play_from_to_track(((struct cdrom_ti *)arg)->cdti_trk0, 
-		       ((struct cdrom_ti *)arg)->cdti_trk1);
-    return 0;
-  case CDROMSTOP: 
-    PAUSED=0;
-    if (cd->dsb & dsb_play_in_progress) return type_0_command(c_stop, 1);
-    else return 0;
-  case CDROMPAUSE: 
-    get_drive_status();
-    if (cd->dsb & dsb_play_in_progress) {
-      type_0_command(c_stop, 1);
-      type_1_command(c_audio_status, 5, cd->audio_status);
-      PAUSED=1;	/* say we're paused */
-    }
-    return 0;
-  case CDROMRESUME:
-    if (PAUSED) play_from_to_track(0,0);
-    PAUSED=0;
-    return 0;
-  case CDROMSTART:
-  case CDROMVOLCTRL:
-    return 0;
-  case CDROMSUBCHNL: 
-    return get_current_q((struct cdrom_subchnl *)arg);
-  default:
-    return -EINVAL;
-  }
+	switch (cmd) {
+	case CDROMREADTOCHDR:
+		return read_toc_header((struct cdrom_tochdr *) arg);
+	case CDROMREADTOCENTRY:
+		get_toc_entry((struct cdrom_tocentry *) arg);
+		return 0;
+	case CDROMPLAYMSF:
+		play_from_to_msf((struct cdrom_msf *) arg);
+		return 0;
+	case CDROMPLAYTRKIND:	/* admittedly, not particularly beautiful */
+		play_from_to_track(((struct cdrom_ti *) arg)->cdti_trk0,
+				   ((struct cdrom_ti *) arg)->cdti_trk1);
+		return 0;
+	case CDROMSTOP:
+		PAUSED = 0;
+		if (cd->dsb & dsb_play_in_progress)
+			return type_0_command(c_stop, 1);
+		else
+			return 0;
+	case CDROMPAUSE:
+		get_drive_status();
+		if (cd->dsb & dsb_play_in_progress) {
+			type_0_command(c_stop, 1);
+			type_1_command(c_audio_status, 5,
+				       cd->audio_status);
+			PAUSED = 1;	/* say we're paused */
+		}
+		return 0;
+	case CDROMRESUME:
+		if (PAUSED)
+			play_from_to_track(0, 0);
+		PAUSED = 0;
+		return 0;
+	case CDROMSTART:
+	case CDROMVOLCTRL:
+		return 0;
+	case CDROMSUBCHNL:
+		return get_current_q((struct cdrom_subchnl *) arg);
+	default:
+		return -EINVAL;
+	}
 }
 
 /* Ioctl. These ioctls are specific to the cm206 driver. I have made
    some driver statistics accessible through ioctl calls.
  */
 
-static int cm206_ioctl(struct cdrom_device_info * cdi, unsigned int cmd, 
+static int cm206_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
 		       unsigned long arg)
 {
-  switch (cmd) {
+	switch (cmd) {
 #ifdef STATISTICS
-  case CM206CTL_GET_STAT:
-    if (arg >= NR_STATS) return -EINVAL;
-    else return cd->stats[arg];
-  case CM206CTL_GET_LAST_STAT:
-    if (arg >= NR_STATS) return -EINVAL;
-    else return cd->last_stat[arg];
-#endif    
-  default:
-    debug(("Unknown ioctl call 0x%x\n", cmd));
-    return -EINVAL;
-  }
-}     
-
-int cm206_media_changed(struct cdrom_device_info * cdi, int disc_nr) 
-{
-  if (cd != NULL) {
-    int r;
-    get_drive_status();		/* ensure cd->media_changed OK */
-    r = cd->media_changed;
-    cd->media_changed = 0;	/* clear bit */
-    return r;
-  }
-  else return -EIO;
+	case CM206CTL_GET_STAT:
+		if (arg >= NR_STATS)
+			return -EINVAL;
+		else
+			return cd->stats[arg];
+	case CM206CTL_GET_LAST_STAT:
+		if (arg >= NR_STATS)
+			return -EINVAL;
+		else
+			return cd->last_stat[arg];
+#endif
+	default:
+		debug(("Unknown ioctl call 0x%x\n", cmd));
+		return -EINVAL;
+	}
+}
+
+int cm206_media_changed(struct cdrom_device_info *cdi, int disc_nr)
+{
+	if (cd != NULL) {
+		int r;
+		get_drive_status();	/* ensure cd->media_changed OK */
+		r = cd->media_changed;
+		cd->media_changed = 0;	/* clear bit */
+		return r;
+	} else
+		return -EIO;
 }
 
 /* The new generic cdrom support. Routines should be concise, most of
    the logic should be in cdrom.c */
 
 /* returns number of times device is in use */
-int cm206_open_files(struct cdrom_device_info * cdi)	
+int cm206_open_files(struct cdrom_device_info *cdi)
 {
-  if (cd) return cd->openfiles;
-  return -1;
+	if (cd)
+		return cd->openfiles;
+	return -1;
 }
 
 /* controls tray movement */
-int cm206_tray_move(struct cdrom_device_info * cdi, int position) 
+int cm206_tray_move(struct cdrom_device_info *cdi, int position)
 {
-  if (position) {		/* 1: eject */
-    type_0_command(c_open_tray,1);
-    invalidate_toc();
-  } 
-  else type_0_command(c_close_tray, 1);	/* 0: close */
-  return 0;
+	if (position) {		/* 1: eject */
+		type_0_command(c_open_tray, 1);
+		invalidate_toc();
+	} else
+		type_0_command(c_close_tray, 1);	/* 0: close */
+	return 0;
 }
 
 /* gives current state of the drive */
-int cm206_drive_status(struct cdrom_device_info * cdi, int slot_nr)
+int cm206_drive_status(struct cdrom_device_info *cdi, int slot_nr)
 {
-  get_drive_status();
-  if (cd->dsb & dsb_tray_not_closed) return CDS_TRAY_OPEN;
-  if (!(cd->dsb & dsb_disc_present)) return CDS_NO_DISC; 
-  if (cd->dsb & dsb_drive_not_ready) return CDS_DRIVE_NOT_READY;
-  return CDS_DISC_OK;
+	get_drive_status();
+	if (cd->dsb & dsb_tray_not_closed)
+		return CDS_TRAY_OPEN;
+	if (!(cd->dsb & dsb_disc_present))
+		return CDS_NO_DISC;
+	if (cd->dsb & dsb_drive_not_ready)
+		return CDS_DRIVE_NOT_READY;
+	return CDS_DISC_OK;
 }
- 
+
 /* locks or unlocks door lock==1: lock; return 0 upon success */
-int cm206_lock_door(struct cdrom_device_info * cdi, int lock)
+int cm206_lock_door(struct cdrom_device_info *cdi, int lock)
 {
-  uch command = (lock) ? c_lock_tray : c_unlock_tray;
-  type_0_command(command, 1);	/* wait and get dsb */
-  /* the logic calculates the success, 0 means successful */
-  return lock ^ ((cd->dsb & dsb_tray_locked) != 0);
+	uch command = (lock) ? c_lock_tray : c_unlock_tray;
+	type_0_command(command, 1);	/* wait and get dsb */
+	/* the logic calculates the success, 0 means successful */
+	return lock ^ ((cd->dsb & dsb_tray_locked) != 0);
 }
-  
+
 /* Although a session start should be in LBA format, we return it in 
    MSF format because it is slightly easier, and the new generic ioctl
    will take care of the necessary conversion. */
-int cm206_get_last_session(struct cdrom_device_info * cdi, 
-			   struct cdrom_multisession * mssp) 
+int cm206_get_last_session(struct cdrom_device_info *cdi,
+			   struct cdrom_multisession *mssp)
 {
-  if (!FIRST_TRACK) get_disc_status();
-  if (mssp != NULL) {
-    if (DISC_STATUS & cds_multi_session) { /* multi-session */
-      mssp->addr.msf.frame = cd->disc_status[3];
-      mssp->addr.msf.second = cd->disc_status[4];
-      mssp->addr.msf.minute = cd->disc_status[5];
-      mssp->addr_format = CDROM_MSF;
-      mssp->xa_flag = 1;
-    } else {
-      mssp->xa_flag = 0;
-    }
-    return 1;
-  }
-  return 0;
-}
-
-int cm206_get_upc(struct cdrom_device_info * cdi, struct cdrom_mcn * mcn)
-{
-  uch upc[10];
-  char * ret = mcn->medium_catalog_number;
-  int i;
-  
-  if (type_1_command(c_read_upc, 10, upc)) return -EIO;
-  for (i=0; i<13; i++) {
-    int w=i/2+1, r=i%2;
-    if (r) ret[i] = 0x30 | (upc[w] & 0x0f);
-    else ret[i] = 0x30 | ((upc[w] >> 4) & 0x0f);
-  }
-  ret[13] = '\0';
-  return 0;
-} 
-
-int cm206_reset(struct cdrom_device_info * cdi)
-{
-  stop_read();
-  reset_cm260();
-  outw(dc_normal | dc_break | READ_AHEAD, r_data_control);
-  mdelay(1);			/* 750 musec minimum */
-  outw(dc_normal | READ_AHEAD, r_data_control);
-  cd->sector_last = -1;		/* flag no data buffered */
-  cd->adapter_last = -1;    
-  invalidate_toc();
-  return 0;
-}
-
-int cm206_select_speed(struct cdrom_device_info * cdi, int speed)
-{
-  int r;
-  switch (speed) {
-  case 0: 
-    r = type_0_command(c_auto_mode, 1);
-    break;
-  case 1:
-    r = type_0_command(c_force_1x, 1);
-    break;
-  case 2:
-    r = type_0_command(c_force_2x, 1);
-    break;
-  default:
-    return -1;
-  }
-  if (r<0) return r;
-  else return 1;
+	if (!FIRST_TRACK)
+		get_disc_status();
+	if (mssp != NULL) {
+		if (DISC_STATUS & cds_multi_session) {	/* multi-session */
+			mssp->addr.msf.frame = cd->disc_status[3];
+			mssp->addr.msf.second = cd->disc_status[4];
+			mssp->addr.msf.minute = cd->disc_status[5];
+			mssp->addr_format = CDROM_MSF;
+			mssp->xa_flag = 1;
+		} else {
+			mssp->xa_flag = 0;
+		}
+		return 1;
+	}
+	return 0;
+}
+
+int cm206_get_upc(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn)
+{
+	uch upc[10];
+	char *ret = mcn->medium_catalog_number;
+	int i;
+
+	if (type_1_command(c_read_upc, 10, upc))
+		return -EIO;
+	for (i = 0; i < 13; i++) {
+		int w = i / 2 + 1, r = i % 2;
+		if (r)
+			ret[i] = 0x30 | (upc[w] & 0x0f);
+		else
+			ret[i] = 0x30 | ((upc[w] >> 4) & 0x0f);
+	}
+	ret[13] = '\0';
+	return 0;
+}
+
+int cm206_reset(struct cdrom_device_info *cdi)
+{
+	stop_read();
+	reset_cm260();
+	outw(dc_normal | dc_break | READ_AHEAD, r_data_control);
+	mdelay(1);		/* 750 musec minimum */
+	outw(dc_normal | READ_AHEAD, r_data_control);
+	cd->sector_last = -1;	/* flag no data buffered */
+	cd->adapter_last = -1;
+	invalidate_toc();
+	return 0;
+}
+
+int cm206_select_speed(struct cdrom_device_info *cdi, int speed)
+{
+	int r;
+	switch (speed) {
+	case 0:
+		r = type_0_command(c_auto_mode, 1);
+		break;
+	case 1:
+		r = type_0_command(c_force_1x, 1);
+		break;
+	case 2:
+		r = type_0_command(c_force_2x, 1);
+		break;
+	default:
+		return -1;
+	}
+	if (r < 0)
+		return r;
+	else
+		return 1;
 }
 
 static struct cdrom_device_ops cm206_dops = {
-	open:			cm206_open,
-	release:		cm206_release,
-	drive_status:		cm206_drive_status,
-	media_changed:		cm206_media_changed,
-	tray_move:		cm206_tray_move,
-	lock_door:		cm206_lock_door,
-	select_speed:		cm206_select_speed,
-	get_last_session:	cm206_get_last_session,
-	get_mcn:		cm206_get_upc,
-	reset:			cm206_reset,
-	audio_ioctl:		cm206_audio_ioctl,
-	dev_ioctl:		cm206_ioctl,
-	capability:		CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK |
-				CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
-				CDC_MCN | CDC_PLAY_AUDIO | CDC_SELECT_SPEED |
-				CDC_IOCTLS | CDC_DRIVE_STATUS, 
-	n_minors:		1,
+	open:cm206_open,
+	release:cm206_release,
+	drive_status:cm206_drive_status,
+	media_changed:cm206_media_changed,
+	tray_move:cm206_tray_move,
+	lock_door:cm206_lock_door,
+	select_speed:cm206_select_speed,
+	get_last_session:cm206_get_last_session,
+	get_mcn:cm206_get_upc,
+	reset:cm206_reset,
+	audio_ioctl:cm206_audio_ioctl,
+	dev_ioctl:cm206_ioctl,
+	capability:CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK |
+	    CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
+	    CDC_MCN | CDC_PLAY_AUDIO | CDC_SELECT_SPEED |
+	    CDC_IOCTLS | CDC_DRIVE_STATUS,
+	n_minors:1,
 };
 
 
 static struct cdrom_device_info cm206_info = {
-	ops:		&cm206_dops,
-	speed:		2,
-	capacity:	1,
-	name:		"cm206",
+	ops:&cm206_dops,
+	speed:2,
+	capacity:1,
+	name:"cm206",
 };
 
 /* This routine gets called during initialization if things go wrong,
  * can be used in cleanup_module as well. */
 static void cleanup(int level)
 {
-  switch (level) {
-  case 4: 
-    if (unregister_cdrom(&cm206_info)) {
-      printk("Can't unregister cdrom cm206\n");
-      return;
-    }
-    if (devfs_unregister_blkdev(MAJOR_NR, "cm206")) {
-      printk("Can't unregister major cm206\n");
-      return;
-    }
-    blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
-  case 3: 
-    free_irq(cm206_irq, NULL);
-  case 2: 
-  case 1: 
-    kfree(cd);
-    release_region(cm206_base, 16);
-  default:;
-  }
+	switch (level) {
+	case 4:
+		if (unregister_cdrom(&cm206_info)) {
+			printk("Can't unregister cdrom cm206\n");
+			return;
+		}
+		if (devfs_unregister_blkdev(MAJOR_NR, "cm206")) {
+			printk("Can't unregister major cm206\n");
+			return;
+		}
+		blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
+	case 3:
+		free_irq(cm206_irq, NULL);
+	case 2:
+	case 1:
+		kfree(cd);
+		release_region(cm206_base, 16);
+	default:;
+	}
 }
 
 /* This function probes for the adapter card. It returns the base
@@ -1299,117 +1382,129 @@
  */
 int __init probe_base_port(int base)
 {
-  int b=0x300, e=0x370;		/* this is the range of start addresses */
-  volatile int fool, i;
+	int b = 0x300, e = 0x370;	/* this is the range of start addresses */
+	volatile int fool, i;
 
-  if (base) b=e=base;
-  for (base=b; base<=e; base += 0x10) {
-    if (check_region(base, 0x10)) continue;
-    for (i=0; i<3; i++) 
-      fool = inw(base+2); /* empty possibly uart_receive_buffer */
-    if((inw(base+6) & 0xffef) != 0x0001 || /* line_status */
-       (inw(base) & 0xad00) != 0) /* data status */
-      continue;
-    return(base);
-  }
-  return 0;
+	if (base)
+		b = e = base;
+	for (base = b; base <= e; base += 0x10) {
+		if (check_region(base, 0x10))
+			continue;
+		for (i = 0; i < 3; i++)
+			fool = inw(base + 2);	/* empty possibly uart_receive_buffer */
+		if ((inw(base + 6) & 0xffef) != 0x0001 ||	/* line_status */
+		    (inw(base) & 0xad00) != 0)	/* data status */
+			continue;
+		return (base);
+	}
+	return 0;
 }
 
 #if !defined(MODULE) || defined(AUTO_PROBE_MODULE)
 /* Probe for irq# nr. If nr==0, probe for all possible irq's. */
-int __init probe_irq(int nr){
-  int irqs, irq;
-  outw(dc_normal | READ_AHEAD, r_data_control);	/* disable irq-generation */
-  sti(); 
-  irqs = probe_irq_on();
-  reset_cm260();		/* causes interrupt */
-  udelay(100);			/* wait for it */
-  irq = probe_irq_off(irqs);
-  outw(dc_normal | READ_AHEAD, r_data_control);	/* services interrupt */
-  if (nr && irq!=nr && irq>0) return 0;	/* wrong interrupt happened */
-  else return irq;
+int __init probe_irq(int nr)
+{
+	int irqs, irq;
+	outw(dc_normal | READ_AHEAD, r_data_control);	/* disable irq-generation */
+	sti();
+	irqs = probe_irq_on();
+	reset_cm260();		/* causes interrupt */
+	udelay(100);		/* wait for it */
+	irq = probe_irq_off(irqs);
+	outw(dc_normal | READ_AHEAD, r_data_control);	/* services interrupt */
+	if (nr && irq != nr && irq > 0)
+		return 0;	/* wrong interrupt happened */
+	else
+		return irq;
 }
 #endif
 
 int __init cm206_init(void)
 {
-  uch e=0;
-  long int size=sizeof(struct cm206_struct);
+	uch e = 0;
+	long int size = sizeof(struct cm206_struct);
 
-  printk(KERN_INFO "cm206 cdrom driver " REVISION);
-  cm206_base = probe_base_port(auto_probe ? 0 : cm206_base);
-  if (!cm206_base) {
-    printk(" can't find adapter!\n");
-    return -EIO;
-  }
-  printk(" adapter at 0x%x", cm206_base);
-  request_region(cm206_base, 16, "cm206");
-  cd = (struct cm206_struct *) kmalloc(size, GFP_KERNEL);
-  if (!cd) return -EIO;
-  /* Now we have found the adaptor card, try to reset it. As we have
-   * found out earlier, this process generates an interrupt as well,
-   * so we might just exploit that fact for irq probing! */
+	printk(KERN_INFO "cm206 cdrom driver " REVISION);
+	cm206_base = probe_base_port(auto_probe ? 0 : cm206_base);
+	if (!cm206_base) {
+		printk(" can't find adapter!\n");
+		return -EIO;
+	}
+	printk(" adapter at 0x%x", cm206_base);
+	request_region(cm206_base, 16, "cm206");
+	cd = (struct cm206_struct *) kmalloc(size, GFP_KERNEL);
+	if (!cd)
+		return -EIO;
+	/* Now we have found the adaptor card, try to reset it. As we have
+	 * found out earlier, this process generates an interrupt as well,
+	 * so we might just exploit that fact for irq probing! */
 #if !defined(MODULE) || defined(AUTO_PROBE_MODULE)
-  cm206_irq = probe_irq(auto_probe ? 0 : cm206_irq);	
-  if (cm206_irq<=0) {
-    printk("can't find IRQ!\n");
-    cleanup(1);
-    return -EIO;
-  }
-  else printk(" IRQ %d found\n", cm206_irq);
+	cm206_irq = probe_irq(auto_probe ? 0 : cm206_irq);
+	if (cm206_irq <= 0) {
+		printk("can't find IRQ!\n");
+		cleanup(1);
+		return -EIO;
+	} else
+		printk(" IRQ %d found\n", cm206_irq);
 #else
-  cli();
-  reset_cm260();
-  /* Now, the problem here is that reset_cm260 can generate an
-     interrupt. It seems that this can cause a kernel oops some time
-     later. So we wait a while and `service' this interrupt. */
-  mdelay(1);
-  outw(dc_normal | READ_AHEAD, r_data_control);
-  sti();
-  printk(" using IRQ %d\n", cm206_irq);
+	cli();
+	reset_cm260();
+	/* Now, the problem here is that reset_cm260 can generate an
+	   interrupt. It seems that this can cause a kernel oops some time
+	   later. So we wait a while and `service' this interrupt. */
+	mdelay(1);
+	outw(dc_normal | READ_AHEAD, r_data_control);
+	sti();
+	printk(" using IRQ %d\n", cm206_irq);
 #endif
-  if (send_receive_polled(c_drive_configuration) != c_drive_configuration) 
-    {
-      printk(KERN_INFO " drive not there\n");
-      cleanup(1);
-      return -EIO;
-    }
-  e = send_receive_polled(c_gimme);
-  printk(KERN_INFO "Firmware revision %d", e & dcf_revision_code);
-  if (e & dcf_transfer_rate) printk(" double");
-  else printk(" single");
-  printk(" speed drive");
-  if (e & dcf_motorized_tray) printk(", motorized tray");
-  if (request_irq(cm206_irq, cm206_interrupt, 0, "cm206", NULL)) {
-    printk("\nUnable to reserve IRQ---aborted\n");
-    cleanup(2);
-    return -EIO;
-  }
-  printk(".\n");
-  if (devfs_register_blkdev(MAJOR_NR, "cm206", &cdrom_fops) != 0) {
-    printk(KERN_INFO "Cannot register for major %d!\n", MAJOR_NR);
-    cleanup(3);
-    return -EIO;
-  }
-  cm206_info.dev = MKDEV(MAJOR_NR,0);
-  if (register_cdrom(&cm206_info) != 0) {
-    printk(KERN_INFO "Cannot register for cdrom %d!\n", MAJOR_NR);
-    cleanup(3);
-    return -EIO;
-  }    
-  blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST);
-  blksize_size[MAJOR_NR] = cm206_blocksizes;
-  read_ahead[MAJOR_NR] = 16;	/* reads ahead what? */
-  init_bh(CM206_BH, cm206_bh);
-
-  memset(cd, 0, sizeof(*cd));	/* give'm some reasonable value */
-  cd->sector_last = -1;		/* flag no data buffered */
-  cd->adapter_last = -1;
-  cd->timer.function = cm206_timeout;
-  cd->max_sectors = (inw(r_data_status) & ds_ram_size) ? 24 : 97;
-  printk(KERN_INFO "%d kB adapter memory available, "  
-	 " %ld bytes kernel memory used.\n", cd->max_sectors*2, size);
-  return 0;
+	if (send_receive_polled(c_drive_configuration) !=
+	    c_drive_configuration) {
+		printk(KERN_INFO " drive not there\n");
+		cleanup(1);
+		return -EIO;
+	}
+	e = send_receive_polled(c_gimme);
+	printk(KERN_INFO "Firmware revision %d", e & dcf_revision_code);
+	if (e & dcf_transfer_rate)
+		printk(" double");
+	else
+		printk(" single");
+	printk(" speed drive");
+	if (e & dcf_motorized_tray)
+		printk(", motorized tray");
+	if (request_irq(cm206_irq, cm206_interrupt, 0, "cm206", NULL)) {
+		printk("\nUnable to reserve IRQ---aborted\n");
+		cleanup(2);
+		return -EIO;
+	}
+	printk(".\n");
+	if (devfs_register_blkdev(MAJOR_NR, "cm206", &cdrom_fops) != 0) {
+		printk(KERN_INFO "Cannot register for major %d!\n",
+		       MAJOR_NR);
+		cleanup(3);
+		return -EIO;
+	}
+	cm206_info.dev = MKDEV(MAJOR_NR, 0);
+	if (register_cdrom(&cm206_info) != 0) {
+		printk(KERN_INFO "Cannot register for cdrom %d!\n",
+		       MAJOR_NR);
+		cleanup(3);
+		return -EIO;
+	}
+	blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST);
+	blksize_size[MAJOR_NR] = cm206_blocksizes;
+	read_ahead[MAJOR_NR] = 16;	/* reads ahead what? */
+	init_bh(CM206_BH, cm206_bh);
+
+	memset(cd, 0, sizeof(*cd));	/* give'm some reasonable value */
+	cd->sector_last = -1;	/* flag no data buffered */
+	cd->adapter_last = -1;
+	cd->timer.function = cm206_timeout;
+	cd->max_sectors = (inw(r_data_status) & ds_ram_size) ? 24 : 97;
+	printk(KERN_INFO "%d kB adapter memory available, "
+	       " %ld bytes kernel memory used.\n", cd->max_sectors * 2,
+	       size);
+	return 0;
 }
 
 #ifdef MODULE
@@ -1417,65 +1512,67 @@
 
 static void __init parse_options(void)
 {
-  int i;
-  for (i=0; i<2; i++) {
-    if (0x300 <= cm206[i] && i<= 0x370 && cm206[i] % 0x10 == 0) {
-      cm206_base = cm206[i];
-      auto_probe=0;
-    }
-    else if (3 <= cm206[i] && cm206[i] <= 15) {
-      cm206_irq = cm206[i];
-      auto_probe=0;
-    }
-  }
+	int i;
+	for (i = 0; i < 2; i++) {
+		if (0x300 <= cm206[i] && i <= 0x370
+		    && cm206[i] % 0x10 == 0) {
+			cm206_base = cm206[i];
+			auto_probe = 0;
+		} else if (3 <= cm206[i] && cm206[i] <= 15) {
+			cm206_irq = cm206[i];
+			auto_probe = 0;
+		}
+	}
 }
 
 int __cm206_init(void)
 {
 	parse_options();
 #if !defined(AUTO_PROBE_MODULE)
-	auto_probe=0;
+	auto_probe = 0;
 #endif
 	return cm206_init();
 }
 
 void __exit cm206_exit(void)
 {
-  cleanup(4);
-  printk(KERN_INFO "cm206 removed\n");
+	cleanup(4);
+	printk(KERN_INFO "cm206 removed\n");
 }
 
 module_init(__cm206_init);
 module_exit(cm206_exit);
-      
-#else /* !MODULE */
+
+#else				/* !MODULE */
 
 /* This setup function accepts either `auto' or numbers in the range
  * 3--11 (for irq) or 0x300--0x370 (for base port) or both. */
 
 static int __init cm206_setup(char *s)
 {
-  int i, p[4];
-  
-  (void)get_options(s, ARRAY_SIZE(p), p);
-  
-  if (!strcmp(s, "auto")) auto_probe=1;
-  for(i=1; i<=p[0]; i++) {
-    if (0x300 <= p[i] && i<= 0x370 && p[i] % 0x10 == 0) {
-      cm206_base = p[i];
-      auto_probe = 0;
-    }
-    else if (3 <= p[i] && p[i] <= 15) {
-      cm206_irq = p[i];
-      auto_probe = 0;
-    }
-  }
- return 1;
+	int i, p[4];
+
+	(void) get_options(s, ARRAY_SIZE(p), p);
+
+	if (!strcmp(s, "auto"))
+		auto_probe = 1;
+	for (i = 1; i <= p[0]; i++) {
+		if (0x300 <= p[i] && i <= 0x370 && p[i] % 0x10 == 0) {
+			cm206_base = p[i];
+			auto_probe = 0;
+		} else if (3 <= p[i] && p[i] <= 15) {
+			cm206_irq = p[i];
+			auto_probe = 0;
+		}
+	}
+	return 1;
 }
 
 __setup("cm206=", cm206_setup);
 
-#endif /* !MODULE */
+#endif				/* !MODULE */
+
+
 /*
  * Local variables:
  * compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/include -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe -fno-strength-reduce -m486 -DMODULE -DMODVERSIONS -include /usr/src/linux/include/linux/modversions.h  -c -o cm206.o cm206.c"
diff -u --recursive --new-file v2.4.9/linux/drivers/cdrom/gscd.c linux/drivers/cdrom/gscd.c
--- v2.4.9/linux/drivers/cdrom/gscd.c	Fri Feb  9 11:30:22 2001
+++ linux/drivers/cdrom/gscd.c	Fri Sep  7 09:28:38 2001
@@ -41,8 +41,8 @@
 
 */
 
-/* These settings are for various debug-level. Leave they untouched ... */ 
-#define  NO_GSCD_DEBUG 
+/* These settings are for various debug-level. Leave they untouched ... */
+#define  NO_GSCD_DEBUG
 #define  NO_IOCTL_DEBUG
 #define  NO_MODULE_DEBUG
 #define  NO_FUTURE_WORK
@@ -71,81 +71,82 @@
 
 #define MAJOR_NR GOLDSTAR_CDROM_MAJOR
 #include <linux/blk.h>
-#define gscd_port gscd /* for compatible parameter passing with "insmod" */
+#define gscd_port gscd		/* for compatible parameter passing with "insmod" */
 #include "gscd.h"
 
-static int gscd_blocksizes[1] = {512};
+static int gscd_blocksizes[1] = { 512 };
 
-static int gscdPresent            = 0;
+static int gscdPresent = 0;
 
-static unsigned char gscd_buf[2048];    /* buffer for block size conversion */
-static int   gscd_bn              = -1;
-static short gscd_port            = GSCD_BASE_ADDR;
+static unsigned char gscd_buf[2048];	/* buffer for block size conversion */
+static int gscd_bn = -1;
+static short gscd_port = GSCD_BASE_ADDR;
 MODULE_PARM(gscd, "h");
 
 /* Kommt spaeter vielleicht noch mal dran ...
  *    static DECLARE_WAIT_QUEUE_HEAD(gscd_waitq);
- */ 
+ */
 
-static void gscd_transfer         (void);
-static void gscd_read_cmd         (void);
-static void gscd_hsg2msf          (long hsg, struct msf *msf);
-static void gscd_bin2bcd          (unsigned char *p);
+static void gscd_transfer(void);
+static void gscd_read_cmd(void);
+static void gscd_hsg2msf(long hsg, struct msf *msf);
+static void gscd_bin2bcd(unsigned char *p);
 
 /* Schnittstellen zum Kern/FS */
 
-static void do_gscd_request       (request_queue_t *);
-static void __do_gscd_request     (unsigned long dummy);
-static int  gscd_ioctl            (struct inode *, struct file *, unsigned int, unsigned long);
-static int  gscd_open             (struct inode *, struct file *);
-static int  gscd_release          (struct inode *, struct file *);
-static int  check_gscd_med_chg    (kdev_t);
+static void do_gscd_request(request_queue_t *);
+static void __do_gscd_request(unsigned long dummy);
+static int gscd_ioctl(struct inode *, struct file *, unsigned int,
+		      unsigned long);
+static int gscd_open(struct inode *, struct file *);
+static int gscd_release(struct inode *, struct file *);
+static int check_gscd_med_chg(kdev_t);
 
 /*      GoldStar Funktionen    */
 
-static void cc_Reset             (void);
-static int  wait_drv_ready       (void);
-static int  find_drives          (void);
-static void cmd_out              (int, char *, char *, int);
-static void cmd_status           (void);
-static void cc_Ident             (char *);
-static void cc_SetSpeed          (void);
-static void init_cd_drive        (int);
-
-static int  get_status           (void);
-static void clear_Audio          (void);
-static void cc_invalidate        (void);
+static void cc_Reset(void);
+static int wait_drv_ready(void);
+static int find_drives(void);
+static void cmd_out(int, char *, char *, int);
+static void cmd_status(void);
+static void cc_Ident(char *);
+static void cc_SetSpeed(void);
+static void init_cd_drive(int);
+
+static int get_status(void);
+static void clear_Audio(void);
+static void cc_invalidate(void);
 
 /* some things for the next version */
 #ifdef FUTURE_WORK
-static void update_state          (void);
-static long gscd_msf2hsg          (struct msf *mp);
-static int  gscd_bcd2bin          (unsigned char bcd);
+static void update_state(void);
+static long gscd_msf2hsg(struct msf *mp);
+static int gscd_bcd2bin(unsigned char bcd);
 #endif
 
 /*    common GoldStar Initialization    */
 
-static int my_gscd_init (void);
+static int my_gscd_init(void);
 
 
 /*      lo-level cmd-Funktionen    */
 
-static void cmd_info_in          ( char *, int );
-static void cmd_end              ( void );
-static void cmd_read_b           ( char *, int, int );
-static void cmd_read_w           ( char *, int, int );
-static int  cmd_unit_alive       ( void );
-static void cmd_write_cmd        ( char * );
+static void cmd_info_in(char *, int);
+static void cmd_end(void);
+static void cmd_read_b(char *, int, int);
+static void cmd_read_w(char *, int, int);
+static int cmd_unit_alive(void);
+static void cmd_write_cmd(char *);
 
 
 /*      GoldStar Variablen     */
 
-static int  curr_drv_state;
-static int  drv_states[]       = {0,0,0,0,0,0,0,0};
-static int  drv_mode;
-static int  disk_state;
-static int  speed;
-static int  ndrives;
+static int curr_drv_state;
+static int drv_states[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+static int drv_mode;
+static int disk_state;
+static int speed;
+static int ndrives;
 
 static unsigned char drv_num_read;
 static unsigned char f_dsk_valid;
@@ -155,93 +156,91 @@
 
 static char f_AudioPlay;
 static char f_AudioPause;
-static int  AudioStart_m;
-static int  AudioStart_f;
-static int  AudioEnd_m;
-static int  AudioEnd_f;
- 
+static int AudioStart_m;
+static int AudioStart_f;
+static int AudioEnd_m;
+static int AudioEnd_f;
+
 static struct timer_list gscd_timer;
 
 static struct block_device_operations gscd_fops = {
-	open:			gscd_open,
-	release:		gscd_release,
-	ioctl:			gscd_ioctl,
-	check_media_change:	check_gscd_med_chg,
+	open:gscd_open,
+	release:gscd_release,
+	ioctl:gscd_ioctl,
+	check_media_change:check_gscd_med_chg,
 };
 
 /* 
  * Checking if the media has been changed
  * (not yet implemented)
  */
-static int check_gscd_med_chg (kdev_t full_dev)
+static int check_gscd_med_chg(kdev_t full_dev)
 {
-   int target;
+	int target;
 
 
-   target = MINOR(full_dev);
+	target = MINOR(full_dev);
 
-   if (target > 0) 
-   {
-      printk("GSCD: GoldStar CD-ROM request error: invalid device.\n");
-      return 0;
-   }
+	if (target > 0) {
+		printk
+		    ("GSCD: GoldStar CD-ROM request error: invalid device.\n");
+		return 0;
+	}
+#ifdef GSCD_DEBUG
+	printk("gscd: check_med_change\n");
+#endif
 
-   #ifdef GSCD_DEBUG
-   printk ("gscd: check_med_change\n");
-   #endif
- 
-  return 0;
+	return 0;
 }
 
 
 #ifndef MODULE
 /* Using new interface for kernel-parameters */
-  
-static int __init gscd_setup (char *str)
+
+static int __init gscd_setup(char *str)
 {
-  int ints[2];
-  (void)get_options(str, ARRAY_SIZE(ints), ints);
-  
-  if (ints[0] > 0) 
-  {
-     gscd_port = ints[1];
-  }
- return 1;
+	int ints[2];
+	(void) get_options(str, ARRAY_SIZE(ints), ints);
+
+	if (ints[0] > 0) {
+		gscd_port = ints[1];
+	}
+	return 1;
 }
 
 __setup("gscd=", gscd_setup);
 
 #endif
 
-static int gscd_ioctl (struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg)
+static int gscd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
+		      unsigned long arg)
 {
-unsigned char to_do[10];
-unsigned char dummy;
+	unsigned char to_do[10];
+	unsigned char dummy;
+
 
-                             
-    switch (cmd)
-    {
-       case CDROMSTART:     /* Spin up the drive */
+	switch (cmd) {
+	case CDROMSTART:	/* Spin up the drive */
 		/* Don't think we can do this.  Even if we could,
- 		 * I think the drive times out and stops after a while
+		 * I think the drive times out and stops after a while
 		 * anyway.  For now, ignore it.
 		 */
-            return 0;
+		return 0;
 
-       case CDROMRESUME:   /* keine Ahnung was das ist */
-            return 0;
+	case CDROMRESUME:	/* keine Ahnung was das ist */
+		return 0;
 
 
-       case CDROMEJECT:
-            cmd_status ();
-            to_do[0] = CMD_TRAY_CTL;
-            cmd_out (TYPE_INFO, (char *)&to_do, (char *)&dummy, 0);
+	case CDROMEJECT:
+		cmd_status();
+		to_do[0] = CMD_TRAY_CTL;
+		cmd_out(TYPE_INFO, (char *) &to_do, (char *) &dummy, 0);
 
-            return 0;
+		return 0;
 
-       default:
-            return -EINVAL;
-    }
+	default:
+		return -EINVAL;
+	}
 
 }
 
@@ -251,17 +250,16 @@
  * When Linux gets variable block sizes this will probably go away.
  */
 
-static void gscd_transfer (void)
+static void gscd_transfer(void)
 {
-long offs;
+	long offs;
 
-	while (CURRENT -> nr_sectors > 0 && gscd_bn == CURRENT -> sector / 4)
-	{
-		offs = (CURRENT -> sector & 3) * 512;
-		memcpy(CURRENT -> buffer, gscd_buf + offs, 512);
-		CURRENT -> nr_sectors--;
-		CURRENT -> sector++;
-		CURRENT -> buffer += 512;
+	while (CURRENT->nr_sectors > 0 && gscd_bn == CURRENT->sector / 4) {
+		offs = (CURRENT->sector & 3) * 512;
+		memcpy(CURRENT->buffer, gscd_buf + offs, 512);
+		CURRENT->nr_sectors--;
+		CURRENT->sector++;
+		CURRENT->buffer += 512;
 	}
 }
 
@@ -270,17 +268,17 @@
  * I/O request routine called from Linux kernel.
  */
 
-static void do_gscd_request (request_queue_t * q)
+static void do_gscd_request(request_queue_t * q)
 {
-  __do_gscd_request(0);
+	__do_gscd_request(0);
 }
 
-static void __do_gscd_request (unsigned long dummy)
+static void __do_gscd_request(unsigned long dummy)
 {
-unsigned int block,dev;
-unsigned int nsect;
+	unsigned int block, dev;
+	unsigned int nsect;
 
-repeat:
+      repeat:
 	if (QUEUE_EMPTY || CURRENT->rq_status == RQ_INACTIVE)
 		goto out;
 	INIT_REQUEST;
@@ -288,18 +286,16 @@
 	block = CURRENT->sector;
 	nsect = CURRENT->nr_sectors;
 
-	if (QUEUE_EMPTY || CURRENT -> sector == -1)
+	if (QUEUE_EMPTY || CURRENT->sector == -1)
 		goto out;
 
-	if (CURRENT -> cmd != READ)
-	{
-		printk("GSCD: bad cmd %d\n", CURRENT -> cmd);
+	if (CURRENT->cmd != READ) {
+		printk("GSCD: bad cmd %d\n", CURRENT->cmd);
 		end_request(0);
 		goto repeat;
 	}
 
-	if (MINOR(CURRENT -> rq_dev) != 0)
-	{
+	if (MINOR(CURRENT->rq_dev) != 0) {
 		printk("GSCD: this version supports only one device\n");
 		end_request(0);
 		goto repeat;
@@ -309,18 +305,16 @@
 
 	/* if we satisfied the request from the buffer, we're done. */
 
-	if (CURRENT -> nr_sectors == 0)
-	{
+	if (CURRENT->nr_sectors == 0) {
 		end_request(1);
 		goto repeat;
 	}
-
 #ifdef GSCD_DEBUG
-        printk ("GSCD: dev %d, block %d, nsect %d\n", dev, block, nsect );
+	printk("GSCD: dev %d, block %d, nsect %d\n", dev, block, nsect);
 #endif
 
-	gscd_read_cmd ();
-out:
+	gscd_read_cmd();
+      out:
 	return;
 }
 
@@ -331,47 +325,42 @@
  * read-data command.
  */
 
-static void
-gscd_read_cmd (void)
+static void gscd_read_cmd(void)
 {
-long   block;
-struct gscd_Play_msf gscdcmd;
-char   cmd[] = { CMD_READ, 0x80, 0,0,0, 0,1 }; /* cmd mode M-S-F secth sectl */
+	long block;
+	struct gscd_Play_msf gscdcmd;
+	char cmd[] = { CMD_READ, 0x80, 0, 0, 0, 0, 1 };	/* cmd mode M-S-F secth sectl */
 
 
 
-        cmd_status ();
-        if ( disk_state & (ST_NO_DISK | ST_DOOR_OPEN) )
-        {
-           printk ( "GSCD: no disk or door open\n" );
-           end_request (0);
-        }
-        else
-        {
-           if ( disk_state & ST_INVALID )
-           {
-              printk ( "GSCD: disk invalid\n" );
-              end_request (0);
-           }
-           else
-           {
-              gscd_bn = -1;		/* purge our buffer */
-              block = CURRENT -> sector / 4;
-              gscd_hsg2msf(block, &gscdcmd.start);	/* cvt to msf format */
-
-              cmd[2] = gscdcmd.start.min;
-              cmd[3] = gscdcmd.start.sec;
-              cmd[4] = gscdcmd.start.frame;
+	cmd_status();
+	if (disk_state & (ST_NO_DISK | ST_DOOR_OPEN)) {
+		printk("GSCD: no disk or door open\n");
+		end_request(0);
+	} else {
+		if (disk_state & ST_INVALID) {
+			printk("GSCD: disk invalid\n");
+			end_request(0);
+		} else {
+			gscd_bn = -1;	/* purge our buffer */
+			block = CURRENT->sector / 4;
+			gscd_hsg2msf(block, &gscdcmd.start);	/* cvt to msf format */
+
+			cmd[2] = gscdcmd.start.min;
+			cmd[3] = gscdcmd.start.sec;
+			cmd[4] = gscdcmd.start.frame;
 
 #ifdef GSCD_DEBUG
-              printk ("GSCD: read msf %d:%d:%d\n", cmd[2], cmd[3], cmd[4] ); 
-#endif 
-              cmd_out ( TYPE_DATA, (char *)&cmd, (char *)&gscd_buf[0], 1 );
-        
-              gscd_bn = CURRENT -> sector / 4;
-              gscd_transfer();
-              end_request(1);
-	   }
+			printk("GSCD: read msf %d:%d:%d\n", cmd[2], cmd[3],
+			       cmd[4]);
+#endif
+			cmd_out(TYPE_DATA, (char *) &cmd,
+				(char *) &gscd_buf[0], 1);
+
+			gscd_bn = CURRENT->sector / 4;
+			gscd_transfer();
+			end_request(1);
+		}
 	}
 	SET_TIMER(__do_gscd_request, 1);
 }
@@ -381,28 +370,27 @@
  * Open the device special file.  Check that a disk is in.
  */
 
-static int gscd_open (struct inode *ip, struct file *fp)
+static int gscd_open(struct inode *ip, struct file *fp)
 {
-int   st;
+	int st;
 
 #ifdef GSCD_DEBUG
-printk ( "GSCD: open\n" );
+	printk("GSCD: open\n");
 #endif
 
 	if (gscdPresent == 0)
-		return -ENXIO;			/* no hardware */
+		return -ENXIO;	/* no hardware */
 
 	MOD_INC_USE_COUNT;
 
-        get_status ();
-        st = disk_state & (ST_NO_DISK | ST_DOOR_OPEN);
-        if ( st )
-        {
-           printk ( "GSCD: no disk or door open\n" );
-           MOD_DEC_USE_COUNT;
-           return -ENXIO;
-        }
-                   
+	get_status();
+	st = disk_state & (ST_NO_DISK | ST_DOOR_OPEN);
+	if (st) {
+		printk("GSCD: no disk or door open\n");
+		MOD_DEC_USE_COUNT;
+		return -ENXIO;
+	}
+
 /*	if (updateToc() < 0)
 		return -EIO;
 */
@@ -415,11 +403,11 @@
  * On close, we flush all gscd blocks from the buffer cache.
  */
 
-static int gscd_release (struct inode * inode, struct file * file)
+static int gscd_release(struct inode *inode, struct file *file)
 {
 
 #ifdef GSCD_DEBUG
-printk ( "GSCD: release\n" );
+	printk("GSCD: release\n");
 #endif
 
 	gscd_bn = -1;
@@ -429,692 +417,642 @@
 }
 
 
-int get_status (void)
+int get_status(void)
 {
-int  status;
+	int status;
+
+	cmd_status();
+	status = disk_state & (ST_x08 | ST_x04 | ST_INVALID | ST_x01);
 
-    cmd_status ();
-    status = disk_state & (ST_x08 | ST_x04 | ST_INVALID | ST_x01);
-     
-    if ( status == (ST_x08 | ST_x04 | ST_INVALID | ST_x01) )
-    {
-       cc_invalidate ();
-       return 1;
-    }
-    else
-    {
-       return 0;
-    }
+	if (status == (ST_x08 | ST_x04 | ST_INVALID | ST_x01)) {
+		cc_invalidate();
+		return 1;
+	} else {
+		return 0;
+	}
 }
 
 
-void cc_invalidate (void)
-{
-   drv_num_read  = 0xFF;
-   f_dsk_valid   = 0xFF;
-   current_drive = 0xFF;
-   f_drv_ok      = 0xFF;
-
-   clear_Audio ();
-   
-}   
-
-void clear_Audio (void)
-{
-
-   f_AudioPlay = 0;
-   f_AudioPause = 0;
-   AudioStart_m = 0;
-   AudioStart_f = 0;
-   AudioEnd_m   = 0;
-   AudioEnd_f   = 0;
-   
+void cc_invalidate(void)
+{
+	drv_num_read = 0xFF;
+	f_dsk_valid = 0xFF;
+	current_drive = 0xFF;
+	f_drv_ok = 0xFF;
+
+	clear_Audio();
+
+}
+
+void clear_Audio(void)
+{
+
+	f_AudioPlay = 0;
+	f_AudioPause = 0;
+	AudioStart_m = 0;
+	AudioStart_f = 0;
+	AudioEnd_m = 0;
+	AudioEnd_f = 0;
+
 }
 
 /*
  *   waiting ?  
  */
 
-int wait_drv_ready (void)
+int wait_drv_ready(void)
 {
-int found, read;
+	int found, read;
+
+	do {
+		found = inb(GSCDPORT(0));
+		found &= 0x0f;
+		read = inb(GSCDPORT(0));
+		read &= 0x0f;
+	} while (read != found);
 
-   do
-   {  
-       found = inb ( GSCDPORT(0) ); 
-       found &= 0x0f;
-       read  = inb ( GSCDPORT(0) );
-       read  &= 0x0f;
-   } while ( read != found );
-   
 #ifdef GSCD_DEBUG
-printk ( "Wait for: %d\n", read );
-#endif   
-   
-   return read;
+	printk("Wait for: %d\n", read);
+#endif
+
+	return read;
 }
 
-void cc_Ident (char * respons)
+void cc_Ident(char *respons)
 {
-char to_do [] = {CMD_IDENT, 0, 0};
+	char to_do[] = { CMD_IDENT, 0, 0 };
 
-    cmd_out (TYPE_INFO, (char *)&to_do, (char *)respons, (int)0x1E );
+	cmd_out(TYPE_INFO, (char *) &to_do, (char *) respons, (int) 0x1E);
 
 }
 
-void cc_SetSpeed (void)
+void cc_SetSpeed(void)
 {
-char to_do [] = {CMD_SETSPEED, 0, 0};
-char dummy;
+	char to_do[] = { CMD_SETSPEED, 0, 0 };
+	char dummy;
 
-    if ( speed > 0 )
-    {
-       to_do[1] = speed & 0x0F;
-       cmd_out (TYPE_INFO, (char *)&to_do, (char *)&dummy, 0);
-    }
+	if (speed > 0) {
+		to_do[1] = speed & 0x0F;
+		cmd_out(TYPE_INFO, (char *) &to_do, (char *) &dummy, 0);
+	}
 }
 
 
-void cc_Reset (void)
+void cc_Reset(void)
 {
-char to_do [] = {CMD_RESET, 0};
-char dummy;
+	char to_do[] = { CMD_RESET, 0 };
+	char dummy;
 
-   cmd_out (TYPE_INFO, (char *)&to_do, (char *)&dummy, 0);
+	cmd_out(TYPE_INFO, (char *) &to_do, (char *) &dummy, 0);
 }
 
 
 
-void cmd_status (void)
+void cmd_status(void)
 {
-char to_do [] = {CMD_STATUS, 0};
-char dummy;
+	char to_do[] = { CMD_STATUS, 0 };
+	char dummy;
 
-   cmd_out (TYPE_INFO, (char *)&to_do, (char *)&dummy, 0);
+	cmd_out(TYPE_INFO, (char *) &to_do, (char *) &dummy, 0);
 
 #ifdef GSCD_DEBUG
-printk ("GSCD: Status: %d\n", disk_state );
+	printk("GSCD: Status: %d\n", disk_state);
 #endif
 
 }
 
-void cmd_out ( int cmd_type, char * cmd, char * respo_buf, int respo_count )
+void cmd_out(int cmd_type, char *cmd, char *respo_buf, int respo_count)
 {
-int        result;
+	int result;
+
+
+	result = wait_drv_ready();
+	if (result != drv_mode) {
+		unsigned long test_loops = 0xFFFF;
+		int i, dummy;
 
+		outb(curr_drv_state, GSCDPORT(0));
 
-       result = wait_drv_ready ();
-       if ( result != drv_mode )
-       {
-       unsigned long test_loops = 0xFFFF;
-       int           i,dummy;
-
-          outb ( curr_drv_state, GSCDPORT(0));
-          
-          /* LOCLOOP_170 */
-          do
-          {
-             result = wait_drv_ready ();
-             test_loops--;
-          } while ( (result != drv_mode) && (test_loops > 0) );
-
-          if ( result != drv_mode )
-          {
-             disk_state = ST_x08 | ST_x04 | ST_INVALID;
-             return;
-          }          
-        
-          /* ...and waiting */
-          for ( i=1,dummy=1 ; i<0xFFFF ; i++ )
-          {
-             dummy *= i;
-          }              
-       }
-
-       /* LOC_172 */    
-       /* check the unit */
-       /* and wake it up */
-       if ( cmd_unit_alive () != 0x08 )
-       {
-          /* LOC_174 */
-          /* game over for this unit */
-          disk_state = ST_x08 | ST_x04 | ST_INVALID;
-          return;
-       }
-       
-       /* LOC_176 */
-       #ifdef GSCD_DEBUG
-        printk ("LOC_176 ");
-       #endif       
-       if ( drv_mode == 0x09 )
-       {
-          /* magic... */
-          printk ("GSCD: magic ...\n");       
-          outb ( result, GSCDPORT(2));
-       }
-
-       /* write the command to the drive */
-       cmd_write_cmd (cmd);
-
-       /* LOC_178 */
-       for (;;)
-       {
-          result = wait_drv_ready ();
-          if ( result != drv_mode )
-          {
-             /* LOC_179 */
-             if ( result == 0x04 )                  /* Mode 4 */
-             {
-                /* LOC_205 */
-                #ifdef GSCD_DEBUG
-                printk ("LOC_205 ");	              
-                #endif
-                disk_state = inb ( GSCDPORT (2));
-             
-                do
-                {
-                   result = wait_drv_ready ();
-                } while ( result != drv_mode );
-                return;
-
-             }
-             else
-             {
-                if ( result == 0x06 )               /* Mode 6 */
-                {
-                   /* LOC_181 */
-                   #ifdef GSCD_DEBUG
-                    printk ("LOC_181 ");	              
-                   #endif
-
-                   if (cmd_type == TYPE_DATA)
-                   {
-                      /* read data */
-                      /* LOC_184 */
-                      if ( drv_mode == 9 )
-                      {
-                         /* read the data to the buffer (word) */
- 
-                         /* (*(cmd+1))?(CD_FRAMESIZE/2):(CD_FRAMESIZE_RAW/2) */
-                         cmd_read_w ( respo_buf, respo_count, CD_FRAMESIZE/2 );
-                         return;
-                      } 
-                      else
-                      { 
-                         /* read the data to the buffer (byte) */
-                         
-                         /* (*(cmd+1))?(CD_FRAMESIZE):(CD_FRAMESIZE_RAW)    */
-                         cmd_read_b ( respo_buf, respo_count, CD_FRAMESIZE );
-                         return;
-                      }
-                   }
-                   else
-                   { 
-                      /* read the info to the buffer */
-                      cmd_info_in ( respo_buf, respo_count ); 
-                      return;
-                   }                  
-
-                   return;
-                }
-             }
-
-          }
-          else
-          {
-             disk_state = ST_x08 | ST_x04 | ST_INVALID;         
-             return;
-          }    
-       } /* for (;;) */
+		/* LOCLOOP_170 */
+		do {
+			result = wait_drv_ready();
+			test_loops--;
+		} while ((result != drv_mode) && (test_loops > 0));
 
+		if (result != drv_mode) {
+			disk_state = ST_x08 | ST_x04 | ST_INVALID;
+			return;
+		}
+
+		/* ...and waiting */
+		for (i = 1, dummy = 1; i < 0xFFFF; i++) {
+			dummy *= i;
+		}
+	}
 
+	/* LOC_172 */
+	/* check the unit */
+	/* and wake it up */
+	if (cmd_unit_alive() != 0x08) {
+		/* LOC_174 */
+		/* game over for this unit */
+		disk_state = ST_x08 | ST_x04 | ST_INVALID;
+		return;
+	}
+
+	/* LOC_176 */
 #ifdef GSCD_DEBUG
-printk ("\n");       
-#endif    
+	printk("LOC_176 ");
+#endif
+	if (drv_mode == 0x09) {
+		/* magic... */
+		printk("GSCD: magic ...\n");
+		outb(result, GSCDPORT(2));
+	}
+
+	/* write the command to the drive */
+	cmd_write_cmd(cmd);
+
+	/* LOC_178 */
+	for (;;) {
+		result = wait_drv_ready();
+		if (result != drv_mode) {
+			/* LOC_179 */
+			if (result == 0x04) {	/* Mode 4 */
+				/* LOC_205 */
+#ifdef GSCD_DEBUG
+				printk("LOC_205 ");
+#endif
+				disk_state = inb(GSCDPORT(2));
+
+				do {
+					result = wait_drv_ready();
+				} while (result != drv_mode);
+				return;
+
+			} else {
+				if (result == 0x06) {	/* Mode 6 */
+					/* LOC_181 */
+#ifdef GSCD_DEBUG
+					printk("LOC_181 ");
+#endif
+
+					if (cmd_type == TYPE_DATA) {
+						/* read data */
+						/* LOC_184 */
+						if (drv_mode == 9) {
+							/* read the data to the buffer (word) */
+
+							/* (*(cmd+1))?(CD_FRAMESIZE/2):(CD_FRAMESIZE_RAW/2) */
+							cmd_read_w
+							    (respo_buf,
+							     respo_count,
+							     CD_FRAMESIZE /
+							     2);
+							return;
+						} else {
+							/* read the data to the buffer (byte) */
+
+							/* (*(cmd+1))?(CD_FRAMESIZE):(CD_FRAMESIZE_RAW)    */
+							cmd_read_b
+							    (respo_buf,
+							     respo_count,
+							     CD_FRAMESIZE);
+							return;
+						}
+					} else {
+						/* read the info to the buffer */
+						cmd_info_in(respo_buf,
+							    respo_count);
+						return;
+					}
+
+					return;
+				}
+			}
+
+		} else {
+			disk_state = ST_x08 | ST_x04 | ST_INVALID;
+			return;
+		}
+	}			/* for (;;) */
+
+
+#ifdef GSCD_DEBUG
+	printk("\n");
+#endif
+}
+
+
+static void cmd_write_cmd(char *pstr)
+{
+	int i, j;
+
+	/* LOC_177 */
+#ifdef GSCD_DEBUG
+	printk("LOC_177 ");
+#endif
+
+	/* calculate the number of parameter */
+	j = *pstr & 0x0F;
+
+	/* shift it out */
+	for (i = 0; i < j; i++) {
+		outb(*pstr, GSCDPORT(2));
+		pstr++;
+	}
 }
 
 
-static void cmd_write_cmd ( char *pstr )
+static int cmd_unit_alive(void)
 {
-int  i,j;
+	int result;
+	unsigned long max_test_loops;
+
+
+	/* LOC_172 */
+#ifdef GSCD_DEBUG
+	printk("LOC_172 ");
+#endif
+
+	outb(curr_drv_state, GSCDPORT(0));
+	max_test_loops = 0xFFFF;
 
-    /* LOC_177 */
-    #ifdef GSCD_DEBUG
-     printk ("LOC_177 ");       
-    #endif
-       
-    /* calculate the number of parameter */
-    j = *pstr & 0x0F;
-
-    /* shift it out */
-    for ( i=0 ; i<j ; i++ )
-    {
-       outb ( *pstr, GSCDPORT(2) );
-       pstr++;
-    }
-}
-
-
-static int cmd_unit_alive ( void )
-{
-int            result;
-unsigned long  max_test_loops;
-
-
-    /* LOC_172 */
-    #ifdef GSCD_DEBUG
-     printk ("LOC_172 ");       
-    #endif
-
-    outb ( curr_drv_state, GSCDPORT(0));       
-    max_test_loops = 0xFFFF;
-     
-    do
-    {
-       result = wait_drv_ready ();
-       max_test_loops--;
-    } while ( (result != 0x08) && (max_test_loops > 0) );
-
-    return result;
-}       
-
-
-static void cmd_info_in ( char *pb, int count )
-{
-int   result;
-char  read;
-
-
-        /* read info */
-        /* LOC_182 */
-        #ifdef GSCD_DEBUG
-         printk ("LOC_182 ");				              
-        #endif
-       
-        do
-        {
-           read = inb (GSCDPORT(2)); 
-           if ( count > 0 )
-           {
-              *pb = read;
-              pb++;
-              count--;
-           }
-                         
-           /* LOC_183 */
-           do
-           {
-              result = wait_drv_ready ();
-           } while ( result == 0x0E );
-        } while ( result == 6 );                     
-
-        cmd_end ();
-        return;
-}
-
-
-static void cmd_read_b ( char *pb, int count, int size )
-{
-int  result;
-int  i;
-                     
-                     
-       /* LOC_188 */
-       /* LOC_189 */
-       #ifdef GSCD_DEBUG
-        printk ("LOC_189 ");			              
-       #endif
-
-       do 
-       {
-          do
-          {
-             result = wait_drv_ready ();
-          } while ( result != 6 || result == 0x0E );
-                         
-          if ( result != 6 )
-          {
-             cmd_end ();
-             return;
-          }                       
-          
-          #ifdef GSCD_DEBUG
-           printk ("LOC_191 ");       
-          #endif
-
-          for ( i=0 ; i< size ; i++ )
-          {
-             *pb = inb (GSCDPORT(2));
-             pb++;
-          }
-          count--;
-       } while ( count > 0 );
-       
-       cmd_end ();
-       return;
-}
-
-
-static void cmd_end (void)
-{
-int   result;
-
-
-      /* LOC_204 */
-      #ifdef GSCD_DEBUG
-       printk ("LOC_204 ");				              
-      #endif
-      
-      do
-      {
-         result = wait_drv_ready ();
-         if ( result == drv_mode )
-         {
-            return;
-         }
-      } while ( result != 4 );
-
-      /* LOC_205 */
-      #ifdef GSCD_DEBUG
-       printk ("LOC_205 ");			              
-      #endif
-       
-      disk_state = inb ( GSCDPORT (2));
-             
-      do
-      {
-         result = wait_drv_ready ();
-      } while ( result != drv_mode );
-      return;
-
-}
-
-
-static void cmd_read_w ( char *pb, int count, int size )
-{
-int  result;
-int  i;
-
-
-    #ifdef GSCD_DEBUG
-     printk ("LOC_185 ");			              
-    #endif
- 
-    do 
-    {
-       /* LOC_185 */
-       do
-       {
-          result = wait_drv_ready ();
-       } while ( result != 6 || result == 0x0E );
-                         
-       if ( result != 6 )
-       {
-          cmd_end ();
-          return;
-       }                       
-                         
-       for ( i=0 ; i<size ; i++ )
-       {
-           /* na, hier muss ich noch mal drueber nachdenken */
-           *pb = inw(GSCDPORT(2));
-           pb++;
-        }
-        count--;
-     } while ( count > 0 );
-                    
-     cmd_end ();
-     return;
-}
-
-int __init find_drives (void)
-{
-int *pdrv;
-int drvnum;
-int subdrv;
-int i;
-
-    speed           = 0;
-    pdrv            = (int *)&drv_states;
-    curr_drv_state  = 0xFE;
-    subdrv          = 0;
-    drvnum          = 0;
-
-    for ( i=0 ; i<8 ; i++ )
-    { 
-       subdrv++;
-       cmd_status ();
-       disk_state &= ST_x08 | ST_x04 | ST_INVALID | ST_x01;
-       if ( disk_state != (ST_x08 | ST_x04 | ST_INVALID) )
-       {
-          /* LOC_240 */
-          *pdrv = curr_drv_state;
-          init_cd_drive (drvnum);
-          pdrv++;
-          drvnum++;
-       }
-       else
-       {
-          if ( subdrv < 2 )
-          {
-             continue;
-          }
-          else
-          {
-             subdrv = 0;
-          }
-       }   
+	do {
+		result = wait_drv_ready();
+		max_test_loops--;
+	} while ((result != 0x08) && (max_test_loops > 0));
+
+	return result;
+}
 
-/*       curr_drv_state<<1;         <-- das geht irgendwie nicht */ 
+
+static void cmd_info_in(char *pb, int count)
+{
+	int result;
+	char read;
+
+
+	/* read info */
+	/* LOC_182 */
+#ifdef GSCD_DEBUG
+	printk("LOC_182 ");
+#endif
+
+	do {
+		read = inb(GSCDPORT(2));
+		if (count > 0) {
+			*pb = read;
+			pb++;
+			count--;
+		}
+
+		/* LOC_183 */
+		do {
+			result = wait_drv_ready();
+		} while (result == 0x0E);
+	} while (result == 6);
+
+	cmd_end();
+	return;
+}
+
+
+static void cmd_read_b(char *pb, int count, int size)
+{
+	int result;
+	int i;
+
+
+	/* LOC_188 */
+	/* LOC_189 */
+#ifdef GSCD_DEBUG
+	printk("LOC_189 ");
+#endif
+
+	do {
+		do {
+			result = wait_drv_ready();
+		} while (result != 6 || result == 0x0E);
+
+		if (result != 6) {
+			cmd_end();
+			return;
+		}
+#ifdef GSCD_DEBUG
+		printk("LOC_191 ");
+#endif
+
+		for (i = 0; i < size; i++) {
+			*pb = inb(GSCDPORT(2));
+			pb++;
+		}
+		count--;
+	} while (count > 0);
+
+	cmd_end();
+	return;
+}
+
+
+static void cmd_end(void)
+{
+	int result;
+
+
+	/* LOC_204 */
+#ifdef GSCD_DEBUG
+	printk("LOC_204 ");
+#endif
+
+	do {
+		result = wait_drv_ready();
+		if (result == drv_mode) {
+			return;
+		}
+	} while (result != 4);
+
+	/* LOC_205 */
+#ifdef GSCD_DEBUG
+	printk("LOC_205 ");
+#endif
+
+	disk_state = inb(GSCDPORT(2));
+
+	do {
+		result = wait_drv_ready();
+	} while (result != drv_mode);
+	return;
+
+}
+
+
+static void cmd_read_w(char *pb, int count, int size)
+{
+	int result;
+	int i;
+
+
+#ifdef GSCD_DEBUG
+	printk("LOC_185 ");
+#endif
+
+	do {
+		/* LOC_185 */
+		do {
+			result = wait_drv_ready();
+		} while (result != 6 || result == 0x0E);
+
+		if (result != 6) {
+			cmd_end();
+			return;
+		}
+
+		for (i = 0; i < size; i++) {
+			/* na, hier muss ich noch mal drueber nachdenken */
+			*pb = inw(GSCDPORT(2));
+			pb++;
+		}
+		count--;
+	} while (count > 0);
+
+	cmd_end();
+	return;
+}
+
+int __init find_drives(void)
+{
+	int *pdrv;
+	int drvnum;
+	int subdrv;
+	int i;
+
+	speed = 0;
+	pdrv = (int *) &drv_states;
+	curr_drv_state = 0xFE;
+	subdrv = 0;
+	drvnum = 0;
+
+	for (i = 0; i < 8; i++) {
+		subdrv++;
+		cmd_status();
+		disk_state &= ST_x08 | ST_x04 | ST_INVALID | ST_x01;
+		if (disk_state != (ST_x08 | ST_x04 | ST_INVALID)) {
+			/* LOC_240 */
+			*pdrv = curr_drv_state;
+			init_cd_drive(drvnum);
+			pdrv++;
+			drvnum++;
+		} else {
+			if (subdrv < 2) {
+				continue;
+			} else {
+				subdrv = 0;
+			}
+		}
+
+/*       curr_drv_state<<1;         <-- das geht irgendwie nicht */
 /* muss heissen:    curr_drv_state <<= 1; (ist ja Wert-Zuweisung) */
-         curr_drv_state *= 2;
-         curr_drv_state |= 1;
+		curr_drv_state *= 2;
+		curr_drv_state |= 1;
 #ifdef GSCD_DEBUG
-         printk ("DriveState: %d\n", curr_drv_state );
+		printk("DriveState: %d\n", curr_drv_state);
 #endif
-    } 
+	}
 
-    ndrives = drvnum;
-    return drvnum;
-}    
+	ndrives = drvnum;
+	return drvnum;
+}
 
-void __init init_cd_drive ( int num )
+void __init init_cd_drive(int num)
 {
-char resp [50];
-int  i;
+	char resp[50];
+	int i;
 
-   printk ("GSCD: init unit %d\n", num );
-   cc_Ident ((char *)&resp);
+	printk("GSCD: init unit %d\n", num);
+	cc_Ident((char *) &resp);
 
-   printk ("GSCD: identification: ");
-   for ( i=0 ; i<0x1E; i++ )
-   {
-      printk ( "%c", resp[i] );
-   }
-   printk ("\n");
-   
-   cc_SetSpeed ();  
+	printk("GSCD: identification: ");
+	for (i = 0; i < 0x1E; i++) {
+		printk("%c", resp[i]);
+	}
+	printk("\n");
 
-}    
+	cc_SetSpeed();
+
+}
 
 #ifdef FUTURE_WORK
 /* return_done */
-static void update_state ( void )
+static void update_state(void)
 {
-unsigned int AX;
+	unsigned int AX;
+
+
+	if ((disk_state & (ST_x08 | ST_x04 | ST_INVALID | ST_x01)) == 0) {
+		if (disk_state == (ST_x08 | ST_x04 | ST_INVALID)) {
+			AX = ST_INVALID;
+		}
+
+		if ((disk_state & (ST_x08 | ST_x04 | ST_INVALID | ST_x01))
+		    == 0) {
+			invalidate();
+			f_drv_ok = 0;
+		}
+
+		AX |= 0x8000;
+	}
+
+	if (disk_state & ST_PLAYING) {
+		AX |= 0x200;
+	}
 
+	AX |= 0x100;
+	/* pkt_esbx = AX; */
 
-    if ( (disk_state & (ST_x08 | ST_x04 | ST_INVALID | ST_x01)) == 0 )
-    {
-       if ( disk_state == (ST_x08 | ST_x04 | ST_INVALID))
-       {
-          AX = ST_INVALID;
-       }
-  
-       if ( (disk_state & (ST_x08 | ST_x04 | ST_INVALID | ST_x01)) == 0 )
-       {
-          invalidate ();
-          f_drv_ok = 0;
-       }
-       
-       AX |= 0x8000;
-    }
-    
-    if ( disk_state & ST_PLAYING )
-    {
-       AX |= 0x200;
-    }
-    
-    AX |= 0x100;
-    /* pkt_esbx = AX; */
+	disk_state = 0;
 
-    disk_state = 0;
-    
 }
 #endif
 
 /* Init for the Module-Version */
 int init_gscd(void)
 {
-long err;
+	long err;
 
 
-     /* call the GoldStar-init */
-     err = my_gscd_init ( );
+	/* call the GoldStar-init */
+	err = my_gscd_init();
 
-     if ( err < 0 )
-     {
-         return err;
-     }
-     else
-     {
-        printk (KERN_INFO "Happy GoldStar !\n" );
-        return 0;
-     }    
+	if (err < 0) {
+		return err;
+	} else {
+		printk(KERN_INFO "Happy GoldStar !\n");
+		return 0;
+	}
 }
 
 void __exit exit_gscd(void)
 {
-   CLEAR_TIMER;
+	CLEAR_TIMER;
 
-   devfs_unregister(devfs_find_handle(NULL, "gscd", 0, 0, DEVFS_SPECIAL_BLK,
-				      0));
-   if ((devfs_unregister_blkdev(MAJOR_NR, "gscd" ) == -EINVAL))
-   {
-      printk("What's that: can't unregister GoldStar-module\n" );
-      return;
-   }
-   blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
-   release_region (gscd_port,4);
-   printk(KERN_INFO "GoldStar-module released.\n" );
+	devfs_unregister(devfs_find_handle
+			 (NULL, "gscd", 0, 0, DEVFS_SPECIAL_BLK, 0));
+	if ((devfs_unregister_blkdev(MAJOR_NR, "gscd") == -EINVAL)) {
+		printk("What's that: can't unregister GoldStar-module\n");
+		return;
+	}
+	blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
+	release_region(gscd_port, 4);
+	printk(KERN_INFO "GoldStar-module released.\n");
 }
 
 #ifdef MODULE
 module_init(init_gscd);
-#endif 
+#endif
 module_exit(exit_gscd);
 
 
 /* Test for presence of drive and initialize it.  Called only at boot time. */
-int __init gscd_init (void)
+int __init gscd_init(void)
 {
-   return my_gscd_init ();
+	return my_gscd_init();
 }
 
 
 /* This is the common initialisation for the GoldStar drive. */
 /* It is called at boot time AND for module init.           */
-int __init my_gscd_init (void)
+int __init my_gscd_init(void)
 {
-int i;
-int result;
+	int i;
+	int result;
 
-        printk (KERN_INFO "GSCD: version %s\n", GSCD_VERSION);
-        printk (KERN_INFO "GSCD: Trying to detect a Goldstar R420 CD-ROM drive at 0x%X.\n", gscd_port);
-
-        if (check_region(gscd_port, 4)) 
-        {
-	  printk("GSCD: Init failed, I/O port (%X) already in use.\n", gscd_port);
-	  return -EIO;
+	printk(KERN_INFO "GSCD: version %s\n", GSCD_VERSION);
+	printk(KERN_INFO
+	       "GSCD: Trying to detect a Goldstar R420 CD-ROM drive at 0x%X.\n",
+	       gscd_port);
+
+	if (check_region(gscd_port, 4)) {
+		printk
+		    ("GSCD: Init failed, I/O port (%X) already in use.\n",
+		     gscd_port);
+		return -EIO;
 	}
-	  
+
 
 	/* check for card */
-	result = wait_drv_ready ();
-        if ( result == 0x09 )
-        {
-           printk ("GSCD: DMA kann ich noch nicht!\n" );
-           return -EIO;
-        }
- 
-        if ( result == 0x0b )
-        {
-           drv_mode = result;
-           i = find_drives ();
-           if ( i == 0 )
-           {
-              printk ( "GSCD: GoldStar CD-ROM Drive is not found.\n" );
-              return -EIO;
-           }
-        }
-
-        if ( (result != 0x0b) && (result != 0x09) )
-        {
-              printk ("GSCD: GoldStar Interface Adapter does not exist or H/W error\n" );
-              return -EIO;
-        }          		            
-
-        /* reset all drives */
-        i = 0;
-        while ( drv_states[i] != 0 )
-        {
-           curr_drv_state = drv_states[i];
-           printk (KERN_INFO "GSCD: Reset unit %d ... ",i );
-           cc_Reset ();
-           printk ( "done\n" );
-           i++;
-        }
-
-	if (devfs_register_blkdev(MAJOR_NR, "gscd", &gscd_fops) != 0)
-	{
-		printk("GSCD: Unable to get major %d for GoldStar CD-ROM\n",
-		       MAJOR_NR);
+	result = wait_drv_ready();
+	if (result == 0x09) {
+		printk("GSCD: DMA kann ich noch nicht!\n");
 		return -EIO;
 	}
-	devfs_register (NULL, "gscd", DEVFS_FL_DEFAULT, MAJOR_NR, 0,
-			S_IFBLK | S_IRUGO | S_IWUGO, &gscd_fops, NULL);
+
+	if (result == 0x0b) {
+		drv_mode = result;
+		i = find_drives();
+		if (i == 0) {
+			printk
+			    ("GSCD: GoldStar CD-ROM Drive is not found.\n");
+			return -EIO;
+		}
+	}
+
+	if ((result != 0x0b) && (result != 0x09)) {
+		printk
+		    ("GSCD: GoldStar Interface Adapter does not exist or H/W error\n");
+		return -EIO;
+	}
+
+	/* reset all drives */
+	i = 0;
+	while (drv_states[i] != 0) {
+		curr_drv_state = drv_states[i];
+		printk(KERN_INFO "GSCD: Reset unit %d ... ", i);
+		cc_Reset();
+		printk("done\n");
+		i++;
+	}
+
+	if (devfs_register_blkdev(MAJOR_NR, "gscd", &gscd_fops) != 0) {
+		printk
+		    ("GSCD: Unable to get major %d for GoldStar CD-ROM\n",
+		     MAJOR_NR);
+		return -EIO;
+	}
+	devfs_register(NULL, "gscd", DEVFS_FL_DEFAULT, MAJOR_NR, 0,
+		       S_IFBLK | S_IRUGO | S_IWUGO, &gscd_fops, NULL);
 
 	blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST);
 	blksize_size[MAJOR_NR] = gscd_blocksizes;
 	read_ahead[MAJOR_NR] = 4;
-        
-        disk_state = 0;
-        gscdPresent = 1;
+
+	disk_state = 0;
+	gscdPresent = 1;
 
 	request_region(gscd_port, 4, "gscd");
-	register_disk(NULL, MKDEV(MAJOR_NR,0), 1, &gscd_fops, 0);
+	register_disk(NULL, MKDEV(MAJOR_NR, 0), 1, &gscd_fops, 0);
 
-        printk (KERN_INFO "GSCD: GoldStar CD-ROM Drive found.\n" );
+	printk(KERN_INFO "GSCD: GoldStar CD-ROM Drive found.\n");
 	return 0;
 }
 
-static void gscd_hsg2msf (long hsg, struct msf *msf)
+static void gscd_hsg2msf(long hsg, struct msf *msf)
 {
 	hsg += CD_MSF_OFFSET;
-	msf -> min = hsg / (CD_FRAMES*CD_SECS);
-	hsg %= CD_FRAMES*CD_SECS;
-	msf -> sec = hsg / CD_FRAMES;
-	msf -> frame = hsg % CD_FRAMES;
+	msf->min = hsg / (CD_FRAMES * CD_SECS);
+	hsg %= CD_FRAMES * CD_SECS;
+	msf->sec = hsg / CD_FRAMES;
+	msf->frame = hsg % CD_FRAMES;
 
-	gscd_bin2bcd(&msf -> min);		/* convert to BCD */
-	gscd_bin2bcd(&msf -> sec);
-	gscd_bin2bcd(&msf -> frame);
+	gscd_bin2bcd(&msf->min);	/* convert to BCD */
+	gscd_bin2bcd(&msf->sec);
+	gscd_bin2bcd(&msf->frame);
 }
- 
 
-static void gscd_bin2bcd (unsigned char *p)
+
+static void gscd_bin2bcd(unsigned char *p)
 {
-int u, t;
+	int u, t;
 
 	u = *p % 10;
 	t = *p / 10;
@@ -1123,18 +1061,19 @@
 
 
 #ifdef FUTURE_WORK
-static long gscd_msf2hsg (struct msf *mp)
+static long gscd_msf2hsg(struct msf *mp)
 {
-	return gscd_bcd2bin(mp -> frame)
-		+ gscd_bcd2bin(mp -> sec) * CD_FRAMES
-		+ gscd_bcd2bin(mp -> min) * CD_FRAMES * CD_SECS
-		- CD_MSF_OFFSET;
+	return gscd_bcd2bin(mp->frame)
+	    + gscd_bcd2bin(mp->sec) * CD_FRAMES
+	    + gscd_bcd2bin(mp->min) * CD_FRAMES * CD_SECS - CD_MSF_OFFSET;
 }
 
-static int gscd_bcd2bin (unsigned char bcd)
+static int gscd_bcd2bin(unsigned char bcd)
 {
 	return (bcd >> 4) * 10 + (bcd & 0xF);
 }
 #endif
 
-
+MODULE_AUTHOR("Oliver Raupach <raupach@nwfs1.rz.fh-hannover.de>");
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/cdrom/isp16.c linux/drivers/cdrom/isp16.c
--- v2.4.9/linux/drivers/cdrom/isp16.c	Mon Dec 13 14:08:40 1999
+++ linux/drivers/cdrom/isp16.c	Fri Sep  7 09:28:38 2001
@@ -44,9 +44,7 @@
 #define ISP16_VERSION_MAJOR 0
 #define ISP16_VERSION_MINOR 6
 
-#ifdef MODULE
 #include <linux/module.h>
-#endif  /* MODULE */
 
 #include <linux/fs.h>
 #include <linux/kernel.h>
@@ -59,8 +57,9 @@
 static short isp16_detect(void);
 static short isp16_c928__detect(void);
 static short isp16_c929__detect(void);
-static short isp16_cdi_config(int base, u_char drive_type, int irq, int dma);
-static short isp16_type; /* dependent on type of interface card */
+static short isp16_cdi_config(int base, u_char drive_type, int irq,
+			      int dma);
+static short isp16_type;	/* dependent on type of interface card */
 static u_char isp16_ctrl;
 static u_short isp16_enable_port;
 
@@ -69,11 +68,12 @@
 static int isp16_cdrom_dma = ISP16_CDROM_DMA;
 static char *isp16_cdrom_type = ISP16_CDROM_TYPE;
 
-#ifdef MODULE
 MODULE_PARM(isp16_cdrom_base, "i");
 MODULE_PARM(isp16_cdrom_irq, "i");
 MODULE_PARM(isp16_cdrom_dma, "i");
 MODULE_PARM(isp16_cdrom_type, "s");
+
+#ifdef MODULE
 void isp16_exit(void);
 #endif
 
@@ -82,243 +82,279 @@
 
 #ifndef MODULE
 
-static int 
+static int
 __init isp16_setup(char *str)
 {
-  int ints[4];
-  
-  (void)get_options(str, ARRAY_SIZE(ints), ints);
-  if ( ints[0] > 0 )
-    isp16_cdrom_base = ints[1];
-  if ( ints[0] > 1 )      
-    isp16_cdrom_irq = ints[2];
-  if ( ints[0] > 2 )      
-    isp16_cdrom_dma = ints[3];
-  if ( str )
-    isp16_cdrom_type = str;
+	int ints[4];
 
-  return 1;
+	(void) get_options(str, ARRAY_SIZE(ints), ints);
+	if (ints[0] > 0)
+		isp16_cdrom_base = ints[1];
+	if (ints[0] > 1)
+		isp16_cdrom_irq = ints[2];
+	if (ints[0] > 2)
+		isp16_cdrom_dma = ints[3];
+	if (str)
+		isp16_cdrom_type = str;
+
+	return 1;
 }
 
 __setup("isp16=", isp16_setup);
 
-#endif /* MODULE */
+#endif				/* MODULE */
 
 /*
  *  ISP16 initialisation.
  *
  */
-int __init 
-isp16_init(void)
+int __init isp16_init(void)
 {
-  u_char expected_drive;
-
-  printk(KERN_INFO "ISP16: configuration cdrom interface, version %d.%d.\n", ISP16_VERSION_MAJOR,
-    ISP16_VERSION_MINOR);
+	u_char expected_drive;
 
-  if ( !strcmp(isp16_cdrom_type, "noisp16") ) {
-    printk("ISP16: no cdrom interface configured.\n");
-    return(0);
-  }
-
-  if (check_region(ISP16_IO_BASE, ISP16_IO_SIZE)) {
-    printk("ISP16: i/o ports already in use.\n");
-    return(-EIO);
-  }
-
-  if ( (isp16_type=isp16_detect()) < 0 ) {
-    printk("ISP16: no cdrom interface found.\n");
-    return(-EIO);
-  }
-
-  printk(KERN_INFO "ISP16: cdrom interface (with OPTi 82C92%d chip) detected.\n",
-    (isp16_type==2) ? 9 : 8);
-
-  if ( !strcmp(isp16_cdrom_type, "Sanyo") )
-    expected_drive = (isp16_type ? ISP16_SANYO1 : ISP16_SANYO0);
-  else if ( !strcmp(isp16_cdrom_type, "Sony") )
-    expected_drive = ISP16_SONY;
-  else if ( !strcmp(isp16_cdrom_type, "Panasonic") )
-    expected_drive = (isp16_type ? ISP16_PANASONIC1 : ISP16_PANASONIC0);
-  else if ( !strcmp(isp16_cdrom_type, "Mitsumi") )
-    expected_drive = ISP16_MITSUMI;
-  else {
-    printk("ISP16: %s not supported by cdrom interface.\n", isp16_cdrom_type);
-    return(-EIO);
-  }
-
-  if ( isp16_cdi_config(isp16_cdrom_base, expected_drive,
-    isp16_cdrom_irq, isp16_cdrom_dma ) < 0) {
-    printk("ISP16: cdrom interface has not been properly configured.\n");
-    return(-EIO);
-  }
-  printk(KERN_INFO "ISP16: cdrom interface set up with io base 0x%03X, irq %d, dma %d,"
-    " type %s.\n", isp16_cdrom_base, isp16_cdrom_irq, isp16_cdrom_dma,
-    isp16_cdrom_type);
-  return(0);
+	printk(KERN_INFO
+	       "ISP16: configuration cdrom interface, version %d.%d.\n",
+	       ISP16_VERSION_MAJOR, ISP16_VERSION_MINOR);
+
+	if (!strcmp(isp16_cdrom_type, "noisp16")) {
+		printk("ISP16: no cdrom interface configured.\n");
+		return (0);
+	}
+
+	if (check_region(ISP16_IO_BASE, ISP16_IO_SIZE)) {
+		printk("ISP16: i/o ports already in use.\n");
+		return (-EIO);
+	}
+
+	if ((isp16_type = isp16_detect()) < 0) {
+		printk("ISP16: no cdrom interface found.\n");
+		return (-EIO);
+	}
+
+	printk(KERN_INFO
+	       "ISP16: cdrom interface (with OPTi 82C92%d chip) detected.\n",
+	       (isp16_type == 2) ? 9 : 8);
+
+	if (!strcmp(isp16_cdrom_type, "Sanyo"))
+		expected_drive =
+		    (isp16_type ? ISP16_SANYO1 : ISP16_SANYO0);
+	else if (!strcmp(isp16_cdrom_type, "Sony"))
+		expected_drive = ISP16_SONY;
+	else if (!strcmp(isp16_cdrom_type, "Panasonic"))
+		expected_drive =
+		    (isp16_type ? ISP16_PANASONIC1 : ISP16_PANASONIC0);
+	else if (!strcmp(isp16_cdrom_type, "Mitsumi"))
+		expected_drive = ISP16_MITSUMI;
+	else {
+		printk("ISP16: %s not supported by cdrom interface.\n",
+		       isp16_cdrom_type);
+		return (-EIO);
+	}
+
+	if (isp16_cdi_config(isp16_cdrom_base, expected_drive,
+			     isp16_cdrom_irq, isp16_cdrom_dma) < 0) {
+		printk
+		    ("ISP16: cdrom interface has not been properly configured.\n");
+		return (-EIO);
+	}
+	printk(KERN_INFO
+	       "ISP16: cdrom interface set up with io base 0x%03X, irq %d, dma %d,"
+	       " type %s.\n", isp16_cdrom_base, isp16_cdrom_irq,
+	       isp16_cdrom_dma, isp16_cdrom_type);
+	return (0);
 }
 
-static short __init 
-isp16_detect(void)
+static short __init isp16_detect(void)
 {
 
-  if ( isp16_c929__detect() >= 0 )
-    return(2);
-  else
-    return(isp16_c928__detect());
+	if (isp16_c929__detect() >= 0)
+		return (2);
+	else
+		return (isp16_c928__detect());
 }
 
-static short __init 
-isp16_c928__detect(void)
+static short __init isp16_c928__detect(void)
 {
-  u_char ctrl;
-  u_char enable_cdrom;
-  u_char io;
-  short i = -1;
-
-  isp16_ctrl = ISP16_C928__CTRL;
-  isp16_enable_port = ISP16_C928__ENABLE_PORT;
-
-  /* read' and write' are a special read and write, respectively */
-
-  /* read' ISP16_CTRL_PORT, clear last two bits and write' back the result */
-  ctrl = ISP16_IN( ISP16_CTRL_PORT ) & 0xFC;
-  ISP16_OUT( ISP16_CTRL_PORT, ctrl );
-
-  /* read' 3,4 and 5-bit from the cdrom enable port */
-  enable_cdrom = ISP16_IN( ISP16_C928__ENABLE_PORT ) & 0x38;
-
-  if ( !(enable_cdrom & 0x20) ) {  /* 5-bit not set */
-    /* read' last 2 bits of ISP16_IO_SET_PORT */
-    io = ISP16_IN( ISP16_IO_SET_PORT ) & 0x03;
-    if ( ((io&0x01)<<1) == (io&0x02) ) {  /* bits are the same */
-      if ( io == 0 ) {  /* ...the same and 0 */
-        i = 0;
-        enable_cdrom |= 0x20;
-      }
-      else {  /* ...the same and 1 */  /* my card, first time 'round */
-        i = 1;
-        enable_cdrom |= 0x28;
-      }
-      ISP16_OUT( ISP16_C928__ENABLE_PORT, enable_cdrom );
-    }
-    else {  /* bits are not the same */
-      ISP16_OUT( ISP16_CTRL_PORT, ctrl );
-      return(i); /* -> not detected: possibly incorrect conclusion */
-    }
-  }
-  else if ( enable_cdrom == 0x20 )
-    i = 0;
-  else if ( enable_cdrom == 0x28 )  /* my card, already initialised */
-    i = 1;
+	u_char ctrl;
+	u_char enable_cdrom;
+	u_char io;
+	short i = -1;
+
+	isp16_ctrl = ISP16_C928__CTRL;
+	isp16_enable_port = ISP16_C928__ENABLE_PORT;
+
+	/* read' and write' are a special read and write, respectively */
+
+	/* read' ISP16_CTRL_PORT, clear last two bits and write' back the result */
+	ctrl = ISP16_IN(ISP16_CTRL_PORT) & 0xFC;
+	ISP16_OUT(ISP16_CTRL_PORT, ctrl);
+
+	/* read' 3,4 and 5-bit from the cdrom enable port */
+	enable_cdrom = ISP16_IN(ISP16_C928__ENABLE_PORT) & 0x38;
+
+	if (!(enable_cdrom & 0x20)) {	/* 5-bit not set */
+		/* read' last 2 bits of ISP16_IO_SET_PORT */
+		io = ISP16_IN(ISP16_IO_SET_PORT) & 0x03;
+		if (((io & 0x01) << 1) == (io & 0x02)) {	/* bits are the same */
+			if (io == 0) {	/* ...the same and 0 */
+				i = 0;
+				enable_cdrom |= 0x20;
+			} else {	/* ...the same and 1 *//* my card, first time 'round */
+				i = 1;
+				enable_cdrom |= 0x28;
+			}
+			ISP16_OUT(ISP16_C928__ENABLE_PORT, enable_cdrom);
+		} else {	/* bits are not the same */
+			ISP16_OUT(ISP16_CTRL_PORT, ctrl);
+			return (i);	/* -> not detected: possibly incorrect conclusion */
+		}
+	} else if (enable_cdrom == 0x20)
+		i = 0;
+	else if (enable_cdrom == 0x28)	/* my card, already initialised */
+		i = 1;
 
-  ISP16_OUT( ISP16_CTRL_PORT, ctrl );
+	ISP16_OUT(ISP16_CTRL_PORT, ctrl);
 
-  return(i);
+	return (i);
 }
 
-static short __init 
-isp16_c929__detect(void)
+static short __init isp16_c929__detect(void)
 {
-  u_char ctrl;
-  u_char tmp;
+	u_char ctrl;
+	u_char tmp;
 
-  isp16_ctrl = ISP16_C929__CTRL;
-  isp16_enable_port = ISP16_C929__ENABLE_PORT;
+	isp16_ctrl = ISP16_C929__CTRL;
+	isp16_enable_port = ISP16_C929__ENABLE_PORT;
 
-  /* read' and write' are a special read and write, respectively */
+	/* read' and write' are a special read and write, respectively */
 
-  /* read' ISP16_CTRL_PORT and save */
-  ctrl = ISP16_IN( ISP16_CTRL_PORT );
+	/* read' ISP16_CTRL_PORT and save */
+	ctrl = ISP16_IN(ISP16_CTRL_PORT);
 
-  /* write' zero to the ctrl port and get response */
-  ISP16_OUT( ISP16_CTRL_PORT, 0 );
-  tmp = ISP16_IN( ISP16_CTRL_PORT );
+	/* write' zero to the ctrl port and get response */
+	ISP16_OUT(ISP16_CTRL_PORT, 0);
+	tmp = ISP16_IN(ISP16_CTRL_PORT);
 
-  if ( tmp != 2 )  /* isp16 with 82C929 not detected */
-    return(-1);
+	if (tmp != 2)		/* isp16 with 82C929 not detected */
+		return (-1);
 
-  /* restore ctrl port value */
-  ISP16_OUT( ISP16_CTRL_PORT, ctrl );
-  
-  return(2);
+	/* restore ctrl port value */
+	ISP16_OUT(ISP16_CTRL_PORT, ctrl);
+
+	return (2);
 }
 
-static short __init 
+static short __init
 isp16_cdi_config(int base, u_char drive_type, int irq, int dma)
 {
-  u_char base_code;
-  u_char irq_code;
-  u_char dma_code;
-  u_char i;
-
-  if ( (drive_type == ISP16_MITSUMI) && (dma != 0) )
-    printk("ISP16: Mitsumi cdrom drive has no dma support.\n");
-
-  switch (base) {
-  case 0x340: base_code = ISP16_BASE_340; break;
-  case 0x330: base_code = ISP16_BASE_330; break;
-  case 0x360: base_code = ISP16_BASE_360; break;
-  case 0x320: base_code = ISP16_BASE_320; break;
-  default:
-    printk("ISP16: base address 0x%03X not supported by cdrom interface.\n",
-      base);
-    return(-1);
-  }
-  switch (irq) {
-  case 0: irq_code = ISP16_IRQ_X; break; /* disable irq */
-  case 5: irq_code = ISP16_IRQ_5;
-          printk("ISP16: irq 5 shouldn't be used by cdrom interface,"
-            " due to possible conflicts with the sound card.\n");
-          break;
-  case 7: irq_code = ISP16_IRQ_7;
-          printk("ISP16: irq 7 shouldn't be used by cdrom interface,"
-            " due to possible conflicts with the sound card.\n");
-          break;
-  case 3: irq_code = ISP16_IRQ_3; break;
-  case 9: irq_code = ISP16_IRQ_9; break;
-  case 10: irq_code = ISP16_IRQ_10; break;
-  case 11: irq_code = ISP16_IRQ_11; break;
-  default:
-    printk("ISP16: irq %d not supported by cdrom interface.\n", irq );
-    return(-1);
-  }
-  switch (dma) {
-  case 0: dma_code = ISP16_DMA_X; break;  /* disable dma */
-  case 1: printk("ISP16: dma 1 cannot be used by cdrom interface,"
-            " due to conflict with the sound card.\n");
-          return(-1); break;
-  case 3: dma_code = ISP16_DMA_3; break;
-  case 5: dma_code = ISP16_DMA_5; break;
-  case 6: dma_code = ISP16_DMA_6; break;
-  case 7: dma_code = ISP16_DMA_7; break;
-  default:
-    printk("ISP16: dma %d not supported by cdrom interface.\n", dma);
-    return(-1);
-  }
-
-  if ( drive_type != ISP16_SONY && drive_type != ISP16_PANASONIC0 &&
-    drive_type != ISP16_PANASONIC1 && drive_type != ISP16_SANYO0 &&
-    drive_type != ISP16_SANYO1 && drive_type != ISP16_MITSUMI &&
-    drive_type != ISP16_DRIVE_X ) {
-    printk("ISP16: drive type (code 0x%02X) not supported by cdrom"
-     " interface.\n", drive_type );
-    return(-1);
-  }
-
-  /* set type of interface */
-  i = ISP16_IN(ISP16_DRIVE_SET_PORT) & ISP16_DRIVE_SET_MASK;  /* clear some bits */
-  ISP16_OUT( ISP16_DRIVE_SET_PORT, i|drive_type );
-
-  /* enable cdrom on interface with 82C929 chip */
-  if ( isp16_type > 1 )
-    ISP16_OUT( isp16_enable_port, ISP16_ENABLE_CDROM );
-
-  /* set base address, irq and dma */
-  i = ISP16_IN(ISP16_IO_SET_PORT) & ISP16_IO_SET_MASK;  /* keep some bits */
-  ISP16_OUT( ISP16_IO_SET_PORT, i|base_code|irq_code|dma_code );
+	u_char base_code;
+	u_char irq_code;
+	u_char dma_code;
+	u_char i;
+
+	if ((drive_type == ISP16_MITSUMI) && (dma != 0))
+		printk("ISP16: Mitsumi cdrom drive has no dma support.\n");
+
+	switch (base) {
+	case 0x340:
+		base_code = ISP16_BASE_340;
+		break;
+	case 0x330:
+		base_code = ISP16_BASE_330;
+		break;
+	case 0x360:
+		base_code = ISP16_BASE_360;
+		break;
+	case 0x320:
+		base_code = ISP16_BASE_320;
+		break;
+	default:
+		printk
+		    ("ISP16: base address 0x%03X not supported by cdrom interface.\n",
+		     base);
+		return (-1);
+	}
+	switch (irq) {
+	case 0:
+		irq_code = ISP16_IRQ_X;
+		break;		/* disable irq */
+	case 5:
+		irq_code = ISP16_IRQ_5;
+		printk("ISP16: irq 5 shouldn't be used by cdrom interface,"
+		       " due to possible conflicts with the sound card.\n");
+		break;
+	case 7:
+		irq_code = ISP16_IRQ_7;
+		printk("ISP16: irq 7 shouldn't be used by cdrom interface,"
+		       " due to possible conflicts with the sound card.\n");
+		break;
+	case 3:
+		irq_code = ISP16_IRQ_3;
+		break;
+	case 9:
+		irq_code = ISP16_IRQ_9;
+		break;
+	case 10:
+		irq_code = ISP16_IRQ_10;
+		break;
+	case 11:
+		irq_code = ISP16_IRQ_11;
+		break;
+	default:
+		printk("ISP16: irq %d not supported by cdrom interface.\n",
+		       irq);
+		return (-1);
+	}
+	switch (dma) {
+	case 0:
+		dma_code = ISP16_DMA_X;
+		break;		/* disable dma */
+	case 1:
+		printk("ISP16: dma 1 cannot be used by cdrom interface,"
+		       " due to conflict with the sound card.\n");
+		return (-1);
+		break;
+	case 3:
+		dma_code = ISP16_DMA_3;
+		break;
+	case 5:
+		dma_code = ISP16_DMA_5;
+		break;
+	case 6:
+		dma_code = ISP16_DMA_6;
+		break;
+	case 7:
+		dma_code = ISP16_DMA_7;
+		break;
+	default:
+		printk("ISP16: dma %d not supported by cdrom interface.\n",
+		       dma);
+		return (-1);
+	}
+
+	if (drive_type != ISP16_SONY && drive_type != ISP16_PANASONIC0 &&
+	    drive_type != ISP16_PANASONIC1 && drive_type != ISP16_SANYO0 &&
+	    drive_type != ISP16_SANYO1 && drive_type != ISP16_MITSUMI &&
+	    drive_type != ISP16_DRIVE_X) {
+		printk
+		    ("ISP16: drive type (code 0x%02X) not supported by cdrom"
+		     " interface.\n", drive_type);
+		return (-1);
+	}
+
+	/* set type of interface */
+	i = ISP16_IN(ISP16_DRIVE_SET_PORT) & ISP16_DRIVE_SET_MASK;	/* clear some bits */
+	ISP16_OUT(ISP16_DRIVE_SET_PORT, i | drive_type);
+
+	/* enable cdrom on interface with 82C929 chip */
+	if (isp16_type > 1)
+		ISP16_OUT(isp16_enable_port, ISP16_ENABLE_CDROM);
+
+	/* set base address, irq and dma */
+	i = ISP16_IN(ISP16_IO_SET_PORT) & ISP16_IO_SET_MASK;	/* keep some bits */
+	ISP16_OUT(ISP16_IO_SET_PORT, i | base_code | irq_code | dma_code);
 
-  return(0);
+	return (0);
 }
 
 void __exit isp16_exit(void)
@@ -332,4 +368,5 @@
 #endif
 module_exit(isp16_exit);
 
-
+EXPORT_NO_SYMBOLS;
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/cdrom/mcd.c linux/drivers/cdrom/mcd.c
--- v2.4.9/linux/drivers/cdrom/mcd.c	Wed Jul 25 17:10:19 2001
+++ linux/drivers/cdrom/mcd.c	Sun Sep  9 10:43:02 2001
@@ -2,6 +2,7 @@
 	linux/kernel/blk_drv/mcd.c - Mitsumi CDROM driver
 
 	Copyright (C) 1992  Martin Harriss
+	Portions Copyright (C) 2001 Red Hat
 
 	martin@bdsi.com (no longer valid - where are you now, Martin?)
 
@@ -74,7 +75,8 @@
 			 module_init & module_exit.
 			 Torben Mathiasen <tmm@image.dk>
 		
-			 
+	September 2001 - Reformatted and cleaned up the code
+			 Alan Cox <alan@redhat.com>			 
 */
 
 #include <linux/module.h>
@@ -102,14 +104,14 @@
 #define MAJOR_NR MITSUMI_CDROM_MAJOR
 #include <linux/blk.h>
 
-#define mcd_port mcd    /* for compatible parameter passing with "insmod" */
+#define mcd_port mcd		/* for compatible parameter passing with "insmod" */
 #include "mcd.h"
 
 static int mcd_blocksizes[1];
 
 
 /* I added A flag to drop to 1x speed if too many errors 0 = 1X ; 1 = 2X */
-static int mcdDouble; 
+static int mcdDouble;
 
 /* How many sectors to hold at 1x speed counter */
 static int mcd1xhold;
@@ -117,22 +119,8 @@
 /* Is the drive connected properly and responding?? */
 static int mcdPresent;
 
-#if 0
-#define TEST1 /* <int-..> */
-#define TEST2 /* do_mcd_req */
-#define TEST3 */ /* MCD_S_state */
-#define TEST4 /* QUICK_LOOP-counter */
-#define TEST5 */ /* port(1) state */
-#endif
-
-#if 1
-#define QUICK_LOOP_DELAY udelay(45)  /* use udelay */
+#define QUICK_LOOP_DELAY udelay(45)	/* use udelay */
 #define QUICK_LOOP_COUNT 20
-#else
-#define QUICK_LOOP_DELAY
-#define QUICK_LOOP_COUNT 140 /* better wait constant time */
-#endif
-/* #define DOUBLE_QUICK_ONLY */
 
 #define CURRENT_VALID \
 (!QUEUE_EMPTY && MAJOR(CURRENT -> rq_dev) == MAJOR_NR && CURRENT -> cmd == READ \
@@ -141,32 +129,30 @@
 #define MFL_STATUSorDATA (MFL_STATUS | MFL_DATA)
 #define MCD_BUF_SIZ 16
 static volatile int mcd_transfer_is_active;
-static char mcd_buf[2048*MCD_BUF_SIZ];	/* buffer for block size conversion */
+static char mcd_buf[2048 * MCD_BUF_SIZ];	/* buffer for block size conversion */
 static volatile int mcd_buf_bn[MCD_BUF_SIZ], mcd_next_bn;
 static volatile int mcd_buf_in, mcd_buf_out = -1;
 static volatile int mcd_error;
 static int mcd_open_count;
 enum mcd_state_e {
-  MCD_S_IDLE,   /* 0 */
-  MCD_S_START,  /* 1 */
-  MCD_S_MODE, /* 2 */
-  MCD_S_READ,   /* 3 */
-  MCD_S_DATA,   /* 4 */
-  MCD_S_STOP,   /* 5 */
-  MCD_S_STOPPING /* 6 */
+	MCD_S_IDLE,		/* 0 */
+	MCD_S_START,		/* 1 */
+	MCD_S_MODE,		/* 2 */
+	MCD_S_READ,		/* 3 */
+	MCD_S_DATA,		/* 4 */
+	MCD_S_STOP,		/* 5 */
+	MCD_S_STOPPING		/* 6 */
 };
 static volatile enum mcd_state_e mcd_state = MCD_S_IDLE;
 static int mcd_mode = -1;
-static int MCMD_DATA_READ= MCMD_PLAY_READ;
+static int MCMD_DATA_READ = MCMD_PLAY_READ;
+
 #define READ_TIMEOUT 3000
-#define WORK_AROUND_MITSUMI_BUG_92
-#define WORK_AROUND_MITSUMI_BUG_93
-#ifdef WORK_AROUND_MITSUMI_BUG_93
+
 int mitsumi_bug_93_wait;
-#endif /* WORK_AROUND_MITSUMI_BUG_93 */
 
-static short mcd_port = CONFIG_MCD_BASE; /* used as "mcd" by "insmod" */
-static int   mcd_irq  = CONFIG_MCD_IRQ; /* must directly follow mcd_port */
+static short mcd_port = CONFIG_MCD_BASE;	/* used as "mcd" by "insmod" */
+static int mcd_irq = CONFIG_MCD_IRQ;	/* must directly follow mcd_port */
 MODULE_PARM(mcd, "1-2i");
 
 static int McdTimeout, McdTries;
@@ -195,75 +181,58 @@
 static int GetDiskInfo(void);
 static int GetToc(void);
 static int getValue(unsigned char *result);
-static int mcd_open(struct cdrom_device_info * cdi, int purpose);
-static void mcd_release(struct cdrom_device_info * cdi);
-static int mcd_media_changed(struct cdrom_device_info * cdi, int disc_nr);
-static int mcd_tray_move(struct cdrom_device_info * cdi, int position);
-int mcd_audio_ioctl(struct cdrom_device_info * cdi, unsigned int cmd,
-                      void * arg);
-int mcd_drive_status(struct cdrom_device_info * cdi, int slot_nr);
+static int mcd_open(struct cdrom_device_info *cdi, int purpose);
+static void mcd_release(struct cdrom_device_info *cdi);
+static int mcd_media_changed(struct cdrom_device_info *cdi, int disc_nr);
+static int mcd_tray_move(struct cdrom_device_info *cdi, int position);
+int mcd_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
+		    void *arg);
+int mcd_drive_status(struct cdrom_device_info *cdi, int slot_nr);
 
 static struct timer_list mcd_timer;
 
 static struct cdrom_device_ops mcd_dops = {
-	open:			mcd_open,
-	release:		mcd_release,
-	drive_status:		mcd_drive_status,
-	media_changed:		mcd_media_changed,
-	tray_move:		mcd_tray_move,
-	audio_ioctl:		mcd_audio_ioctl,
-	capability:		CDC_OPEN_TRAY | CDC_MEDIA_CHANGED |
-				CDC_PLAY_AUDIO | CDC_DRIVE_STATUS,
+	open:mcd_open,
+	release:mcd_release,
+	drive_status:mcd_drive_status,
+	media_changed:mcd_media_changed,
+	tray_move:mcd_tray_move,
+	audio_ioctl:mcd_audio_ioctl,
+	capability:CDC_OPEN_TRAY | CDC_MEDIA_CHANGED |
+	    CDC_PLAY_AUDIO | CDC_DRIVE_STATUS,
 };
 
 static struct cdrom_device_info mcd_info = {
-	ops:			&mcd_dops,
-	speed:			2,
-	capacity:		1,
-	name:			"mcd",
+	ops:&mcd_dops,
+	speed:2,
+	capacity:1,
+	name:"mcd",
 };
 
 #ifndef MODULE
 static int __init mcd_setup(char *str)
 {
-   int ints[9];
-   
-   (void)get_options(str, ARRAY_SIZE(ints), ints);
-   
-   if (ints[0] > 0)
-      mcd_port = ints[1];
-   if (ints[0] > 1)      
-      mcd_irq  = ints[2];
-#ifdef WORK_AROUND_MITSUMI_BUG_93
-   if (ints[0] > 2)
-      mitsumi_bug_93_wait = ints[3];
-#endif /* WORK_AROUND_MITSUMI_BUG_93 */
+	int ints[9];
+
+	(void) get_options(str, ARRAY_SIZE(ints), ints);
 
- return 1;
+	if (ints[0] > 0)
+		mcd_port = ints[1];
+	if (ints[0] > 1)
+		mcd_irq = ints[2];
+	if (ints[0] > 2)
+		mitsumi_bug_93_wait = ints[3];
+
+	return 1;
 }
 
 __setup("mcd=", mcd_setup);
 
-#endif /* MODULE */ 
+#endif				/* MODULE */
 
-static int mcd_media_changed(struct cdrom_device_info * cdi, int disc_nr)
+static int mcd_media_changed(struct cdrom_device_info *cdi, int disc_nr)
 {
-   int retval;
-
-
-#if 1	 /* the below is not reliable */
-   return 0;
-#endif  
-
-   if (cdi->dev) {
-      printk("mcd: Mitsumi CD-ROM request error: invalid device.\n");
-      return 0;
-   }
-
-   retval = mcdDiskChanged;
-   mcdDiskChanged = 0;
-
-   return retval;
+	return 0;
 }
 
 
@@ -272,18 +241,17 @@
  * because it calls 'getMcdStatus' which sleeps.
  */
 
-static int
-statusCmd(void)
+static int statusCmd(void)
 {
 	int st = -1, retry;
 
-	for (retry = 0; retry < MCD_RETRY_ATTEMPTS; retry++)
-	{
-		outb(MCMD_GET_STATUS, MCDPORT(0));    /* send get-status cmd */
+	for (retry = 0; retry < MCD_RETRY_ATTEMPTS; retry++) {
+		/* send get-status cmd */
+		outb(MCMD_GET_STATUS, MCDPORT(0));
 
 		st = getMcdStatus(MCD_STATUS_DELAY);
-		if (st != -1) 
-        		break;
+		if (st != -1)
+			break;
 	}
 
 	return st;
@@ -294,13 +262,11 @@
  * Send a 'Play' command and get the status.  Use only from the top half.
  */
 
-static int
-mcdPlay(struct mcd_Play_msf *arg)
+static int mcdPlay(struct mcd_Play_msf *arg)
 {
 	int retry, st = -1;
 
-	for (retry = 0; retry < MCD_RETRY_ATTEMPTS; retry++)
-	{
+	for (retry = 0; retry < MCD_RETRY_ATTEMPTS; retry++) {
 		sendMcdCmd(MCMD_PLAY_READ, arg);
 		st = getMcdStatus(2 * MCD_STATUS_DELAY);
 		if (st != -1)
@@ -311,45 +277,39 @@
 }
 
 
-static int 
-mcd_tray_move(struct cdrom_device_info * cdi, int position)
+static int mcd_tray_move(struct cdrom_device_info *cdi, int position)
 {
 	int i;
 	if (position) {
-	/*  Eject */
-       		/* all drives can at least stop! */
+		/*  Eject */
+		/* all drives can at least stop! */
 		if (audioStatus == CDROM_AUDIO_PLAY) {
-	  	outb(MCMD_STOP, MCDPORT(0));
-	  	i = getMcdStatus(MCD_STATUS_DELAY);
+			outb(MCMD_STOP, MCDPORT(0));
+			i = getMcdStatus(MCD_STATUS_DELAY);
 		}
 
-                audioStatus = CDROM_AUDIO_NO_STATUS;
+		audioStatus = CDROM_AUDIO_NO_STATUS;
 
-                outb(MCMD_EJECT, MCDPORT(0));
-                /*
-                 * the status (i) shows failure on all but the FX drives.
-                 * But nothing we can do about that in software!
-                 * So just read the status and forget it. - Jon.
-                 */
-                i = getMcdStatus(MCD_STATUS_DELAY);
-                return 0;
-	}
-	else 
+		outb(MCMD_EJECT, MCDPORT(0));
+		/*
+		 * the status (i) shows failure on all but the FX drives.
+		 * But nothing we can do about that in software!
+		 * So just read the status and forget it. - Jon.
+		 */
+		i = getMcdStatus(MCD_STATUS_DELAY);
+		return 0;
+	} else
 		return -EINVAL;
 }
 
-long
-msf2hsg(struct msf *mp)
+long msf2hsg(struct msf *mp)
 {
-	return bcd2bin(mp -> frame)
-		+ bcd2bin(mp -> sec) * 75
-		+ bcd2bin(mp -> min) * 4500
-		- 150;
+	return bcd2bin(mp->frame) + bcd2bin(mp->sec) * 75 + bcd2bin(mp->min) * 4500 - 150;
 }
 
 
-int mcd_audio_ioctl(struct cdrom_device_info * cdi, unsigned int cmd,
-                      void * arg)
+int mcd_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
+		    void *arg)
 {
 	int i, st;
 	struct mcd_Toc qInfo;
@@ -365,24 +325,22 @@
 	if (st < 0)
 		return -EIO;
 
-	if (!tocUpToDate)
-	{
+	if (!tocUpToDate) {
 		i = updateToc();
-		if (i < 0) 
+		if (i < 0)
 			return i;	/* error reading TOC */
 	}
 
-	switch (cmd)
-	{
-	case CDROMSTART:     /* Spin up the drive */
+	switch (cmd) {
+	case CDROMSTART:	/* Spin up the drive */
 		/* Don't think we can do this.  Even if we could,
- 		 * I think the drive times out and stops after a while
+		 * I think the drive times out and stops after a while
 		 * anyway.  For now, ignore it.
 		 */
 
 		return 0;
 
-	case CDROMSTOP:      /* Spin down the drive */
+	case CDROMSTOP:	/* Spin down the drive */
 		outb(MCMD_STOP, MCDPORT(0));
 		i = getMcdStatus(MCD_STATUS_DELAY);
 
@@ -391,15 +349,14 @@
 		audioStatus = CDROM_AUDIO_NO_STATUS;
 		return 0;
 
-	case CDROMPAUSE:     /* Pause the drive */
+	case CDROMPAUSE:	/* Pause the drive */
 		if (audioStatus != CDROM_AUDIO_PLAY)
 			return -EINVAL;
 
 		outb(MCMD_STOP, MCDPORT(0));
 		i = getMcdStatus(MCD_STATUS_DELAY);
 
-		if (GetQChannelInfo(&qInfo) < 0)
-		{
+		if (GetQChannelInfo(&qInfo) < 0) {
 			/* didn't get q channel info */
 
 			audioStatus = CDROM_AUDIO_NO_STATUS;
@@ -411,15 +368,14 @@
 		audioStatus = CDROM_AUDIO_PAUSED;
 		return 0;
 
-	case CDROMRESUME:    /* Play it again, Sam */
+	case CDROMRESUME:	/* Play it again, Sam */
 		if (audioStatus != CDROM_AUDIO_PAUSED)
 			return -EINVAL;
 
 		/* restart the drive at the saved position. */
 
 		i = mcdPlay(&mcd_Play);
-		if (i < 0)
-		{
+		if (i < 0) {
 			audioStatus = CDROM_AUDIO_ERROR;
 			return -EIO;
 		}
@@ -427,14 +383,13 @@
 		audioStatus = CDROM_AUDIO_PLAY;
 		return 0;
 
-	case CDROMPLAYTRKIND:     /* Play a track.  This currently ignores index. */
+	case CDROMPLAYTRKIND:	/* Play a track.  This currently ignores index. */
 
-		ti=(struct cdrom_ti *) arg;
+		ti = (struct cdrom_ti *) arg;
 
 		if (ti->cdti_trk0 < DiskInfo.first
-			|| ti->cdti_trk0 > DiskInfo.last
-			|| ti->cdti_trk1 < ti->cdti_trk0)
-		{
+		    || ti->cdti_trk0 > DiskInfo.last
+		    || ti->cdti_trk1 < ti->cdti_trk0) {
 			return -EINVAL;
 		}
 
@@ -445,14 +400,14 @@
 		mcd_Play.end = Toc[ti->cdti_trk1 + 1].diskTime;
 
 #ifdef MCD_DEBUG
-printk("play: %02x:%02x.%02x to %02x:%02x.%02x\n",
-	mcd_Play.start.min, mcd_Play.start.sec, mcd_Play.start.frame,
-	mcd_Play.end.min, mcd_Play.end.sec, mcd_Play.end.frame);
+		printk("play: %02x:%02x.%02x to %02x:%02x.%02x\n",
+		       mcd_Play.start.min, mcd_Play.start.sec,
+		       mcd_Play.start.frame, mcd_Play.end.min,
+		       mcd_Play.end.sec, mcd_Play.end.frame);
 #endif
 
 		i = mcdPlay(&mcd_Play);
-		if (i < 0)
-		{
+		if (i < 0) {
 			audioStatus = CDROM_AUDIO_ERROR;
 			return -EIO;
 		}
@@ -460,15 +415,15 @@
 		audioStatus = CDROM_AUDIO_PLAY;
 		return 0;
 
-	case CDROMPLAYMSF:   /* Play starting at the given MSF address. */
+	case CDROMPLAYMSF:	/* Play starting at the given MSF address. */
 
 		if (audioStatus == CDROM_AUDIO_PLAY) {
-		  outb(MCMD_STOP, MCDPORT(0));
-		  i = getMcdStatus(MCD_STATUS_DELAY);
-		  audioStatus = CDROM_AUDIO_NO_STATUS;
+			outb(MCMD_STOP, MCDPORT(0));
+			i = getMcdStatus(MCD_STATUS_DELAY);
+			audioStatus = CDROM_AUDIO_NO_STATUS;
 		}
 
-		msf=(struct cdrom_msf *) arg;
+		msf = (struct cdrom_msf *) arg;
 
 		/* convert to bcd */
 
@@ -487,14 +442,14 @@
 		mcd_Play.end.frame = msf->cdmsf_frame1;
 
 #ifdef MCD_DEBUG
-printk("play: %02x:%02x.%02x to %02x:%02x.%02x\n",
-mcd_Play.start.min, mcd_Play.start.sec, mcd_Play.start.frame,
-mcd_Play.end.min, mcd_Play.end.sec, mcd_Play.end.frame);
+		printk("play: %02x:%02x.%02x to %02x:%02x.%02x\n",
+		       mcd_Play.start.min, mcd_Play.start.sec,
+		       mcd_Play.start.frame, mcd_Play.end.min,
+		       mcd_Play.end.sec, mcd_Play.end.frame);
 #endif
 
 		i = mcdPlay(&mcd_Play);
-		if (i < 0)
-		{
+		if (i < 0) {
 			audioStatus = CDROM_AUDIO_ERROR;
 			return -EIO;
 		}
@@ -502,35 +457,37 @@
 		audioStatus = CDROM_AUDIO_PLAY;
 		return 0;
 
-	case CDROMREADTOCHDR:        /* Read the table of contents header */
-	        tocHdr=(struct cdrom_tochdr *) arg; 
+	case CDROMREADTOCHDR:	/* Read the table of contents header */
+		tocHdr = (struct cdrom_tochdr *) arg;
 		tocHdr->cdth_trk0 = DiskInfo.first;
 		tocHdr->cdth_trk1 = DiskInfo.last;
 		return 0;
 
-	case CDROMREADTOCENTRY:      /* Read an entry in the table of contents */
-		entry=(struct cdrom_tocentry *) arg;
+	case CDROMREADTOCENTRY:	/* Read an entry in the table of contents */
+		entry = (struct cdrom_tocentry *) arg;
 		if (entry->cdte_track == CDROM_LEADOUT)
 			tocPtr = &Toc[DiskInfo.last - DiskInfo.first + 1];
 
 		else if (entry->cdte_track > DiskInfo.last
-				|| entry->cdte_track < DiskInfo.first)
+			 || entry->cdte_track < DiskInfo.first)
 			return -EINVAL;
 
 		else
 			tocPtr = &Toc[entry->cdte_track];
 
-		entry->cdte_adr = tocPtr -> ctrl_addr;
-		entry->cdte_ctrl = tocPtr -> ctrl_addr >> 4;
+		entry->cdte_adr = tocPtr->ctrl_addr;
+		entry->cdte_ctrl = tocPtr->ctrl_addr >> 4;
 
 		if (entry->cdte_format == CDROM_LBA)
-			entry->cdte_addr.lba = msf2hsg(&tocPtr -> diskTime);
+			entry->cdte_addr.lba = msf2hsg(&tocPtr->diskTime);
 
-		else if (entry->cdte_format == CDROM_MSF)
-		{
-			entry->cdte_addr.msf.minute = bcd2bin(tocPtr -> diskTime.min);
-			entry->cdte_addr.msf.second = bcd2bin(tocPtr -> diskTime.sec);
-			entry->cdte_addr.msf.frame = bcd2bin(tocPtr -> diskTime.frame);
+		else if (entry->cdte_format == CDROM_MSF) {
+			entry->cdte_addr.msf.minute =
+			    bcd2bin(tocPtr->diskTime.min);
+			entry->cdte_addr.msf.second =
+			    bcd2bin(tocPtr->diskTime.sec);
+			entry->cdte_addr.msf.frame =
+			    bcd2bin(tocPtr->diskTime.frame);
 		}
 
 		else
@@ -538,9 +495,9 @@
 
 		return 0;
 
-	case CDROMSUBCHNL:   /* Get subchannel info */
+	case CDROMSUBCHNL:	/* Get subchannel info */
 
-                subchnl=(struct cdrom_subchnl *) arg;
+		subchnl = (struct cdrom_subchnl *) arg;
 		if (GetQChannelInfo(&qInfo) < 0)
 			return -EIO;
 
@@ -551,14 +508,14 @@
 		subchnl->cdsc_ind = bcd2bin(qInfo.pointIndex);
 		subchnl->cdsc_absaddr.msf.minute = bcd2bin(qInfo.diskTime.min);
 		subchnl->cdsc_absaddr.msf.second = bcd2bin(qInfo.diskTime.sec);
-		subchnl->cdsc_absaddr.msf.frame = bcd2bin(qInfo.diskTime.frame);
+		subchnl->cdsc_absaddr.msf.frame  = bcd2bin(qInfo.diskTime.frame);
 		subchnl->cdsc_reladdr.msf.minute = bcd2bin(qInfo.trackTime.min);
 		subchnl->cdsc_reladdr.msf.second = bcd2bin(qInfo.trackTime.sec);
-		subchnl->cdsc_reladdr.msf.frame = bcd2bin(qInfo.trackTime.frame);
-		return(0);
+		subchnl->cdsc_reladdr.msf.frame  = bcd2bin(qInfo.trackTime.frame);
+		return (0);
 
-	case CDROMVOLCTRL:   /* Volume control */
-		volctrl=(struct cdrom_volctrl *) arg;
+	case CDROMVOLCTRL:	/* Volume control */
+		volctrl = (struct cdrom_volctrl *) arg;
 		outb(MCMD_SET_VOLUME, MCDPORT(0));
 		outb(volctrl->channel0, MCDPORT(0));
 		outb(255, MCDPORT(0));
@@ -590,37 +547,37 @@
  * When Linux gets variable block sizes this will probably go away.
  */
 
-static void
-mcd_transfer(void)
+static void mcd_transfer(void)
 {
-  if (CURRENT_VALID) {
-    while (CURRENT -> nr_sectors) {
-      int bn = CURRENT -> sector / 4;
-      int i;
-      for (i = 0; i < MCD_BUF_SIZ && mcd_buf_bn[i] != bn; ++i)
-	;
-      if (i < MCD_BUF_SIZ) {
-	int offs = (i * 4 + (CURRENT -> sector & 3)) * 512;
-	int nr_sectors = 4 - (CURRENT -> sector & 3);
-	if (mcd_buf_out != i) {
-	  mcd_buf_out = i;
-	  if (mcd_buf_bn[i] != bn) {
-	    mcd_buf_out = -1;
-	    continue;
-	  }
-	}
-	if (nr_sectors > CURRENT -> nr_sectors)
-	  nr_sectors = CURRENT -> nr_sectors;
-	memcpy(CURRENT -> buffer, mcd_buf + offs, nr_sectors * 512);
-	CURRENT -> nr_sectors -= nr_sectors;
-	CURRENT -> sector += nr_sectors;
-	CURRENT -> buffer += nr_sectors * 512;
-      } else {
-	mcd_buf_out = -1;
-	break;
-      }
-    }
-  }
+	if (CURRENT_VALID) {
+		while (CURRENT->nr_sectors) {
+			int bn = CURRENT->sector / 4;
+			int i;
+			for (i = 0; i < MCD_BUF_SIZ && mcd_buf_bn[i] != bn;
+			     ++i);
+			if (i < MCD_BUF_SIZ) {
+				int offs =(i * 4 + (CURRENT->sector & 3)) * 512;
+				int nr_sectors = 4 - (CURRENT->sector & 3);
+				if (mcd_buf_out != i) {
+					mcd_buf_out = i;
+					if (mcd_buf_bn[i] != bn) {
+						mcd_buf_out = -1;
+						continue;
+					}
+				}
+				if (nr_sectors > CURRENT->nr_sectors)
+					nr_sectors = CURRENT->nr_sectors;
+				memcpy(CURRENT->buffer, mcd_buf + offs,
+				       nr_sectors * 512);
+				CURRENT->nr_sectors -= nr_sectors;
+				CURRENT->sector += nr_sectors;
+				CURRENT->buffer += nr_sectors * 512;
+			} else {
+				mcd_buf_out = -1;
+				break;
+			}
+		}
+	}
 }
 
 
@@ -629,500 +586,423 @@
  * Just take the interrupt and clear out the status reg.
  */
 
-static void
-mcd_interrupt(int irq, void *dev_id, struct pt_regs * regs)
+static void mcd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	int st;
 
 	st = inb(MCDPORT(1)) & 0xFF;
-#ifdef TEST1
-		printk("<int1-%02X>", st);
-#endif
-	if (!(st & MFL_STATUS))
-	{
+	test1(printk("<int1-%02X>", st));
+	if (!(st & MFL_STATUS)) {
 		st = inb(MCDPORT(0)) & 0xFF;
-#ifdef TEST1
-		printk("<int0-%02X>", st);
-#endif
+		test1(printk("<int0-%02X>", st));
 		if ((st & 0xFF) != 0xFF)
-		  mcd_error = st ? st & 0xFF : -1;
+			mcd_error = st ? st & 0xFF : -1;
 	}
 }
 
 
-static void
-do_mcd_request(request_queue_t * q)
+static void do_mcd_request(request_queue_t * q)
 {
-#ifdef TEST2
-  printk(" do_mcd_request(%ld+%ld)\n", CURRENT -> sector, CURRENT -> nr_sectors);
-#endif
-  mcd_transfer_is_active = 1;
-  while (CURRENT_VALID) {
-    if (CURRENT->bh) {
-      if (!buffer_locked(CURRENT->bh))
-	panic(DEVICE_NAME ": block not locked");
-    }
-    mcd_transfer();
-    if (CURRENT -> nr_sectors == 0) {
-      end_request(1);
-    } else {
-      mcd_buf_out = -1;		/* Want to read a block not in buffer */
-      if (mcd_state == MCD_S_IDLE) {
-	if (!tocUpToDate) {
-	  if (updateToc() < 0) {
-	    while (CURRENT_VALID)
-	      end_request(0);
-	    break;
-	  }
-	}
-	mcd_state = MCD_S_START;
-	McdTries = 5;
-	SET_TIMER(mcd_poll, 1);
-      }
-      break;
-    }
-  }
-  mcd_transfer_is_active = 0;
-#ifdef TEST2
-  printk(" do_mcd_request ends\n");
-#endif
+	test2(printk(" do_mcd_request(%ld+%ld)\n", CURRENT->sector,
+	       CURRENT->nr_sectors));
+
+		mcd_transfer_is_active = 1;
+	while (CURRENT_VALID) {
+		if (CURRENT->bh) {
+			if (!buffer_locked(CURRENT->bh))
+				panic(DEVICE_NAME ": block not locked");
+		}
+		mcd_transfer();
+		if (CURRENT->nr_sectors == 0) {
+			end_request(1);
+		} else {
+			mcd_buf_out = -1;	/* Want to read a block not in buffer */
+			if (mcd_state == MCD_S_IDLE) {
+				if (!tocUpToDate) {
+					if (updateToc() < 0) {
+						while (CURRENT_VALID)
+							end_request(0);
+						break;
+					}
+				}
+				mcd_state = MCD_S_START;
+				McdTries = 5;
+				mcd_timer.function = mcd_poll;
+				mod_timer(&mcd_timer, jiffies + 1);
+			}
+			break;
+		}
+	}
+	mcd_transfer_is_active = 0;
+	test2(printk(" do_mcd_request ends\n"));
 }
 
 
 
-static void
-mcd_poll(unsigned long dummy)
+static void mcd_poll(unsigned long dummy)
 {
-  int st;
+	int st;
 
 
-  if (mcd_error) 
-  {
-    if (mcd_error & 0xA5) 
-    {
-      printk("mcd: I/O error 0x%02x", mcd_error);
-      if (mcd_error & 0x80)
-	printk(" (Door open)");
-      if (mcd_error & 0x20)
-	printk(" (Disk changed)");
-      if (mcd_error & 0x04)
-	{
-	printk(" (Read error)"); /* Bitch about the problem. */
-	
-	/* Time to get fancy! If at 2x speed and 1 error, drop to 1x speed! */
-	/* Interesting how it STAYS at MCD_RETRY_ATTEMPTS on first error! */
-	/* But I find that rather HANDY!!! */
-	/* Neat! it REALLY WORKS on those LOW QUALITY CD's!!! Smile! :) */
-	/* AJK [06/17/95] */
-	
-	/* Slap the CD down to single speed! */
-	if (mcdDouble == 1 && McdTries == MCD_RETRY_ATTEMPTS && MCMD_DATA_READ == MCMD_2X_READ) 
-		{
-		MCMD_DATA_READ = MCMD_PLAY_READ; /* Uhhh, Ummmm, muhuh-huh! */
-		mcd1xhold = SINGLE_HOLD_SECTORS; /* Hey Beavis! */
-		printk(" Speed now 1x");	 /* Pull my finger! */
+	if (mcd_error) {
+		if (mcd_error & 0xA5) {
+			printk(KERN_ERR "mcd: I/O error 0x%02x", mcd_error);
+			if (mcd_error & 0x80)
+				printk(" (Door open)");
+			if (mcd_error & 0x20)
+				printk(" (Disk changed)");
+			if (mcd_error & 0x04) {
+				printk(" (Read error)");	/* Bitch about the problem. */
+
+				/* Time to get fancy! If at 2x speed and 1 error, drop to 1x speed! */
+				/* Interesting how it STAYS at MCD_RETRY_ATTEMPTS on first error! */
+				/* But I find that rather HANDY!!! */
+				/* Neat! it REALLY WORKS on those LOW QUALITY CD's!!! Smile! :) */
+				/* AJK [06/17/95] */
+
+				/* Slap the CD down to single speed! */
+				if (mcdDouble == 1
+				    && McdTries == MCD_RETRY_ATTEMPTS
+				    && MCMD_DATA_READ == MCMD_2X_READ) {
+					MCMD_DATA_READ = MCMD_PLAY_READ;	/* Uhhh, Ummmm, muhuh-huh! */
+					mcd1xhold = SINGLE_HOLD_SECTORS;	/* Hey Beavis! */
+					printk(" Speed now 1x");	/* Pull my finger! */
+				}
+			}
+			printk("\n");
+			mcd_invalidate_buffers();
+#ifdef WARN_IF_READ_FAILURE
+			if (McdTries == MCD_RETRY_ATTEMPTS)
+				printk(KERN_ERR "mcd: read of block %d failed\n",
+				       mcd_next_bn);
+#endif
+			if (!McdTries--) {
+				/* Nuts! This cd is ready for recycling! */
+				/* When WAS the last time YOU cleaned it CORRECTLY?! */
+				printk(KERN_ERR "mcd: read of block %d failed, giving up\n",
+				     mcd_next_bn);
+				if (mcd_transfer_is_active) {
+					McdTries = 0;
+					goto ret;
+				}
+				if (CURRENT_VALID)
+					end_request(0);
+				McdTries = MCD_RETRY_ATTEMPTS;
+			}
 		}
+		mcd_error = 0;
+		mcd_state = MCD_S_STOP;
 	}
-      printk("\n");
-      mcd_invalidate_buffers();
-#ifdef WARN_IF_READ_FAILURE
-      if (McdTries == MCD_RETRY_ATTEMPTS)
-	printk("mcd: read of block %d failed\n", mcd_next_bn);
-#endif
-      if (!McdTries--) 
-        {
-	/* Nuts! This cd is ready for recycling! */
-	/* When WAS the last time YOU cleaned it CORRECTLY?! */
-	printk("mcd: read of block %d failed, giving up\n", mcd_next_bn);
-	if (mcd_transfer_is_active) 
-	{
-	  McdTries = 0;
-	  goto ret;
-	}
-	if (CURRENT_VALID)
-	  end_request(0);
-	McdTries = MCD_RETRY_ATTEMPTS;
-      }
-    }
-    mcd_error = 0;
-    mcd_state = MCD_S_STOP;
-  }
 	/* Switch back to Double speed if enough GOOD sectors were read! */
-	
-	/* Are we a double speed with a crappy CD?! */
-    if (mcdDouble == 1 && McdTries == MCD_RETRY_ATTEMPTS && MCMD_DATA_READ == MCMD_PLAY_READ)
-    	{
-	/* We ARE a double speed and we ARE bitching! */
-	if (mcd1xhold == 0) /* Okay, Like are we STILL at single speed? */
-		{ /* We need to switch back to double speed now... */
-		MCMD_DATA_READ = MCMD_2X_READ; /* Uhhh... BACK You GO! */
-		printk("mcd: Switching back to 2X speed!\n"); /* Tell 'em! */
-		}
-	else mcd1xhold--; /* No?! Count down the good reads some more... */
-				/* and try, try again! */
-    	}
-
-
-
- immediately:
-  switch (mcd_state) {
-
 
+	/* Are we a double speed with a crappy CD?! */
+	if (mcdDouble == 1 && McdTries == MCD_RETRY_ATTEMPTS
+	    && MCMD_DATA_READ == MCMD_PLAY_READ) {
+		/* We ARE a double speed and we ARE bitching! */
+		if (mcd1xhold == 0) {	/* Okay, Like are we STILL at single speed? *//* We need to switch back to double speed now... */
+			MCMD_DATA_READ = MCMD_2X_READ;	/* Uhhh... BACK You GO! */
+			printk(KERN_INFO "mcd: Switching back to 2X speed!\n");	/* Tell 'em! */
+		} else
+			mcd1xhold--;	/* No?! Count down the good reads some more... */
+		/* and try, try again! */
+	}
+
+immediately:
+	switch (mcd_state) {
+	case MCD_S_IDLE:
+		test3(printk("MCD_S_IDLE\n"));
+		goto out;
+
+	case MCD_S_START:
+		test3(printk("MCD_S_START\n"));
+		outb(MCMD_GET_STATUS, MCDPORT(0));
+		mcd_state = mcd_mode == 1 ? MCD_S_READ : MCD_S_MODE;
+		McdTimeout = 3000;
+		break;
+
+	case MCD_S_MODE:
+		test3(printk("MCD_S_MODE\n"));
+		if ((st = mcdStatus()) != -1) {
+			if (st & MST_DSK_CHG) {
+				mcdDiskChanged = 1;
+				tocUpToDate = 0;
+				mcd_invalidate_buffers();
+			}
 
-  case MCD_S_IDLE:
-#ifdef TEST3
-    printk("MCD_S_IDLE\n");
-#endif
-    goto out;
-
-
-
-  case MCD_S_START:
-#ifdef TEST3
-    printk("MCD_S_START\n");
-#endif
-
-    outb(MCMD_GET_STATUS, MCDPORT(0));
-    mcd_state = mcd_mode == 1 ? MCD_S_READ : MCD_S_MODE;
-    McdTimeout = 3000;
-    break;
-
-
-
-  case MCD_S_MODE:
-#ifdef TEST3
-    printk("MCD_S_MODE\n");
-#endif
-
-    if ((st = mcdStatus()) != -1) {
-
-      if (st & MST_DSK_CHG) {
-	mcdDiskChanged = 1;
-	tocUpToDate = 0;
-	mcd_invalidate_buffers();
-      }
-
-    set_mode_immediately:
-
-      if ((st & MST_DOOR_OPEN) || !(st & MST_READY)) {
-	mcdDiskChanged = 1;
-	tocUpToDate = 0;
-	if (mcd_transfer_is_active) {
-	  mcd_state = MCD_S_START;
-	  goto immediately;
-	}
-	printk((st & MST_DOOR_OPEN) ? "mcd: door open\n" : "mcd: disk removed\n");
-	mcd_state = MCD_S_IDLE;
-	while (CURRENT_VALID)
-	  end_request(0);
-	goto out;
-      }
-
-      outb(MCMD_SET_MODE, MCDPORT(0));
-      outb(1, MCDPORT(0));
-      mcd_mode = 1;
-      mcd_state = MCD_S_READ;
-      McdTimeout = 3000;
-
-    }
-    break;
-
+set_mode_immediately:
+			if ((st & MST_DOOR_OPEN) || !(st & MST_READY)) {
+				mcdDiskChanged = 1;
+				tocUpToDate = 0;
+				if (mcd_transfer_is_active) {
+					mcd_state = MCD_S_START;
+					goto immediately;
+				}
+				printk(KERN_INFO);
+				printk((st & MST_DOOR_OPEN) ?
+				       "mcd: door open\n" :
+				       "mcd: disk removed\n");
+				mcd_state = MCD_S_IDLE;
+				while (CURRENT_VALID)
+					end_request(0);
+				goto out;
+			}
+			outb(MCMD_SET_MODE, MCDPORT(0));
+			outb(1, MCDPORT(0));
+			mcd_mode = 1;
+			mcd_state = MCD_S_READ;
+			McdTimeout = 3000;
+		}
+		break;
 
+	case MCD_S_READ:
+		test3(printk("MCD_S_READ\n"));
+		if ((st = mcdStatus()) != -1) {
+			if (st & MST_DSK_CHG) {
+				mcdDiskChanged = 1;
+				tocUpToDate = 0;
+				mcd_invalidate_buffers();
+			}
 
-  case MCD_S_READ:
-#ifdef TEST3
-    printk("MCD_S_READ\n");
-#endif
+read_immediately:
+			if ((st & MST_DOOR_OPEN) || !(st & MST_READY)) {
+				mcdDiskChanged = 1;
+				tocUpToDate = 0;
+				if (mcd_transfer_is_active) {
+					mcd_state = MCD_S_START;
+					goto immediately;
+				}
+				printk(KERN_INFO);
+				printk((st & MST_DOOR_OPEN) ?
+				       "mcd: door open\n" :
+				       "mcd: disk removed\n");
+				mcd_state = MCD_S_IDLE;
+				while (CURRENT_VALID)
+					end_request(0);
+				goto out;
+			}
 
-    if ((st = mcdStatus()) != -1) {
+			if (CURRENT_VALID) {
+				struct mcd_Play_msf msf;
+				mcd_next_bn = CURRENT->sector / 4;
+				hsg2msf(mcd_next_bn, &msf.start);
+				msf.end.min = ~0;
+				msf.end.sec = ~0;
+				msf.end.frame = ~0;
+				sendMcdCmd(MCMD_DATA_READ, &msf);
+				mcd_state = MCD_S_DATA;
+				McdTimeout = READ_TIMEOUT;
+			} else {
+				mcd_state = MCD_S_STOP;
+				goto immediately;
+			}
 
-      if (st & MST_DSK_CHG) {
-	mcdDiskChanged = 1;
-	tocUpToDate = 0;
-	mcd_invalidate_buffers();
-      }
+		}
+		break;
 
-    read_immediately:
+	case MCD_S_DATA:
+		test3(printk("MCD_S_DATA\n"));
+		st = inb(MCDPORT(1)) & (MFL_STATUSorDATA);
+data_immediately:
+		test5(printk("Status %02x\n", st))
+		switch (st) {
+		case MFL_DATA:
+#ifdef WARN_IF_READ_FAILURE
+			if (McdTries == 5)
+				printk(KERN_WARNING "mcd: read of block %d failed\n",
+				       mcd_next_bn);
+#endif
+			if (!McdTries--) {
+				printk(KERN_ERR "mcd: read of block %d failed, giving up\n", mcd_next_bn);
+				if (mcd_transfer_is_active) {
+					McdTries = 0;
+					break;
+				}
+				if (CURRENT_VALID)
+					end_request(0);
+				McdTries = 5;
+			}
+			mcd_state = MCD_S_START;
+			McdTimeout = READ_TIMEOUT;
+			goto immediately;
 
-      if ((st & MST_DOOR_OPEN) || !(st & MST_READY)) {
-	mcdDiskChanged = 1;
-	tocUpToDate = 0;
-	if (mcd_transfer_is_active) {
-	  mcd_state = MCD_S_START;
-	  goto immediately;
-	}
-	printk((st & MST_DOOR_OPEN) ? "mcd: door open\n" : "mcd: disk removed\n");
-	mcd_state = MCD_S_IDLE;
-	while (CURRENT_VALID)
-	  end_request(0);
-	goto out;
-      }
-
-      if (CURRENT_VALID) {
-	struct mcd_Play_msf msf;
-	mcd_next_bn = CURRENT -> sector / 4;
-	hsg2msf(mcd_next_bn, &msf.start);
-	msf.end.min = ~0;
-	msf.end.sec = ~0;
-	msf.end.frame = ~0;
-	sendMcdCmd(MCMD_DATA_READ, &msf);
-	mcd_state = MCD_S_DATA;
-	McdTimeout = READ_TIMEOUT;
-      } else {
-	mcd_state = MCD_S_STOP;
-	goto immediately;
-      }
-
-    }
-    break;
-
-
-  case MCD_S_DATA:
-#ifdef TEST3
-    printk("MCD_S_DATA\n");
-#endif
+		case MFL_STATUSorDATA:
+			break;
 
-    st = inb(MCDPORT(1)) & (MFL_STATUSorDATA);
-  data_immediately:
-#ifdef TEST5
-    printk("Status %02x\n",st);
-#endif
-    switch (st) {
+		default:
+			McdTries = 5;
+			if (!CURRENT_VALID && mcd_buf_in == mcd_buf_out) {
+				mcd_state = MCD_S_STOP;
+				goto immediately;
+			}
+			mcd_buf_bn[mcd_buf_in] = -1;
+			insb(MCDPORT(0), mcd_buf + 2048 * mcd_buf_in,
+				  2048);
+			mcd_buf_bn[mcd_buf_in] = mcd_next_bn++;
+			if (mcd_buf_out == -1)
+				mcd_buf_out = mcd_buf_in;
+			mcd_buf_in = mcd_buf_in + 1 == MCD_BUF_SIZ ? 0 : mcd_buf_in + 1;
+			if (!mcd_transfer_is_active) {
+				while (CURRENT_VALID) {
+					mcd_transfer();
+					if (CURRENT->nr_sectors == 0)
+						end_request(1);
+					else
+						break;
+				}
+			}
 
-    case MFL_DATA:
-#ifdef WARN_IF_READ_FAILURE
-      if (McdTries == 5)
-	printk("mcd: read of block %d failed\n", mcd_next_bn);
-#endif
-      if (!McdTries--) {
-	printk("mcd: read of block %d failed, giving up\n", mcd_next_bn);
-	if (mcd_transfer_is_active) {
-	  McdTries = 0;
-	  break;
-	}
-	if (CURRENT_VALID)
-	  end_request(0);
-	McdTries = 5;
-      }
-      mcd_state = MCD_S_START;
-      McdTimeout = READ_TIMEOUT;
-      goto immediately;
-
-    case MFL_STATUSorDATA:
-      break;
-
-    default:
-      McdTries = 5;
-      if (!CURRENT_VALID && mcd_buf_in == mcd_buf_out) {
-	mcd_state = MCD_S_STOP;
-	goto immediately;
-      }
-      mcd_buf_bn[mcd_buf_in] = -1;
-      READ_DATA(MCDPORT(0), mcd_buf + 2048 * mcd_buf_in, 2048);
-      mcd_buf_bn[mcd_buf_in] = mcd_next_bn++;
-      if (mcd_buf_out == -1)
-	mcd_buf_out = mcd_buf_in;
-      mcd_buf_in = mcd_buf_in + 1 == MCD_BUF_SIZ ? 0 : mcd_buf_in + 1;
-      if (!mcd_transfer_is_active) {
-	while (CURRENT_VALID) {
-	  mcd_transfer();
-	  if (CURRENT -> nr_sectors == 0)
-	    end_request(1);
-	  else
-	    break;
-	}
-      }
-
-      if (CURRENT_VALID
-	  && (CURRENT -> sector / 4 < mcd_next_bn || 
-	      CURRENT -> sector / 4 > mcd_next_bn + 16)) {
-	mcd_state = MCD_S_STOP;
-	goto immediately;
-      }
-      McdTimeout = READ_TIMEOUT;
-#ifdef DOUBLE_QUICK_ONLY
-      if (MCMD_DATA_READ != MCMD_PLAY_READ)
-#endif
-      {
-	int count= QUICK_LOOP_COUNT;
-	while (count--) {
-          QUICK_LOOP_DELAY;
-	  if ((st = (inb(MCDPORT(1))) & (MFL_STATUSorDATA)) != (MFL_STATUSorDATA)) {
-#   ifdef TEST4
-/*	    printk("Quickloop success at %d\n",QUICK_LOOP_COUNT-count); */
-	    printk(" %d ",QUICK_LOOP_COUNT-count);
-#   endif
-	    goto data_immediately;
-	  }
-	}
-#   ifdef TEST4
-/*      printk("Quickloop ended at %d\n",QUICK_LOOP_COUNT); */
-	printk("ended ");
-#   endif
-      }
-      break;
-    }
-    break;
+			if (CURRENT_VALID
+			    && (CURRENT->sector / 4 < mcd_next_bn ||
+				CURRENT->sector / 4 > mcd_next_bn + 16)) {
+				mcd_state = MCD_S_STOP;
+				goto immediately;
+			}
+			McdTimeout = READ_TIMEOUT;
+			{
+				int count = QUICK_LOOP_COUNT;
+				while (count--) {
+					QUICK_LOOP_DELAY;
+					if ((st = (inb(MCDPORT(1))) & (MFL_STATUSorDATA)) != (MFL_STATUSorDATA)) {
+						test4(printk(" %d ", QUICK_LOOP_COUNT - count));
+						goto data_immediately;
+					}
+				}
+				test4(printk("ended "));
+			}
+			break;
+		}
+		break;
 
+	case MCD_S_STOP:
+		test3(printk("MCD_S_STOP\n"));
+		if (!mitsumi_bug_93_wait)
+			goto do_not_work_around_mitsumi_bug_93_1;
+
+		McdTimeout = mitsumi_bug_93_wait;
+		mcd_state = 9 + 3 + 1;
+		break;
 
+	case 9 + 3 + 1:
+		if (McdTimeout)
+			break;
 
-  case MCD_S_STOP:
-#ifdef TEST3
-    printk("MCD_S_STOP\n");
-#endif
+do_not_work_around_mitsumi_bug_93_1:
+		outb(MCMD_STOP, MCDPORT(0));
+		if ((inb(MCDPORT(1)) & MFL_STATUSorDATA) == MFL_STATUS) {
+			int i = 4096;
+			do {
+				inb(MCDPORT(0));
+			} while ((inb(MCDPORT(1)) & MFL_STATUSorDATA) == MFL_STATUS && --i);
+			outb(MCMD_STOP, MCDPORT(0));
+			if ((inb(MCDPORT(1)) & MFL_STATUSorDATA) == MFL_STATUS) {
+				i = 4096;
+				do {
+					inb(MCDPORT(0));
+				} while ((inb(MCDPORT(1)) & MFL_STATUSorDATA) == MFL_STATUS && --i);
+				outb(MCMD_STOP, MCDPORT(0));
+			}
+		}
 
-#ifdef WORK_AROUND_MITSUMI_BUG_93
-    if (!mitsumi_bug_93_wait)
-      goto do_not_work_around_mitsumi_bug_93_1;
-
-    McdTimeout = mitsumi_bug_93_wait;
-    mcd_state = 9+3+1;
-    break;
-
-  case 9+3+1:
-    if (McdTimeout)
-      break;
-
-  do_not_work_around_mitsumi_bug_93_1:
-#endif /* WORK_AROUND_MITSUMI_BUG_93 */
-
-    outb(MCMD_STOP, MCDPORT(0));
-
-#ifdef WORK_AROUND_MITSUMI_BUG_92
-    if ((inb(MCDPORT(1)) & MFL_STATUSorDATA) == MFL_STATUS) {
-      int i = 4096;
-      do {
-	inb(MCDPORT(0));
-      } while ((inb(MCDPORT(1)) & MFL_STATUSorDATA) == MFL_STATUS && --i);
-      outb(MCMD_STOP, MCDPORT(0));
-      if ((inb(MCDPORT(1)) & MFL_STATUSorDATA) == MFL_STATUS) {
-	i = 4096;
-	do {
-	  inb(MCDPORT(0));
-	} while ((inb(MCDPORT(1)) & MFL_STATUSorDATA) == MFL_STATUS && --i);
-	outb(MCMD_STOP, MCDPORT(0));
-      }
-    }
-#endif /* WORK_AROUND_MITSUMI_BUG_92 */
-
-    mcd_state = MCD_S_STOPPING;
-    McdTimeout = 1000;
-    break;
-
-  case MCD_S_STOPPING:
-#ifdef TEST3
-    printk("MCD_S_STOPPING\n");
-#endif
+		mcd_state = MCD_S_STOPPING;
+		McdTimeout = 1000;
+		break;
+
+	case MCD_S_STOPPING:
+		test3(printk("MCD_S_STOPPING\n"));
+		if ((st = mcdStatus()) == -1 && McdTimeout)
+			break;
 
-    if ((st = mcdStatus()) == -1 && McdTimeout)
-      break;
+		if ((st != -1) && (st & MST_DSK_CHG)) {
+			mcdDiskChanged = 1;
+			tocUpToDate = 0;
+			mcd_invalidate_buffers();
+		}
+		if (!mitsumi_bug_93_wait)
+			goto do_not_work_around_mitsumi_bug_93_2;
 
-    if ((st != -1) && (st & MST_DSK_CHG)) {
-      mcdDiskChanged = 1;
-      tocUpToDate = 0;
-      mcd_invalidate_buffers();
-    }
-
-#ifdef WORK_AROUND_MITSUMI_BUG_93
-    if (!mitsumi_bug_93_wait)
-      goto do_not_work_around_mitsumi_bug_93_2;
-
-    McdTimeout = mitsumi_bug_93_wait;
-    mcd_state = 9+3+2;
-    break;
-
-  case 9+3+2:
-    if (McdTimeout)
-      break;
-
-    st = -1;
-
-  do_not_work_around_mitsumi_bug_93_2:
-#endif /* WORK_AROUND_MITSUMI_BUG_93 */
-
-#ifdef TEST3
-    printk("CURRENT_VALID %d mcd_mode %d\n",
-	   CURRENT_VALID, mcd_mode);
-#endif
+		McdTimeout = mitsumi_bug_93_wait;
+		mcd_state = 9 + 3 + 2;
+		break;
 
-    if (CURRENT_VALID) {
-      if (st != -1) {
-	if (mcd_mode == 1)
-	  goto read_immediately;
-	else
-	  goto set_mode_immediately;
-      } else {
-	mcd_state = MCD_S_START;
-	McdTimeout = 1;
-      }
-    } else {
-      mcd_state = MCD_S_IDLE;
-      goto out;
-    }
-    break;
-
-  default:
-    printk("mcd: invalid state %d\n", mcd_state);
-    goto out;
-  }
-
- ret:
-  if (!McdTimeout--) {
-    printk("mcd: timeout in state %d\n", mcd_state);
-    mcd_state = MCD_S_STOP;
-  }
+	case 9 + 3 + 2:
+		if (McdTimeout)
+			break;
+		st = -1;
 
-  SET_TIMER(mcd_poll, 1);
+do_not_work_around_mitsumi_bug_93_2:
+		test3(printk("CURRENT_VALID %d mcd_mode %d\n", CURRENT_VALID, mcd_mode));
+		if (CURRENT_VALID) {
+			if (st != -1) {
+				if (mcd_mode == 1)
+					goto read_immediately;
+				else
+					goto set_mode_immediately;
+			} else {
+				mcd_state = MCD_S_START;
+				McdTimeout = 1;
+			}
+		} else {
+			mcd_state = MCD_S_IDLE;
+			goto out;
+		}
+		break;
+	default:
+		printk(KERN_ERR "mcd: invalid state %d\n", mcd_state);
+		goto out;
+	}
+ret:
+	if (!McdTimeout--) {
+		printk(KERN_WARNING "mcd: timeout in state %d\n", mcd_state);
+		mcd_state = MCD_S_STOP;
+	}
+	mcd_timer.function = mcd_poll;
+	mod_timer(&mcd_timer, jiffies + 1);
 out:
-  return;
+	return;
 }
 
-
-
-static void
-mcd_invalidate_buffers(void)
+static void mcd_invalidate_buffers(void)
 {
-  int i;
-  for (i = 0; i < MCD_BUF_SIZ; ++i)
-    mcd_buf_bn[i] = -1;
-  mcd_buf_out = -1;
+	int i;
+	for (i = 0; i < MCD_BUF_SIZ; ++i)
+		mcd_buf_bn[i] = -1;
+	mcd_buf_out = -1;
 }
 
-
 /*
  * Open the device special file.  Check that a disk is in.
  */
-static int mcd_open(struct cdrom_device_info * cdi, int purpose)
+static int mcd_open(struct cdrom_device_info *cdi, int purpose)
 {
-	int st, count=0;
+	int st, count = 0;
 	if (mcdPresent == 0)
-		return -ENXIO;			/* no hardware */
+		return -ENXIO;	/* no hardware */
 
-        MOD_INC_USE_COUNT;
+	MOD_INC_USE_COUNT;
 
-        if (mcd_open_count || mcd_state != MCD_S_IDLE)
+	if (mcd_open_count || mcd_state != MCD_S_IDLE)
 		goto bump_count;
 
-        mcd_invalidate_buffers();
-        do {
-                st = statusCmd();               /* check drive status */
-                if (st == -1)
-                        goto err_out;            /* drive doesn't respond */
-                if ((st & MST_READY) == 0) {    /* no disk? wait a sec... */
-                        current->state = TASK_INTERRUPTIBLE;
-                        schedule_timeout(HZ);
-                }
-        } while (((st & MST_READY) == 0) && count++ < MCD_RETRY_ATTEMPTS);
+	mcd_invalidate_buffers();
+	do {
+		st = statusCmd();	/* check drive status */
+		if (st == -1)
+			goto err_out;	/* drive doesn't respond */
+		if ((st & MST_READY) == 0) {	/* no disk? wait a sec... */
+			current->state = TASK_INTERRUPTIBLE;
+			schedule_timeout(HZ);
+		}
+	} while (((st & MST_READY) == 0) && count++ < MCD_RETRY_ATTEMPTS);
 
-        if (updateToc() < 0)
-                       goto err_out;
+	if (updateToc() < 0)
+		goto err_out;
 
 bump_count:
 	++mcd_open_count;
 	return 0;
 
 err_out:
-        MOD_DEC_USE_COUNT;
+	MOD_DEC_USE_COUNT;
 	return -EIO;
 }
 
@@ -1130,11 +1010,12 @@
 /*
  * On close, we flush all mcd blocks from the buffer cache.
  */
-static void mcd_release(struct cdrom_device_info * cdi)
-{ MOD_DEC_USE_COUNT;
-  if (!--mcd_open_count) {
-	mcd_invalidate_buffers();
-  }
+static void mcd_release(struct cdrom_device_info *cdi)
+{
+	if (!--mcd_open_count) {
+		mcd_invalidate_buffers();
+	}
+	MOD_DEC_USE_COUNT;
 }
 
 
@@ -1143,23 +1024,23 @@
  * and is used in mcd_exit as well. */
 static void cleanup(int level)
 {
-  switch (level) {
-  case 3:
-    if (unregister_cdrom(&mcd_info)) {
-      printk(KERN_WARNING "Can't unregister cdrom mcd\n");
-      return;
-    }
-    free_irq(mcd_irq, NULL);
-  case 2:
-    release_region(mcd_port,4);
-  case 1:
-    if (devfs_unregister_blkdev(MAJOR_NR, "mcd")) {
-      printk(KERN_WARNING "Can't unregister major mcd\n");
-      return;
-    }
-    blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
-  default:;
-  }
+	switch (level) {
+	case 3:
+		if (unregister_cdrom(&mcd_info)) {
+			printk(KERN_WARNING "Can't unregister cdrom mcd\n");
+			return;
+		}
+		free_irq(mcd_irq, NULL);
+	case 2:
+		release_region(mcd_port, 4);
+	case 1:
+		if (devfs_unregister_blkdev(MAJOR_NR, "mcd")) {
+			printk(KERN_WARNING "Can't unregister major mcd\n");
+			return;
+		}
+		blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
+	default:;
+	}
 }
 
 
@@ -1175,21 +1056,18 @@
 	char msg[80];
 
 	if (mcd_port <= 0 || mcd_irq <= 0) {
-	  printk("skip mcd_init\n");
-          return -EIO;
+		printk(KERN_INFO "mcd: not probing.\n");
+		return -EIO;
 	}
 
-	if (devfs_register_blkdev(MAJOR_NR, "mcd", &cdrom_fops) != 0)
-	{
-		printk("Unable to get major %d for Mitsumi CD-ROM\n",
-		       MAJOR_NR);
-                return -EIO;
-	}
-        if (check_region(mcd_port, 4)) {
-	  cleanup(1);
-	  printk("Init failed, I/O port (%X) already in use\n",
-		 mcd_port);
-          return -EIO;
+	if (devfs_register_blkdev(MAJOR_NR, "mcd", &cdrom_fops) != 0) {
+		printk(KERN_ERR "mcd: Unable to get major %d for Mitsumi CD-ROM\n", MAJOR_NR);
+		return -EIO;
+	}
+	if (check_region(mcd_port, 4)) {
+		cleanup(1);
+		printk(KERN_ERR "mcd: Initialization failed, I/O port (%X) already in use\n", mcd_port);
+		return -EIO;
 	}
 
 	blksize_size[MAJOR_NR] = mcd_blocksizes;
@@ -1198,106 +1076,103 @@
 
 	/* check for card */
 
-	outb(0, MCDPORT(1));			/* send reset */
+	outb(0, MCDPORT(1));	/* send reset */
 	for (count = 0; count < 2000000; count++)
-		(void) inb(MCDPORT(1));		/* delay a bit */
+		(void) inb(MCDPORT(1));	/* delay a bit */
 
-	outb(0x40, MCDPORT(0));	                /* send get-stat cmd */
+	outb(0x40, MCDPORT(0));	/* send get-stat cmd */
 	for (count = 0; count < 2000000; count++)
 		if (!(inb(MCDPORT(1)) & MFL_STATUS))
 			break;
 
 	if (count >= 2000000) {
-		printk("Init failed. No mcd device at 0x%x irq %d\n",
-		     mcd_port, mcd_irq);
+		printk(KERN_INFO "mcd: initialisation failed - No mcd device at 0x%x irq %d\n",
+		       mcd_port, mcd_irq);
 		cleanup(1);
-                return -EIO;
+		return -EIO;
 	}
-	count = inb(MCDPORT(0));		/* pick up the status */
-	
-	outb(MCMD_GET_VERSION,MCDPORT(0));
-	for(count=0;count<3;count++)
-		if(getValue(result+count)) {
-			printk("mitsumi get version failed at 0x%x\n",
+	count = inb(MCDPORT(0));	/* pick up the status */
+
+	outb(MCMD_GET_VERSION, MCDPORT(0));
+	for (count = 0; count < 3; count++)
+		if (getValue(result + count)) {
+			printk(KERN_ERR "mcd: mitsumi get version failed at 0x%x\n",
 			       mcd_port);
-                        cleanup(1);
-                        return -EIO;
-		}	
+			cleanup(1);
+			return -EIO;
+		}
 
 	if (result[0] == result[1] && result[1] == result[2]) {
 		cleanup(1);
-                return -EIO;
+		return -EIO;
 	}
 
-	mcdVersion=result[2];
+	mcdVersion = result[2];
 
-	if (mcdVersion >=4)
-		outb(4,MCDPORT(2)); 	/* magic happens */
+	if (mcdVersion >= 4)
+		outb(4, MCDPORT(2));	/* magic happens */
 
 	/* don't get the IRQ until we know for sure the drive is there */
 
-	if (request_irq(mcd_irq, mcd_interrupt, SA_INTERRUPT, "Mitsumi CD", NULL))
-	{
-		printk("Unable to get IRQ%d for Mitsumi CD-ROM\n", mcd_irq);
+	if (request_irq(mcd_irq, mcd_interrupt, SA_INTERRUPT, "Mitsumi CD", NULL)) {
+		printk(KERN_ERR "mcd: Unable to get IRQ%d for Mitsumi CD-ROM\n", mcd_irq);
 		cleanup(1);
-                return -EIO;
+		return -EIO;
 	}
 
-        if (result[1] == 'D') 
-	{
+	if (result[1] == 'D') {
 		MCMD_DATA_READ = MCMD_2X_READ;
 		/* Added flag to drop to 1x speed if too many errors */
 		mcdDouble = 1;
-        } else 
+	} else
 		mcd_info.speed = 1;
 	sprintf(msg, " mcd: Mitsumi %s Speed CD-ROM at port=0x%x,"
-		     " irq=%d\n", mcd_info.speed == 1 ?  "Single" : "Double", mcd_port, mcd_irq);
+		" irq=%d\n", mcd_info.speed == 1 ? "Single" : "Double",
+		mcd_port, mcd_irq);
 
 	request_region(mcd_port, 4, "mcd");
 
 	outb(MCMD_CONFIG_DRIVE, MCDPORT(0));
-	outb(0x02,MCDPORT(0));
-	outb(0x00,MCDPORT(0));
+	outb(0x02, MCDPORT(0));
+	outb(0x00, MCDPORT(0));
 	getValue(result);
 
 	outb(MCMD_CONFIG_DRIVE, MCDPORT(0));
-	outb(0x10,MCDPORT(0));
-	outb(0x04,MCDPORT(0));
+	outb(0x10, MCDPORT(0));
+	outb(0x04, MCDPORT(0));
 	getValue(result);
 
 	mcd_invalidate_buffers();
 	mcdPresent = 1;
 
-	mcd_info.dev = MKDEV(MAJOR_NR,0);
+	mcd_info.dev = MKDEV(MAJOR_NR, 0);
 
-        if (register_cdrom(&mcd_info) != 0) {
-              printk("Cannot register Mitsumi CD-ROM!\n");
-              cleanup(3);
-              return -EIO;
-        }
-        printk(msg);
+	if (register_cdrom(&mcd_info) != 0) {
+		printk(KERN_ERR "mcd: Unable to register Mitsumi CD-ROM.\n");
+		cleanup(3);
+		return -EIO;
+	}
+	printk(msg);
 
 	return 0;
 }
 
 
-static void
-hsg2msf(long hsg, struct msf *msf)
+static void hsg2msf(long hsg, struct msf *msf)
 {
 	hsg += 150;
-	msf -> min = hsg / 4500;
+	msf->min = hsg / 4500;
 	hsg %= 4500;
-	msf -> sec = hsg / 75;
-	msf -> frame = hsg % 75;
+	msf->sec = hsg / 75;
+	msf->frame = hsg % 75;
 
-	bin2bcd(&msf -> min);		/* convert to BCD */
-	bin2bcd(&msf -> sec);
-	bin2bcd(&msf -> frame);
+	bin2bcd(&msf->min);	/* convert to BCD */
+	bin2bcd(&msf->sec);
+	bin2bcd(&msf->frame);
 }
 
 
-static void
-bin2bcd(unsigned char *p)
+static void bin2bcd(unsigned char *p)
 {
 	int u, t;
 
@@ -1306,8 +1181,7 @@
 	*p = u | (t << 4);
 }
 
-static int
-bcd2bin(unsigned char bcd)
+static int bcd2bin(unsigned char bcd)
 {
 	return (bcd >> 4) * 10 + (bcd & 0xF);
 }
@@ -1318,19 +1192,16 @@
  * if it is ready.
  */
 
-static int
-mcdStatus(void)
+static int mcdStatus(void)
 {
 	int i;
 	int st;
 
 	st = inb(MCDPORT(1)) & MFL_STATUS;
-	if (!st)
-	{
+	if (!st) {
 		i = inb(MCDPORT(0)) & 0xFF;
 		return i;
-	}
-	else
+	} else
 		return -1;
 }
 
@@ -1339,16 +1210,15 @@
  * Send a play or read command to the drive
  */
 
-static void
-sendMcdCmd(int cmd, struct mcd_Play_msf *params)
+static void sendMcdCmd(int cmd, struct mcd_Play_msf *params)
 {
 	outb(cmd, MCDPORT(0));
-	outb(params -> start.min, MCDPORT(0));
-	outb(params -> start.sec, MCDPORT(0));
-	outb(params -> start.frame, MCDPORT(0));
-	outb(params -> end.min, MCDPORT(0));
-	outb(params -> end.sec, MCDPORT(0));
-	outb(params -> end.frame, MCDPORT(0));
+	outb(params->start.min, MCDPORT(0));
+	outb(params->start.sec, MCDPORT(0));
+	outb(params->start.frame, MCDPORT(0));
+	outb(params->end.min, MCDPORT(0));
+	outb(params->end.sec, MCDPORT(0));
+	outb(params->end.frame, MCDPORT(0));
 }
 
 
@@ -1357,23 +1227,20 @@
  * (see the next routine)
  */
 
-static void
-mcdStatTimer(unsigned long dummy)
+static void mcdStatTimer(unsigned long dummy)
 {
-	if (!(inb(MCDPORT(1)) & MFL_STATUS))
-	{
+	if (!(inb(MCDPORT(1)) & MFL_STATUS)) {
 		wake_up(&mcd_waitq);
 		return;
 	}
 
 	McdTimeout--;
-	if (McdTimeout <= 0)
-	{
+	if (McdTimeout <= 0) {
 		wake_up(&mcd_waitq);
 		return;
 	}
-
-	SET_TIMER(mcdStatTimer, 1);
+	mcd_timer.function = mcdStatTimer;
+	mod_timer(&mcd_timer, jiffies + 1);
 }
 
 
@@ -1383,13 +1250,13 @@
  * excessive rescheduling.
  */
 
-static int
-getMcdStatus(int timeout)
+static int getMcdStatus(int timeout)
 {
 	int st;
 
 	McdTimeout = timeout;
-	SET_TIMER(mcdStatTimer, 1);
+	mcd_timer.function = mcdStatTimer;
+	mod_timer(&mcd_timer, jiffies + 1);
 	sleep_on(&mcd_waitq);
 	if (McdTimeout <= 0)
 		return -1;
@@ -1402,8 +1269,7 @@
 		/* XXX might be an error? look at q-channel? */
 		audioStatus = CDROM_AUDIO_COMPLETED;
 
-	if (st & MST_DSK_CHG)
-	{
+	if (st & MST_DSK_CHG) {
 		mcdDiskChanged = 1;
 		tocUpToDate = 0;
 		audioStatus = CDROM_AUDIO_NO_STATUS;
@@ -1415,18 +1281,23 @@
 
 /* gives current state of the drive This function is quite unreliable, 
    and should probably be rewritten by someone, eventually... */
-int mcd_drive_status(struct cdrom_device_info * cdi, int slot_nr)
+
+int mcd_drive_status(struct cdrom_device_info *cdi, int slot_nr)
 {
-  int st;
+	int st;
 
-  st = statusCmd();               /* check drive status */
-  if (st == -1)
-      return -EIO;            /* drive doesn't respond */
-  if ((st & MST_READY)) return CDS_DISC_OK;
-  if ((st & MST_DOOR_OPEN)) return CDS_TRAY_OPEN;
-  if ((st & MST_DSK_CHG)) return CDS_NO_DISC;
-  if ((st & MST_BUSY)) return CDS_DRIVE_NOT_READY;
-  return -EIO;
+	st = statusCmd();	/* check drive status */
+	if (st == -1)
+		return -EIO;	/* drive doesn't respond */
+	if ((st & MST_READY))
+		return CDS_DISC_OK;
+	if ((st & MST_DOOR_OPEN))
+		return CDS_TRAY_OPEN;
+	if ((st & MST_DSK_CHG))
+		return CDS_NO_DISC;
+	if ((st & MST_BUSY))
+		return CDS_DRIVE_NOT_READY;
+	return -EIO;
 }
 
 
@@ -1434,18 +1305,16 @@
  * Read a value from the drive.
  */
 
-static int
-getValue(unsigned char *result)
+static int getValue(unsigned char *result)
 {
-        int count;
+	int count;
 	int s;
 
 	for (count = 0; count < 2000; count++)
 		if (!(inb(MCDPORT(1)) & MFL_STATUS))
 			break;
 
-	if (count >= 2000)
-	{
+	if (count >= 2000) {
 		printk("mcd: getValue timeout\n");
 		return -1;
 	}
@@ -1455,20 +1324,17 @@
 	return 0;
 }
 
-
 /*
  * Read the current Q-channel info.  Also used for reading the
  * table of contents.
  */
 
-int
-GetQChannelInfo(struct mcd_Toc *qp)
+int GetQChannelInfo(struct mcd_Toc *qp)
 {
 	unsigned char notUsed;
 	int retry;
 
-	for (retry = 0; retry < MCD_RETRY_ATTEMPTS; retry++)
-	{
+	for (retry = 0; retry < MCD_RETRY_ATTEMPTS; retry++) {
 		outb(MCMD_GET_Q_CHANNEL, MCDPORT(0));
 		if (getMcdStatus(MCD_STATUS_DELAY) != -1)
 			break;
@@ -1477,27 +1343,35 @@
 	if (retry >= MCD_RETRY_ATTEMPTS)
 		return -1;
 
-	if (getValue(&qp -> ctrl_addr) < 0) return -1;
-	if (getValue(&qp -> track) < 0) return -1;
-	if (getValue(&qp -> pointIndex) < 0) return -1;
-	if (getValue(&qp -> trackTime.min) < 0) return -1;
-	if (getValue(&qp -> trackTime.sec) < 0) return -1;
-	if (getValue(&qp -> trackTime.frame) < 0) return -1;
-	if (getValue(&notUsed) < 0) return -1;
-	if (getValue(&qp -> diskTime.min) < 0) return -1;
-	if (getValue(&qp -> diskTime.sec) < 0) return -1;
-	if (getValue(&qp -> diskTime.frame) < 0) return -1;
+	if (getValue(&qp->ctrl_addr) < 0)
+		return -1;
+	if (getValue(&qp->track) < 0)
+		return -1;
+	if (getValue(&qp->pointIndex) < 0)
+		return -1;
+	if (getValue(&qp->trackTime.min) < 0)
+		return -1;
+	if (getValue(&qp->trackTime.sec) < 0)
+		return -1;
+	if (getValue(&qp->trackTime.frame) < 0)
+		return -1;
+	if (getValue(&notUsed) < 0)
+		return -1;
+	if (getValue(&qp->diskTime.min) < 0)
+		return -1;
+	if (getValue(&qp->diskTime.sec) < 0)
+		return -1;
+	if (getValue(&qp->diskTime.frame) < 0)
+		return -1;
 
 	return 0;
 }
 
-
 /*
  * Read the table of contents (TOC) and TOC header if necessary
  */
 
-static int
-updateToc()
+static int updateToc(void)
 {
 	if (tocUpToDate)
 		return 0;
@@ -1512,18 +1386,15 @@
 	return 0;
 }
 
-
 /*
  * Read the table of contents header
  */
 
-static int
-GetDiskInfo()
+static int GetDiskInfo(void)
 {
 	int retry;
 
-	for (retry = 0; retry < MCD_RETRY_ATTEMPTS; retry++)
-	{
+	for (retry = 0; retry < MCD_RETRY_ATTEMPTS; retry++) {
 		outb(MCMD_GET_DISK_INFO, MCDPORT(0));
 		if (getMcdStatus(MCD_STATUS_DELAY) != -1)
 			break;
@@ -1532,41 +1403,44 @@
 	if (retry >= MCD_RETRY_ATTEMPTS)
 		return -1;
 
-	if (getValue(&DiskInfo.first) < 0) return -1;
-	if (getValue(&DiskInfo.last) < 0) return -1;
+	if (getValue(&DiskInfo.first) < 0)
+		return -1;
+	if (getValue(&DiskInfo.last) < 0)
+		return -1;
 
 	DiskInfo.first = bcd2bin(DiskInfo.first);
 	DiskInfo.last = bcd2bin(DiskInfo.last);
 
 #ifdef MCD_DEBUG
-printk("Disk Info: first %d last %d length %02x:%02x.%02x first %02x:%02x.%02x\n",
-	DiskInfo.first,
-	DiskInfo.last,
-	DiskInfo.diskLength.min,
-	DiskInfo.diskLength.sec,
-	DiskInfo.diskLength.frame,
-	DiskInfo.firstTrack.min,
-	DiskInfo.firstTrack.sec,
-	DiskInfo.firstTrack.frame);
+	printk
+	    ("Disk Info: first %d last %d length %02x:%02x.%02x first %02x:%02x.%02x\n",
+	     DiskInfo.first, DiskInfo.last, DiskInfo.diskLength.min,
+	     DiskInfo.diskLength.sec, DiskInfo.diskLength.frame,
+	     DiskInfo.firstTrack.min, DiskInfo.firstTrack.sec,
+	     DiskInfo.firstTrack.frame);
 #endif
 
-	if (getValue(&DiskInfo.diskLength.min) < 0) return -1;
-	if (getValue(&DiskInfo.diskLength.sec) < 0) return -1;
-	if (getValue(&DiskInfo.diskLength.frame) < 0) return -1;
-	if (getValue(&DiskInfo.firstTrack.min) < 0) return -1;
-	if (getValue(&DiskInfo.firstTrack.sec) < 0) return -1;
-	if (getValue(&DiskInfo.firstTrack.frame) < 0) return -1;
+	if (getValue(&DiskInfo.diskLength.min) < 0)
+		return -1;
+	if (getValue(&DiskInfo.diskLength.sec) < 0)
+		return -1;
+	if (getValue(&DiskInfo.diskLength.frame) < 0)
+		return -1;
+	if (getValue(&DiskInfo.firstTrack.min) < 0)
+		return -1;
+	if (getValue(&DiskInfo.firstTrack.sec) < 0)
+		return -1;
+	if (getValue(&DiskInfo.firstTrack.frame) < 0)
+		return -1;
 
 	return 0;
 }
 
-
 /*
  * Read the table of contents (TOC)
  */
 
-static int
-GetToc()
+static int GetToc(void)
 {
 	int i, px;
 	int limit;
@@ -1578,8 +1452,7 @@
 
 	i = DiskInfo.last + 3;
 
-	for (retry = 0; retry < MCD_RETRY_ATTEMPTS; retry++)
-	{
+	for (retry = 0; retry < MCD_RETRY_ATTEMPTS; retry++) {
 		outb(MCMD_STOP, MCDPORT(0));
 		if (getMcdStatus(MCD_STATUS_DELAY) != -1)
 			break;
@@ -1588,10 +1461,9 @@
 	if (retry >= MCD_RETRY_ATTEMPTS)
 		return -1;
 
-	for (retry = 0; retry < MCD_RETRY_ATTEMPTS; retry++)
-	{
+	for (retry = 0; retry < MCD_RETRY_ATTEMPTS; retry++) {
 		outb(MCMD_SET_MODE, MCDPORT(0));
-		outb(0x05, MCDPORT(0));			/* mode: toc */
+		outb(0x05, MCDPORT(0));	/* mode: toc */
 		mcd_mode = 0x05;
 		if (getMcdStatus(MCD_STATUS_DELAY) != -1)
 			break;
@@ -1600,15 +1472,13 @@
 	if (retry >= MCD_RETRY_ATTEMPTS)
 		return -1;
 
-	for (limit = 300; limit > 0; limit--)
-	{
+	for (limit = 300; limit > 0; limit--) {
 		if (GetQChannelInfo(&qInfo) < 0)
 			break;
 
 		px = bcd2bin(qInfo.pointIndex);
 		if (px > 0 && px < MAX_TRACKS && qInfo.track == 0)
-			if (Toc[px].pointIndex == 0)
-			{
+			if (Toc[px].pointIndex == 0) {
 				Toc[px] = qInfo;
 				i--;
 			}
@@ -1619,41 +1489,44 @@
 
 	Toc[DiskInfo.last + 1].diskTime = DiskInfo.diskLength;
 
-	for (retry = 0; retry < MCD_RETRY_ATTEMPTS; retry++)
-	{
-                outb(MCMD_SET_MODE, MCDPORT(0));
-                outb(0x01, MCDPORT(0));
+	for (retry = 0; retry < MCD_RETRY_ATTEMPTS; retry++) {
+		outb(MCMD_SET_MODE, MCDPORT(0));
+		outb(0x01, MCDPORT(0));
 		mcd_mode = 1;
-                if (getMcdStatus(MCD_STATUS_DELAY) != -1)
-                        break;
+		if (getMcdStatus(MCD_STATUS_DELAY) != -1)
+			break;
 	}
 
 #ifdef MCD_DEBUG
-for (i = 1; i <= DiskInfo.last; i++)
-printk("i = %2d ctl-adr = %02X track %2d px %02X %02X:%02X.%02X    %02X:%02X.%02X\n",
-i, Toc[i].ctrl_addr, Toc[i].track, Toc[i].pointIndex,
-Toc[i].trackTime.min, Toc[i].trackTime.sec, Toc[i].trackTime.frame,
-Toc[i].diskTime.min, Toc[i].diskTime.sec, Toc[i].diskTime.frame);
-for (i = 100; i < 103; i++)
-printk("i = %2d ctl-adr = %02X track %2d px %02X %02X:%02X.%02X    %02X:%02X.%02X\n",
-i, Toc[i].ctrl_addr, Toc[i].track, Toc[i].pointIndex,
-Toc[i].trackTime.min, Toc[i].trackTime.sec, Toc[i].trackTime.frame,
-Toc[i].diskTime.min, Toc[i].diskTime.sec, Toc[i].diskTime.frame);
+	for (i = 1; i <= DiskInfo.last; i++)
+		printk
+		    ("i = %2d ctl-adr = %02X track %2d px %02X %02X:%02X.%02X    %02X:%02X.%02X\n",
+		     i, Toc[i].ctrl_addr, Toc[i].track, Toc[i].pointIndex,
+		     Toc[i].trackTime.min, Toc[i].trackTime.sec,
+		     Toc[i].trackTime.frame, Toc[i].diskTime.min,
+		     Toc[i].diskTime.sec, Toc[i].diskTime.frame);
+	for (i = 100; i < 103; i++)
+		printk
+		    ("i = %2d ctl-adr = %02X track %2d px %02X %02X:%02X.%02X    %02X:%02X.%02X\n",
+		     i, Toc[i].ctrl_addr, Toc[i].track, Toc[i].pointIndex,
+		     Toc[i].trackTime.min, Toc[i].trackTime.sec,
+		     Toc[i].trackTime.frame, Toc[i].diskTime.min,
+		     Toc[i].diskTime.sec, Toc[i].diskTime.frame);
 #endif
 
 	return limit > 0 ? 0 : -1;
 }
 
-
 void __exit mcd_exit(void)
 {
-  cleanup(3);
-  del_timer_sync(&mcd_timer);
+	cleanup(3);
+	del_timer_sync(&mcd_timer);
 }
 
 #ifdef MODULE
 module_init(mcd_init);
-#endif 
+#endif
 module_exit(mcd_exit);
 
-
+MODULE_AUTHOR("Martin Harriss");
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/cdrom/mcd.h linux/drivers/cdrom/mcd.h
--- v2.4.9/linux/drivers/cdrom/mcd.h	Wed Jul  5 11:24:41 2000
+++ linux/drivers/cdrom/mcd.h	Sun Sep  9 10:43:02 2001
@@ -70,17 +70,6 @@
 
 /* borrowed from hd.c */
 
-#define READ_DATA(port, buf, nr) \
-insb(port, buf, nr)
-
-#define SET_TIMER(func, jifs) 				\
-	do {						\
-		mcd_timer.function = func;		\
-		mod_timer(&mcd_timer, jiffies + jifs);	\
-	} while (0)
-
-#define CLEAR_TIMER		del_timer_async(&mcd_timer);
-
 #define MAX_TRACKS		104
 
 struct msf {
@@ -108,3 +97,10 @@
 	struct msf	trackTime;
 	struct msf	diskTime;
 };
+
+#define test1(x)
+#define test2(x)
+#define test3(x)
+#define test4(x)
+#define test5(x)
+
diff -u --recursive --new-file v2.4.9/linux/drivers/cdrom/mcdx.c linux/drivers/cdrom/mcdx.c
--- v2.4.9/linux/drivers/cdrom/mcdx.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/cdrom/mcdx.c	Fri Sep  7 09:28:38 2001
@@ -53,7 +53,7 @@
 
 #if RCS
 static const char *mcdx_c_version
-		= "$Id: mcdx.c,v 1.21 1997/01/26 07:12:59 davem Exp $";
+    = "$Id: mcdx.c,v 1.21 1997/01/26 07:12:59 davem Exp $";
 #endif
 
 #include <linux/version.h>
@@ -120,10 +120,10 @@
 enum datamodes { MODE0, MODE1, MODE2 };
 enum resetmodes { SOFT, HARD };
 
-const int SINGLE = 0x01;		/* single speed drive (FX001S, LU) */
-const int DOUBLE = 0x02;		/* double speed drive (FX001D, ..? */
-const int DOOR   = 0x04;		/* door locking capability */
-const int MULTI  = 0x08;		/* multi session capability */
+const int SINGLE = 0x01;	/* single speed drive (FX001S, LU) */
+const int DOUBLE = 0x02;	/* double speed drive (FX001D, ..? */
+const int DOOR = 0x04;		/* door locking capability */
+const int MULTI = 0x08;		/* multi session capability */
 
 const unsigned char READ1X = 0xc0;
 const unsigned char READ2X = 0xc1;
@@ -159,53 +159,53 @@
 
 struct s_drive_stuff {
 	/* waitqueues */
-    wait_queue_head_t busyq;
-    wait_queue_head_t lockq;
-    wait_queue_head_t sleepq;
-
- 	/* flags */
-    volatile int introk;	/* status of last irq operation */
-    volatile int busy;		/* drive performs an operation */
-    volatile int lock;		/* exclusive usage */
+	wait_queue_head_t busyq;
+	wait_queue_head_t lockq;
+	wait_queue_head_t sleepq;
+
+	/* flags */
+	volatile int introk;	/* status of last irq operation */
+	volatile int busy;	/* drive performs an operation */
+	volatile int lock;	/* exclusive usage */
 
 	/* cd infos */
 	struct s_diskinfo di;
 	struct s_multi multi;
-	struct s_subqcode* toc;	/* first entry of the toc array */
+	struct s_subqcode *toc;	/* first entry of the toc array */
 	struct s_subqcode start;
-    struct s_subqcode stop;
-	int xa;					/* 1 if xa disk */
-	int audio;				/* 1 if audio disk */
+	struct s_subqcode stop;
+	int xa;			/* 1 if xa disk */
+	int audio;		/* 1 if audio disk */
 	int audiostatus;
 
 	/* `buffer' control */
-    volatile int valid;			/* pending, ..., values are valid */
-    volatile int pending;		/* next sector to be read */
-    volatile int low_border;	/* first sector not to be skipped direct */
-    volatile int high_border; /* first sector `out of area' */
+	volatile int valid;	/* pending, ..., values are valid */
+	volatile int pending;	/* next sector to be read */
+	volatile int low_border;	/* first sector not to be skipped direct */
+	volatile int high_border;	/* first sector `out of area' */
 #ifdef AK2
-    volatile int int_err;
-#endif /* AK2 */
+	volatile int int_err;
+#endif				/* AK2 */
 
 	/* adds and odds */
-	void* wreg_data;	/* w data */
-	void* wreg_reset;	/* w hardware reset */
-	void* wreg_hcon;	/* w hardware conf */
-	void* wreg_chn;		/* w channel */
-	void* rreg_data;	/* r data */
-	void* rreg_status;	/* r status */
-
-    int irq;			/* irq used by this drive */
-    int minor;			/* minor number of this drive */
-    int present;	    /* drive present and its capabilities */
-    unsigned char readcmd;	/* read cmd depends on single/double speed */
-    unsigned char playcmd;  /* play should always be single speed */
-    unsigned int xxx;      /* set if changed, reset while open */
-    unsigned int yyy;      /* set if changed, reset by media_changed */
-    int users;				/* keeps track of open/close */
-    int lastsector;			/* last block accessible */
-    int status;				/* last operation's error / status */
-	int readerrs;			/* # of blocks read w/o error */
+	void *wreg_data;	/* w data */
+	void *wreg_reset;	/* w hardware reset */
+	void *wreg_hcon;	/* w hardware conf */
+	void *wreg_chn;		/* w channel */
+	void *rreg_data;	/* r data */
+	void *rreg_status;	/* r status */
+
+	int irq;		/* irq used by this drive */
+	int minor;		/* minor number of this drive */
+	int present;		/* drive present and its capabilities */
+	unsigned char readcmd;	/* read cmd depends on single/double speed */
+	unsigned char playcmd;	/* play should always be single speed */
+	unsigned int xxx;	/* set if changed, reset while open */
+	unsigned int yyy;	/* set if changed, reset by media_changed */
+	int users;		/* keeps track of open/close */
+	int lastsector;		/* last block accessible */
+	int status;		/* last operation's error / status */
+	int readerrs;		/* # of blocks read w/o error */
 };
 
 
@@ -225,299 +225,333 @@
 	structure mcdx_dops. */
 
 /* ???  exported by the mcdx_sigaction struct */
-static void mcdx_intr(int, void *, struct pt_regs*);
+static void mcdx_intr(int, void *, struct pt_regs *);
 
 /* exported by file_ops */
-static int mcdx_open(struct cdrom_device_info * cdi, int purpose);
-static void mcdx_close(struct cdrom_device_info * cdi);
-static int mcdx_media_changed(struct cdrom_device_info * cdi, int disc_nr);
-static int mcdx_tray_move(struct cdrom_device_info * cdi, int position);
-static int mcdx_lockdoor(struct cdrom_device_info * cdi, int lock);
-static int mcdx_audio_ioctl(struct cdrom_device_info * cdi, unsigned int cmd,
-                      void * arg);
+static int mcdx_open(struct cdrom_device_info *cdi, int purpose);
+static void mcdx_close(struct cdrom_device_info *cdi);
+static int mcdx_media_changed(struct cdrom_device_info *cdi, int disc_nr);
+static int mcdx_tray_move(struct cdrom_device_info *cdi, int position);
+static int mcdx_lockdoor(struct cdrom_device_info *cdi, int lock);
+static int mcdx_audio_ioctl(struct cdrom_device_info *cdi,
+			    unsigned int cmd, void *arg);
 
 /* misc internal support functions */
-static void log2msf(unsigned int, struct cdrom_msf0*);
-static unsigned int msf2log(const struct cdrom_msf0*);
+static void log2msf(unsigned int, struct cdrom_msf0 *);
+static unsigned int msf2log(const struct cdrom_msf0 *);
 static unsigned int uint2bcd(unsigned int);
 static unsigned int bcd2uint(unsigned char);
-static char *port(int*);
-static int irq(int*);
-static void mcdx_delay(struct s_drive_stuff*, long jifs);
-static int mcdx_transfer(struct s_drive_stuff*, char* buf, int sector, int nr_sectors);
-static int mcdx_xfer(struct s_drive_stuff*, char* buf, int sector, int nr_sectors);
-
-static int mcdx_config(struct s_drive_stuff*, int);
-static int mcdx_requestversion(struct s_drive_stuff*, struct s_version*, int);
-static int mcdx_stop(struct s_drive_stuff*, int);
-static int mcdx_hold(struct s_drive_stuff*, int);
-static int mcdx_reset(struct s_drive_stuff*, enum resetmodes, int);
-static int mcdx_setdrivemode(struct s_drive_stuff*, enum drivemodes, int);
-static int mcdx_setdatamode(struct s_drive_stuff*, enum datamodes, int);
-static int mcdx_requestsubqcode(struct s_drive_stuff*, struct s_subqcode*, int);
-static int mcdx_requestmultidiskinfo(struct s_drive_stuff*, struct s_multi*, int);
-static int mcdx_requesttocdata(struct s_drive_stuff*, struct s_diskinfo*, int);
-static int mcdx_getstatus(struct s_drive_stuff*, int);
-static int mcdx_getval(struct s_drive_stuff*, int to, int delay, char*);
-static int mcdx_talk(struct s_drive_stuff*,
-		const unsigned char* cmd, size_t,
-        void *buffer, size_t size,
-        unsigned int timeout, int);
-static int mcdx_readtoc(struct s_drive_stuff*);
-static int mcdx_playtrk(struct s_drive_stuff*, const struct cdrom_ti*);
-static int mcdx_playmsf(struct s_drive_stuff*, const struct cdrom_msf*);
-static int mcdx_setattentuator(struct s_drive_stuff*, struct cdrom_volctrl*, int);
+static char *port(int *);
+static int irq(int *);
+static void mcdx_delay(struct s_drive_stuff *, long jifs);
+static int mcdx_transfer(struct s_drive_stuff *, char *buf, int sector,
+			 int nr_sectors);
+static int mcdx_xfer(struct s_drive_stuff *, char *buf, int sector,
+		     int nr_sectors);
+
+static int mcdx_config(struct s_drive_stuff *, int);
+static int mcdx_requestversion(struct s_drive_stuff *, struct s_version *,
+			       int);
+static int mcdx_stop(struct s_drive_stuff *, int);
+static int mcdx_hold(struct s_drive_stuff *, int);
+static int mcdx_reset(struct s_drive_stuff *, enum resetmodes, int);
+static int mcdx_setdrivemode(struct s_drive_stuff *, enum drivemodes, int);
+static int mcdx_setdatamode(struct s_drive_stuff *, enum datamodes, int);
+static int mcdx_requestsubqcode(struct s_drive_stuff *,
+				struct s_subqcode *, int);
+static int mcdx_requestmultidiskinfo(struct s_drive_stuff *,
+				     struct s_multi *, int);
+static int mcdx_requesttocdata(struct s_drive_stuff *, struct s_diskinfo *,
+			       int);
+static int mcdx_getstatus(struct s_drive_stuff *, int);
+static int mcdx_getval(struct s_drive_stuff *, int to, int delay, char *);
+static int mcdx_talk(struct s_drive_stuff *,
+		     const unsigned char *cmd, size_t,
+		     void *buffer, size_t size, unsigned int timeout, int);
+static int mcdx_readtoc(struct s_drive_stuff *);
+static int mcdx_playtrk(struct s_drive_stuff *, const struct cdrom_ti *);
+static int mcdx_playmsf(struct s_drive_stuff *, const struct cdrom_msf *);
+static int mcdx_setattentuator(struct s_drive_stuff *,
+			       struct cdrom_volctrl *, int);
 
 /* static variables ************************************************/
 
 static int mcdx_blocksizes[MCDX_NDRIVES];
 static int mcdx_drive_map[][2] = MCDX_DRIVEMAP;
-static struct s_drive_stuff* mcdx_stuffp[MCDX_NDRIVES];
-static struct s_drive_stuff* mcdx_irq_map[16] =
-		{0, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0};
+static struct s_drive_stuff *mcdx_stuffp[MCDX_NDRIVES];
+static struct s_drive_stuff *mcdx_irq_map[16] = { 0, 0, 0, 0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0, 0, 0, 0
+};
 MODULE_PARM(mcdx, "1-4i");
 
 static struct cdrom_device_ops mcdx_dops = {
-		open:			mcdx_open,
-		release:		mcdx_close,
-		media_changed:	mcdx_media_changed,
-		tray_move:		mcdx_tray_move,
-		lock_door:		mcdx_lockdoor,
-		audio_ioctl:	mcdx_audio_ioctl,
-		capability:		CDC_OPEN_TRAY | CDC_LOCK | CDC_MEDIA_CHANGED |
-						CDC_PLAY_AUDIO | CDC_DRIVE_STATUS,
+	open:mcdx_open,
+	release:mcdx_close,
+	media_changed:mcdx_media_changed,
+	tray_move:mcdx_tray_move,
+	lock_door:mcdx_lockdoor,
+	audio_ioctl:mcdx_audio_ioctl,
+	capability:CDC_OPEN_TRAY | CDC_LOCK | CDC_MEDIA_CHANGED |
+	    CDC_PLAY_AUDIO | CDC_DRIVE_STATUS,
 };
 
 static struct cdrom_device_info mcdx_info = {
-	ops:				&mcdx_dops,
-	speed:				2,
-	capacity:			1,
-	name:				"mcdx",
+	ops:&mcdx_dops,
+	speed:2,
+	capacity:1,
+	name:"mcdx",
 };
 
 
 /* KERNEL INTERFACE FUNCTIONS **************************************/
 
 
-static int mcdx_audio_ioctl(struct cdrom_device_info * cdi, unsigned int cmd,
-                      void * arg)
+static int mcdx_audio_ioctl(struct cdrom_device_info *cdi,
+			    unsigned int cmd, void *arg)
 {
 	struct s_drive_stuff *stuffp = mcdx_stuffp[MINOR(cdi->dev)];
 
-	if (!stuffp->present) return -ENXIO;
+	if (!stuffp->present)
+		return -ENXIO;
 
-	if (stuffp->xxx)
-	{
-		if(-1 == mcdx_requesttocdata(stuffp, &stuffp->di, 1))
-		{
+	if (stuffp->xxx) {
+		if (-1 == mcdx_requesttocdata(stuffp, &stuffp->di, 1)) {
 			stuffp->lastsector = -1;
-		}
-		else
-		{
+		} else {
 			stuffp->lastsector = (CD_FRAMESIZE / 512)
-					* msf2log(&stuffp->di.msf_leadout) - 1;
+			    * msf2log(&stuffp->di.msf_leadout) - 1;
 		}
 
-		if (stuffp->toc)
-		{
+		if (stuffp->toc) {
 			kfree(stuffp->toc);
 			stuffp->toc = NULL;
-			if (-1 == mcdx_readtoc(stuffp)) return -1;
+			if (-1 == mcdx_readtoc(stuffp))
+				return -1;
 		}
 
-		stuffp->xxx=0;
+		stuffp->xxx = 0;
 	}
 
 	switch (cmd) {
-		case CDROMSTART: {       
-			     xtrace(IOCTL, "ioctl() START\n");
-		        /* Spin up the drive.  Don't think we can do this.
-                 * For now, ignore it.
-                 */
+	case CDROMSTART:{
+			xtrace(IOCTL, "ioctl() START\n");
+			/* Spin up the drive.  Don't think we can do this.
+			   * For now, ignore it.
+			 */
 			return 0;
 		}
 
-		case CDROMSTOP: {
+	case CDROMSTOP:{
 			xtrace(IOCTL, "ioctl() STOP\n");
-            stuffp->audiostatus = CDROM_AUDIO_INVALID;
+			stuffp->audiostatus = CDROM_AUDIO_INVALID;
 			if (-1 == mcdx_stop(stuffp, 1))
 				return -EIO;
 			return 0;
 		}
 
-		case CDROMPLAYTRKIND: {
-			struct cdrom_ti *ti=(struct cdrom_ti *) arg;
+	case CDROMPLAYTRKIND:{
+			struct cdrom_ti *ti = (struct cdrom_ti *) arg;
 
 			xtrace(IOCTL, "ioctl() PLAYTRKIND\n");
 			if ((ti->cdti_trk0 < stuffp->di.n_first)
-					|| (ti->cdti_trk0 > stuffp->di.n_last)
-					|| (ti->cdti_trk1 < stuffp->di.n_first))
-			return -EINVAL;
+			    || (ti->cdti_trk0 > stuffp->di.n_last)
+			    || (ti->cdti_trk1 < stuffp->di.n_first))
+				return -EINVAL;
 			if (ti->cdti_trk1 > stuffp->di.n_last)
-					ti->cdti_trk1 = stuffp->di.n_last;
-            xtrace(PLAYTRK, "ioctl() track %d to %d\n", ti->cdti_trk0, ti->cdti_trk1);
-            return mcdx_playtrk(stuffp, ti);
-        }
+				ti->cdti_trk1 = stuffp->di.n_last;
+			xtrace(PLAYTRK, "ioctl() track %d to %d\n",
+			       ti->cdti_trk0, ti->cdti_trk1);
+			return mcdx_playtrk(stuffp, ti);
+		}
 
-        case CDROMPLAYMSF: {
-            struct cdrom_msf *msf=(struct cdrom_msf *) arg;
+	case CDROMPLAYMSF:{
+			struct cdrom_msf *msf = (struct cdrom_msf *) arg;
 
-            xtrace(IOCTL, "ioctl() PLAYMSF\n");
+			xtrace(IOCTL, "ioctl() PLAYMSF\n");
 
-            if ((stuffp->audiostatus == CDROM_AUDIO_PLAY)
-                && (-1 == mcdx_hold(stuffp, 1))) return -EIO;
+			if ((stuffp->audiostatus == CDROM_AUDIO_PLAY)
+			    && (-1 == mcdx_hold(stuffp, 1)))
+				return -EIO;
 
-            msf->cdmsf_min0 = uint2bcd(msf->cdmsf_min0);
-            msf->cdmsf_sec0 = uint2bcd(msf->cdmsf_sec0);
-            msf->cdmsf_frame0 = uint2bcd(msf->cdmsf_frame0);
+			msf->cdmsf_min0 = uint2bcd(msf->cdmsf_min0);
+			msf->cdmsf_sec0 = uint2bcd(msf->cdmsf_sec0);
+			msf->cdmsf_frame0 = uint2bcd(msf->cdmsf_frame0);
 
-            msf->cdmsf_min1 = uint2bcd(msf->cdmsf_min1);
-            msf->cdmsf_sec1 = uint2bcd(msf->cdmsf_sec1);
-            msf->cdmsf_frame1 = uint2bcd(msf->cdmsf_frame1);
+			msf->cdmsf_min1 = uint2bcd(msf->cdmsf_min1);
+			msf->cdmsf_sec1 = uint2bcd(msf->cdmsf_sec1);
+			msf->cdmsf_frame1 = uint2bcd(msf->cdmsf_frame1);
 
-            stuffp->stop.dt.minute = msf->cdmsf_min1;
-            stuffp->stop.dt.second = msf->cdmsf_sec1;
-            stuffp->stop.dt.frame = msf->cdmsf_frame1;
+			stuffp->stop.dt.minute = msf->cdmsf_min1;
+			stuffp->stop.dt.second = msf->cdmsf_sec1;
+			stuffp->stop.dt.frame = msf->cdmsf_frame1;
 
-            return mcdx_playmsf(stuffp, msf);
-        }
+			return mcdx_playmsf(stuffp, msf);
+		}
 
-        case CDROMRESUME: {
-            xtrace(IOCTL, "ioctl() RESUME\n");
-            return mcdx_playtrk(stuffp, NULL);
-        }
+	case CDROMRESUME:{
+			xtrace(IOCTL, "ioctl() RESUME\n");
+			return mcdx_playtrk(stuffp, NULL);
+		}
 
-		case CDROMREADTOCENTRY: {
-			struct cdrom_tocentry *entry=(struct cdrom_tocentry *) arg;
+	case CDROMREADTOCENTRY:{
+			struct cdrom_tocentry *entry =
+			    (struct cdrom_tocentry *) arg;
 			struct s_subqcode *tp = NULL;
 			xtrace(IOCTL, "ioctl() READTOCENTRY\n");
 
-            if (-1 == mcdx_readtoc(stuffp)) return -1;
+			if (-1 == mcdx_readtoc(stuffp))
+				return -1;
 			if (entry->cdte_track == CDROM_LEADOUT)
-				tp = &stuffp->toc[stuffp->di.n_last - stuffp->di.n_first + 1];
+				tp = &stuffp->toc[stuffp->di.n_last -
+						  stuffp->di.n_first + 1];
 			else if (entry->cdte_track > stuffp->di.n_last
-					|| entry->cdte_track < stuffp->di.n_first) return -EINVAL;
-			else tp = &stuffp->toc[entry->cdte_track - stuffp->di.n_first];
+				 || entry->cdte_track < stuffp->di.n_first)
+				return -EINVAL;
+			else
+				tp = &stuffp->toc[entry->cdte_track -
+						  stuffp->di.n_first];
 
-			if (NULL == tp) 
+			if (NULL == tp)
 				return -EIO;
 			entry->cdte_adr = tp->control;
 			entry->cdte_ctrl = tp->control >> 4;
-            /* Always return stuff in MSF, and let the Uniform cdrom driver
-                worry about what the user actually wants */
-			entry->cdte_addr.msf.minute = bcd2uint(tp->dt.minute);
-			entry->cdte_addr.msf.second = bcd2uint(tp->dt.second);
-			entry->cdte_addr.msf.frame = bcd2uint(tp->dt.frame);
+			/* Always return stuff in MSF, and let the Uniform cdrom driver
+			   worry about what the user actually wants */
+			entry->cdte_addr.msf.minute =
+			    bcd2uint(tp->dt.minute);
+			entry->cdte_addr.msf.second =
+			    bcd2uint(tp->dt.second);
+			entry->cdte_addr.msf.frame =
+			    bcd2uint(tp->dt.frame);
 			return 0;
 		}
 
-		case CDROMSUBCHNL: {
-			struct cdrom_subchnl *sub= (struct cdrom_subchnl *)arg;
+	case CDROMSUBCHNL:{
+			struct cdrom_subchnl *sub =
+			    (struct cdrom_subchnl *) arg;
 			struct s_subqcode q;
 
 			xtrace(IOCTL, "ioctl() SUBCHNL\n");
 
-			if (-1 == mcdx_requestsubqcode(stuffp, &q, 2)) 
+			if (-1 == mcdx_requestsubqcode(stuffp, &q, 2))
 				return -EIO;
 
-            xtrace(SUBCHNL, "audiostatus: %x\n", stuffp->audiostatus);
+			xtrace(SUBCHNL, "audiostatus: %x\n",
+			       stuffp->audiostatus);
 			sub->cdsc_audiostatus = stuffp->audiostatus;
 			sub->cdsc_adr = q.control;
 			sub->cdsc_ctrl = q.control >> 4;
 			sub->cdsc_trk = bcd2uint(q.tno);
 			sub->cdsc_ind = bcd2uint(q.index);
 
-            xtrace(SUBCHNL, "trk %d, ind %d\n",
-                    sub->cdsc_trk, sub->cdsc_ind);
-            /* Always return stuff in MSF, and let the Uniform cdrom driver
-                worry about what the user actually wants */
-			sub->cdsc_absaddr.msf.minute = bcd2uint(q.dt.minute);
-			sub->cdsc_absaddr.msf.second = bcd2uint(q.dt.second);
+			xtrace(SUBCHNL, "trk %d, ind %d\n",
+			       sub->cdsc_trk, sub->cdsc_ind);
+			/* Always return stuff in MSF, and let the Uniform cdrom driver
+			   worry about what the user actually wants */
+			sub->cdsc_absaddr.msf.minute =
+			    bcd2uint(q.dt.minute);
+			sub->cdsc_absaddr.msf.second =
+			    bcd2uint(q.dt.second);
 			sub->cdsc_absaddr.msf.frame = bcd2uint(q.dt.frame);
-			sub->cdsc_reladdr.msf.minute = bcd2uint(q.tt.minute);
-			sub->cdsc_reladdr.msf.second = bcd2uint(q.tt.second);
+			sub->cdsc_reladdr.msf.minute =
+			    bcd2uint(q.tt.minute);
+			sub->cdsc_reladdr.msf.second =
+			    bcd2uint(q.tt.second);
 			sub->cdsc_reladdr.msf.frame = bcd2uint(q.tt.frame);
 			xtrace(SUBCHNL,
-					"msf: abs %02d:%02d:%02d, rel %02d:%02d:%02d\n",
-					sub->cdsc_absaddr.msf.minute, sub->cdsc_absaddr.msf.second,
-					sub->cdsc_absaddr.msf.frame, sub->cdsc_reladdr.msf.minute,
-					sub->cdsc_reladdr.msf.second, sub->cdsc_reladdr.msf.frame);
+			       "msf: abs %02d:%02d:%02d, rel %02d:%02d:%02d\n",
+			       sub->cdsc_absaddr.msf.minute,
+			       sub->cdsc_absaddr.msf.second,
+			       sub->cdsc_absaddr.msf.frame,
+			       sub->cdsc_reladdr.msf.minute,
+			       sub->cdsc_reladdr.msf.second,
+			       sub->cdsc_reladdr.msf.frame);
 
 			return 0;
 		}
 
-		case CDROMREADTOCHDR: {
-			struct cdrom_tochdr *toc=(struct cdrom_tochdr *) arg;
+	case CDROMREADTOCHDR:{
+			struct cdrom_tochdr *toc =
+			    (struct cdrom_tochdr *) arg;
 
 			xtrace(IOCTL, "ioctl() READTOCHDR\n");
 			toc->cdth_trk0 = stuffp->di.n_first;
 			toc->cdth_trk1 = stuffp->di.n_last;
-			xtrace(TOCHDR, "ioctl() track0 = %d, track1 = %d\n",
-					stuffp->di.n_first, stuffp->di.n_last);
+			xtrace(TOCHDR,
+			       "ioctl() track0 = %d, track1 = %d\n",
+			       stuffp->di.n_first, stuffp->di.n_last);
 			return 0;
 		}
 
-		case CDROMPAUSE: {
+	case CDROMPAUSE:{
 			xtrace(IOCTL, "ioctl() PAUSE\n");
-			if (stuffp->audiostatus != CDROM_AUDIO_PLAY) return -EINVAL;
-			if (-1 == mcdx_stop(stuffp, 1)) return -EIO;
-            stuffp->audiostatus = CDROM_AUDIO_PAUSED;
-			if (-1 == mcdx_requestsubqcode(stuffp, &stuffp->start, 1))
+			if (stuffp->audiostatus != CDROM_AUDIO_PLAY)
+				return -EINVAL;
+			if (-1 == mcdx_stop(stuffp, 1))
+				return -EIO;
+			stuffp->audiostatus = CDROM_AUDIO_PAUSED;
+			if (-1 ==
+			    mcdx_requestsubqcode(stuffp, &stuffp->start,
+						 1))
 				return -EIO;
 			return 0;
 		}
 
-		case CDROMMULTISESSION: {
-			struct cdrom_multisession *ms=(struct cdrom_multisession *) arg;
+	case CDROMMULTISESSION:{
+			struct cdrom_multisession *ms =
+			    (struct cdrom_multisession *) arg;
 			xtrace(IOCTL, "ioctl() MULTISESSION\n");
 			/* Always return stuff in LBA, and let the Uniform cdrom driver
-				worry about what the user actually wants */
+			   worry about what the user actually wants */
 			ms->addr.lba = msf2log(&stuffp->multi.msf_last);
 			ms->xa_flag = !!stuffp->multi.multi;
-			xtrace(MS, "ioctl() (%d, 0x%08x [%02x:%02x.%02x])\n",
-				ms->xa_flag, ms->addr.lba, stuffp->multi.msf_last.minute,
-                    stuffp->multi.msf_last.second,stuffp->multi.msf_last.frame);
- 
+			xtrace(MS,
+			       "ioctl() (%d, 0x%08x [%02x:%02x.%02x])\n",
+			       ms->xa_flag, ms->addr.lba,
+			       stuffp->multi.msf_last.minute,
+			       stuffp->multi.msf_last.second,
+			       stuffp->multi.msf_last.frame);
+
 			return 0;
 		}
 
-		case CDROMEJECT: {
+	case CDROMEJECT:{
 			xtrace(IOCTL, "ioctl() EJECT\n");
-			if (stuffp->users > 1) return -EBUSY;
-			return(mcdx_tray_move(cdi, 1));
+			if (stuffp->users > 1)
+				return -EBUSY;
+			return (mcdx_tray_move(cdi, 1));
 		}
 
-        case CDROMCLOSETRAY: {
-            xtrace(IOCTL, "ioctl() CDROMCLOSETRAY\n");
-            return(mcdx_tray_move(cdi, 0));
-        }
+	case CDROMCLOSETRAY:{
+			xtrace(IOCTL, "ioctl() CDROMCLOSETRAY\n");
+			return (mcdx_tray_move(cdi, 0));
+		}
 
-        case CDROMVOLCTRL: {
-			struct cdrom_volctrl *volctrl=(struct cdrom_volctrl *)arg;
-            xtrace(IOCTL, "ioctl() VOLCTRL\n");
+	case CDROMVOLCTRL:{
+			struct cdrom_volctrl *volctrl =
+			    (struct cdrom_volctrl *) arg;
+			xtrace(IOCTL, "ioctl() VOLCTRL\n");
 
-#if 0		/* not tested! */
+#if 0				/* not tested! */
 			/* adjust for the weirdness of workman (md) */
 			/* can't test it (hs) */
 			volctrl.channel2 = volctrl.channel1;
 			volctrl.channel1 = volctrl.channel3 = 0x00;
 #endif
-            return mcdx_setattentuator(stuffp, volctrl, 2);
-        }
+			return mcdx_setattentuator(stuffp, volctrl, 2);
+		}
 
-		default:
-			xwarn("ioctl(): unknown request 0x%04x\n", cmd);
-	    	return -EINVAL;
+	default:
+		return -EINVAL;
 	}
 }
 
 void do_mcdx_request(request_queue_t * q)
 {
-    int dev;
-    struct s_drive_stuff *stuffp;
+	int dev;
+	struct s_drive_stuff *stuffp;
 
-  again:
+      again:
 
 	if (QUEUE_EMPTY) {
 		xtrace(REQUEST, "end_request(0): CURRENT == NULL\n");
@@ -525,237 +559,257 @@
 	}
 
 	if (CURRENT->rq_status == RQ_INACTIVE) {
-		xtrace(REQUEST, "end_request(0): rq_status == RQ_INACTIVE\n");
+		xtrace(REQUEST,
+		       "end_request(0): rq_status == RQ_INACTIVE\n");
 		return;
 	}
 
-    INIT_REQUEST;
+	INIT_REQUEST;
 
-    dev = MINOR(CURRENT->rq_dev);
-    stuffp = mcdx_stuffp[dev];
+	dev = MINOR(CURRENT->rq_dev);
+	stuffp = mcdx_stuffp[dev];
 
 	if ((dev < 0)
-		|| (dev >= MCDX_NDRIVES)
-		|| !stuffp
-		|| (!stuffp->present)) {
+	    || (dev >= MCDX_NDRIVES)
+	    || !stuffp || (!stuffp->present)) {
 		xwarn("do_request(): bad device: %s\n",
-				kdevname(CURRENT->rq_dev));
+		      kdevname(CURRENT->rq_dev));
 		xtrace(REQUEST, "end_request(0): bad device\n");
-		end_request(0); return;
-    }
+		end_request(0);
+		return;
+	}
 
 	if (stuffp->audio) {
 		xwarn("do_request() attempt to read from audio cd\n");
 		xtrace(REQUEST, "end_request(0): read from audio\n");
-		end_request(0); return;
+		end_request(0);
+		return;
 	}
 
 	xtrace(REQUEST, "do_request() (%lu + %lu)\n",
-			CURRENT->sector, CURRENT->nr_sectors);
+	       CURRENT->sector, CURRENT->nr_sectors);
 
-    switch (CURRENT->cmd) {
-      case WRITE:
-	  xwarn("do_request(): attempt to write to cd!!\n");
-	  xtrace(REQUEST, "end_request(0): write\n");
-	  end_request(0); return;
-
-      case READ:
-	  stuffp->status = 0;
-	  while (CURRENT->nr_sectors) {
-	      int i;
-
-	      i = mcdx_transfer(stuffp,
-				  CURRENT->buffer,
-				  CURRENT->sector,
-				  CURRENT->nr_sectors);
-
-		  if (i == -1) {
-			  end_request(0);
-			  goto again;
-		  }
-		  CURRENT->sector += i;
-	 	  CURRENT->nr_sectors -= i;
-		  CURRENT->buffer += (i * 512);
-	  }
-	  end_request(1);
-	  goto again;
-
-	  xtrace(REQUEST, "end_request(1)\n");
-	  end_request(1);
-	  break;
-
-      default:
-	  panic(MCDX "do_request: unknown command.\n");
-	  break;
-    }
+	switch (CURRENT->cmd) {
+	case WRITE:
+		xwarn("do_request(): attempt to write to cd!!\n");
+		xtrace(REQUEST, "end_request(0): write\n");
+		end_request(0);
+		return;
+
+	case READ:
+		stuffp->status = 0;
+		while (CURRENT->nr_sectors) {
+			int i;
+
+			i = mcdx_transfer(stuffp,
+					  CURRENT->buffer,
+					  CURRENT->sector,
+					  CURRENT->nr_sectors);
+
+			if (i == -1) {
+				end_request(0);
+				goto again;
+			}
+			CURRENT->sector += i;
+			CURRENT->nr_sectors -= i;
+			CURRENT->buffer += (i * 512);
+		}
+		end_request(1);
+		goto again;
+
+		xtrace(REQUEST, "end_request(1)\n");
+		end_request(1);
+		break;
+
+	default:
+		panic(MCDX "do_request: unknown command.\n");
+		break;
+	}
 
-    goto again;
+	goto again;
 }
 
-static int 
-mcdx_open(struct cdrom_device_info * cdi, int purpose)
+static int mcdx_open(struct cdrom_device_info *cdi, int purpose)
 {
-    struct s_drive_stuff *stuffp;
+	struct s_drive_stuff *stuffp;
 	xtrace(OPENCLOSE, "open()\n");
-    stuffp = mcdx_stuffp[MINOR(cdi->dev)];
-    if (!stuffp->present) return -ENXIO;
+	stuffp = mcdx_stuffp[MINOR(cdi->dev)];
+	if (!stuffp->present)
+		return -ENXIO;
 
 	/* Make the modules looking used ... (thanx bjorn).
 	 * But we shouldn't forget to decrement the module counter
 	 * on error return */
 	MOD_INC_USE_COUNT;
 
-    /* this is only done to test if the drive talks with us */
-    if (-1 == mcdx_getstatus(stuffp, 1)) {
+	/* this is only done to test if the drive talks with us */
+	if (-1 == mcdx_getstatus(stuffp, 1)) {
 		MOD_DEC_USE_COUNT;
 		return -EIO;
 	}
 
-    if (stuffp->xxx) {
+	if (stuffp->xxx) {
+
+		xtrace(OPENCLOSE, "open() media changed\n");
+		stuffp->audiostatus = CDROM_AUDIO_INVALID;
+		stuffp->readcmd = 0;
+		xtrace(OPENCLOSE, "open() Request multisession info\n");
+		if (-1 ==
+		    mcdx_requestmultidiskinfo(stuffp, &stuffp->multi, 6))
+			xinfo("No multidiskinfo\n");
+	} else {
+		/* multisession ? */
+		if (!stuffp->multi.multi)
+			stuffp->multi.msf_last.second = 2;
+
+		xtrace(OPENCLOSE, "open() MS: %d, last @ %02x:%02x.%02x\n",
+		       stuffp->multi.multi,
+		       stuffp->multi.msf_last.minute,
+		       stuffp->multi.msf_last.second,
+		       stuffp->multi.msf_last.frame);
+
+		{;
+		}		/* got multisession information */
+		/* request the disks table of contents (aka diskinfo) */
+		if (-1 == mcdx_requesttocdata(stuffp, &stuffp->di, 1)) {
+
+			stuffp->lastsector = -1;
 
-        xtrace(OPENCLOSE, "open() media changed\n");
-        stuffp->audiostatus = CDROM_AUDIO_INVALID;
-        stuffp->readcmd = 0;
-        xtrace(OPENCLOSE, "open() Request multisession info\n");
-        if (-1 == mcdx_requestmultidiskinfo( stuffp, &stuffp->multi, 6))
-            	xinfo("No multidiskinfo\n");
 		} else {
-            /* multisession ? */
-            if (!stuffp->multi.multi)
-                stuffp->multi.msf_last.second = 2;
-
-            xtrace(OPENCLOSE, "open() MS: %d, last @ %02x:%02x.%02x\n",
-                    stuffp->multi.multi,
-                    stuffp->multi.msf_last.minute,
-                    stuffp->multi.msf_last.second,
-                    stuffp->multi.msf_last.frame);
-
-        { ; } /* got multisession information */
-        /* request the disks table of contents (aka diskinfo) */
-        if (-1 == mcdx_requesttocdata(stuffp, &stuffp->di, 1)) {
-
-            stuffp->lastsector = -1;
-
-        } else {
-
-            stuffp->lastsector = (CD_FRAMESIZE / 512)
-                    * msf2log(&stuffp->di.msf_leadout) - 1;
-
-            xtrace(OPENCLOSE, "open() start %d (%02x:%02x.%02x) %d\n",
-                    stuffp->di.n_first,
-                    stuffp->di.msf_first.minute,
-                    stuffp->di.msf_first.second,
-                    stuffp->di.msf_first.frame,
-                    msf2log(&stuffp->di.msf_first));
-            xtrace(OPENCLOSE, "open() last %d (%02x:%02x.%02x) %d\n",
-                    stuffp->di.n_last,
-                    stuffp->di.msf_leadout.minute,
-                    stuffp->di.msf_leadout.second,
-                    stuffp->di.msf_leadout.frame,
-                    msf2log(&stuffp->di.msf_leadout));
-        }
-      
-        if (stuffp->toc) {
-            xtrace(MALLOC, "open() free old toc @ %p\n", stuffp->toc);
-            kfree(stuffp->toc);
-
-            stuffp->toc = NULL;
-        }
-
-        xtrace(OPENCLOSE, "open() init irq generation\n");
-        if (-1 == mcdx_config(stuffp, 1)) {
-            MOD_DEC_USE_COUNT;
-            return -EIO;
-        }
 
+			stuffp->lastsector = (CD_FRAMESIZE / 512)
+			    * msf2log(&stuffp->di.msf_leadout) - 1;
+
+			xtrace(OPENCLOSE,
+			       "open() start %d (%02x:%02x.%02x) %d\n",
+			       stuffp->di.n_first,
+			       stuffp->di.msf_first.minute,
+			       stuffp->di.msf_first.second,
+			       stuffp->di.msf_first.frame,
+			       msf2log(&stuffp->di.msf_first));
+			xtrace(OPENCLOSE,
+			       "open() last %d (%02x:%02x.%02x) %d\n",
+			       stuffp->di.n_last,
+			       stuffp->di.msf_leadout.minute,
+			       stuffp->di.msf_leadout.second,
+			       stuffp->di.msf_leadout.frame,
+			       msf2log(&stuffp->di.msf_leadout));
+		}
+
+		if (stuffp->toc) {
+			xtrace(MALLOC, "open() free old toc @ %p\n",
+			       stuffp->toc);
+			kfree(stuffp->toc);
+
+			stuffp->toc = NULL;
+		}
+
+		xtrace(OPENCLOSE, "open() init irq generation\n");
+		if (-1 == mcdx_config(stuffp, 1)) {
+			MOD_DEC_USE_COUNT;
+			return -EIO;
+		}
 #if FALLBACK
-        /* Set the read speed */
-        xwarn("AAA %x AAA\n", stuffp->readcmd);
-        if (stuffp->readerrs) stuffp->readcmd = READ1X;
-        else stuffp->readcmd =
-                stuffp->present | SINGLE ? READ1X : READ2X;
-        xwarn("XXX %x XXX\n", stuffp->readcmd);
+		/* Set the read speed */
+		xwarn("AAA %x AAA\n", stuffp->readcmd);
+		if (stuffp->readerrs)
+			stuffp->readcmd = READ1X;
+		else
+			stuffp->readcmd =
+			    stuffp->present | SINGLE ? READ1X : READ2X;
+		xwarn("XXX %x XXX\n", stuffp->readcmd);
 #else
-        stuffp->readcmd = stuffp->present | SINGLE ? READ1X : READ2X;
+		stuffp->readcmd =
+		    stuffp->present | SINGLE ? READ1X : READ2X;
 #endif
 
-        /* try to get the first sector, iff any ... */
-        if (stuffp->lastsector >= 0) {
-            char buf[512];
-            int ans;
-            int tries;
-
-            stuffp->xa = 0;
-            stuffp->audio = 0;
-
-            for (tries = 6; tries; tries--) {
-
-                stuffp->introk = 1;
-
-                xtrace(OPENCLOSE, "open() try as %s\n",
-                    stuffp->xa ? "XA" : "normal");
-                /* set data mode */
-                if (-1 == (ans = mcdx_setdatamode(stuffp,
-                        stuffp->xa ? MODE2 : MODE1, 1))) {
-                    /* MOD_DEC_USE_COUNT, return -EIO; */
-                    stuffp->xa = 0;
-                    break;
-                }
-
-                if ((stuffp->audio = e_audio(ans))) break;
-
-                while (0 == (ans = mcdx_transfer(stuffp, buf, 0, 1)))
-                    ;
-
-                if (ans == 1) break;
-                stuffp->xa = !stuffp->xa;
-            }
-        }
-        /* xa disks will be read in raw mode, others not */
-        if (-1 == mcdx_setdrivemode(stuffp,
-                stuffp->xa ? RAW : COOKED, 1)) {
-            MOD_DEC_USE_COUNT;
-            return -EIO;
-        }
-        if (stuffp->audio) {
-            xinfo("open() audio disk found\n");
-        } else if (stuffp->lastsector >= 0) {
-            xinfo("open() %s%s disk found\n",
-                    stuffp->xa ? "XA / " : "",
-                    stuffp->multi.multi ? "Multi Session" : "Single Session");
-        }
-    }
+		/* try to get the first sector, iff any ... */
+		if (stuffp->lastsector >= 0) {
+			char buf[512];
+			int ans;
+			int tries;
+
+			stuffp->xa = 0;
+			stuffp->audio = 0;
+
+			for (tries = 6; tries; tries--) {
+
+				stuffp->introk = 1;
+
+				xtrace(OPENCLOSE, "open() try as %s\n",
+				       stuffp->xa ? "XA" : "normal");
+				/* set data mode */
+				if (-1 == (ans = mcdx_setdatamode(stuffp,
+								  stuffp->
+								  xa ?
+								  MODE2 :
+								  MODE1,
+								  1))) {
+					/* MOD_DEC_USE_COUNT, return -EIO; */
+					stuffp->xa = 0;
+					break;
+				}
+
+				if ((stuffp->audio = e_audio(ans)))
+					break;
+
+				while (0 ==
+				       (ans =
+					mcdx_transfer(stuffp, buf, 0, 1)));
+
+				if (ans == 1)
+					break;
+				stuffp->xa = !stuffp->xa;
+			}
+		}
+		/* xa disks will be read in raw mode, others not */
+		if (-1 == mcdx_setdrivemode(stuffp,
+					    stuffp->xa ? RAW : COOKED,
+					    1)) {
+			MOD_DEC_USE_COUNT;
+			return -EIO;
+		}
+		if (stuffp->audio) {
+			xinfo("open() audio disk found\n");
+		} else if (stuffp->lastsector >= 0) {
+			xinfo("open() %s%s disk found\n",
+			      stuffp->xa ? "XA / " : "",
+			      stuffp->multi.
+			      multi ? "Multi Session" : "Single Session");
+		}
+	}
 	stuffp->xxx = 0;
-    stuffp->users++;
-    return 0;
+	stuffp->users++;
+	return 0;
 }
 
-static void mcdx_close(struct cdrom_device_info * cdi)
+static void mcdx_close(struct cdrom_device_info *cdi)
 {
-    struct s_drive_stuff *stuffp;
+	struct s_drive_stuff *stuffp;
 
-    xtrace(OPENCLOSE, "close()\n");
+	xtrace(OPENCLOSE, "close()\n");
 
-    stuffp = mcdx_stuffp[MINOR(cdi->dev)];
+	stuffp = mcdx_stuffp[MINOR(cdi->dev)];
 
-    --stuffp->users;
+	--stuffp->users;
 
-    MOD_DEC_USE_COUNT;
+	MOD_DEC_USE_COUNT;
 }
 
-static int mcdx_media_changed(struct cdrom_device_info * cdi, int disc_nr) 
+static int mcdx_media_changed(struct cdrom_device_info *cdi, int disc_nr)
 /*	Return: 1 if media changed since last call to this function
 			0 otherwise */
 {
-    struct s_drive_stuff *stuffp;
+	struct s_drive_stuff *stuffp;
 
-    xinfo("mcdx_media_changed called for device %s\n",
-	  kdevname(cdi->dev));
+	xinfo("mcdx_media_changed called for device %s\n",
+	      kdevname(cdi->dev));
 
 	stuffp = mcdx_stuffp[MINOR(cdi->dev)];
 	mcdx_getstatus(stuffp, 1);
 
-	if (stuffp->yyy == 0) return 0;
+	if (stuffp->yyy == 0)
+		return 0;
 
 	stuffp->yyy = 0;
 	return 1;
@@ -765,10 +819,12 @@
 static int __init mcdx_setup(char *str)
 {
 	int pi[4];
-	(void)get_options(str, ARRAY_SIZE(pi), pi);
-	
-	if (pi[0] > 0) mcdx_drive_map[0][0] = pi[1];
-	if (pi[0] > 1) mcdx_drive_map[0][1] = pi[2];
+	(void) get_options(str, ARRAY_SIZE(pi), pi);
+
+	if (pi[0] > 0)
+		mcdx_drive_map[0][0] = pi[1];
+	if (pi[0] > 1)
+		mcdx_drive_map[0][1] = pi[2];
 	return 1;
 }
 
@@ -787,7 +843,8 @@
  *	May be we could use a simple count loop w/ jumps to itself, but
  *	I wanna make this independent of cpu speed. [1 jiffy is 1/HZ] sec */
 {
-	if (jifs < 0) return;
+	if (jifs < 0)
+		return;
 
 	xtrace(SLEEP, "*** delay: sleepq\n");
 	interruptible_sleep_on_timeout(&stuff->sleepq, jifs);
@@ -797,24 +854,22 @@
 	}
 }
 
-static void
-mcdx_intr(int irq, void *dev_id, struct pt_regs* regs)
+static void mcdx_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
-    struct s_drive_stuff *stuffp;
+	struct s_drive_stuff *stuffp;
 	unsigned char b;
 
-    stuffp = mcdx_irq_map[irq];
+	stuffp = mcdx_irq_map[irq];
 
-    if (stuffp == NULL ) {
+	if (stuffp == NULL) {
 		xwarn("mcdx: no device for intr %d\n", irq);
 		return;
-    }
-
+	}
 #ifdef AK2
-	if ( !stuffp->busy && stuffp->pending )
+	if (!stuffp->busy && stuffp->pending)
 		stuffp->int_err = 1;
 
-#endif /* AK2 */
+#endif				/* AK2 */
 	/* get the interrupt status */
 	b = inb((unsigned int) stuffp->rreg_status);
 	stuffp->introk = ~b & MCDX_RBIT_DTEN;
@@ -829,26 +884,23 @@
 	if (!stuffp->introk) {
 		xtrace(IRQ, "intr() irq %d hw status 0x%02x\n", irq, b);
 		if (~b & MCDX_RBIT_STEN) {
-			xinfo(  "intr() irq %d    status 0x%02x\n",
-					irq, inb((unsigned int) stuffp->rreg_data));
+			xinfo("intr() irq %d    status 0x%02x\n",
+			      irq, inb((unsigned int) stuffp->rreg_data));
 		} else {
-			xinfo(  "intr() irq %d ambiguous hw status\n", irq);
+			xinfo("intr() irq %d ambiguous hw status\n", irq);
 		}
 	} else {
 		xtrace(IRQ, "irq() irq %d ok, status %02x\n", irq, b);
-    }
+	}
 
-    stuffp->busy = 0;
-    wake_up_interruptible(&stuffp->busyq);
+	stuffp->busy = 0;
+	wake_up_interruptible(&stuffp->busyq);
 }
 
 
-static int
-mcdx_talk (
-		struct s_drive_stuff *stuffp,
-		const unsigned char *cmd, size_t cmdlen,
-		void *buffer, size_t size,
-		unsigned int timeout, int tries)
+static int mcdx_talk(struct s_drive_stuff *stuffp,
+	  const unsigned char *cmd, size_t cmdlen,
+	  void *buffer, size_t size, unsigned int timeout, int tries)
 /* Send a command to the drive, wait for the result.
  * returns -1 on timeout, drive status otherwise
  * If buffer is not zero, the result (length size) is stored there.
@@ -857,99 +909,108 @@
  */
 {
 	int st;
-    char c;
-    int discard;
+	char c;
+	int discard;
 
 	/* Somebody wants the data read? */
-    if ((discard = (buffer == NULL))) buffer = &c;
+	if ((discard = (buffer == NULL)))
+		buffer = &c;
 
-    while (stuffp->lock) {
+	while (stuffp->lock) {
 		xtrace(SLEEP, "*** talk: lockq\n");
 		interruptible_sleep_on(&stuffp->lockq);
 		xtrace(SLEEP, "talk: awoken\n");
 	}
 
-    stuffp->lock = 1;
+	stuffp->lock = 1;
 
 	/* An operation other then reading data destroys the
-     * data already requested and remembered in stuffp->request, ... */
-    stuffp->valid = 0;
+	   * data already requested and remembered in stuffp->request, ... */
+	stuffp->valid = 0;
 
 #if MCDX_DEBUG & TALK
 	{
 		unsigned char i;
-		xtrace(TALK, "talk() %d / %d tries, res.size %d, command 0x%02x",
-				tries, timeout, size, (unsigned char) cmd[0]);
-		for (i = 1; i < cmdlen; i++) xtrace(TALK, " 0x%02x", cmd[i]);
+		xtrace(TALK,
+		       "talk() %d / %d tries, res.size %d, command 0x%02x",
+		       tries, timeout, size, (unsigned char) cmd[0]);
+		for (i = 1; i < cmdlen; i++)
+			xtrace(TALK, " 0x%02x", cmd[i]);
 		xtrace(TALK, "\n");
 	}
 #endif
 
-    /*  give up if all tries are done (bad) or if the status
-     *  st != -1 (good) */
+	/*  give up if all tries are done (bad) or if the status
+	 *  st != -1 (good) */
 	for (st = -1; st == -1 && tries; tries--) {
 
-		char *bp = (char*) buffer;
+		char *bp = (char *) buffer;
 		size_t sz = size;
 
 		outsb((unsigned int) stuffp->wreg_data, cmd, cmdlen);
-        xtrace(TALK, "talk() command sent\n");
+		xtrace(TALK, "talk() command sent\n");
 
-        /* get the status byte */
-        if (-1 == mcdx_getval(stuffp, timeout, 0, bp)) {
-            xinfo("talk() %02x timed out (status), %d tr%s left\n",
-                    cmd[0], tries - 1, tries == 2 ? "y" : "ies");
-                continue;
-        }
-        st = *bp;
-        sz--;
-        if (!discard) bp++;
-
-        xtrace(TALK, "talk() got status 0x%02x\n", st);
-
-        /* command error? */
-        if (e_cmderr(st)) {
-            xwarn("command error cmd = %02x %s \n",
-                    cmd[0], cmdlen > 1 ? "..." : "");
-            st = -1;
-            continue;
-		}
-
-        /* audio status? */
-        if (stuffp->audiostatus == CDROM_AUDIO_INVALID)
-            stuffp->audiostatus =
-                    e_audiobusy(st) ? CDROM_AUDIO_PLAY : CDROM_AUDIO_NO_STATUS;
-        else if (stuffp->audiostatus == CDROM_AUDIO_PLAY
-                && e_audiobusy(st) == 0)
-            stuffp->audiostatus = CDROM_AUDIO_COMPLETED;
-
-        /* media change? */
-        if (e_changed(st)) {
-            xinfo("talk() media changed\n");
-            stuffp->xxx = stuffp->yyy = 1;
-        }
-
-        /* now actually get the data */
-        while (sz--) {
-            if (-1 == mcdx_getval(stuffp, timeout, 0, bp)) {
-                xinfo("talk() %02x timed out (data), %d tr%s left\n",
-                        cmd[0], tries - 1, tries == 2 ? "y" : "ies");
-                st = -1; break;
-            }
-            if (!discard) bp++;
-            xtrace(TALK, "talk() got 0x%02x\n", *(bp - 1));
-        }
-    }
+		/* get the status byte */
+		if (-1 == mcdx_getval(stuffp, timeout, 0, bp)) {
+			xinfo("talk() %02x timed out (status), %d tr%s left\n",
+			     cmd[0], tries - 1, tries == 2 ? "y" : "ies");
+			continue;
+		}
+		st = *bp;
+		sz--;
+		if (!discard)
+			bp++;
+
+		xtrace(TALK, "talk() got status 0x%02x\n", st);
+
+		/* command error? */
+		if (e_cmderr(st)) {
+			xwarn("command error cmd = %02x %s \n",
+			      cmd[0], cmdlen > 1 ? "..." : "");
+			st = -1;
+			continue;
+		}
+
+		/* audio status? */
+		if (stuffp->audiostatus == CDROM_AUDIO_INVALID)
+			stuffp->audiostatus =
+			    e_audiobusy(st) ? CDROM_AUDIO_PLAY :
+			    CDROM_AUDIO_NO_STATUS;
+		else if (stuffp->audiostatus == CDROM_AUDIO_PLAY
+			 && e_audiobusy(st) == 0)
+			stuffp->audiostatus = CDROM_AUDIO_COMPLETED;
+
+		/* media change? */
+		if (e_changed(st)) {
+			xinfo("talk() media changed\n");
+			stuffp->xxx = stuffp->yyy = 1;
+		}
+
+		/* now actually get the data */
+		while (sz--) {
+			if (-1 == mcdx_getval(stuffp, timeout, 0, bp)) {
+				xinfo("talk() %02x timed out (data), %d tr%s left\n",
+				     cmd[0], tries - 1,
+				     tries == 2 ? "y" : "ies");
+				st = -1;
+				break;
+			}
+			if (!discard)
+				bp++;
+			xtrace(TALK, "talk() got 0x%02x\n", *(bp - 1));
+		}
+	}
 
 #if !MCDX_QUIET
-    if (!tries && st == -1) xinfo("talk() giving up\n");
+	if (!tries && st == -1)
+		xinfo("talk() giving up\n");
 #endif
 
-    stuffp->lock = 0;
-    wake_up_interruptible(&stuffp->lockq);
+	stuffp->lock = 0;
+	wake_up_interruptible(&stuffp->lockq);
 
 	xtrace(TALK, "talk() done with 0x%02x\n", st);
-    return st;
+	return st;
 }
 
 /* MODULE STUFF ***********************************************************/
@@ -962,51 +1023,56 @@
 	int drives = 0;
 
 	mcdx_init();
-	for (i = 0; i < MCDX_NDRIVES; i++)  {
+	for (i = 0; i < MCDX_NDRIVES; i++) {
 		if (mcdx_stuffp[i]) {
-		xtrace(INIT, "init_module() drive %d stuff @ %p\n",
-				i, mcdx_stuffp[i]);
+			xtrace(INIT, "init_module() drive %d stuff @ %p\n",
+			       i, mcdx_stuffp[i]);
 			drives++;
 		}
 	}
 
-    if (!drives)
+	if (!drives)
 		return -EIO;
 
-    return 0;
+	return 0;
 }
 
 void __exit mcdx_exit(void)
 {
-    int i;
+	int i;
 
 	xinfo("cleanup_module called\n");
 
-    for (i = 0; i < MCDX_NDRIVES; i++) {
+	for (i = 0; i < MCDX_NDRIVES; i++) {
 		struct s_drive_stuff *stuffp;
-        	if (unregister_cdrom(&mcdx_info)) {
+		if (unregister_cdrom(&mcdx_info)) {
 			printk(KERN_WARNING "Can't unregister cdrom mcdx\n");
 			return;
 		}
 		stuffp = mcdx_stuffp[i];
-		if (!stuffp) continue;
-		release_region((unsigned long) stuffp->wreg_data, MCDX_IO_SIZE);
+		if (!stuffp)
+			continue;
+		release_region((unsigned long) stuffp->wreg_data,
+			       MCDX_IO_SIZE);
 		free_irq(stuffp->irq, NULL);
 		if (stuffp->toc) {
-			xtrace(MALLOC, "cleanup_module() free toc @ %p\n", stuffp->toc);
+			xtrace(MALLOC, "cleanup_module() free toc @ %p\n",
+			       stuffp->toc);
 			kfree(stuffp->toc);
 		}
-		xtrace(MALLOC, "cleanup_module() free stuffp @ %p\n", stuffp);
+		xtrace(MALLOC, "cleanup_module() free stuffp @ %p\n",
+		       stuffp);
 		mcdx_stuffp[i] = NULL;
 		kfree(stuffp);
-    }
+	}
 
-    if (devfs_unregister_blkdev(MAJOR_NR, "mcdx") != 0) {
-        xwarn("cleanup() unregister_blkdev() failed\n");
-    }
+	if (devfs_unregister_blkdev(MAJOR_NR, "mcdx") != 0) {
+		xwarn("cleanup() unregister_blkdev() failed\n");
+	}
 	blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
 #if !MCDX_QUIET
-	else xinfo("cleanup() succeeded\n");
+	else
+	xinfo("cleanup() succeeded\n");
 #endif
 }
 
@@ -1021,7 +1087,7 @@
 int __init mcdx_init_drive(int drive)
 {
 	struct s_version version;
-	struct s_drive_stuff* stuffp;
+	struct s_drive_stuff *stuffp;
 	int size = sizeof(*stuffp);
 	char msg[80];
 
@@ -1047,11 +1113,12 @@
 
 	/* setup our irq and i/o addresses */
 	stuffp->irq = irq(mcdx_drive_map[drive]);
-	stuffp->wreg_data = stuffp->rreg_data = port(mcdx_drive_map[drive]);
+	stuffp->wreg_data = stuffp->rreg_data =
+	    port(mcdx_drive_map[drive]);
 	stuffp->wreg_reset = stuffp->rreg_status = stuffp->wreg_data + 1;
 	stuffp->wreg_hcon = stuffp->wreg_reset + 1;
 	stuffp->wreg_chn = stuffp->wreg_hcon + 1;
-	
+
 	init_waitqueue_head(&stuffp->busyq);
 	init_waitqueue_head(&stuffp->lockq);
 	init_waitqueue_head(&stuffp->sleepq);
@@ -1066,7 +1133,7 @@
 		xtrace(MALLOC, "init() free stuffp @ %p\n", stuffp);
 		kfree(stuffp);
 		xtrace(INIT, "init() continue at next drive\n");
-		return 0; /* next drive */
+		return 0;	/* next drive */
 	}
 
 	xtrace(INIT, "init() i/o port is available at 0x%3p\n",
@@ -1078,8 +1145,7 @@
 	if (-1 == mcdx_requestversion(stuffp, &version, 4)) {
 		/* failed, next drive */
 		xwarn("%s=0x%3p,%d: Init failed. Can't get version.\n",
-		      MCDX,
-		      stuffp->wreg_data, stuffp->irq);
+		      MCDX, stuffp->wreg_data, stuffp->irq);
 		xtrace(MALLOC, "init() free stuffp @ %p\n", stuffp);
 		kfree(stuffp);
 		xtrace(INIT, "init() continue at next drive\n");
@@ -1088,35 +1154,35 @@
 
 	switch (version.code) {
 	case 'D':
-                stuffp->readcmd = READ2X;
-                stuffp->present = DOUBLE | DOOR | MULTI;
-                break;
+		stuffp->readcmd = READ2X;
+		stuffp->present = DOUBLE | DOOR | MULTI;
+		break;
 	case 'F':
-                stuffp->readcmd = READ1X;
-                stuffp->present = SINGLE | DOOR | MULTI;
-                break;
+		stuffp->readcmd = READ1X;
+		stuffp->present = SINGLE | DOOR | MULTI;
+		break;
 	case 'M':
-                stuffp->readcmd = READ1X;
-                stuffp->present = SINGLE;
-                break;
+		stuffp->readcmd = READ1X;
+		stuffp->present = SINGLE;
+		break;
 	default:
-                stuffp->present = 0; break;
+		stuffp->present = 0;
+		break;
 	}
 
-        stuffp->playcmd = READ1X;
+	stuffp->playcmd = READ1X;
 
 	if (!stuffp->present) {
 		xwarn("%s=0x%3p,%d: Init failed. No Mitsumi CD-ROM?.\n",
 		      MCDX, stuffp->wreg_data, stuffp->irq);
 		kfree(stuffp);
-		return 0; /* next drive */
+		return 0;	/* next drive */
 	}
 
 	xtrace(INIT, "init() register blkdev\n");
 	if (devfs_register_blkdev(MAJOR_NR, "mcdx", &cdrom_fops) != 0) {
 		xwarn("%s=0x%3p,%d: Init failed. Can't get major %d.\n",
-		      MCDX,
-		      stuffp->wreg_data, stuffp->irq, MAJOR_NR);
+		      MCDX, stuffp->wreg_data, stuffp->irq, MAJOR_NR);
 		kfree(stuffp);
 		return 1;
 	}
@@ -1129,21 +1195,19 @@
 	mcdx_irq_map[stuffp->irq] = stuffp;
 	if (request_irq(stuffp->irq, mcdx_intr, SA_INTERRUPT, "mcdx", NULL)) {
 		xwarn("%s=0x%3p,%d: Init failed. Can't get irq (%d).\n",
-		      MCDX,
-		      stuffp->wreg_data, stuffp->irq, stuffp->irq);
+		      MCDX, stuffp->wreg_data, stuffp->irq, stuffp->irq);
 		stuffp->irq = 0;
 		blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
 		kfree(stuffp);
 		return 0;
 	}
 	request_region((unsigned int) stuffp->wreg_data,
-		       MCDX_IO_SIZE,
-		       "mcdx");
+		       MCDX_IO_SIZE, "mcdx");
 
 	xtrace(INIT, "init() get garbage\n");
 	{
 		int i;
-		mcdx_delay(stuffp, HZ/2);
+		mcdx_delay(stuffp, HZ / 2);
 		for (i = 100; i; i--)
 			(void) inb((unsigned int) stuffp->rreg_status);
 	}
@@ -1160,24 +1224,23 @@
 	stuffp->minor = drive;
 
 	sprintf(msg, " mcdx: Mitsumi CD-ROM installed at 0x%3p, irq %d."
-		" (Firmware version %c %x)\n", 
-		stuffp->wreg_data, stuffp->irq, version.code,
-		version.ver);
+		" (Firmware version %c %x)\n",
+		stuffp->wreg_data, stuffp->irq, version.code, version.ver);
 	mcdx_stuffp[drive] = stuffp;
 	xtrace(INIT, "init() mcdx_stuffp[%d] = %p\n", drive, stuffp);
-	mcdx_info.dev = MKDEV(MAJOR_NR,0);
-        if (register_cdrom(&mcdx_info) != 0) {
+	mcdx_info.dev = MKDEV(MAJOR_NR, 0);
+	if (register_cdrom(&mcdx_info) != 0) {
 		printk("Cannot register Mitsumi CD-ROM!\n");
 		release_region((unsigned long) stuffp->wreg_data,
 			       MCDX_IO_SIZE);
 		free_irq(stuffp->irq, NULL);
 		kfree(stuffp);
 		if (devfs_unregister_blkdev(MAJOR_NR, "mcdx") != 0)
-        		xwarn("cleanup() unregister_blkdev() failed\n");
+			xwarn("cleanup() unregister_blkdev() failed\n");
 		blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
 		return 2;
-        }
-        printk(msg);
+	}
+	printk(msg);
 	return 0;
 }
 
@@ -1198,7 +1261,7 @@
 
 	/* do the initialisation */
 	for (drive = 0; drive < MCDX_NDRIVES; drive++) {
-		switch(mcdx_init_drive(drive)) {
+		switch (mcdx_init_drive(drive)) {
 		case 2:
 			return -EIO;
 		case 1:
@@ -1208,9 +1271,8 @@
 	return 0;
 }
 
-static int
-mcdx_transfer(struct s_drive_stuff *stuffp,
-		char *p, int sector, int nr_sectors)
+static int mcdx_transfer(struct s_drive_stuff *stuffp,
+	      char *p, int sector, int nr_sectors)
 /*	This seems to do the actually transfer.  But it does more.  It
 	keeps track of errors occurred and will (if possible) fall back
 	to single speed on error.
@@ -1222,8 +1284,10 @@
 	ans = mcdx_xfer(stuffp, p, sector, nr_sectors);
 	return ans;
 #if FALLBACK
-	if (-1 == ans) stuffp->readerrs++;
-	else return ans;
+	if (-1 == ans)
+		stuffp->readerrs++;
+	else
+		return ans;
 
 	if (stuffp->readerrs && stuffp->readcmd == READ1X) {
 		xwarn("XXX Already reading 1x -- no chance\n");
@@ -1240,99 +1304,109 @@
 
 
 static int mcdx_xfer(struct s_drive_stuff *stuffp,
-		char *p, int sector, int nr_sectors)
+		     char *p, int sector, int nr_sectors)
 /*	This does actually the transfer from the drive.
 	Return:	-1 on timeout or other error
 			else status byte (as in stuff->st) */
 {
-    int border;
-    int done = 0;
+	int border;
+	int done = 0;
 	long timeout;
 
 	if (stuffp->audio) {
-			xwarn("Attempt to read from audio CD.\n");
-			return -1;
+		xwarn("Attempt to read from audio CD.\n");
+		return -1;
 	}
 
 	if (!stuffp->readcmd) {
-			xinfo("Can't transfer from missing disk.\n");
-			return -1;
+		xinfo("Can't transfer from missing disk.\n");
+		return -1;
 	}
 
-    while (stuffp->lock) {
+	while (stuffp->lock) {
 		interruptible_sleep_on(&stuffp->lockq);
 	}
 
-    if (stuffp->valid
-			&& (sector >= stuffp->pending)
-			&& (sector < stuffp->low_border)) {
+	if (stuffp->valid && (sector >= stuffp->pending)
+	    && (sector < stuffp->low_border)) {
 
 		/* All (or at least a part of the sectors requested) seems
-         * to be already requested, so we don't need to bother the
-		 * drive with new requests ...
-		 * Wait for the drive become idle, but first
-		 * check for possible occurred errors --- the drive
-		 * seems to report them asynchronously */
-
-
-	border = stuffp->high_border < (border = sector + nr_sectors)
-			? stuffp->high_border : border;
-
-	stuffp->lock = current->pid;
-
-	do {
-
-	    while (stuffp->busy) {
-
-			timeout = interruptible_sleep_on_timeout(&stuffp->busyq, 5*HZ);
+		   * to be already requested, so we don't need to bother the
+		   * drive with new requests ...
+		   * Wait for the drive become idle, but first
+		   * check for possible occurred errors --- the drive
+		   * seems to report them asynchronously */
+
+
+		border = stuffp->high_border < (border =
+						sector + nr_sectors)
+		    ? stuffp->high_border : border;
+
+		stuffp->lock = current->pid;
+
+		do {
+
+			while (stuffp->busy) {
+
+				timeout =
+				    interruptible_sleep_on_timeout
+				    (&stuffp->busyq, 5 * HZ);
+
+				if (!stuffp->introk) {
+					xtrace(XFER,
+					       "error via interrupt\n");
+				} else if (!timeout) {
+					xtrace(XFER, "timeout\n");
+				} else if (signal_pending(current)) {
+					xtrace(XFER, "signal\n");
+				} else
+					continue;
+
+				stuffp->lock = 0;
+				stuffp->busy = 0;
+				stuffp->valid = 0;
+
+				wake_up_interruptible(&stuffp->lockq);
+				xtrace(XFER, "transfer() done (-1)\n");
+				return -1;
+			}
 
-			if (!stuffp->introk) { xtrace(XFER, "error via interrupt\n"); }
-			else if (!timeout) { xtrace(XFER, "timeout\n"); }
-			else if (signal_pending(current)) {
-				xtrace(XFER, "signal\n");
-			} else continue;
+			/* check if we need to set the busy flag (as we
+			 * expect an interrupt */
+			stuffp->busy = (3 == (stuffp->pending & 3));
+
+			/* Test if it's the first sector of a block,
+			 * there we have to skip some bytes as we read raw data */
+			if (stuffp->xa && (0 == (stuffp->pending & 3))) {
+				const int HEAD =
+				    CD_FRAMESIZE_RAW - CD_XA_TAIL -
+				    CD_FRAMESIZE;
+				insb((unsigned int) stuffp->rreg_data, p,
+				     HEAD);
+			}
 
-			stuffp->lock = 0;
-			stuffp->busy = 0;
-			stuffp->valid = 0;
+			/* now actually read the data */
+			insb((unsigned int) stuffp->rreg_data, p, 512);
 
-			wake_up_interruptible(&stuffp->lockq);
-			xtrace(XFER, "transfer() done (-1)\n");
-			return -1;
-	    }
+			/* test if it's the last sector of a block,
+			 * if so, we have to handle XA special */
+			if ((3 == (stuffp->pending & 3)) && stuffp->xa) {
+				char dummy[CD_XA_TAIL];
+				insb((unsigned int) stuffp->rreg_data,
+				     &dummy[0], CD_XA_TAIL);
+			}
 
- 		/* check if we need to set the busy flag (as we
-		 * expect an interrupt */
-		stuffp->busy = (3 == (stuffp->pending & 3));
-
-		/* Test if it's the first sector of a block,
-		 * there we have to skip some bytes as we read raw data */
-		if (stuffp->xa && (0 == (stuffp->pending & 3))) {
-			const int HEAD = CD_FRAMESIZE_RAW - CD_XA_TAIL - CD_FRAMESIZE;
-			insb((unsigned int) stuffp->rreg_data, p, HEAD);
-		}
-
-		/* now actually read the data */
-	    insb((unsigned int) stuffp->rreg_data, p, 512);
-
-		/* test if it's the last sector of a block,
-		 * if so, we have to handle XA special */
-		if ((3 == (stuffp->pending & 3)) && stuffp->xa) {
-			char dummy[CD_XA_TAIL];
-			insb((unsigned int) stuffp->rreg_data, &dummy[0], CD_XA_TAIL);
-		}
-
-	    if (stuffp->pending == sector) {
-			p += 512;
-			done++;
-			sector++;
-	    }
-	} while (++(stuffp->pending) < border);
+			if (stuffp->pending == sector) {
+				p += 512;
+				done++;
+				sector++;
+			}
+		} while (++(stuffp->pending) < border);
 
-	stuffp->lock = 0;
-	wake_up_interruptible(&stuffp->lockq);
+		stuffp->lock = 0;
+		wake_up_interruptible(&stuffp->lockq);
 
-    } else {
+	} else {
 
 		/* The requested sector(s) is/are out of the
 		 * already requested range, so we have to bother the drive
@@ -1352,8 +1426,9 @@
 
 		/* do some sanity checks */
 		if (stuffp->pending > stuffp->lastsector) {
-			xwarn("transfer() sector %d from nirvana requested.\n",
-				stuffp->pending);
+			xwarn
+			    ("transfer() sector %d from nirvana requested.\n",
+			     stuffp->pending);
 			stuffp->status = MCDX_ST_EOM;
 			stuffp->valid = 0;
 			xtrace(XFER, "transfer() done (-1)\n");
@@ -1361,17 +1436,17 @@
 		}
 
 		if ((stuffp->low_border = stuffp->pending + DIRECT_SIZE)
-				> stuffp->lastsector + 1) {
+		    > stuffp->lastsector + 1) {
 			xtrace(XFER, "cut low_border\n");
 			stuffp->low_border = stuffp->lastsector + 1;
 		}
 		if ((stuffp->high_border = stuffp->pending + REQUEST_SIZE)
-				> stuffp->lastsector + 1) {
-			xtrace(XFER,  "cut high_border\n");
+		    > stuffp->lastsector + 1) {
+			xtrace(XFER, "cut high_border\n");
 			stuffp->high_border = stuffp->lastsector + 1;
 		}
 
-		{	/* Convert the sector to be requested to MSF format */
+		{		/* Convert the sector to be requested to MSF format */
 			struct cdrom_msf0 pending;
 			log2msf(stuffp->pending / 4, &pending);
 			cmd[1] = pending.minute;
@@ -1379,59 +1454,71 @@
 			cmd[3] = pending.frame;
 		}
 
-		cmd[6] = (unsigned char) ((stuffp->high_border - stuffp->pending) / 4);
+		cmd[6] =
+		    (unsigned
+		     char) ((stuffp->high_border - stuffp->pending) / 4);
 		xtrace(XFER, "[%2d]\n", cmd[6]);
 
 		stuffp->busy = 1;
 		/* Now really issue the request command */
 		outsb((unsigned int) stuffp->wreg_data, cmd, sizeof cmd);
 
-    }
+	}
 #ifdef AK2
-	if ( stuffp->int_err ) {
+	if (stuffp->int_err) {
 		stuffp->valid = 0;
 		stuffp->int_err = 0;
 		return -1;
 	}
-#endif /* AK2 */
+#endif				/* AK2 */
 
-    stuffp->low_border = (stuffp->low_border += done) < stuffp->high_border
-	    ? stuffp->low_border : stuffp->high_border;
+	stuffp->low_border = (stuffp->low_border +=
+			      done) <
+	    stuffp->high_border ? stuffp->low_border : stuffp->high_border;
 
-    return done;
+	return done;
 }
 
 
 /*	Access to elements of the mcdx_drive_map members */
 
-static char* port(int *ip) { return (char*) ip[0]; }
-static int irq(int *ip) { return ip[1]; }
+static char *port(int *ip)
+{
+	return (char *) ip[0];
+}
+static int irq(int *ip)
+{
+	return ip[1];
+}
 
 /*	Misc number converters */
 
 static unsigned int bcd2uint(unsigned char c)
-{ return (c >> 4) * 10 + (c & 0x0f); }
+{
+	return (c >> 4) * 10 + (c & 0x0f);
+}
 
 static unsigned int uint2bcd(unsigned int ival)
-{ return ((ival / 10) << 4) | (ival % 10); }
+{
+	return ((ival / 10) << 4) | (ival % 10);
+}
 
-static void log2msf(unsigned int l, struct cdrom_msf0* pmsf)
+static void log2msf(unsigned int l, struct cdrom_msf0 *pmsf)
 {
-    l += CD_MSF_OFFSET;
-    pmsf->minute = uint2bcd(l / 4500), l %= 4500;
-    pmsf->second = uint2bcd(l / 75);
-    pmsf->frame = uint2bcd(l % 75);
+	l += CD_MSF_OFFSET;
+	pmsf->minute = uint2bcd(l / 4500), l %= 4500;
+	pmsf->second = uint2bcd(l / 75);
+	pmsf->frame = uint2bcd(l % 75);
 }
 
-static unsigned int msf2log(const struct cdrom_msf0* pmsf)
+static unsigned int msf2log(const struct cdrom_msf0 *pmsf)
 {
-    return bcd2uint(pmsf->frame)
-    + bcd2uint(pmsf->second) * 75
-    + bcd2uint(pmsf->minute) * 4500
-    - CD_MSF_OFFSET;
+	return bcd2uint(pmsf->frame)
+	    + bcd2uint(pmsf->second) * 75
+	    + bcd2uint(pmsf->minute) * 4500 - CD_MSF_OFFSET;
 }
 
-int mcdx_readtoc(struct s_drive_stuff* stuffp)
+int mcdx_readtoc(struct s_drive_stuff *stuffp)
 /*  Read the toc entries from the CD,
  *  Return: -1 on failure, else 0 */
 {
@@ -1442,17 +1529,21 @@
 	}
 
 	xtrace(READTOC, "ioctl() readtoc for %d tracks\n",
-			stuffp->di.n_last - stuffp->di.n_first + 1);
+	       stuffp->di.n_last - stuffp->di.n_first + 1);
 
-    if (-1 == mcdx_hold(stuffp, 1)) return -1;
+	if (-1 == mcdx_hold(stuffp, 1))
+		return -1;
 
 	xtrace(READTOC, "ioctl() tocmode\n");
-	if (-1 == mcdx_setdrivemode(stuffp, TOC, 1)) return -EIO;
+	if (-1 == mcdx_setdrivemode(stuffp, TOC, 1))
+		return -EIO;
 
 	/* all seems to be ok so far ... malloc */
 	{
 		int size;
-		size = sizeof(struct s_subqcode) * (stuffp->di.n_last - stuffp->di.n_first + 2);
+		size =
+		    sizeof(struct s_subqcode) * (stuffp->di.n_last -
+						 stuffp->di.n_first + 2);
 
 		xtrace(MALLOC, "ioctl() malloc %d bytes\n", size);
 		stuffp->toc = kmalloc(size, GFP_KERNEL);
@@ -1469,11 +1560,11 @@
 		int retries;
 
 		for (trk = 0;
-				trk < (stuffp->di.n_last - stuffp->di.n_first + 1);
-				trk++)
+		     trk < (stuffp->di.n_last - stuffp->di.n_first + 1);
+		     trk++)
 			stuffp->toc[trk].index = 0;
 
-		for (retries = 300; retries; retries--) { /* why 300? */
+		for (retries = 300; retries; retries--) {	/* why 300? */
 			struct s_subqcode q;
 			unsigned int idx;
 
@@ -1485,19 +1576,24 @@
 			idx = bcd2uint(q.index);
 
 			if ((idx > 0)
-					&& (idx <= stuffp->di.n_last)
-					&& (q.tno == 0)
-					&& (stuffp->toc[idx - stuffp->di.n_first].index == 0)) {
+			    && (idx <= stuffp->di.n_last)
+			    && (q.tno == 0)
+			    && (stuffp->toc[idx - stuffp->di.n_first].
+				index == 0)) {
 				stuffp->toc[idx - stuffp->di.n_first] = q;
-				xtrace(READTOC, "ioctl() toc idx %d (trk %d)\n", idx, trk);
+				xtrace(READTOC,
+				       "ioctl() toc idx %d (trk %d)\n",
+				       idx, trk);
 				trk--;
 			}
-			if (trk == 0) break;
+			if (trk == 0)
+				break;
 		}
-		memset(&stuffp->toc[stuffp->di.n_last - stuffp->di.n_first + 1],
-				0, sizeof(stuffp->toc[0]));
-		stuffp->toc[stuffp->di.n_last - stuffp->di.n_first + 1].dt
-				= stuffp->di.msf_leadout;
+		memset(&stuffp->
+		       toc[stuffp->di.n_last - stuffp->di.n_first + 1], 0,
+		       sizeof(stuffp->toc[0]));
+		stuffp->toc[stuffp->di.n_last - stuffp->di.n_first +
+			    1].dt = stuffp->di.msf_leadout;
 	}
 
 	/* unset toc mode */
@@ -1506,16 +1602,23 @@
 		return -EIO;
 
 #if MCDX_DEBUG && READTOC
-	{ int trk;
-	for (trk = 0;
-			trk < (stuffp->di.n_last - stuffp->di.n_first + 2);
-			trk++)
-		xtrace(READTOC, "ioctl() %d readtoc %02x %02x %02x"
-				"  %02x:%02x.%02x  %02x:%02x.%02x\n",
-				trk + stuffp->di.n_first,
-				stuffp->toc[trk].control, stuffp->toc[trk].tno, stuffp->toc[trk].index,
-				stuffp->toc[trk].tt.minute, stuffp->toc[trk].tt.second, stuffp->toc[trk].tt.frame,
-				stuffp->toc[trk].dt.minute, stuffp->toc[trk].dt.second, stuffp->toc[trk].dt.frame);
+	{
+		int trk;
+		for (trk = 0;
+		     trk < (stuffp->di.n_last - stuffp->di.n_first + 2);
+		     trk++)
+			xtrace(READTOC, "ioctl() %d readtoc %02x %02x %02x"
+			       "  %02x:%02x.%02x  %02x:%02x.%02x\n",
+			       trk + stuffp->di.n_first,
+			       stuffp->toc[trk].control,
+			       stuffp->toc[trk].tno,
+			       stuffp->toc[trk].index,
+			       stuffp->toc[trk].tt.minute,
+			       stuffp->toc[trk].tt.second,
+			       stuffp->toc[trk].tt.frame,
+			       stuffp->toc[trk].dt.minute,
+			       stuffp->toc[trk].dt.second,
+			       stuffp->toc[trk].dt.frame);
 	}
 #endif
 
@@ -1523,109 +1626,110 @@
 }
 
 static int
-mcdx_playmsf(struct s_drive_stuff* stuffp, const struct cdrom_msf* msf)
+mcdx_playmsf(struct s_drive_stuff *stuffp, const struct cdrom_msf *msf)
 {
-    unsigned char cmd[7] = {
-        0, 0, 0, 0, 0, 0, 0
-    };
+	unsigned char cmd[7] = {
+		0, 0, 0, 0, 0, 0, 0
+	};
 
 	if (!stuffp->readcmd) {
 		xinfo("Can't play from missing disk.\n");
 		return -1;
 	}
 
-    cmd[0] = stuffp->playcmd;
+	cmd[0] = stuffp->playcmd;
+
+	cmd[1] = msf->cdmsf_min0;
+	cmd[2] = msf->cdmsf_sec0;
+	cmd[3] = msf->cdmsf_frame0;
+	cmd[4] = msf->cdmsf_min1;
+	cmd[5] = msf->cdmsf_sec1;
+	cmd[6] = msf->cdmsf_frame1;
+
+	xtrace(PLAYMSF, "ioctl(): play %x "
+	       "%02x:%02x:%02x -- %02x:%02x:%02x\n",
+	       cmd[0], cmd[1], cmd[2], cmd[3], cmd[4], cmd[5], cmd[6]);
 
-    cmd[1] = msf->cdmsf_min0;
-    cmd[2] = msf->cdmsf_sec0;
-    cmd[3] = msf->cdmsf_frame0;
-    cmd[4] = msf->cdmsf_min1;
-    cmd[5] = msf->cdmsf_sec1;
-    cmd[6] = msf->cdmsf_frame1;
-
-    xtrace(PLAYMSF, "ioctl(): play %x "
-            "%02x:%02x:%02x -- %02x:%02x:%02x\n",
-            cmd[0], cmd[1], cmd[2], cmd[3],
-            cmd[4], cmd[5], cmd[6]);
-
-    outsb((unsigned int) stuffp->wreg_data, cmd, sizeof cmd);
-
-    if (-1 == mcdx_getval(stuffp, 3 * HZ, 0, NULL)) {
-        xwarn("playmsf() timeout\n");
-        return -1;
-    }
+	outsb((unsigned int) stuffp->wreg_data, cmd, sizeof cmd);
 
-    stuffp->audiostatus = CDROM_AUDIO_PLAY;
-    return 0;
+	if (-1 == mcdx_getval(stuffp, 3 * HZ, 0, NULL)) {
+		xwarn("playmsf() timeout\n");
+		return -1;
+	}
+
+	stuffp->audiostatus = CDROM_AUDIO_PLAY;
+	return 0;
 }
 
 static int
-mcdx_playtrk(struct s_drive_stuff* stuffp, const struct cdrom_ti* ti)
+mcdx_playtrk(struct s_drive_stuff *stuffp, const struct cdrom_ti *ti)
 {
-    struct s_subqcode* p;
-    struct cdrom_msf msf;
-
-    if (-1 == mcdx_readtoc(stuffp)) return -1;
-
-    if (ti) p = &stuffp->toc[ti->cdti_trk0 - stuffp->di.n_first];
-    else p = &stuffp->start;
+	struct s_subqcode *p;
+	struct cdrom_msf msf;
 
-    msf.cdmsf_min0 = p->dt.minute;
-    msf.cdmsf_sec0 = p->dt.second;
-    msf.cdmsf_frame0 = p->dt.frame;
-
-    if (ti) {
-        p = &stuffp->toc[ti->cdti_trk1 - stuffp->di.n_first + 1];
-        stuffp->stop = *p;
-    } else p = &stuffp->stop;
+	if (-1 == mcdx_readtoc(stuffp))
+		return -1;
 
-    msf.cdmsf_min1 = p->dt.minute;
-    msf.cdmsf_sec1 = p->dt.second;
-    msf.cdmsf_frame1 = p->dt.frame;
+	if (ti)
+		p = &stuffp->toc[ti->cdti_trk0 - stuffp->di.n_first];
+	else
+		p = &stuffp->start;
+
+	msf.cdmsf_min0 = p->dt.minute;
+	msf.cdmsf_sec0 = p->dt.second;
+	msf.cdmsf_frame0 = p->dt.frame;
+
+	if (ti) {
+		p = &stuffp->toc[ti->cdti_trk1 - stuffp->di.n_first + 1];
+		stuffp->stop = *p;
+	} else
+		p = &stuffp->stop;
+
+	msf.cdmsf_min1 = p->dt.minute;
+	msf.cdmsf_sec1 = p->dt.second;
+	msf.cdmsf_frame1 = p->dt.frame;
 
-    return mcdx_playmsf(stuffp, &msf);
+	return mcdx_playmsf(stuffp, &msf);
 }
 
 
 /* Drive functions ************************************************/
 
-static int
-mcdx_tray_move(struct cdrom_device_info * cdi, int position)
+static int mcdx_tray_move(struct cdrom_device_info *cdi, int position)
 {
-    struct s_drive_stuff *stuffp = mcdx_stuffp[MINOR(cdi->dev)];
+	struct s_drive_stuff *stuffp = mcdx_stuffp[MINOR(cdi->dev)];
 
-    if (!stuffp->present) 
+	if (!stuffp->present)
 		return -ENXIO;
 	if (!(stuffp->present & DOOR))
-		return -ENOSYS; 
+		return -ENOSYS;
 
- 	if (position)                /* 1: eject */
-        	return mcdx_talk(stuffp, "\xf6", 1, NULL, 1, 5 * HZ, 3);
-	else /* 0: close */
-			return mcdx_talk(stuffp, "\xf8", 1, NULL, 1, 5 * HZ, 3);
-    return 1;
+	if (position)		/* 1: eject */
+		return mcdx_talk(stuffp, "\xf6", 1, NULL, 1, 5 * HZ, 3);
+	else			/* 0: close */
+		return mcdx_talk(stuffp, "\xf8", 1, NULL, 1, 5 * HZ, 3);
+	return 1;
 }
 
-static int
-mcdx_stop(struct s_drive_stuff *stuffp, int tries)
-{ return mcdx_talk(stuffp, "\xf0", 1, NULL, 1, 2 * HZ, tries); }
+static int mcdx_stop(struct s_drive_stuff *stuffp, int tries)
+{
+	return mcdx_talk(stuffp, "\xf0", 1, NULL, 1, 2 * HZ, tries);
+}
 
-static int
-mcdx_hold(struct s_drive_stuff *stuffp, int tries)
-{ return mcdx_talk(stuffp, "\x70", 1, NULL, 1, 2 * HZ, tries); }
+static int mcdx_hold(struct s_drive_stuff *stuffp, int tries)
+{
+	return mcdx_talk(stuffp, "\x70", 1, NULL, 1, 2 * HZ, tries);
+}
 
-static int
-mcdx_requestsubqcode(struct s_drive_stuff *stuffp,
-        struct s_subqcode *sub,
-        int tries)
+static int mcdx_requestsubqcode(struct s_drive_stuff *stuffp,
+		     struct s_subqcode *sub, int tries)
 {
 	char buf[11];
 	int ans;
 
-	if (-1 == (ans = mcdx_talk(
-            stuffp, "\x20", 1, buf, sizeof(buf),
-            2 * HZ, tries)))
-        return -1;
+	if (-1 == (ans = mcdx_talk(stuffp, "\x20", 1, buf, sizeof(buf),
+				   2 * HZ, tries)))
+		return -1;
 	sub->control = buf[1];
 	sub->tno = buf[2];
 	sub->index = buf[3];
@@ -1639,31 +1743,34 @@
 	return ans;
 }
 
-static int
-mcdx_requestmultidiskinfo(struct s_drive_stuff *stuffp, struct s_multi *multi, int tries)
+static int mcdx_requestmultidiskinfo(struct s_drive_stuff *stuffp,
+			  struct s_multi *multi, int tries)
 {
 	char buf[5];
 	int ans;
 
-    if (stuffp->present & MULTI) {
-		ans = mcdx_talk(stuffp, "\x11", 1, buf, sizeof(buf), 2 * HZ, tries);
+	if (stuffp->present & MULTI) {
+		ans =
+		    mcdx_talk(stuffp, "\x11", 1, buf, sizeof(buf), 2 * HZ,
+			      tries);
 		multi->multi = buf[1];
-        multi->msf_last.minute = buf[2];
-        multi->msf_last.second = buf[3];
-        multi->msf_last.frame = buf[4];
-        return ans;
-    } else {
-        multi->multi = 0;
-        return 0;
-    }
+		multi->msf_last.minute = buf[2];
+		multi->msf_last.second = buf[3];
+		multi->msf_last.frame = buf[4];
+		return ans;
+	} else {
+		multi->multi = 0;
+		return 0;
+	}
 }
 
-static int
-mcdx_requesttocdata(struct s_drive_stuff *stuffp, struct s_diskinfo *info, int tries)
+static int mcdx_requesttocdata(struct s_drive_stuff *stuffp, struct s_diskinfo *info,
+		    int tries)
 {
 	char buf[9];
 	int ans;
-	ans = mcdx_talk(stuffp, "\x10", 1, buf, sizeof(buf), 2 * HZ, tries);
+	ans =
+	    mcdx_talk(stuffp, "\x10", 1, buf, sizeof(buf), 2 * HZ, tries);
 	if (ans == -1) {
 		info->n_first = 0;
 		info->n_last = 0;
@@ -1680,8 +1787,8 @@
 	return ans;
 }
 
-static int
-mcdx_setdrivemode(struct s_drive_stuff *stuffp, enum drivemodes mode, int tries)
+static int mcdx_setdrivemode(struct s_drive_stuff *stuffp, enum drivemodes mode,
+		  int tries)
 {
 	char cmd[2];
 	int ans;
@@ -1692,32 +1799,47 @@
 		return -1;
 
 	switch (mode) {
-	  case TOC: cmd[1] |= 0x04; break;
-	  case DATA: cmd[1] &= ~0x04; break;
-	  case RAW: cmd[1] |= 0x40; break;
-	  case COOKED: cmd[1] &= ~0x40; break;
-	  default: break;
+	case TOC:
+		cmd[1] |= 0x04;
+		break;
+	case DATA:
+		cmd[1] &= ~0x04;
+		break;
+	case RAW:
+		cmd[1] |= 0x40;
+		break;
+	case COOKED:
+		cmd[1] &= ~0x40;
+		break;
+	default:
+		break;
 	}
 	cmd[0] = 0x50;
 	return mcdx_talk(stuffp, cmd, 2, NULL, 1, 5 * HZ, tries);
 }
 
-static int
-mcdx_setdatamode(struct s_drive_stuff *stuffp, enum datamodes mode, int tries)
+static int mcdx_setdatamode(struct s_drive_stuff *stuffp, enum datamodes mode,
+		 int tries)
 {
 	unsigned char cmd[2] = { 0xa0 };
 	xtrace(HW, "setdatamode() %d\n", mode);
 	switch (mode) {
-	  case MODE0: cmd[1] = 0x00; break;
-	  case MODE1: cmd[1] = 0x01; break;
-	  case MODE2: cmd[1] = 0x02; break;
-	  default: return -EINVAL;
+	case MODE0:
+		cmd[1] = 0x00;
+		break;
+	case MODE1:
+		cmd[1] = 0x01;
+		break;
+	case MODE2:
+		cmd[1] = 0x02;
+		break;
+	default:
+		return -EINVAL;
 	}
 	return mcdx_talk(stuffp, cmd, 2, NULL, 1, 5 * HZ, tries);
 }
 
-static int
-mcdx_config(struct s_drive_stuff *stuffp, int tries)
+static int mcdx_config(struct s_drive_stuff *stuffp, int tries)
 {
 	char cmd[4];
 
@@ -1737,14 +1859,14 @@
 	return mcdx_talk(stuffp, cmd, 3, NULL, 1, 1 * HZ, tries);
 }
 
-static int
-mcdx_requestversion(struct s_drive_stuff *stuffp, struct s_version *ver, int tries)
+static int mcdx_requestversion(struct s_drive_stuff *stuffp, struct s_version *ver,
+		    int tries)
 {
 	char buf[3];
 	int ans;
 
 	if (-1 == (ans = mcdx_talk(stuffp, "\xdc",
-			1, buf, sizeof(buf), 2 * HZ, tries)))
+				   1, buf, sizeof(buf), 2 * HZ, tries)))
 		return ans;
 
 	ver->code = buf[1];
@@ -1753,65 +1875,66 @@
 	return ans;
 }
 
-static int
-mcdx_reset(struct s_drive_stuff *stuffp, enum resetmodes mode, int tries)
+static int mcdx_reset(struct s_drive_stuff *stuffp, enum resetmodes mode, int tries)
 {
 	if (mode == HARD) {
-		outb(0, (unsigned int) stuffp->wreg_chn);		/* no dma, no irq -> hardware */
-		outb(0, (unsigned int) stuffp->wreg_reset);		/* hw reset */
+		outb(0, (unsigned int) stuffp->wreg_chn);	/* no dma, no irq -> hardware */
+		outb(0, (unsigned int) stuffp->wreg_reset);	/* hw reset */
 		return 0;
-	} else return mcdx_talk(stuffp, "\x60", 1, NULL, 1, 5 * HZ, tries);
+	} else
+		return mcdx_talk(stuffp, "\x60", 1, NULL, 1, 5 * HZ, tries);
 }
 
-static int mcdx_lockdoor(struct cdrom_device_info * cdi, int lock)
+static int mcdx_lockdoor(struct cdrom_device_info *cdi, int lock)
 {
-    struct s_drive_stuff *stuffp = mcdx_stuffp[MINOR(cdi->dev)];
+	struct s_drive_stuff *stuffp = mcdx_stuffp[MINOR(cdi->dev)];
 	char cmd[2] = { 0xfe };
 
-    if (!(stuffp->present & DOOR))
+	if (!(stuffp->present & DOOR))
 		return -ENOSYS;
-    if (stuffp->present & DOOR) {
-        cmd[1] = lock ? 0x01 : 0x00;
-        return mcdx_talk(stuffp, cmd, sizeof(cmd), NULL, 1, 5 * HZ, 3);
-    } else return 0;
+	if (stuffp->present & DOOR) {
+		cmd[1] = lock ? 0x01 : 0x00;
+		return mcdx_talk(stuffp, cmd, sizeof(cmd), NULL, 1, 5 * HZ, 3);
+	} else
+		return 0;
 }
 
-static int
-mcdx_getstatus(struct s_drive_stuff *stuffp, int tries)
-{ return mcdx_talk(stuffp, "\x40", 1, NULL, 1, 5 * HZ, tries); }
+static int mcdx_getstatus(struct s_drive_stuff *stuffp, int tries)
+{
+	return mcdx_talk(stuffp, "\x40", 1, NULL, 1, 5 * HZ, tries);
+}
 
 static int
-mcdx_getval(struct s_drive_stuff *stuffp, int to, int delay, char* buf)
+mcdx_getval(struct s_drive_stuff *stuffp, int to, int delay, char *buf)
 {
-    unsigned long timeout = to + jiffies;
-    char c;
+	unsigned long timeout = to + jiffies;
+	char c;
 
-    if (!buf) buf = &c;
+	if (!buf)
+		buf = &c;
 
-    while (inb((unsigned int) stuffp->rreg_status) & MCDX_RBIT_STEN) {
-        if (time_after(jiffies, timeout)) return -1;
-        mcdx_delay(stuffp, delay);
-    }
+	while (inb((unsigned int) stuffp->rreg_status) & MCDX_RBIT_STEN) {
+		if (time_after(jiffies, timeout))
+			return -1;
+		mcdx_delay(stuffp, delay);
+	}
 
-    *buf = (unsigned char) inb((unsigned int) stuffp->rreg_data) & 0xff;
+	*buf = (unsigned char) inb((unsigned int) stuffp->rreg_data) & 0xff;
 
-    return 0;
+	return 0;
 }
 
-static int
-mcdx_setattentuator(
-        struct s_drive_stuff* stuffp,
-        struct cdrom_volctrl* vol,
-        int tries)
-{
-    char cmd[5];
-    cmd[0] = 0xae;
-    cmd[1] = vol->channel0;
-    cmd[2] = 0;
-    cmd[3] = vol->channel1;
-    cmd[4] = 0;
+static int mcdx_setattentuator(struct s_drive_stuff *stuffp,
+		    struct cdrom_volctrl *vol, int tries)
+{
+	char cmd[5];
+	cmd[0] = 0xae;
+	cmd[1] = vol->channel0;
+	cmd[2] = 0;
+	cmd[3] = vol->channel1;
+	cmd[4] = 0;
 
-    return mcdx_talk(stuffp, cmd, sizeof(cmd), NULL, 5, 200, tries);
+	return mcdx_talk(stuffp, cmd, sizeof(cmd), NULL, 5, 200, tries);
 }
 
-/* ex:set ts=4 sw=4 ai si: */
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/cdrom/optcd.c linux/drivers/cdrom/optcd.c
--- v2.4.9/linux/drivers/cdrom/optcd.c	Sun Feb  4 10:05:29 2001
+++ linux/drivers/cdrom/optcd.c	Sun Sep  9 10:43:02 2001
@@ -2097,3 +2097,4 @@
 module_exit(optcd_exit);
 
 
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/cdrom/sbpcd.c linux/drivers/cdrom/sbpcd.c
--- v2.4.9/linux/drivers/cdrom/sbpcd.c	Wed Jul 25 17:10:19 2001
+++ linux/drivers/cdrom/sbpcd.c	Sun Sep  9 10:43:02 2001
@@ -4272,6 +4272,12 @@
 		D_S[d].aud_buf=NULL;
 		D_S[d].sbp_audsiz=arg;
 		
+		if (D_S[d].sbp_audsiz>16)
+		{
+			D_S[d].sbp_audsiz = 0;
+			RETURN_UP(D_S[d].sbp_audsiz);
+		}
+	
 		if (D_S[d].sbp_audsiz>0)
 		{
 			D_S[d].aud_buf=(u_char *) vmalloc(D_S[d].sbp_audsiz*CD_FRAMESIZE_RAW);
@@ -6016,6 +6022,9 @@
 {
    return sbpcd_chk_disk_change(cdi->dev);
 }
+
+MODULE_LICENSE("GPL");
+
 /*==========================================================================*/
 /*
  * Overrides for Emacs so that we follow Linus's tabbing style.
@@ -6033,3 +6042,4 @@
  * c-continued-brace-offset: 0
  * End:
  */
+
diff -u --recursive --new-file v2.4.9/linux/drivers/cdrom/sjcd.c linux/drivers/cdrom/sjcd.c
--- v2.4.9/linux/drivers/cdrom/sjcd.c	Thu Oct 26 23:35:48 2000
+++ linux/drivers/cdrom/sjcd.c	Fri Sep  7 09:28:38 2001
@@ -82,13 +82,13 @@
 
 static int sjcd_present = 0;
 
-#define SJCD_BUF_SIZ 32 /* cdr-h94a has internal 64K buffer */
+#define SJCD_BUF_SIZ 32		/* cdr-h94a has internal 64K buffer */
 
 /*
  * buffer for block size conversion
  */
-static char sjcd_buf[ 2048 * SJCD_BUF_SIZ ];
-static volatile int sjcd_buf_bn[ SJCD_BUF_SIZ ], sjcd_next_bn;
+static char sjcd_buf[2048 * SJCD_BUF_SIZ];
+static volatile int sjcd_buf_bn[SJCD_BUF_SIZ], sjcd_next_bn;
 static volatile int sjcd_buf_in, sjcd_buf_out = -1;
 
 /*
@@ -113,9 +113,7 @@
 
 static int sjcd_base = SJCD_BASE_ADDR;
 
-#ifdef MODULE
 MODULE_PARM(sjcd_base, "i");
-#endif
 
 static DECLARE_WAIT_QUEUE_HEAD(sjcd_waitq);
 
@@ -125,13 +123,13 @@
 static volatile unsigned short sjcd_transfer_is_active = 0;
 
 enum sjcd_transfer_state {
-  SJCD_S_IDLE     = 0,
-  SJCD_S_START    = 1,
-  SJCD_S_MODE     = 2,
-  SJCD_S_READ     = 3,
-  SJCD_S_DATA     = 4,
-  SJCD_S_STOP     = 5,
-  SJCD_S_STOPPING = 6
+	SJCD_S_IDLE = 0,
+	SJCD_S_START = 1,
+	SJCD_S_MODE = 2,
+	SJCD_S_READ = 3,
+	SJCD_S_DATA = 4,
+	SJCD_S_STOP = 5,
+	SJCD_S_STOPPING = 6
 };
 static enum sjcd_transfer_state sjcd_transfer_state = SJCD_S_IDLE;
 static long sjcd_transfer_timeout = 0;
@@ -166,14 +164,14 @@
  * base address.
  */
 #ifndef MODULE
-static int __init sjcd_setup( char *str)
+static int __init sjcd_setup(char *str)
 {
-   int ints[2];
-   (void)get_options(str, ARRAY_SIZE(ints), ints);
-   if (ints[0] > 0)
-      sjcd_base = ints[1];
+	int ints[2];
+	(void) get_options(str, ARRAY_SIZE(ints), ints);
+	if (ints[0] > 0)
+		sjcd_base = ints[1];
 
-   return 1;
+	return 1;
 }
 
 __setup("sjcd=", sjcd_setup);
@@ -183,168 +181,191 @@
 /*
  * Special converters.
  */
-static unsigned char bin2bcd( int bin ){
-  int u, v;
+static unsigned char bin2bcd(int bin)
+{
+	int u, v;
 
-  u = bin % 10; v = bin / 10;
-  return( u | ( v << 4 ) );
+	u = bin % 10;
+	v = bin / 10;
+	return (u | (v << 4));
 }
 
-static int bcd2bin( unsigned char bcd ){
-    return( ( bcd >> 4 ) * 10 + ( bcd & 0x0F ) );
+static int bcd2bin(unsigned char bcd)
+{
+	return ((bcd >> 4) * 10 + (bcd & 0x0F));
 }
 
-static long msf2hsg( struct msf *mp ){
-  return( bcd2bin( mp->frame ) + bcd2bin( mp->sec ) * 75
-	 + bcd2bin( mp->min ) * 4500 - 150 );
+static long msf2hsg(struct msf *mp)
+{
+	return (bcd2bin(mp->frame) + bcd2bin(mp->sec) * 75
+		+ bcd2bin(mp->min) * 4500 - 150);
 }
 
-static void hsg2msf( long hsg, struct msf *msf ){
-  hsg += 150; msf->min = hsg / 4500;
-  hsg %= 4500; msf->sec = hsg / 75; msf->frame = hsg % 75;
-  msf->min = bin2bcd( msf->min );       /* convert to BCD */
-  msf->sec = bin2bcd( msf->sec );
-  msf->frame = bin2bcd( msf->frame );
+static void hsg2msf(long hsg, struct msf *msf)
+{
+	hsg += 150;
+	msf->min = hsg / 4500;
+	hsg %= 4500;
+	msf->sec = hsg / 75;
+	msf->frame = hsg % 75;
+	msf->min = bin2bcd(msf->min);	/* convert to BCD */
+	msf->sec = bin2bcd(msf->sec);
+	msf->frame = bin2bcd(msf->frame);
 }
 
 /*
  * Send a command to cdrom. Invalidate status.
  */
-static void sjcd_send_cmd( unsigned char cmd ){
+static void sjcd_send_cmd(unsigned char cmd)
+{
 #if defined( SJCD_TRACE )
-  printk( "SJCD: send_cmd( 0x%x )\n", cmd );
+	printk("SJCD: send_cmd( 0x%x )\n", cmd);
 #endif
-  outb( cmd, SJCDPORT( 0 ) );
-  sjcd_command_is_in_progress = 1;
-  sjcd_status_valid = 0;
-  sjcd_command_failed = 0;
+	outb(cmd, SJCDPORT(0));
+	sjcd_command_is_in_progress = 1;
+	sjcd_status_valid = 0;
+	sjcd_command_failed = 0;
 }
 
 /*
  * Send a command with one arg to cdrom. Invalidate status.
  */
-static void sjcd_send_1_cmd( unsigned char cmd, unsigned char a ){
+static void sjcd_send_1_cmd(unsigned char cmd, unsigned char a)
+{
 #if defined( SJCD_TRACE )
-  printk( "SJCD: send_1_cmd( 0x%x, 0x%x )\n", cmd, a );
+	printk("SJCD: send_1_cmd( 0x%x, 0x%x )\n", cmd, a);
 #endif
-  outb( cmd, SJCDPORT( 0 ) );
-  outb( a, SJCDPORT( 0 ) );
-  sjcd_command_is_in_progress = 1;
-  sjcd_status_valid = 0;
-  sjcd_command_failed = 0;
+	outb(cmd, SJCDPORT(0));
+	outb(a, SJCDPORT(0));
+	sjcd_command_is_in_progress = 1;
+	sjcd_status_valid = 0;
+	sjcd_command_failed = 0;
 }
 
 /*
  * Send a command with four args to cdrom. Invalidate status.
  */
-static void sjcd_send_4_cmd( unsigned char cmd, unsigned char a,
-	    unsigned char b, unsigned char c, unsigned char d ){
+static void sjcd_send_4_cmd(unsigned char cmd, unsigned char a,
+			    unsigned char b, unsigned char c,
+			    unsigned char d)
+{
 #if defined( SJCD_TRACE )
-  printk( "SJCD: send_4_cmd( 0x%x )\n", cmd );
+	printk("SJCD: send_4_cmd( 0x%x )\n", cmd);
 #endif
-  outb( cmd, SJCDPORT( 0 ) );
-  outb( a, SJCDPORT( 0 ) );
-  outb( b, SJCDPORT( 0 ) );
-  outb( c, SJCDPORT( 0 ) );
-  outb( d, SJCDPORT( 0 ) );
-  sjcd_command_is_in_progress = 1;
-  sjcd_status_valid = 0;
-  sjcd_command_failed = 0;
+	outb(cmd, SJCDPORT(0));
+	outb(a, SJCDPORT(0));
+	outb(b, SJCDPORT(0));
+	outb(c, SJCDPORT(0));
+	outb(d, SJCDPORT(0));
+	sjcd_command_is_in_progress = 1;
+	sjcd_status_valid = 0;
+	sjcd_command_failed = 0;
 }
 
 /*
  * Send a play or read command to cdrom. Invalidate Status.
  */
-static void sjcd_send_6_cmd( unsigned char cmd, struct sjcd_play_msf *pms ){
+static void sjcd_send_6_cmd(unsigned char cmd, struct sjcd_play_msf *pms)
+{
 #if defined( SJCD_TRACE )
-  printk( "SJCD: send_long_cmd( 0x%x )\n", cmd );
+	printk("SJCD: send_long_cmd( 0x%x )\n", cmd);
 #endif
-  outb( cmd, SJCDPORT( 0 ) );
-  outb( pms->start.min,   SJCDPORT( 0 ) );
-  outb( pms->start.sec,   SJCDPORT( 0 ) );
-  outb( pms->start.frame, SJCDPORT( 0 ) );
-  outb( pms->end.min,     SJCDPORT( 0 ) );
-  outb( pms->end.sec,     SJCDPORT( 0 ) );
-  outb( pms->end.frame,   SJCDPORT( 0 ) );
-  sjcd_command_is_in_progress = 1;
-  sjcd_status_valid = 0;
-  sjcd_command_failed = 0;
+	outb(cmd, SJCDPORT(0));
+	outb(pms->start.min, SJCDPORT(0));
+	outb(pms->start.sec, SJCDPORT(0));
+	outb(pms->start.frame, SJCDPORT(0));
+	outb(pms->end.min, SJCDPORT(0));
+	outb(pms->end.sec, SJCDPORT(0));
+	outb(pms->end.frame, SJCDPORT(0));
+	sjcd_command_is_in_progress = 1;
+	sjcd_status_valid = 0;
+	sjcd_command_failed = 0;
 }
 
 /*
  * Get a value from the data port. Should not block, so we use a little
  * wait for a while. Returns 0 if OK.
  */
-static int sjcd_load_response( void *buf, int len ){
-  unsigned char *resp = ( unsigned char * )buf;
+static int sjcd_load_response(void *buf, int len)
+{
+	unsigned char *resp = (unsigned char *) buf;
 
-  for( ; len; --len ){ 
-    int i;
-    for( i = 200; i-- && !SJCD_STATUS_AVAILABLE( inb( SJCDPORT( 1 ) ) ); );
-    if( i > 0 ) *resp++ = ( unsigned char )inb( SJCDPORT( 0 ) );
-    else break;
-  }
-  return( len );
+	for (; len; --len) {
+		int i;
+		for (i = 200;
+		     i-- && !SJCD_STATUS_AVAILABLE(inb(SJCDPORT(1))););
+		if (i > 0)
+			*resp++ = (unsigned char) inb(SJCDPORT(0));
+		else
+			break;
+	}
+	return (len);
 }
 
 /*
  * Load and parse command completion status (drive info byte and maybe error).
  * Sorry, no error classification yet.
  */
-static void sjcd_load_status( void ){
-  sjcd_media_is_changed = 0;
-  sjcd_completion_error = 0;
-  sjcd_completion_status = inb( SJCDPORT( 0 ) );
-  if( sjcd_completion_status & SST_DOOR_OPENED ){
-    sjcd_door_closed = sjcd_media_is_available = 0;
-  } else {
-    sjcd_door_closed = 1;
-    if( sjcd_completion_status & SST_MEDIA_CHANGED )
-      sjcd_media_is_available = sjcd_media_is_changed = 1;
-    else if( sjcd_completion_status & 0x0F ){
-      /*
-       * OK, we seem to catch an error ...
-       */
-      while( !SJCD_STATUS_AVAILABLE( inb( SJCDPORT( 1 ) ) ) );
-      sjcd_completion_error = inb( SJCDPORT( 0 ) );
-      if( ( sjcd_completion_status & 0x08 ) &&
-	 ( sjcd_completion_error & 0x40 ) )
-	sjcd_media_is_available = 0;
-      else sjcd_command_failed = 1;
-    } else sjcd_media_is_available = 1;
-  }
-  /*
-   * Ok, status loaded successfully.
-   */
-  sjcd_status_valid = 1, sjcd_error_reported = 0;
-  sjcd_command_is_in_progress = 0;
-
-  /*
-   * If the disk is changed, the TOC is not valid.
-   */
-  if( sjcd_media_is_changed ) sjcd_toc_uptodate = 0;
+static void sjcd_load_status(void)
+{
+	sjcd_media_is_changed = 0;
+	sjcd_completion_error = 0;
+	sjcd_completion_status = inb(SJCDPORT(0));
+	if (sjcd_completion_status & SST_DOOR_OPENED) {
+		sjcd_door_closed = sjcd_media_is_available = 0;
+	} else {
+		sjcd_door_closed = 1;
+		if (sjcd_completion_status & SST_MEDIA_CHANGED)
+			sjcd_media_is_available = sjcd_media_is_changed =
+			    1;
+		else if (sjcd_completion_status & 0x0F) {
+			/*
+			 * OK, we seem to catch an error ...
+			 */
+			while (!SJCD_STATUS_AVAILABLE(inb(SJCDPORT(1))));
+			sjcd_completion_error = inb(SJCDPORT(0));
+			if ((sjcd_completion_status & 0x08) &&
+			    (sjcd_completion_error & 0x40))
+				sjcd_media_is_available = 0;
+			else
+				sjcd_command_failed = 1;
+		} else
+			sjcd_media_is_available = 1;
+	}
+	/*
+	 * Ok, status loaded successfully.
+	 */
+	sjcd_status_valid = 1, sjcd_error_reported = 0;
+	sjcd_command_is_in_progress = 0;
+
+	/*
+	 * If the disk is changed, the TOC is not valid.
+	 */
+	if (sjcd_media_is_changed)
+		sjcd_toc_uptodate = 0;
 #if defined( SJCD_TRACE )
-  printk( "SJCD: status %02x.%02x loaded.\n",
-	 ( int )sjcd_completion_status, ( int )sjcd_completion_error );
+	printk("SJCD: status %02x.%02x loaded.\n",
+	       (int) sjcd_completion_status, (int) sjcd_completion_error);
 #endif
 }
 
 /*
  * Read status from cdrom. Check to see if the status is available.
  */
-static int sjcd_check_status( void ){
-  /*
-   * Try to load the response from cdrom into buffer.
-   */
-  if( SJCD_STATUS_AVAILABLE( inb( SJCDPORT( 1 ) ) ) ){
-    sjcd_load_status();
-    return( 1 );
-  } else {
-    /*
-     * No status is available.
-     */
-    return( 0 );
-  }
+static int sjcd_check_status(void)
+{
+	/*
+	 * Try to load the response from cdrom into buffer.
+	 */
+	if (SJCD_STATUS_AVAILABLE(inb(SJCDPORT(1)))) {
+		sjcd_load_status();
+		return (1);
+	} else {
+		/*
+		 * No status is available.
+		 */
+		return (0);
+	}
 }
 
 /*
@@ -359,575 +380,692 @@
  */
 #define SJCD_WAIT_FOR_STATUS_TIMEOUT 1000
 
-static void sjcd_status_timer( void ){
-  if( sjcd_check_status() ){
-    /*
-     * The command completed and status is loaded, stop waiting.
-     */
-    wake_up( &sjcd_waitq );
-  } else if( --sjcd_status_timeout <= 0 ){
-    /*
-     * We are timed out. 
-     */
-    wake_up( &sjcd_waitq );
-  } else {
-    /*
-     * We have still some time to wait. Try again.
-     */
-    SJCD_SET_TIMER( sjcd_status_timer, 1 );
-  }
+static void sjcd_status_timer(void)
+{
+	if (sjcd_check_status()) {
+		/*
+		 * The command completed and status is loaded, stop waiting.
+		 */
+		wake_up(&sjcd_waitq);
+	} else if (--sjcd_status_timeout <= 0) {
+		/*
+		 * We are timed out. 
+		 */
+		wake_up(&sjcd_waitq);
+	} else {
+		/*
+		 * We have still some time to wait. Try again.
+		 */
+		SJCD_SET_TIMER(sjcd_status_timer, 1);
+	}
 }
 
 /*
  * Wait for status for 10 sec approx. Returns non-positive when timed out.
  * Should not be used while reading data CDs.
  */
-static int sjcd_wait_for_status( void ){
-  sjcd_status_timeout = SJCD_WAIT_FOR_STATUS_TIMEOUT;
-  SJCD_SET_TIMER( sjcd_status_timer, 1 ); 
-  sleep_on( &sjcd_waitq );    
+static int sjcd_wait_for_status(void)
+{
+	sjcd_status_timeout = SJCD_WAIT_FOR_STATUS_TIMEOUT;
+	SJCD_SET_TIMER(sjcd_status_timer, 1);
+	sleep_on(&sjcd_waitq);
 #if defined( SJCD_DIAGNOSTIC ) || defined ( SJCD_TRACE )
-  if( sjcd_status_timeout <= 0 )
-    printk( "SJCD: Error Wait For Status.\n" );
+	if (sjcd_status_timeout <= 0)
+		printk("SJCD: Error Wait For Status.\n");
 #endif
-  return( sjcd_status_timeout );
+	return (sjcd_status_timeout);
 }
 
-static int sjcd_receive_status( void ){
-  int i;
+static int sjcd_receive_status(void)
+{
+	int i;
 #if defined( SJCD_TRACE )
-  printk( "SJCD: receive_status\n" );
+	printk("SJCD: receive_status\n");
 #endif
-  /*
-   * Wait a bit for status available.
-   */
-  for( i = 200; i-- && ( sjcd_check_status() == 0 ); );
-  if( i < 0 ){
+	/*
+	 * Wait a bit for status available.
+	 */
+	for (i = 200; i-- && (sjcd_check_status() == 0););
+	if (i < 0) {
 #if defined( SJCD_TRACE )
-    printk( "SJCD: long wait for status\n" );
+		printk("SJCD: long wait for status\n");
 #endif
-    if( sjcd_wait_for_status() <= 0 )
-      printk( "SJCD: Timeout when read status.\n" );
-    else i = 0;
-  }
-  return( i );
+		if (sjcd_wait_for_status() <= 0)
+			printk("SJCD: Timeout when read status.\n");
+		else
+			i = 0;
+	}
+	return (i);
 }
 
 /*
  * Load the status. Issue get status command and wait for status available.
  */
-static void sjcd_get_status( void ){
+static void sjcd_get_status(void)
+{
 #if defined( SJCD_TRACE )
-  printk( "SJCD: get_status\n" );
+	printk("SJCD: get_status\n");
 #endif
-  sjcd_send_cmd( SCMD_GET_STATUS );
-  sjcd_receive_status();
+	sjcd_send_cmd(SCMD_GET_STATUS);
+	sjcd_receive_status();
 }
 
 /*
  * Check the drive if the disk is changed. Should be revised.
  */
-static int sjcd_disk_change( kdev_t full_dev ){
+static int sjcd_disk_change(kdev_t full_dev)
+{
 #if 0
-  printk( "SJCD: sjcd_disk_change( 0x%x )\n", full_dev );
+	printk("SJCD: sjcd_disk_change( 0x%x )\n", full_dev);
 #endif
-  if( MINOR( full_dev ) > 0 ){
-    printk( "SJCD: request error: invalid device minor.\n" );
-    return 0;
-  }
-  if( !sjcd_command_is_in_progress )
-    sjcd_get_status();
-  return( sjcd_status_valid ? sjcd_media_is_changed : 0 );
+	if (MINOR(full_dev) > 0) {
+		printk("SJCD: request error: invalid device minor.\n");
+		return 0;
+	}
+	if (!sjcd_command_is_in_progress)
+		sjcd_get_status();
+	return (sjcd_status_valid ? sjcd_media_is_changed : 0);
 }
 
 /*
  * Read the table of contents (TOC) and TOC header if necessary.
  * We assume that the drive contains no more than 99 toc entries.
  */
-static struct sjcd_hw_disk_info sjcd_table_of_contents[ SJCD_MAX_TRACKS ];
+static struct sjcd_hw_disk_info sjcd_table_of_contents[SJCD_MAX_TRACKS];
 static unsigned char sjcd_first_track_no, sjcd_last_track_no;
 #define sjcd_disk_length  sjcd_table_of_contents[0].un.track_msf
 
-static int sjcd_update_toc( void ){
-  struct sjcd_hw_disk_info info;
-  int i;
-#if defined( SJCD_TRACE )
-  printk( "SJCD: update toc:\n" );
-#endif
-  /*
-   * check to see if we need to do anything
-   */
-  if( sjcd_toc_uptodate ) return( 0 );
-
-  /*
-   * Get the TOC start information.
-   */
-  sjcd_send_1_cmd( SCMD_GET_DISK_INFO, SCMD_GET_1_TRACK );
-  sjcd_receive_status();
-
-  if( !sjcd_status_valid ){
-    printk( "SJCD: cannot load status.\n" );
-    return( -1 );
-  }
-
-  if( !sjcd_media_is_available ){
-    printk( "SJCD: no disk in drive\n" );
-    return( -1 );
-  }
-
-  if( !sjcd_command_failed ){
-    if( sjcd_load_response( &info, sizeof( info ) ) != 0 ){
-      printk( "SJCD: cannot load response about TOC start.\n" );
-      return( -1 );
-    }
-    sjcd_first_track_no = bcd2bin( info.un.track_no );
-  } else {
-    printk( "SJCD: get first failed\n" );
-    return( -1 );
-  }
-#if defined( SJCD_TRACE )
-  printk( "SJCD: TOC start 0x%02x ", sjcd_first_track_no );
-#endif
-  /*
-   * Get the TOC finish information.
-   */
-  sjcd_send_1_cmd( SCMD_GET_DISK_INFO, SCMD_GET_L_TRACK );
-  sjcd_receive_status();
-
-  if( !sjcd_status_valid ){
-    printk( "SJCD: cannot load status.\n" );
-    return( -1 );
-  }
-
-  if( !sjcd_media_is_available ){
-    printk( "SJCD: no disk in drive\n" );
-    return( -1 );
-  }
-
-  if( !sjcd_command_failed ){
-    if( sjcd_load_response( &info, sizeof( info ) ) != 0 ){
-      printk( "SJCD: cannot load response about TOC finish.\n" );
-      return( -1 );
-    }
-    sjcd_last_track_no = bcd2bin( info.un.track_no );
-  } else {
-    printk( "SJCD: get last failed\n" );
-    return( -1 );
-  }
-#if defined( SJCD_TRACE )
-  printk( "SJCD: TOC finish 0x%02x ", sjcd_last_track_no );
-#endif
-  for( i = sjcd_first_track_no; i <= sjcd_last_track_no; i++ ){
-    /*
-     * Get the first track information.
-     */
-    sjcd_send_1_cmd( SCMD_GET_DISK_INFO, bin2bcd( i ) );
-    sjcd_receive_status();
-
-    if( !sjcd_status_valid ){
-      printk( "SJCD: cannot load status.\n" );
-      return( -1 );
-    }
-
-    if( !sjcd_media_is_available ){
-      printk( "SJCD: no disk in drive\n" );
-      return( -1 );
-    }
-
-    if( !sjcd_command_failed ){
-      if( sjcd_load_response( &sjcd_table_of_contents[ i ],
-			     sizeof( struct sjcd_hw_disk_info ) ) != 0 ){
-	printk( "SJCD: cannot load info for %d track\n", i );
-	return( -1 );
-      }
-    } else {
-      printk( "SJCD: get info %d failed\n", i );
-      return( -1 );
-    }
-  }
-
-  /*
-   * Get the disk length info.
-   */
-  sjcd_send_1_cmd( SCMD_GET_DISK_INFO, SCMD_GET_D_SIZE );
-  sjcd_receive_status();
-
-  if( !sjcd_status_valid ){
-    printk( "SJCD: cannot load status.\n" );
-    return( -1 );
-  }
-
-  if( !sjcd_media_is_available ){
-    printk( "SJCD: no disk in drive\n" );
-    return( -1 );
-  }
-
-  if( !sjcd_command_failed ){
-    if( sjcd_load_response( &info, sizeof( info ) ) != 0 ){
-      printk( "SJCD: cannot load response about disk size.\n" );
-      return( -1 );
-    }
-    sjcd_disk_length.min = info.un.track_msf.min;
-    sjcd_disk_length.sec = info.un.track_msf.sec;
-    sjcd_disk_length.frame = info.un.track_msf.frame;
-  } else {
-    printk( "SJCD: get size failed\n" );
-    return( 1 );
-  }
+static int sjcd_update_toc(void)
+{
+	struct sjcd_hw_disk_info info;
+	int i;
 #if defined( SJCD_TRACE )
-  printk( "SJCD: (%02x:%02x.%02x)\n", sjcd_disk_length.min,
-	 sjcd_disk_length.sec, sjcd_disk_length.frame );
+	printk("SJCD: update toc:\n");
 #endif
-  return( 0 );
+	/*
+	 * check to see if we need to do anything
+	 */
+	if (sjcd_toc_uptodate)
+		return (0);
+
+	/*
+	 * Get the TOC start information.
+	 */
+	sjcd_send_1_cmd(SCMD_GET_DISK_INFO, SCMD_GET_1_TRACK);
+	sjcd_receive_status();
+
+	if (!sjcd_status_valid) {
+		printk("SJCD: cannot load status.\n");
+		return (-1);
+	}
+
+	if (!sjcd_media_is_available) {
+		printk("SJCD: no disk in drive\n");
+		return (-1);
+	}
+
+	if (!sjcd_command_failed) {
+		if (sjcd_load_response(&info, sizeof(info)) != 0) {
+			printk
+			    ("SJCD: cannot load response about TOC start.\n");
+			return (-1);
+		}
+		sjcd_first_track_no = bcd2bin(info.un.track_no);
+	} else {
+		printk("SJCD: get first failed\n");
+		return (-1);
+	}
+#if defined( SJCD_TRACE )
+	printk("SJCD: TOC start 0x%02x ", sjcd_first_track_no);
+#endif
+	/*
+	 * Get the TOC finish information.
+	 */
+	sjcd_send_1_cmd(SCMD_GET_DISK_INFO, SCMD_GET_L_TRACK);
+	sjcd_receive_status();
+
+	if (!sjcd_status_valid) {
+		printk("SJCD: cannot load status.\n");
+		return (-1);
+	}
+
+	if (!sjcd_media_is_available) {
+		printk("SJCD: no disk in drive\n");
+		return (-1);
+	}
+
+	if (!sjcd_command_failed) {
+		if (sjcd_load_response(&info, sizeof(info)) != 0) {
+			printk
+			    ("SJCD: cannot load response about TOC finish.\n");
+			return (-1);
+		}
+		sjcd_last_track_no = bcd2bin(info.un.track_no);
+	} else {
+		printk("SJCD: get last failed\n");
+		return (-1);
+	}
+#if defined( SJCD_TRACE )
+	printk("SJCD: TOC finish 0x%02x ", sjcd_last_track_no);
+#endif
+	for (i = sjcd_first_track_no; i <= sjcd_last_track_no; i++) {
+		/*
+		 * Get the first track information.
+		 */
+		sjcd_send_1_cmd(SCMD_GET_DISK_INFO, bin2bcd(i));
+		sjcd_receive_status();
+
+		if (!sjcd_status_valid) {
+			printk("SJCD: cannot load status.\n");
+			return (-1);
+		}
+
+		if (!sjcd_media_is_available) {
+			printk("SJCD: no disk in drive\n");
+			return (-1);
+		}
+
+		if (!sjcd_command_failed) {
+			if (sjcd_load_response(&sjcd_table_of_contents[i],
+					       sizeof(struct
+						      sjcd_hw_disk_info))
+			    != 0) {
+				printk
+				    ("SJCD: cannot load info for %d track\n",
+				     i);
+				return (-1);
+			}
+		} else {
+			printk("SJCD: get info %d failed\n", i);
+			return (-1);
+		}
+	}
+
+	/*
+	 * Get the disk length info.
+	 */
+	sjcd_send_1_cmd(SCMD_GET_DISK_INFO, SCMD_GET_D_SIZE);
+	sjcd_receive_status();
+
+	if (!sjcd_status_valid) {
+		printk("SJCD: cannot load status.\n");
+		return (-1);
+	}
+
+	if (!sjcd_media_is_available) {
+		printk("SJCD: no disk in drive\n");
+		return (-1);
+	}
+
+	if (!sjcd_command_failed) {
+		if (sjcd_load_response(&info, sizeof(info)) != 0) {
+			printk
+			    ("SJCD: cannot load response about disk size.\n");
+			return (-1);
+		}
+		sjcd_disk_length.min = info.un.track_msf.min;
+		sjcd_disk_length.sec = info.un.track_msf.sec;
+		sjcd_disk_length.frame = info.un.track_msf.frame;
+	} else {
+		printk("SJCD: get size failed\n");
+		return (1);
+	}
+#if defined( SJCD_TRACE )
+	printk("SJCD: (%02x:%02x.%02x)\n", sjcd_disk_length.min,
+	       sjcd_disk_length.sec, sjcd_disk_length.frame);
+#endif
+	return (0);
 }
 
 /*
  * Load subchannel information.
  */
-static int sjcd_get_q_info( struct sjcd_hw_qinfo *qp ){
-  int s;
+static int sjcd_get_q_info(struct sjcd_hw_qinfo *qp)
+{
+	int s;
 #if defined( SJCD_TRACE )
-  printk( "SJCD: load sub q\n" );
+	printk("SJCD: load sub q\n");
 #endif
-  sjcd_send_cmd( SCMD_GET_QINFO );
-  s = sjcd_receive_status();
-  if( s < 0 || sjcd_command_failed || !sjcd_status_valid ){
-    sjcd_send_cmd( 0xF2 );
-    s = sjcd_receive_status();
-    if( s < 0 || sjcd_command_failed || !sjcd_status_valid ) return( -1 );
-    sjcd_send_cmd( SCMD_GET_QINFO );
-    s = sjcd_receive_status();
-    if( s < 0 || sjcd_command_failed || !sjcd_status_valid ) return( -1 );
-  }
-  if( sjcd_media_is_available )
-    if( sjcd_load_response( qp, sizeof( *qp ) ) == 0 ) return( 0 );
-  return( -1 );
+	sjcd_send_cmd(SCMD_GET_QINFO);
+	s = sjcd_receive_status();
+	if (s < 0 || sjcd_command_failed || !sjcd_status_valid) {
+		sjcd_send_cmd(0xF2);
+		s = sjcd_receive_status();
+		if (s < 0 || sjcd_command_failed || !sjcd_status_valid)
+			return (-1);
+		sjcd_send_cmd(SCMD_GET_QINFO);
+		s = sjcd_receive_status();
+		if (s < 0 || sjcd_command_failed || !sjcd_status_valid)
+			return (-1);
+	}
+	if (sjcd_media_is_available)
+		if (sjcd_load_response(qp, sizeof(*qp)) == 0)
+			return (0);
+	return (-1);
 }
 
 /*
  * Start playing from the specified position.
  */
-static int sjcd_play( struct sjcd_play_msf *mp ){
-  struct sjcd_play_msf msf;
+static int sjcd_play(struct sjcd_play_msf *mp)
+{
+	struct sjcd_play_msf msf;
 
-  /*
-   * Turn the device to play mode.
-   */
-  sjcd_send_1_cmd( SCMD_SET_MODE, SCMD_MODE_PLAY );
-  if( sjcd_receive_status() < 0 ) return( -1 );
-
-  /*
-   * Seek to the starting point.
-   */
-  msf.start = mp->start;
-  msf.end.min = msf.end.sec = msf.end.frame = 0x00;
-  sjcd_send_6_cmd( SCMD_SEEK, &msf );
-  if( sjcd_receive_status() < 0 ) return( -1 );
-
-  /*
-   * Start playing.
-   */
-  sjcd_send_6_cmd( SCMD_PLAY, mp );
-  return( sjcd_receive_status() );
+	/*
+	 * Turn the device to play mode.
+	 */
+	sjcd_send_1_cmd(SCMD_SET_MODE, SCMD_MODE_PLAY);
+	if (sjcd_receive_status() < 0)
+		return (-1);
+
+	/*
+	 * Seek to the starting point.
+	 */
+	msf.start = mp->start;
+	msf.end.min = msf.end.sec = msf.end.frame = 0x00;
+	sjcd_send_6_cmd(SCMD_SEEK, &msf);
+	if (sjcd_receive_status() < 0)
+		return (-1);
+
+	/*
+	 * Start playing.
+	 */
+	sjcd_send_6_cmd(SCMD_PLAY, mp);
+	return (sjcd_receive_status());
 }
 
 /*
  * Tray control functions.
  */
-static int sjcd_tray_close( void ){
+static int sjcd_tray_close(void)
+{
 #if defined( SJCD_TRACE )
-  printk( "SJCD: tray_close\n" );
+	printk("SJCD: tray_close\n");
 #endif
-  sjcd_send_cmd( SCMD_CLOSE_TRAY );
-  return( sjcd_receive_status() );
+	sjcd_send_cmd(SCMD_CLOSE_TRAY);
+	return (sjcd_receive_status());
 }
 
-static int sjcd_tray_lock( void ){
+static int sjcd_tray_lock(void)
+{
 #if defined( SJCD_TRACE )
-  printk( "SJCD: tray_lock\n" );
+	printk("SJCD: tray_lock\n");
 #endif
-  sjcd_send_cmd( SCMD_LOCK_TRAY );
-  return( sjcd_receive_status() );
+	sjcd_send_cmd(SCMD_LOCK_TRAY);
+	return (sjcd_receive_status());
 }
 
-static int sjcd_tray_unlock( void ){
+static int sjcd_tray_unlock(void)
+{
 #if defined( SJCD_TRACE )
-  printk( "SJCD: tray_unlock\n" );
+	printk("SJCD: tray_unlock\n");
 #endif
-  sjcd_send_cmd( SCMD_UNLOCK_TRAY );
-  return( sjcd_receive_status() );
+	sjcd_send_cmd(SCMD_UNLOCK_TRAY);
+	return (sjcd_receive_status());
 }
 
-static int sjcd_tray_open( void ){
+static int sjcd_tray_open(void)
+{
 #if defined( SJCD_TRACE )
-  printk( "SJCD: tray_open\n" );
+	printk("SJCD: tray_open\n");
 #endif
-  sjcd_send_cmd( SCMD_EJECT_TRAY );
-  return( sjcd_receive_status() );
+	sjcd_send_cmd(SCMD_EJECT_TRAY);
+	return (sjcd_receive_status());
 }
 
 /*
  * Do some user commands.
  */
-static int sjcd_ioctl( struct inode *ip, struct file *fp,
-		       unsigned int cmd, unsigned long arg ){
-#if defined( SJCD_TRACE )
-  printk( "SJCD:ioctl\n" );
-#endif
-
-  if( ip == NULL ) return( -EINVAL );
-
-  sjcd_get_status();
-  if( !sjcd_status_valid ) return( -EIO );
-  if( sjcd_update_toc() < 0 ) return( -EIO );
-
-  switch( cmd ){
-  case CDROMSTART:{
-#if defined( SJCD_TRACE )
-    printk( "SJCD: ioctl: start\n" );
-#endif
-    return( 0 );
-  }
-
-  case CDROMSTOP:{
+static int sjcd_ioctl(struct inode *ip, struct file *fp,
+		      unsigned int cmd, unsigned long arg)
+{
 #if defined( SJCD_TRACE )
-    printk( "SJCD: ioctl: stop\n" );
+	printk("SJCD:ioctl\n");
 #endif
-    sjcd_send_cmd( SCMD_PAUSE );
-    ( void )sjcd_receive_status();
-    sjcd_audio_status = CDROM_AUDIO_NO_STATUS;
-    return( 0 );
-  }
 
-  case CDROMPAUSE:{
-    struct sjcd_hw_qinfo q_info;
-#if defined( SJCD_TRACE )
-    printk( "SJCD: ioctl: pause\n" );
-#endif
-    if( sjcd_audio_status == CDROM_AUDIO_PLAY ){
-      sjcd_send_cmd( SCMD_PAUSE );
-      ( void )sjcd_receive_status();
-      if( sjcd_get_q_info( &q_info ) < 0 ){
-	sjcd_audio_status = CDROM_AUDIO_NO_STATUS;
-      } else {
-	sjcd_audio_status = CDROM_AUDIO_PAUSED;
-	sjcd_playing.start = q_info.abs;
-      }
-      return( 0 );
-    } else return( -EINVAL );
-  }
-
-  case CDROMRESUME:{
-#if defined( SJCD_TRACE )
-    printk( "SJCD: ioctl: resume\n" );
-#endif
-    if( sjcd_audio_status == CDROM_AUDIO_PAUSED ){
-      /*
-       * continue play starting at saved location
-       */
-      if( sjcd_play( &sjcd_playing ) < 0 ){
-	sjcd_audio_status = CDROM_AUDIO_ERROR;
-	return( -EIO );
-      } else {
-	sjcd_audio_status = CDROM_AUDIO_PLAY;
-	return( 0 );
-      }
-    } else return( -EINVAL );
-  }
-
-  case CDROMPLAYTRKIND:{
-    struct cdrom_ti ti; int s;
-#if defined( SJCD_TRACE )
-    printk( "SJCD: ioctl: playtrkind\n" );
-#endif
-    if( ( s = verify_area( VERIFY_READ, (void *)arg, sizeof( ti ) ) ) == 0 ){
-      copy_from_user( &ti, (void *)arg, sizeof( ti ) );
-
-      if( ti.cdti_trk0 < sjcd_first_track_no ) return( -EINVAL );
-      if( ti.cdti_trk1 > sjcd_last_track_no )
-	ti.cdti_trk1 = sjcd_last_track_no;
-      if( ti.cdti_trk0 > ti.cdti_trk1 ) return( -EINVAL );
-
-      sjcd_playing.start = sjcd_table_of_contents[ ti.cdti_trk0 ].un.track_msf;
-      sjcd_playing.end = ( ti.cdti_trk1 < sjcd_last_track_no ) ?
-	sjcd_table_of_contents[ ti.cdti_trk1 + 1 ].un.track_msf :
-	  sjcd_table_of_contents[ 0 ].un.track_msf;
-      
-      if( sjcd_play( &sjcd_playing ) < 0 ){
-	sjcd_audio_status = CDROM_AUDIO_ERROR;
-	return( -EIO );
-      } else sjcd_audio_status = CDROM_AUDIO_PLAY;
-    }
-    return( s );
-  }
-
-  case CDROMPLAYMSF:{
-    struct cdrom_msf sjcd_msf; int s;
-#if defined( SJCD_TRACE )
-    printk( "SJCD: ioctl: playmsf\n" );
-#endif
-    if( ( s = verify_area( VERIFY_READ, (void *)arg, sizeof( sjcd_msf ) ) ) == 0 ){
-      if( sjcd_audio_status == CDROM_AUDIO_PLAY ){
-	sjcd_send_cmd( SCMD_PAUSE );
-	( void )sjcd_receive_status();
-	sjcd_audio_status = CDROM_AUDIO_NO_STATUS;
-      }
-
-      copy_from_user( &sjcd_msf, (void *)arg, sizeof( sjcd_msf ) );
-
-      sjcd_playing.start.min = bin2bcd( sjcd_msf.cdmsf_min0 );
-      sjcd_playing.start.sec = bin2bcd( sjcd_msf.cdmsf_sec0 );
-      sjcd_playing.start.frame = bin2bcd( sjcd_msf.cdmsf_frame0 );
-      sjcd_playing.end.min = bin2bcd( sjcd_msf.cdmsf_min1 );
-      sjcd_playing.end.sec = bin2bcd( sjcd_msf.cdmsf_sec1 );
-      sjcd_playing.end.frame = bin2bcd( sjcd_msf.cdmsf_frame1 );
-
-      if( sjcd_play( &sjcd_playing ) < 0 ){
-	sjcd_audio_status = CDROM_AUDIO_ERROR;
-	return( -EIO );
-      } else sjcd_audio_status = CDROM_AUDIO_PLAY;
-    }
-    return( s );
-  }
+	if (ip == NULL)
+		return (-EINVAL);
 
-  case CDROMREADTOCHDR:{
-    struct cdrom_tochdr toc_header; int s;
+	sjcd_get_status();
+	if (!sjcd_status_valid)
+		return (-EIO);
+	if (sjcd_update_toc() < 0)
+		return (-EIO);
+
+	switch (cmd) {
+	case CDROMSTART:{
+#if defined( SJCD_TRACE )
+			printk("SJCD: ioctl: start\n");
+#endif
+			return (0);
+		}
+
+	case CDROMSTOP:{
+#if defined( SJCD_TRACE )
+			printk("SJCD: ioctl: stop\n");
+#endif
+			sjcd_send_cmd(SCMD_PAUSE);
+			(void) sjcd_receive_status();
+			sjcd_audio_status = CDROM_AUDIO_NO_STATUS;
+			return (0);
+		}
+
+	case CDROMPAUSE:{
+			struct sjcd_hw_qinfo q_info;
+#if defined( SJCD_TRACE )
+			printk("SJCD: ioctl: pause\n");
+#endif
+			if (sjcd_audio_status == CDROM_AUDIO_PLAY) {
+				sjcd_send_cmd(SCMD_PAUSE);
+				(void) sjcd_receive_status();
+				if (sjcd_get_q_info(&q_info) < 0) {
+					sjcd_audio_status =
+					    CDROM_AUDIO_NO_STATUS;
+				} else {
+					sjcd_audio_status =
+					    CDROM_AUDIO_PAUSED;
+					sjcd_playing.start = q_info.abs;
+				}
+				return (0);
+			} else
+				return (-EINVAL);
+		}
+
+	case CDROMRESUME:{
+#if defined( SJCD_TRACE )
+			printk("SJCD: ioctl: resume\n");
+#endif
+			if (sjcd_audio_status == CDROM_AUDIO_PAUSED) {
+				/*
+				 * continue play starting at saved location
+				 */
+				if (sjcd_play(&sjcd_playing) < 0) {
+					sjcd_audio_status =
+					    CDROM_AUDIO_ERROR;
+					return (-EIO);
+				} else {
+					sjcd_audio_status =
+					    CDROM_AUDIO_PLAY;
+					return (0);
+				}
+			} else
+				return (-EINVAL);
+		}
+
+	case CDROMPLAYTRKIND:{
+			struct cdrom_ti ti;
+			int s;
+#if defined( SJCD_TRACE )
+			printk("SJCD: ioctl: playtrkind\n");
+#endif
+			if ((s =
+			     verify_area(VERIFY_READ, (void *) arg,
+					 sizeof(ti))) == 0) {
+				copy_from_user(&ti, (void *) arg,
+					       sizeof(ti));
+
+				if (ti.cdti_trk0 < sjcd_first_track_no)
+					return (-EINVAL);
+				if (ti.cdti_trk1 > sjcd_last_track_no)
+					ti.cdti_trk1 = sjcd_last_track_no;
+				if (ti.cdti_trk0 > ti.cdti_trk1)
+					return (-EINVAL);
+
+				sjcd_playing.start =
+				    sjcd_table_of_contents[ti.cdti_trk0].
+				    un.track_msf;
+				sjcd_playing.end =
+				    (ti.cdti_trk1 <
+				     sjcd_last_track_no) ?
+				    sjcd_table_of_contents[ti.cdti_trk1 +
+							   1].un.
+				    track_msf : sjcd_table_of_contents[0].
+				    un.track_msf;
+
+				if (sjcd_play(&sjcd_playing) < 0) {
+					sjcd_audio_status =
+					    CDROM_AUDIO_ERROR;
+					return (-EIO);
+				} else
+					sjcd_audio_status =
+					    CDROM_AUDIO_PLAY;
+			}
+			return (s);
+		}
+
+	case CDROMPLAYMSF:{
+			struct cdrom_msf sjcd_msf;
+			int s;
+#if defined( SJCD_TRACE )
+			printk("SJCD: ioctl: playmsf\n");
+#endif
+			if ((s =
+			     verify_area(VERIFY_READ, (void *) arg,
+					 sizeof(sjcd_msf))) == 0) {
+				if (sjcd_audio_status == CDROM_AUDIO_PLAY) {
+					sjcd_send_cmd(SCMD_PAUSE);
+					(void) sjcd_receive_status();
+					sjcd_audio_status =
+					    CDROM_AUDIO_NO_STATUS;
+				}
+
+				copy_from_user(&sjcd_msf, (void *) arg,
+					       sizeof(sjcd_msf));
+
+				sjcd_playing.start.min =
+				    bin2bcd(sjcd_msf.cdmsf_min0);
+				sjcd_playing.start.sec =
+				    bin2bcd(sjcd_msf.cdmsf_sec0);
+				sjcd_playing.start.frame =
+				    bin2bcd(sjcd_msf.cdmsf_frame0);
+				sjcd_playing.end.min =
+				    bin2bcd(sjcd_msf.cdmsf_min1);
+				sjcd_playing.end.sec =
+				    bin2bcd(sjcd_msf.cdmsf_sec1);
+				sjcd_playing.end.frame =
+				    bin2bcd(sjcd_msf.cdmsf_frame1);
+
+				if (sjcd_play(&sjcd_playing) < 0) {
+					sjcd_audio_status =
+					    CDROM_AUDIO_ERROR;
+					return (-EIO);
+				} else
+					sjcd_audio_status =
+					    CDROM_AUDIO_PLAY;
+			}
+			return (s);
+		}
+
+	case CDROMREADTOCHDR:{
+			struct cdrom_tochdr toc_header;
+			int s;
 #if defined (SJCD_TRACE )
-    printk( "SJCD: ioctl: readtocheader\n" );
+			printk("SJCD: ioctl: readtocheader\n");
 #endif
-    if( ( s = verify_area( VERIFY_WRITE, (void *)arg, sizeof( toc_header ) ) ) == 0 ){
-      toc_header.cdth_trk0 = sjcd_first_track_no;
-      toc_header.cdth_trk1 = sjcd_last_track_no;
-      copy_to_user( (void *)arg, &toc_header, sizeof( toc_header ) );
-    }
-    return( s );
-  }
-
-  case CDROMREADTOCENTRY:{
-    struct cdrom_tocentry toc_entry; int s;
-#if defined( SJCD_TRACE )
-    printk( "SJCD: ioctl: readtocentry\n" );
-#endif
-    if( ( s = verify_area( VERIFY_WRITE, (void *)arg, sizeof( toc_entry ) ) ) == 0 ){
-      struct sjcd_hw_disk_info *tp;
-
-      copy_from_user( &toc_entry, (void *)arg, sizeof( toc_entry ) );
-
-      if( toc_entry.cdte_track == CDROM_LEADOUT )
-	tp = &sjcd_table_of_contents[ 0 ];
-      else if( toc_entry.cdte_track < sjcd_first_track_no ) return( -EINVAL );
-      else if( toc_entry.cdte_track > sjcd_last_track_no ) return( -EINVAL );
-      else tp = &sjcd_table_of_contents[ toc_entry.cdte_track ];
-
-      toc_entry.cdte_adr = tp->track_control & 0x0F;
-      toc_entry.cdte_ctrl = tp->track_control >> 4;
-
-      switch( toc_entry.cdte_format ){
-      case CDROM_LBA:
-	toc_entry.cdte_addr.lba = msf2hsg( &( tp->un.track_msf ) );
-	break;
-      case CDROM_MSF:
-	toc_entry.cdte_addr.msf.minute = bcd2bin( tp->un.track_msf.min );
-	toc_entry.cdte_addr.msf.second = bcd2bin( tp->un.track_msf.sec );
-	toc_entry.cdte_addr.msf.frame = bcd2bin( tp->un.track_msf.frame );
-	break;
-      default: return( -EINVAL );
-      }
-      copy_to_user( (void *)arg, &toc_entry, sizeof( toc_entry ) );
-    }
-    return( s );
-  }
-
-  case CDROMSUBCHNL:{
-    struct cdrom_subchnl subchnl; int s;
-#if defined( SJCD_TRACE )
-    printk( "SJCD: ioctl: subchnl\n" );
-#endif
-    if( ( s = verify_area( VERIFY_WRITE, (void *)arg, sizeof( subchnl ) ) ) == 0 ){
-      struct sjcd_hw_qinfo q_info;
-
-      copy_from_user( &subchnl, (void *)arg, sizeof( subchnl ) );
-      if( sjcd_get_q_info( &q_info ) < 0 ) return( -EIO );
-
-      subchnl.cdsc_audiostatus = sjcd_audio_status;
-      subchnl.cdsc_adr = q_info.track_control & 0x0F;
-      subchnl.cdsc_ctrl = q_info.track_control >> 4;
-      subchnl.cdsc_trk = bcd2bin( q_info.track_no );
-      subchnl.cdsc_ind = bcd2bin( q_info.x );
-
-      switch( subchnl.cdsc_format ){
-      case CDROM_LBA:
-	subchnl.cdsc_absaddr.lba = msf2hsg( &( q_info.abs ) );
-	subchnl.cdsc_reladdr.lba = msf2hsg( &( q_info.rel ) );
-	break;
-      case CDROM_MSF:
-	subchnl.cdsc_absaddr.msf.minute = bcd2bin( q_info.abs.min );
-	subchnl.cdsc_absaddr.msf.second = bcd2bin( q_info.abs.sec );
-	subchnl.cdsc_absaddr.msf.frame = bcd2bin( q_info.abs.frame );
-	subchnl.cdsc_reladdr.msf.minute = bcd2bin( q_info.rel.min );
-	subchnl.cdsc_reladdr.msf.second = bcd2bin( q_info.rel.sec );
-	subchnl.cdsc_reladdr.msf.frame = bcd2bin( q_info.rel.frame );
-	break;
-      default: return( -EINVAL );
-      }
-      copy_to_user( (void *)arg, &subchnl, sizeof( subchnl ) );
-    }
-    return( s );
-  }
-
-  case CDROMVOLCTRL:{
-    struct cdrom_volctrl vol_ctrl; int s;
-#if defined( SJCD_TRACE )
-    printk( "SJCD: ioctl: volctrl\n" );
-#endif
-    if( ( s = verify_area( VERIFY_READ, (void *)arg, sizeof( vol_ctrl ) ) ) == 0 ){
-      unsigned char dummy[ 4 ];
-
-      copy_from_user( &vol_ctrl, (void *)arg, sizeof( vol_ctrl ) );
-      sjcd_send_4_cmd( SCMD_SET_VOLUME, vol_ctrl.channel0, 0xFF,
-		      vol_ctrl.channel1, 0xFF );
-      if( sjcd_receive_status() < 0 ) return( -EIO );
-      ( void )sjcd_load_response( dummy, 4 );
-    }
-    return( s );
-  }
-
-  case CDROMEJECT:{
-#if defined( SJCD_TRACE )
-    printk( "SJCD: ioctl: eject\n" );
-#endif
-    if( !sjcd_command_is_in_progress ){
-      sjcd_tray_unlock();
-      sjcd_send_cmd( SCMD_EJECT_TRAY );
-      ( void )sjcd_receive_status();
-    }
-    return( 0 );
-  }
+			if ((s =
+			     verify_area(VERIFY_WRITE, (void *) arg,
+					 sizeof(toc_header))) == 0) {
+				toc_header.cdth_trk0 = sjcd_first_track_no;
+				toc_header.cdth_trk1 = sjcd_last_track_no;
+				copy_to_user((void *) arg, &toc_header,
+					     sizeof(toc_header));
+			}
+			return (s);
+		}
+
+	case CDROMREADTOCENTRY:{
+			struct cdrom_tocentry toc_entry;
+			int s;
+#if defined( SJCD_TRACE )
+			printk("SJCD: ioctl: readtocentry\n");
+#endif
+			if ((s =
+			     verify_area(VERIFY_WRITE, (void *) arg,
+					 sizeof(toc_entry))) == 0) {
+				struct sjcd_hw_disk_info *tp;
+
+				copy_from_user(&toc_entry, (void *) arg,
+					       sizeof(toc_entry));
+
+				if (toc_entry.cdte_track == CDROM_LEADOUT)
+					tp = &sjcd_table_of_contents[0];
+				else if (toc_entry.cdte_track <
+					 sjcd_first_track_no)
+					return (-EINVAL);
+				else if (toc_entry.cdte_track >
+					 sjcd_last_track_no)
+					return (-EINVAL);
+				else
+					tp = &sjcd_table_of_contents
+					    [toc_entry.cdte_track];
+
+				toc_entry.cdte_adr =
+				    tp->track_control & 0x0F;
+				toc_entry.cdte_ctrl =
+				    tp->track_control >> 4;
+
+				switch (toc_entry.cdte_format) {
+				case CDROM_LBA:
+					toc_entry.cdte_addr.lba =
+					    msf2hsg(&(tp->un.track_msf));
+					break;
+				case CDROM_MSF:
+					toc_entry.cdte_addr.msf.minute =
+					    bcd2bin(tp->un.track_msf.min);
+					toc_entry.cdte_addr.msf.second =
+					    bcd2bin(tp->un.track_msf.sec);
+					toc_entry.cdte_addr.msf.frame =
+					    bcd2bin(tp->un.track_msf.
+						    frame);
+					break;
+				default:
+					return (-EINVAL);
+				}
+				copy_to_user((void *) arg, &toc_entry,
+					     sizeof(toc_entry));
+			}
+			return (s);
+		}
+
+	case CDROMSUBCHNL:{
+			struct cdrom_subchnl subchnl;
+			int s;
+#if defined( SJCD_TRACE )
+			printk("SJCD: ioctl: subchnl\n");
+#endif
+			if ((s =
+			     verify_area(VERIFY_WRITE, (void *) arg,
+					 sizeof(subchnl))) == 0) {
+				struct sjcd_hw_qinfo q_info;
+
+				copy_from_user(&subchnl, (void *) arg,
+					       sizeof(subchnl));
+				if (sjcd_get_q_info(&q_info) < 0)
+					return (-EIO);
+
+				subchnl.cdsc_audiostatus =
+				    sjcd_audio_status;
+				subchnl.cdsc_adr =
+				    q_info.track_control & 0x0F;
+				subchnl.cdsc_ctrl =
+				    q_info.track_control >> 4;
+				subchnl.cdsc_trk =
+				    bcd2bin(q_info.track_no);
+				subchnl.cdsc_ind = bcd2bin(q_info.x);
+
+				switch (subchnl.cdsc_format) {
+				case CDROM_LBA:
+					subchnl.cdsc_absaddr.lba =
+					    msf2hsg(&(q_info.abs));
+					subchnl.cdsc_reladdr.lba =
+					    msf2hsg(&(q_info.rel));
+					break;
+				case CDROM_MSF:
+					subchnl.cdsc_absaddr.msf.minute =
+					    bcd2bin(q_info.abs.min);
+					subchnl.cdsc_absaddr.msf.second =
+					    bcd2bin(q_info.abs.sec);
+					subchnl.cdsc_absaddr.msf.frame =
+					    bcd2bin(q_info.abs.frame);
+					subchnl.cdsc_reladdr.msf.minute =
+					    bcd2bin(q_info.rel.min);
+					subchnl.cdsc_reladdr.msf.second =
+					    bcd2bin(q_info.rel.sec);
+					subchnl.cdsc_reladdr.msf.frame =
+					    bcd2bin(q_info.rel.frame);
+					break;
+				default:
+					return (-EINVAL);
+				}
+				copy_to_user((void *) arg, &subchnl,
+					     sizeof(subchnl));
+			}
+			return (s);
+		}
+
+	case CDROMVOLCTRL:{
+			struct cdrom_volctrl vol_ctrl;
+			int s;
+#if defined( SJCD_TRACE )
+			printk("SJCD: ioctl: volctrl\n");
+#endif
+			if ((s =
+			     verify_area(VERIFY_READ, (void *) arg,
+					 sizeof(vol_ctrl))) == 0) {
+				unsigned char dummy[4];
+
+				copy_from_user(&vol_ctrl, (void *) arg,
+					       sizeof(vol_ctrl));
+				sjcd_send_4_cmd(SCMD_SET_VOLUME,
+						vol_ctrl.channel0, 0xFF,
+						vol_ctrl.channel1, 0xFF);
+				if (sjcd_receive_status() < 0)
+					return (-EIO);
+				(void) sjcd_load_response(dummy, 4);
+			}
+			return (s);
+		}
+
+	case CDROMEJECT:{
+#if defined( SJCD_TRACE )
+			printk("SJCD: ioctl: eject\n");
+#endif
+			if (!sjcd_command_is_in_progress) {
+				sjcd_tray_unlock();
+				sjcd_send_cmd(SCMD_EJECT_TRAY);
+				(void) sjcd_receive_status();
+			}
+			return (0);
+		}
 
 #if defined( SJCD_GATHER_STAT )
-  case 0xABCD:{
-    int s;
+	case 0xABCD:{
+			int s;
 #if defined( SJCD_TRACE )
-    printk( "SJCD: ioctl: statistic\n" );
+			printk("SJCD: ioctl: statistic\n");
 #endif
-    if( ( s = verify_area( VERIFY_WRITE, (void *)arg, sizeof( statistic ) ) ) == 0 )
-      copy_to_user( (void *)arg, &statistic, sizeof( statistic ) );
-    return( s );
-  }
+			if ((s =
+			     verify_area(VERIFY_WRITE, (void *) arg,
+					 sizeof(statistic))) == 0)
+				copy_to_user((void *) arg, &statistic,
+					     sizeof(statistic));
+			return (s);
+		}
 #endif
 
-  default:
-    return( -EINVAL );
-  }
+	default:
+		return (-EINVAL);
+	}
 }
 
 /*
  * Invalidate internal buffers of the driver.
  */
-static void sjcd_invalidate_buffers( void ){
-  int i;
-  for( i = 0; i < SJCD_BUF_SIZ; sjcd_buf_bn[ i++ ] = -1 );
-  sjcd_buf_out = -1;
+static void sjcd_invalidate_buffers(void)
+{
+	int i;
+	for (i = 0; i < SJCD_BUF_SIZ; sjcd_buf_bn[i++] = -1);
+	sjcd_buf_out = -1;
 }
 
 /*
@@ -939,508 +1077,595 @@
     ( !QUEUE_EMPTY && MAJOR( CURRENT->rq_dev ) == MAJOR_NR && \
       CURRENT->cmd == READ && CURRENT->sector != -1 )
 
-static void sjcd_transfer( void ){
+static void sjcd_transfer(void)
+{
 #if defined( SJCD_TRACE )
-  printk( "SJCD: transfer:\n" );
+	printk("SJCD: transfer:\n");
 #endif
-  if( CURRENT_IS_VALID ){
-    while( CURRENT->nr_sectors ){
-      int i, bn = CURRENT->sector / 4;
-      for( i = 0; i < SJCD_BUF_SIZ && sjcd_buf_bn[ i ] != bn; i++ );
-      if( i < SJCD_BUF_SIZ ){
-	int offs = ( i * 4 + ( CURRENT->sector & 3 ) ) * 512;
-	int nr_sectors = 4 - ( CURRENT->sector & 3 );
-	if( sjcd_buf_out != i ){
-	  sjcd_buf_out = i;
-	  if( sjcd_buf_bn[ i ] != bn ){
-	    sjcd_buf_out = -1;
-	    continue;
-	  }
-	}
-	if( nr_sectors > CURRENT->nr_sectors )
-	  nr_sectors = CURRENT->nr_sectors;
-#if defined( SJCD_TRACE )
-	printk( "SJCD: copy out\n" );
-#endif
-	memcpy( CURRENT->buffer, sjcd_buf + offs, nr_sectors * 512 );
-	CURRENT->nr_sectors -= nr_sectors;
-	CURRENT->sector += nr_sectors;
-	CURRENT->buffer += nr_sectors * 512;
-      } else {
-	sjcd_buf_out = -1;
-	break;
-      }
-    }
-  }
+	if (CURRENT_IS_VALID) {
+		while (CURRENT->nr_sectors) {
+			int i, bn = CURRENT->sector / 4;
+			for (i = 0;
+			     i < SJCD_BUF_SIZ && sjcd_buf_bn[i] != bn;
+			     i++);
+			if (i < SJCD_BUF_SIZ) {
+				int offs =
+				    (i * 4 + (CURRENT->sector & 3)) * 512;
+				int nr_sectors = 4 - (CURRENT->sector & 3);
+				if (sjcd_buf_out != i) {
+					sjcd_buf_out = i;
+					if (sjcd_buf_bn[i] != bn) {
+						sjcd_buf_out = -1;
+						continue;
+					}
+				}
+				if (nr_sectors > CURRENT->nr_sectors)
+					nr_sectors = CURRENT->nr_sectors;
+#if defined( SJCD_TRACE )
+				printk("SJCD: copy out\n");
+#endif
+				memcpy(CURRENT->buffer, sjcd_buf + offs,
+				       nr_sectors * 512);
+				CURRENT->nr_sectors -= nr_sectors;
+				CURRENT->sector += nr_sectors;
+				CURRENT->buffer += nr_sectors * 512;
+			} else {
+				sjcd_buf_out = -1;
+				break;
+			}
+		}
+	}
 #if defined( SJCD_TRACE )
-  printk( "SJCD: transfer: done\n" );
+	printk("SJCD: transfer: done\n");
 #endif
 }
 
-static void sjcd_poll( void ){
+static void sjcd_poll(void)
+{
 #if defined( SJCD_GATHER_STAT )
-  /*
-   * Update total number of ticks.
-   */
-  statistic.ticks++;
-  statistic.tticks[ sjcd_transfer_state ]++;
+	/*
+	 * Update total number of ticks.
+	 */
+	statistic.ticks++;
+	statistic.tticks[sjcd_transfer_state]++;
 #endif
 
- ReSwitch: switch( sjcd_transfer_state ){
-      
-  case SJCD_S_IDLE:{
+      ReSwitch:switch (sjcd_transfer_state) {
+
+	case SJCD_S_IDLE:{
 #if defined( SJCD_GATHER_STAT )
-    statistic.idle_ticks++;
+			statistic.idle_ticks++;
 #endif
 #if defined( SJCD_TRACE )
-    printk( "SJCD_S_IDLE\n" );
+			printk("SJCD_S_IDLE\n");
 #endif
-    return;
-  }
+			return;
+		}
 
-  case SJCD_S_START:{
+	case SJCD_S_START:{
 #if defined( SJCD_GATHER_STAT )
-    statistic.start_ticks++;
+			statistic.start_ticks++;
 #endif
-    sjcd_send_cmd( SCMD_GET_STATUS );
-    sjcd_transfer_state =
-      sjcd_mode == SCMD_MODE_COOKED ? SJCD_S_READ : SJCD_S_MODE;
-    sjcd_transfer_timeout = 500;
-#if defined( SJCD_TRACE )
-    printk( "SJCD_S_START: goto SJCD_S_%s mode\n",
-	   sjcd_transfer_state == SJCD_S_READ ? "READ" : "MODE" );
-#endif
-    break;
-  }
-    
-  case SJCD_S_MODE:{
-    if( sjcd_check_status() ){
-      /*
-       * Previous command is completed.
-       */
-      if( !sjcd_status_valid || sjcd_command_failed ){
-#if defined( SJCD_TRACE )
-	printk( "SJCD_S_MODE: pre-cmd failed: goto to SJCD_S_STOP mode\n" );
-#endif
-	sjcd_transfer_state = SJCD_S_STOP;
-	goto ReSwitch;
-      }
-
-      sjcd_mode = 0; /* unknown mode; should not be valid when failed */
-      sjcd_send_1_cmd( SCMD_SET_MODE, SCMD_MODE_COOKED );
-      sjcd_transfer_state = SJCD_S_READ; sjcd_transfer_timeout = 1000;
+			sjcd_send_cmd(SCMD_GET_STATUS);
+			sjcd_transfer_state =
+			    sjcd_mode ==
+			    SCMD_MODE_COOKED ? SJCD_S_READ : SJCD_S_MODE;
+			sjcd_transfer_timeout = 500;
+#if defined( SJCD_TRACE )
+			printk("SJCD_S_START: goto SJCD_S_%s mode\n",
+			       sjcd_transfer_state ==
+			       SJCD_S_READ ? "READ" : "MODE");
+#endif
+			break;
+		}
+
+	case SJCD_S_MODE:{
+			if (sjcd_check_status()) {
+				/*
+				 * Previous command is completed.
+				 */
+				if (!sjcd_status_valid
+				    || sjcd_command_failed) {
+#if defined( SJCD_TRACE )
+					printk
+					    ("SJCD_S_MODE: pre-cmd failed: goto to SJCD_S_STOP mode\n");
+#endif
+					sjcd_transfer_state = SJCD_S_STOP;
+					goto ReSwitch;
+				}
+
+				sjcd_mode = 0;	/* unknown mode; should not be valid when failed */
+				sjcd_send_1_cmd(SCMD_SET_MODE,
+						SCMD_MODE_COOKED);
+				sjcd_transfer_state = SJCD_S_READ;
+				sjcd_transfer_timeout = 1000;
 #if defined( SJCD_TRACE )
-      printk( "SJCD_S_MODE: goto SJCD_S_READ mode\n" );
+				printk
+				    ("SJCD_S_MODE: goto SJCD_S_READ mode\n");
 #endif
-    }
+			}
 #if defined( SJCD_GATHER_STAT )
-    else statistic.mode_ticks++;
+			else
+				statistic.mode_ticks++;
 #endif
-    break;
-  }
+			break;
+		}
 
-  case SJCD_S_READ:{
-    if( sjcd_status_valid ? 1 : sjcd_check_status() ){
-      /*
-       * Previous command is completed.
-       */
-      if( !sjcd_status_valid || sjcd_command_failed ){
-#if defined( SJCD_TRACE )
-	printk( "SJCD_S_READ: pre-cmd failed: goto to SJCD_S_STOP mode\n" );
-#endif
-	sjcd_transfer_state = SJCD_S_STOP;
-	goto ReSwitch;
-      }
-      if( !sjcd_media_is_available ){
-#if defined( SJCD_TRACE )
-	printk( "SJCD_S_READ: no disk: goto to SJCD_S_STOP mode\n" );
-#endif
-	sjcd_transfer_state = SJCD_S_STOP;
-	goto ReSwitch;
-      }
-      if( sjcd_mode != SCMD_MODE_COOKED ){
-	/*
-	 * We seem to come from set mode. So discard one byte of result.
-	 */
-	if( sjcd_load_response( &sjcd_mode, 1 ) != 0 ){
-#if defined( SJCD_TRACE )
-	  printk( "SJCD_S_READ: load failed: goto to SJCD_S_STOP mode\n" );
-#endif
-	  sjcd_transfer_state = SJCD_S_STOP;
-	  goto ReSwitch;
-	}
-	if( sjcd_mode != SCMD_MODE_COOKED ){
-#if defined( SJCD_TRACE )
-	  printk( "SJCD_S_READ: mode failed: goto to SJCD_S_STOP mode\n" );
+	case SJCD_S_READ:{
+			if (sjcd_status_valid ? 1 : sjcd_check_status()) {
+				/*
+				 * Previous command is completed.
+				 */
+				if (!sjcd_status_valid
+				    || sjcd_command_failed) {
+#if defined( SJCD_TRACE )
+					printk
+					    ("SJCD_S_READ: pre-cmd failed: goto to SJCD_S_STOP mode\n");
+#endif
+					sjcd_transfer_state = SJCD_S_STOP;
+					goto ReSwitch;
+				}
+				if (!sjcd_media_is_available) {
+#if defined( SJCD_TRACE )
+					printk
+					    ("SJCD_S_READ: no disk: goto to SJCD_S_STOP mode\n");
+#endif
+					sjcd_transfer_state = SJCD_S_STOP;
+					goto ReSwitch;
+				}
+				if (sjcd_mode != SCMD_MODE_COOKED) {
+					/*
+					 * We seem to come from set mode. So discard one byte of result.
+					 */
+					if (sjcd_load_response
+					    (&sjcd_mode, 1) != 0) {
+#if defined( SJCD_TRACE )
+						printk
+						    ("SJCD_S_READ: load failed: goto to SJCD_S_STOP mode\n");
+#endif
+						sjcd_transfer_state =
+						    SJCD_S_STOP;
+						goto ReSwitch;
+					}
+					if (sjcd_mode != SCMD_MODE_COOKED) {
+#if defined( SJCD_TRACE )
+						printk
+						    ("SJCD_S_READ: mode failed: goto to SJCD_S_STOP mode\n");
+#endif
+						sjcd_transfer_state =
+						    SJCD_S_STOP;
+						goto ReSwitch;
+					}
+				}
+
+				if (CURRENT_IS_VALID) {
+					struct sjcd_play_msf msf;
+
+					sjcd_next_bn = CURRENT->sector / 4;
+					hsg2msf(sjcd_next_bn, &msf.start);
+					msf.end.min = 0;
+					msf.end.sec = 0;
+					msf.end.frame = sjcd_read_count =
+					    SJCD_BUF_SIZ;
+#if defined( SJCD_TRACE )
+					printk
+					    ("SJCD: ---reading msf-address %x:%x:%x  %x:%x:%x\n",
+					     msf.start.min, msf.start.sec,
+					     msf.start.frame, msf.end.min,
+					     msf.end.sec, msf.end.frame);
+					printk
+					    ("sjcd_next_bn:%x buf_in:%x buf_out:%x buf_bn:%x\n",
+					     sjcd_next_bn, sjcd_buf_in,
+					     sjcd_buf_out,
+					     sjcd_buf_bn[sjcd_buf_in]);
+#endif
+					sjcd_send_6_cmd(SCMD_DATA_READ,
+							&msf);
+					sjcd_transfer_state = SJCD_S_DATA;
+					sjcd_transfer_timeout = 500;
+#if defined( SJCD_TRACE )
+					printk
+					    ("SJCD_S_READ: go to SJCD_S_DATA mode\n");
+#endif
+				} else {
+#if defined( SJCD_TRACE )
+					printk
+					    ("SJCD_S_READ: nothing to read: go to SJCD_S_STOP mode\n");
+#endif
+					sjcd_transfer_state = SJCD_S_STOP;
+					goto ReSwitch;
+				}
+			}
+#if defined( SJCD_GATHER_STAT )
+			else
+				statistic.read_ticks++;
 #endif
-	  sjcd_transfer_state = SJCD_S_STOP;
-	  goto ReSwitch;
-	}
-      }
+			break;
+		}
 
-      if( CURRENT_IS_VALID ){
-	struct sjcd_play_msf msf;
+	case SJCD_S_DATA:{
+			unsigned char stat;
 
-	sjcd_next_bn = CURRENT->sector / 4;
-	hsg2msf( sjcd_next_bn, &msf.start );
-	msf.end.min = 0; msf.end.sec = 0;            
-	msf.end.frame = sjcd_read_count = SJCD_BUF_SIZ;
-#if defined( SJCD_TRACE )
-	printk( "SJCD: ---reading msf-address %x:%x:%x  %x:%x:%x\n",
-	       msf.start.min, msf.start.sec, msf.start.frame,
-	       msf.end.min,   msf.end.sec,   msf.end.frame );
-	printk( "sjcd_next_bn:%x buf_in:%x buf_out:%x buf_bn:%x\n", \
-	     sjcd_next_bn, sjcd_buf_in, sjcd_buf_out,
-	     sjcd_buf_bn[ sjcd_buf_in ] );
-#endif	
-	sjcd_send_6_cmd( SCMD_DATA_READ, &msf );
-	sjcd_transfer_state = SJCD_S_DATA;
-	sjcd_transfer_timeout = 500;
-#if defined( SJCD_TRACE )
-	printk( "SJCD_S_READ: go to SJCD_S_DATA mode\n" );
-#endif
-      } else {
-#if defined( SJCD_TRACE )
-	printk( "SJCD_S_READ: nothing to read: go to SJCD_S_STOP mode\n" );
-#endif
-	sjcd_transfer_state = SJCD_S_STOP;
-	goto ReSwitch;
-      }
-    }
+		      sjcd_s_data:stat =
+			    inb(SJCDPORT
+				(1));
+#if defined( SJCD_TRACE )
+			printk("SJCD_S_DATA: status = 0x%02x\n", stat);
+#endif
+			if (SJCD_STATUS_AVAILABLE(stat)) {
+				/*
+				 * No data is waiting for us in the drive buffer. Status of operation
+				 * completion is available. Read and parse it.
+				 */
+				sjcd_load_status();
+
+				if (!sjcd_status_valid
+				    || sjcd_command_failed) {
+#if defined( SJCD_TRACE )
+					printk
+					    ("SJCD: read block %d failed, maybe audio disk? Giving up\n",
+					     sjcd_next_bn);
+#endif
+					if (CURRENT_IS_VALID)
+						end_request(0);
+#if defined( SJCD_TRACE )
+					printk
+					    ("SJCD_S_DATA: pre-cmd failed: go to SJCD_S_STOP mode\n");
+#endif
+					sjcd_transfer_state = SJCD_S_STOP;
+					goto ReSwitch;
+				}
+
+				if (!sjcd_media_is_available) {
+					printk
+					    ("SJCD_S_DATA: no disk: go to SJCD_S_STOP mode\n");
+					sjcd_transfer_state = SJCD_S_STOP;
+					goto ReSwitch;
+				}
+
+				sjcd_transfer_state = SJCD_S_READ;
+				goto ReSwitch;
+			} else if (SJCD_DATA_AVAILABLE(stat)) {
+				/*
+				 * One frame is read into device buffer. We must copy it to our memory.
+				 * Otherwise cdrom hangs up. Check to see if we have something to copy
+				 * to.
+				 */
+				if (!CURRENT_IS_VALID
+				    && sjcd_buf_in == sjcd_buf_out) {
+#if defined( SJCD_TRACE )
+					printk
+					    ("SJCD_S_DATA: nothing to read: go to SJCD_S_STOP mode\n");
+					printk
+					    (" ... all the date would be discarded\n");
+#endif
+					sjcd_transfer_state = SJCD_S_STOP;
+					goto ReSwitch;
+				}
+
+				/*
+				 * Everything seems to be OK. Just read the frame and recalculate
+				 * indices.
+				 */
+				sjcd_buf_bn[sjcd_buf_in] = -1;	/* ??? */
+				insb(SJCDPORT(2),
+				     sjcd_buf + 2048 * sjcd_buf_in, 2048);
+#if defined( SJCD_TRACE )
+				printk
+				    ("SJCD_S_DATA: next_bn=%d, buf_in=%d, buf_out=%d, buf_bn=%d\n",
+				     sjcd_next_bn, sjcd_buf_in,
+				     sjcd_buf_out,
+				     sjcd_buf_bn[sjcd_buf_in]);
+#endif
+				sjcd_buf_bn[sjcd_buf_in] = sjcd_next_bn++;
+				if (sjcd_buf_out == -1)
+					sjcd_buf_out = sjcd_buf_in;
+				if (++sjcd_buf_in == SJCD_BUF_SIZ)
+					sjcd_buf_in = 0;
+
+				/*
+				 * Only one frame is ready at time. So we should turn over to wait for
+				 * another frame. If we need that, of course.
+				 */
+				if (--sjcd_read_count == 0) {
+					/*
+					 * OK, request seems to be precessed. Continue transferring...
+					 */
+					if (!sjcd_transfer_is_active) {
+						while (CURRENT_IS_VALID) {
+							/*
+							 * Continue transferring.
+							 */
+							sjcd_transfer();
+							if (CURRENT->
+							    nr_sectors ==
+							    0)
+								end_request
+								    (1);
+							else
+								break;
+						}
+					}
+					if (CURRENT_IS_VALID &&
+					    (CURRENT->sector / 4 <
+					     sjcd_next_bn
+					     || CURRENT->sector / 4 >
+					     sjcd_next_bn +
+					     SJCD_BUF_SIZ)) {
+#if defined( SJCD_TRACE )
+						printk
+						    ("SJCD_S_DATA: can't read: go to SJCD_S_STOP mode\n");
+#endif
+						sjcd_transfer_state =
+						    SJCD_S_STOP;
+						goto ReSwitch;
+					}
+				}
+				/*
+				 * Now we should turn around rather than wait for while.
+				 */
+				goto sjcd_s_data;
+			}
 #if defined( SJCD_GATHER_STAT )
-    else statistic.read_ticks++;
+			else
+				statistic.data_ticks++;
 #endif
-    break;
-  }
+			break;
+		}
 
-  case SJCD_S_DATA:{
-    unsigned char stat;
-
-  sjcd_s_data: stat = inb( SJCDPORT( 1 ) );
-#if defined( SJCD_TRACE )
-    printk( "SJCD_S_DATA: status = 0x%02x\n", stat );
+	case SJCD_S_STOP:{
+			sjcd_read_count = 0;
+			sjcd_send_cmd(SCMD_STOP);
+			sjcd_transfer_state = SJCD_S_STOPPING;
+			sjcd_transfer_timeout = 500;
+#if defined( SJCD_GATHER_STAT )
+			statistic.stop_ticks++;
 #endif
-    if( SJCD_STATUS_AVAILABLE( stat ) ){
-      /*
-       * No data is waiting for us in the drive buffer. Status of operation
-       * completion is available. Read and parse it.
-       */
-      sjcd_load_status();
+			break;
+		}
 
-      if( !sjcd_status_valid || sjcd_command_failed ){
-#if defined( SJCD_TRACE )
-	printk( "SJCD: read block %d failed, maybe audio disk? Giving up\n",
-	       sjcd_next_bn );
-#endif
-	if( CURRENT_IS_VALID ) end_request( 0 );
-#if defined( SJCD_TRACE )
-	printk( "SJCD_S_DATA: pre-cmd failed: go to SJCD_S_STOP mode\n" );
+	case SJCD_S_STOPPING:{
+			unsigned char stat;
+
+			stat = inb(SJCDPORT(1));
+#if defined( SJCD_TRACE )
+			printk("SJCD_S_STOP: status = 0x%02x\n", stat);
+#endif
+			if (SJCD_DATA_AVAILABLE(stat)) {
+				int i;
+#if defined( SJCD_TRACE )
+				printk("SJCD_S_STOP: discard data\n");
+#endif
+				/*
+				 * Discard all the data from the pipe. Foolish method.
+				 */
+				for (i = 2048; i--;
+				     (void) inb(SJCDPORT(2)));
+				sjcd_transfer_timeout = 500;
+			} else if (SJCD_STATUS_AVAILABLE(stat)) {
+				sjcd_load_status();
+				if (sjcd_status_valid
+				    && sjcd_media_is_changed) {
+					sjcd_toc_uptodate = 0;
+					sjcd_invalidate_buffers();
+				}
+				if (CURRENT_IS_VALID) {
+					if (sjcd_status_valid)
+						sjcd_transfer_state =
+						    SJCD_S_READ;
+					else
+						sjcd_transfer_state =
+						    SJCD_S_START;
+				} else
+					sjcd_transfer_state = SJCD_S_IDLE;
+				goto ReSwitch;
+			}
+#if defined( SJCD_GATHER_STAT )
+			else
+				statistic.stopping_ticks++;
 #endif
-	sjcd_transfer_state = SJCD_S_STOP;
-	goto ReSwitch;
-      }
+			break;
+		}
 
-      if( !sjcd_media_is_available ){
-	printk( "SJCD_S_DATA: no disk: go to SJCD_S_STOP mode\n" );
-	sjcd_transfer_state = SJCD_S_STOP;
-	goto ReSwitch;
-      }
+	default:
+		printk("SJCD: poll: invalid state %d\n",
+		       sjcd_transfer_state);
+		return;
+	}
 
-      sjcd_transfer_state = SJCD_S_READ;
-      goto ReSwitch;
-    } else if( SJCD_DATA_AVAILABLE( stat ) ){
-      /*
-       * One frame is read into device buffer. We must copy it to our memory.
-       * Otherwise cdrom hangs up. Check to see if we have something to copy
-       * to.
-       */
-      if( !CURRENT_IS_VALID && sjcd_buf_in == sjcd_buf_out ){
-#if defined( SJCD_TRACE )
-	printk( "SJCD_S_DATA: nothing to read: go to SJCD_S_STOP mode\n" );
-	printk( " ... all the date would be discarded\n" );
-#endif
-	sjcd_transfer_state = SJCD_S_STOP;
-	goto ReSwitch;
-      }
+	if (--sjcd_transfer_timeout == 0) {
+		printk("SJCD: timeout in state %d\n", sjcd_transfer_state);
+		while (CURRENT_IS_VALID)
+			end_request(0);
+		sjcd_send_cmd(SCMD_STOP);
+		sjcd_transfer_state = SJCD_S_IDLE;
+		goto ReSwitch;
+	}
 
-      /*
-       * Everything seems to be OK. Just read the frame and recalculate
-       * indices.
-       */
-      sjcd_buf_bn[ sjcd_buf_in ] = -1; /* ??? */
-      insb( SJCDPORT( 2 ), sjcd_buf + 2048 * sjcd_buf_in, 2048 );
-#if defined( SJCD_TRACE )
-      printk( "SJCD_S_DATA: next_bn=%d, buf_in=%d, buf_out=%d, buf_bn=%d\n",
-	     sjcd_next_bn, sjcd_buf_in, sjcd_buf_out,
-	     sjcd_buf_bn[ sjcd_buf_in ] );
-#endif
-      sjcd_buf_bn[ sjcd_buf_in ] = sjcd_next_bn++;
-      if( sjcd_buf_out == -1 ) sjcd_buf_out = sjcd_buf_in;
-      if( ++sjcd_buf_in == SJCD_BUF_SIZ ) sjcd_buf_in = 0;
-
-      /*
-       * Only one frame is ready at time. So we should turn over to wait for
-       * another frame. If we need that, of course.
-       */
-      if( --sjcd_read_count == 0 ){
 	/*
-	 * OK, request seems to be precessed. Continue transferring...
+	 * Get back in some time. 1 should be replaced with count variable to
+	 * avoid unnecessary testings.
 	 */
-	if( !sjcd_transfer_is_active ){
-	  while( CURRENT_IS_VALID ){
-	    /*
-	     * Continue transferring.
-	     */
-	    sjcd_transfer();
-	    if( CURRENT->nr_sectors == 0 ) end_request( 1 );
-	    else break;
-	  }
-	}
-	if( CURRENT_IS_VALID &&
-	   ( CURRENT->sector / 4 < sjcd_next_bn ||
-	    CURRENT->sector / 4 > sjcd_next_bn + SJCD_BUF_SIZ ) ){
-#if defined( SJCD_TRACE )
-	  printk( "SJCD_S_DATA: can't read: go to SJCD_S_STOP mode\n" );
-#endif
-	  sjcd_transfer_state = SJCD_S_STOP;
-	  goto ReSwitch;
-	}
-      }
-      /*
-       * Now we should turn around rather than wait for while.
-       */
-      goto sjcd_s_data;
-    }
-#if defined( SJCD_GATHER_STAT )
-    else statistic.data_ticks++;
-#endif
-    break;
-  }
-
-  case SJCD_S_STOP:{
-    sjcd_read_count = 0;
-    sjcd_send_cmd( SCMD_STOP );
-    sjcd_transfer_state = SJCD_S_STOPPING;
-    sjcd_transfer_timeout = 500;
-#if defined( SJCD_GATHER_STAT )
-    statistic.stop_ticks++;
-#endif
-    break;
-  }
+	SJCD_SET_TIMER(sjcd_poll, 1);
+}
 
-  case SJCD_S_STOPPING:{
-    unsigned char stat;
-    
-    stat = inb( SJCDPORT( 1 ) );
-#if defined( SJCD_TRACE )
-    printk( "SJCD_S_STOP: status = 0x%02x\n", stat );
-#endif      
-    if( SJCD_DATA_AVAILABLE( stat ) ){
-      int i;
-#if defined( SJCD_TRACE )
-      printk( "SJCD_S_STOP: discard data\n" );
-#endif
-      /*
-       * Discard all the data from the pipe. Foolish method.
-       */
-      for( i = 2048; i--; ( void )inb( SJCDPORT( 2 ) ) );
-      sjcd_transfer_timeout = 500;
-    } else if( SJCD_STATUS_AVAILABLE( stat ) ){
-      sjcd_load_status();
-      if( sjcd_status_valid && sjcd_media_is_changed ) {
-	sjcd_toc_uptodate = 0;
-	sjcd_invalidate_buffers();
-      }
-      if( CURRENT_IS_VALID ){
-	if( sjcd_status_valid ) sjcd_transfer_state = SJCD_S_READ;
-	else sjcd_transfer_state = SJCD_S_START;
-      } else sjcd_transfer_state = SJCD_S_IDLE;
-      goto ReSwitch;
-    }
-#if defined( SJCD_GATHER_STAT )
-    else statistic.stopping_ticks++;
+static void do_sjcd_request(request_queue_t * q)
+{
+#if defined( SJCD_TRACE )
+	printk("SJCD: do_sjcd_request(%ld+%ld)\n",
+	       CURRENT->sector, CURRENT->nr_sectors);
 #endif
-    break;
-  }
-
-  default:
-    printk( "SJCD: poll: invalid state %d\n", sjcd_transfer_state );
-    return;
-  }
-  
-  if( --sjcd_transfer_timeout == 0 ){
-    printk( "SJCD: timeout in state %d\n", sjcd_transfer_state );
-    while( CURRENT_IS_VALID ) end_request( 0 );
-    sjcd_send_cmd( SCMD_STOP );
-    sjcd_transfer_state = SJCD_S_IDLE;
-    goto ReSwitch;
-    }
-
-  /*
-   * Get back in some time. 1 should be replaced with count variable to
-   * avoid unnecessary testings.
-   */
-  SJCD_SET_TIMER( sjcd_poll, 1 );
-}
-
-static void do_sjcd_request( request_queue_t * q ){
-#if defined( SJCD_TRACE )
-  printk( "SJCD: do_sjcd_request(%ld+%ld)\n",
-	 CURRENT->sector, CURRENT->nr_sectors );
-#endif
-  sjcd_transfer_is_active = 1;
-  while( CURRENT_IS_VALID ){
-    /*
-     * Who of us are paranoiac?
-     */
-    if( CURRENT->bh && !buffer_locked(CURRENT->bh) )
-      panic( DEVICE_NAME ": block not locked" );
-
-    sjcd_transfer();
-    if( CURRENT->nr_sectors == 0 ) end_request( 1 );
-    else {
-      sjcd_buf_out = -1;         /* Want to read a block not in buffer */
-      if( sjcd_transfer_state == SJCD_S_IDLE ){
-	if( !sjcd_toc_uptodate ){
-	  if( sjcd_update_toc() < 0 ){
-	    printk( "SJCD: transfer: discard\n" );
-	    while( CURRENT_IS_VALID ) end_request( 0 );
-	    break;
-	  }
-	}
-	sjcd_transfer_state = SJCD_S_START;
-	SJCD_SET_TIMER( sjcd_poll, HZ/100 );
-      }
-      break;
-    }
-  }
-  sjcd_transfer_is_active = 0;
-#if defined( SJCD_TRACE )
-  printk( "sjcd_next_bn:%x sjcd_buf_in:%x sjcd_buf_out:%x sjcd_buf_bn:%x\n",
-	 sjcd_next_bn, sjcd_buf_in, sjcd_buf_out, sjcd_buf_bn[ sjcd_buf_in ] );
-  printk( "do_sjcd_request ends\n" );
+	sjcd_transfer_is_active = 1;
+	while (CURRENT_IS_VALID) {
+		/*
+		 * Who of us are paranoiac?
+		 */
+		if (CURRENT->bh && !buffer_locked(CURRENT->bh))
+			panic(DEVICE_NAME ": block not locked");
+
+		sjcd_transfer();
+		if (CURRENT->nr_sectors == 0)
+			end_request(1);
+		else {
+			sjcd_buf_out = -1;	/* Want to read a block not in buffer */
+			if (sjcd_transfer_state == SJCD_S_IDLE) {
+				if (!sjcd_toc_uptodate) {
+					if (sjcd_update_toc() < 0) {
+						printk
+						    ("SJCD: transfer: discard\n");
+						while (CURRENT_IS_VALID)
+							end_request(0);
+						break;
+					}
+				}
+				sjcd_transfer_state = SJCD_S_START;
+				SJCD_SET_TIMER(sjcd_poll, HZ / 100);
+			}
+			break;
+		}
+	}
+	sjcd_transfer_is_active = 0;
+#if defined( SJCD_TRACE )
+	printk
+	    ("sjcd_next_bn:%x sjcd_buf_in:%x sjcd_buf_out:%x sjcd_buf_bn:%x\n",
+	     sjcd_next_bn, sjcd_buf_in, sjcd_buf_out,
+	     sjcd_buf_bn[sjcd_buf_in]);
+	printk("do_sjcd_request ends\n");
 #endif
 }
 
 /*
  * Open the device special file. Check disk is in.
  */
-int sjcd_open( struct inode *ip, struct file *fp ){
-  /*
-   * Check the presence of device.
-   */
-  if( !sjcd_present ) return( -ENXIO );
-  
-  /*
-   * Only read operations are allowed. Really? (:-)
-   */
-  if( fp->f_mode & 2 ) return( -EROFS );
-  
-  MOD_INC_USE_COUNT;
+int sjcd_open(struct inode *ip, struct file *fp)
+{
+	/*
+	 * Check the presence of device.
+	 */
+	if (!sjcd_present)
+		return (-ENXIO);
 
-  if( sjcd_open_count == 0 ){
-    int s, sjcd_open_tries;
+	/*
+	 * Only read operations are allowed. Really? (:-)
+	 */
+	if (fp->f_mode & 2)
+		return (-EROFS);
+
+	MOD_INC_USE_COUNT;
+
+	if (sjcd_open_count == 0) {
+		int s, sjcd_open_tries;
 /* We don't know that, do we? */
 /*
     sjcd_audio_status = CDROM_AUDIO_NO_STATUS;
 */
-    sjcd_mode = 0;
-    sjcd_door_was_open = 0;
-    sjcd_transfer_state = SJCD_S_IDLE;
-    sjcd_invalidate_buffers();
-    sjcd_status_valid = 0;
-
-    /*
-     * Strict status checking.
-     */
-    for( sjcd_open_tries = 4; --sjcd_open_tries; ){
-      if( !sjcd_status_valid ) sjcd_get_status();
-      if( !sjcd_status_valid ){
+		sjcd_mode = 0;
+		sjcd_door_was_open = 0;
+		sjcd_transfer_state = SJCD_S_IDLE;
+		sjcd_invalidate_buffers();
+		sjcd_status_valid = 0;
+
+		/*
+		 * Strict status checking.
+		 */
+		for (sjcd_open_tries = 4; --sjcd_open_tries;) {
+			if (!sjcd_status_valid)
+				sjcd_get_status();
+			if (!sjcd_status_valid) {
 #if defined( SJCD_DIAGNOSTIC )
-	printk( "SJCD: open: timed out when check status.\n" );
+				printk
+				    ("SJCD: open: timed out when check status.\n");
 #endif
-	goto err_out;
-      } else if( !sjcd_media_is_available ){
+				goto err_out;
+			} else if (!sjcd_media_is_available) {
 #if defined( SJCD_DIAGNOSTIC )
-	printk("SJCD: open: no disk in drive\n");
+				printk("SJCD: open: no disk in drive\n");
 #endif
-	if( !sjcd_door_closed ){
-	  sjcd_door_was_open = 1;
+				if (!sjcd_door_closed) {
+					sjcd_door_was_open = 1;
 #if defined( SJCD_TRACE )
-	  printk("SJCD: open: close the tray\n");
+					printk
+					    ("SJCD: open: close the tray\n");
 #endif
-	  s = sjcd_tray_close();
-	  if( s < 0 || !sjcd_status_valid || sjcd_command_failed ){
+					s = sjcd_tray_close();
+					if (s < 0 || !sjcd_status_valid
+					    || sjcd_command_failed) {
 #if defined( SJCD_DIAGNOSTIC )
-	    printk("SJCD: open: tray close attempt failed\n");
+						printk
+						    ("SJCD: open: tray close attempt failed\n");
 #endif
-	    goto err_out;
-	  }
-	  continue;
-	} else goto err_out;
-      }
-      break;
-    }
-    s = sjcd_tray_lock();
-    if( s < 0 || !sjcd_status_valid || sjcd_command_failed ){
+						goto err_out;
+					}
+					continue;
+				} else
+					goto err_out;
+			}
+			break;
+		}
+		s = sjcd_tray_lock();
+		if (s < 0 || !sjcd_status_valid || sjcd_command_failed) {
 #if defined( SJCD_DIAGNOSTIC )
-      printk("SJCD: open: tray lock attempt failed\n");
+			printk("SJCD: open: tray lock attempt failed\n");
 #endif
-      goto err_out;
-    }
+			goto err_out;
+		}
 #if defined( SJCD_TRACE )
-    printk( "SJCD: open: done\n" );
+		printk("SJCD: open: done\n");
 #endif
-  }
+	}
 
-  ++sjcd_open_count;
-  return( 0 );
+	++sjcd_open_count;
+	return (0);
 
-err_out:
-  MOD_DEC_USE_COUNT;
-  return( -EIO );
+      err_out:
+	MOD_DEC_USE_COUNT;
+	return (-EIO);
 }
 
 /*
  * On close, we flush all sjcd blocks from the buffer cache.
  */
-static int sjcd_release( struct inode *inode, struct file *file ){
-  int s;
+static int sjcd_release(struct inode *inode, struct file *file)
+{
+	int s;
 
 #if defined( SJCD_TRACE )
-  printk( "SJCD: release\n" );
+	printk("SJCD: release\n");
 #endif
 #ifdef MODULE
-  MOD_DEC_USE_COUNT;
+	MOD_DEC_USE_COUNT;
 #endif
-  if( --sjcd_open_count == 0 ){
-    sjcd_invalidate_buffers();
-    s = sjcd_tray_unlock();
-    if( s < 0 || !sjcd_status_valid || sjcd_command_failed ){
+	if (--sjcd_open_count == 0) {
+		sjcd_invalidate_buffers();
+		s = sjcd_tray_unlock();
+		if (s < 0 || !sjcd_status_valid || sjcd_command_failed) {
 #if defined( SJCD_DIAGNOSTIC )
-      printk("SJCD: release: tray unlock attempt failed.\n");
+			printk
+			    ("SJCD: release: tray unlock attempt failed.\n");
 #endif
-    }
-    if( sjcd_door_was_open ){
-      s = sjcd_tray_open();
-      if( s < 0 || !sjcd_status_valid || sjcd_command_failed ){
+		}
+		if (sjcd_door_was_open) {
+			s = sjcd_tray_open();
+			if (s < 0 || !sjcd_status_valid
+			    || sjcd_command_failed) {
 #if defined( SJCD_DIAGNOSTIC )
-	printk("SJCD: release: tray unload attempt failed.\n");
+				printk
+				    ("SJCD: release: tray unload attempt failed.\n");
 #endif
-      }
-    }
-  }
-  return 0;
+			}
+		}
+	}
+	return 0;
 }
 
 /*
  * A list of file operations allowed for this cdrom.
  */
 static struct block_device_operations sjcd_fops = {
-	open:			sjcd_open,
-	release:		sjcd_release,
-	ioctl:			sjcd_ioctl,
-	check_media_change:	sjcd_disk_change,
+	open:sjcd_open,
+	release:sjcd_release,
+	ioctl:sjcd_ioctl,
+	check_media_change:sjcd_disk_change,
 };
 
 static int blksize = 2048;
@@ -1453,146 +1678,156 @@
  * The version is two BCD-coded bytes.
  */
 static struct {
-  unsigned char major, minor;
+	unsigned char major, minor;
 } sjcd_version;
 
 /*
  * Test for presence of drive and initialize it. Called at boot time.
  * Probe cdrom, find out version and status.
  */
-int __init sjcd_init( void ){
-  int i;
+int __init sjcd_init(void)
+{
+	int i;
 
-  printk(KERN_INFO "SJCD: Sanyo CDR-H94A cdrom driver version %d.%d.\n", SJCD_VERSION_MAJOR,
-    SJCD_VERSION_MINOR);
+	printk(KERN_INFO
+	       "SJCD: Sanyo CDR-H94A cdrom driver version %d.%d.\n",
+	       SJCD_VERSION_MAJOR, SJCD_VERSION_MINOR);
 
 #if defined( SJCD_TRACE )
-  printk("SJCD: sjcd=0x%x: ", sjcd_base);
-#endif  
+	printk("SJCD: sjcd=0x%x: ", sjcd_base);
+#endif
 
 	hardsect_size[MAJOR_NR] = &secsize;
 	blksize_size[MAJOR_NR] = &blksize;
 
-  if( devfs_register_blkdev( MAJOR_NR, "sjcd", &sjcd_fops ) != 0 ){
-    printk( "SJCD: Unable to get major %d for Sanyo CD-ROM\n", MAJOR_NR );
-    return( -EIO );
-  }
-  
-  blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST);
-  read_ahead[ MAJOR_NR ] = 4;
-  register_disk(NULL, MKDEV(MAJOR_NR,0), 1, &sjcd_fops, 0);
-  
-  if( check_region( sjcd_base, 4 ) ){
-    printk( "SJCD: Init failed, I/O port (%X) is already in use\n",
-      sjcd_base );
-    sjcd_cleanup();
-    return( -EIO );
-  }
-  
-  /*
-   * Check for card. Since we are booting now, we can't use standard
-   * wait algorithm.
-   */
-  printk(KERN_INFO "SJCD: Resetting: " );
-  sjcd_send_cmd( SCMD_RESET );
-  for( i = 1000; i > 0 && !sjcd_status_valid; --i ){
-    unsigned long timer;
-
-    /*
-     * Wait 10ms approx.
-     */
-    for( timer = jiffies; time_before_eq(jiffies, timer); );
-    if ( (i % 100) == 0 ) printk( "." );
-    ( void )sjcd_check_status();
-  }
-  if( i == 0 || sjcd_command_failed ){
-    printk( " reset failed, no drive found.\n" );
-    sjcd_cleanup();
-    return( -EIO );
-  } else printk( "\n" );
-
-  /*
-   * Get and print out cdrom version.
-   */
-  printk(KERN_INFO "SJCD: Getting version: " );
-  sjcd_send_cmd( SCMD_GET_VERSION );
-  for( i = 1000; i > 0 && !sjcd_status_valid; --i ){
-    unsigned long timer;
-
-    /*
-     * Wait 10ms approx.
-     */
-    for( timer = jiffies; time_before_eq(jiffies, timer); );
-    if ( (i % 100) == 0 ) printk( "." );
-    ( void )sjcd_check_status();
-  }
-  if( i == 0 || sjcd_command_failed ){
-    printk( " get version failed, no drive found.\n" );
-    sjcd_cleanup();
-    return( -EIO );
-  }
-
-  if( sjcd_load_response( &sjcd_version, sizeof( sjcd_version ) ) == 0 ){
-    printk( " %1x.%02x\n", ( int )sjcd_version.major,
-	     ( int )sjcd_version.minor );
-  } else {
-    printk( " read version failed, no drive found.\n" );
-    sjcd_cleanup();
-    return( -EIO );
-  }
-
-  /*
-   * Check and print out the tray state. (if it is needed?).
-   */
-  if( !sjcd_status_valid ){
-    printk(KERN_INFO "SJCD: Getting status: " );
-    sjcd_send_cmd( SCMD_GET_STATUS );
-    for( i = 1000; i > 0 && !sjcd_status_valid; --i ){
-      unsigned long timer;
-
-      /*
-       * Wait 10ms approx.
-       */
-      for( timer = jiffies; time_before_eq(jiffies, timer); );
-      if ( (i % 100) == 0 ) printk( "." );
-      ( void )sjcd_check_status();
-    }
-    if( i == 0 || sjcd_command_failed ){
-      printk( " get status failed, no drive found.\n" );
-      sjcd_cleanup();
-      return( -EIO );
-    } else printk( "\n" );
-  }
-
-  printk(KERN_INFO "SJCD: Status: port=0x%x.\n", sjcd_base);
-  devfs_register (NULL, "sjcd", DEVFS_FL_DEFAULT, MAJOR_NR, 0,
-		  S_IFBLK | S_IRUGO | S_IWUGO, &sjcd_fops, NULL);
-
-  sjcd_present++;
-  return( 0 );
-}
-
-static int
-sjcd_cleanup(void)
-{
-  if( (devfs_unregister_blkdev(MAJOR_NR, "sjcd") == -EINVAL) )
-    printk( "SJCD: cannot unregister device.\n" );
-  else {
-    release_region( sjcd_base, 4 );
-    blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
-  }
+	if (devfs_register_blkdev(MAJOR_NR, "sjcd", &sjcd_fops) != 0) {
+		printk("SJCD: Unable to get major %d for Sanyo CD-ROM\n",
+		       MAJOR_NR);
+		return (-EIO);
+	}
+
+	blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST);
+	read_ahead[MAJOR_NR] = 4;
+	register_disk(NULL, MKDEV(MAJOR_NR, 0), 1, &sjcd_fops, 0);
+
+	if (check_region(sjcd_base, 4)) {
+		printk
+		    ("SJCD: Init failed, I/O port (%X) is already in use\n",
+		     sjcd_base);
+		sjcd_cleanup();
+		return (-EIO);
+	}
+
+	/*
+	 * Check for card. Since we are booting now, we can't use standard
+	 * wait algorithm.
+	 */
+	printk(KERN_INFO "SJCD: Resetting: ");
+	sjcd_send_cmd(SCMD_RESET);
+	for (i = 1000; i > 0 && !sjcd_status_valid; --i) {
+		unsigned long timer;
+
+		/*
+		 * Wait 10ms approx.
+		 */
+		for (timer = jiffies; time_before_eq(jiffies, timer););
+		if ((i % 100) == 0)
+			printk(".");
+		(void) sjcd_check_status();
+	}
+	if (i == 0 || sjcd_command_failed) {
+		printk(" reset failed, no drive found.\n");
+		sjcd_cleanup();
+		return (-EIO);
+	} else
+		printk("\n");
+
+	/*
+	 * Get and print out cdrom version.
+	 */
+	printk(KERN_INFO "SJCD: Getting version: ");
+	sjcd_send_cmd(SCMD_GET_VERSION);
+	for (i = 1000; i > 0 && !sjcd_status_valid; --i) {
+		unsigned long timer;
+
+		/*
+		 * Wait 10ms approx.
+		 */
+		for (timer = jiffies; time_before_eq(jiffies, timer););
+		if ((i % 100) == 0)
+			printk(".");
+		(void) sjcd_check_status();
+	}
+	if (i == 0 || sjcd_command_failed) {
+		printk(" get version failed, no drive found.\n");
+		sjcd_cleanup();
+		return (-EIO);
+	}
+
+	if (sjcd_load_response(&sjcd_version, sizeof(sjcd_version)) == 0) {
+		printk(" %1x.%02x\n", (int) sjcd_version.major,
+		       (int) sjcd_version.minor);
+	} else {
+		printk(" read version failed, no drive found.\n");
+		sjcd_cleanup();
+		return (-EIO);
+	}
+
+	/*
+	 * Check and print out the tray state. (if it is needed?).
+	 */
+	if (!sjcd_status_valid) {
+		printk(KERN_INFO "SJCD: Getting status: ");
+		sjcd_send_cmd(SCMD_GET_STATUS);
+		for (i = 1000; i > 0 && !sjcd_status_valid; --i) {
+			unsigned long timer;
+
+			/*
+			 * Wait 10ms approx.
+			 */
+			for (timer = jiffies;
+			     time_before_eq(jiffies, timer););
+			if ((i % 100) == 0)
+				printk(".");
+			(void) sjcd_check_status();
+		}
+		if (i == 0 || sjcd_command_failed) {
+			printk(" get status failed, no drive found.\n");
+			sjcd_cleanup();
+			return (-EIO);
+		} else
+			printk("\n");
+	}
+
+	printk(KERN_INFO "SJCD: Status: port=0x%x.\n", sjcd_base);
+	devfs_register(NULL, "sjcd", DEVFS_FL_DEFAULT, MAJOR_NR, 0,
+		       S_IFBLK | S_IRUGO | S_IWUGO, &sjcd_fops, NULL);
+
+	sjcd_present++;
+	return (0);
+}
+
+static int sjcd_cleanup(void)
+{
+	if ((devfs_unregister_blkdev(MAJOR_NR, "sjcd") == -EINVAL))
+		printk("SJCD: cannot unregister device.\n");
+	else {
+		release_region(sjcd_base, 4);
+		blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
+	}
 
-  return(0);
+	return (0);
 }
 
 
 void __exit sjcd_exit(void)
 {
-  devfs_unregister(devfs_find_handle(NULL, "sjcd", 0, 0, DEVFS_SPECIAL_BLK,0));
-  if ( sjcd_cleanup() )
-    printk( "SJCD: module: cannot be removed.\n" );
-  else
-    printk(KERN_INFO "SJCD: module: removed.\n");
+	devfs_unregister(devfs_find_handle
+			 (NULL, "sjcd", 0, 0, DEVFS_SPECIAL_BLK, 0));
+	if (sjcd_cleanup())
+		printk("SJCD: module: cannot be removed.\n");
+	else
+		printk(KERN_INFO "SJCD: module: removed.\n");
 }
 
 #ifdef MODULE
@@ -1601,3 +1836,4 @@
 module_exit(sjcd_exit);
 
 
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/cdrom/sonycd535.c linux/drivers/cdrom/sonycd535.c
--- v2.4.9/linux/drivers/cdrom/sonycd535.c	Fri Feb  9 11:30:22 2001
+++ linux/drivers/cdrom/sonycd535.c	Sun Sep  9 10:43:02 2001
@@ -1709,3 +1709,4 @@
 module_exit(sony535_exit);
 
 
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/Config.in linux/drivers/char/Config.in
--- v2.4.9/linux/drivers/char/Config.in	Mon Aug 27 12:41:40 2001
+++ linux/drivers/char/Config.in	Sun Sep  9 10:43:02 2001
@@ -59,6 +59,24 @@
      tristate '    Stallion EasyIO or EC8/32 support' CONFIG_STALLION
      tristate '    Stallion EC8/64, ONboard, Brumby support' CONFIG_ISTALLION
    fi
+   if [ "$CONFIG_MIPS" = "y" ]; then
+     bool '  TMPTX3912/PR31700 serial port support' CONFIG_SERIAL_TX3912
+     dep_bool '     Console on TMPTX3912/PR31700 serial port' CONFIG_SERIAL_TX3912_CONSOLE $CONFIG_SERIAL_TX3912
+     bool '  Enable Au1000 UART Support' CONFIG_AU1000_UART
+     if [ "$CONFIG_AU1000_UART" = "y" ]; then
+         bool '        Enable Au1000 serial console' CONFIG_AU1000_SERIAL_CONSOLE
+     fi
+   fi
+fi
+if [ "$CONFIG_IT8712" = "y" ]; then
+   bool 'Enable Qtronix 990P Keyboard Support' CONFIG_QTRONIX_KEYBOARD
+   if [ "$CONFIG_QTRONIX_KEYBOARD" = "y" ]; then
+     define_bool CONFIG_IT8172_CIR y
+   else
+     bool '    Enable PS2 Keyboard Support' CONFIG_PC_KEYB
+   fi
+   bool 'Enable Smart Card Reader 0 Support ' CONFIG_IT8172_SCR0
+   bool 'Enable Smart Card Reader 1 Support ' CONFIG_IT8172_SCR1
 fi
 if [ "$CONFIG_EXPERIMENTAL" = "y" -a "$CONFIG_ZORRO" = "y" ]; then
    tristate 'Commodore A2232 serial support (EXPERIMENTAL)' CONFIG_A2232
diff -u --recursive --new-file v2.4.9/linux/drivers/char/Makefile linux/drivers/char/Makefile
--- v2.4.9/linux/drivers/char/Makefile	Wed Jul 25 17:10:19 2001
+++ linux/drivers/char/Makefile	Sun Sep  9 10:43:02 2001
@@ -41,18 +41,10 @@
   SERIAL   =
 endif
 
-ifeq ($(ARCH),s390x)
-  KEYMAP   =
-  KEYBD    =
-  CONSOLE  =
-  SERIAL   =
-endif
-
-ifeq ($(ARCH),s390)
-  KEYMAP   =
-  KEYBD    =
-  CONSOLE  =
-  SERIAL   =
+ifeq ($(ARCH),mips)
+  ifneq ($(CONFIG_PC_KEYB),y)
+    KEYBD    =
+  endif
 endif
 
 ifeq ($(ARCH),s390x)
@@ -109,8 +101,9 @@
 endif
 
 ifeq ($(CONFIG_DECSTATION),y)
+  KEYMAP   =
   KEYBD    =
-  SERIAL   =
+  SERIAL   = decserial.o
 endif
 
 ifeq ($(CONFIG_BAGET_MIPS),y)
@@ -118,10 +111,18 @@
   SERIAL   =
 endif
 
+ifeq ($(CONFIG_NINO),y)
+  SERIAL   =
+endif
+
 ifneq ($(CONFIG_SUN_SERIAL),)
   SERIAL   =
 endif
 
+ifeq ($(CONFIG_QTRONIX_KEYBOARD),y)
+  KEYBD    = qtronix.o
+  KEYMAP   = qtronixmap.o
+endif
 
 obj-$(CONFIG_VT) += vt.o vc_screen.o consolemap.o consolemap_deftbl.o $(CONSOLE) selection.o
 obj-$(CONFIG_SERIAL) += $(SERIAL)
@@ -161,6 +162,7 @@
 obj-$(CONFIG_MVME147_SCC) += generic_serial.o vme_scc.o
 obj-$(CONFIG_MVME162_SCC) += generic_serial.o vme_scc.o
 obj-$(CONFIG_BVME6000_SCC) += generic_serial.o vme_scc.o
+obj-$(CONFIG_SERIAL_TX3912) += generic_serial.o serial_tx3912.o
 
 subdir-$(CONFIG_RIO) += rio
 subdir-$(CONFIG_INPUT) += joystick
@@ -241,5 +243,10 @@
 
 consolemap_deftbl.o: consolemap_deftbl.c $(TOPDIR)/include/linux/types.h
 
+.DELETE_ON_ERROR:
+
 defkeymap.c: defkeymap.map
-	loadkeys --mktable defkeymap.map > defkeymap.c
+	set -e ; loadkeys --mktable $< | sed -e 's/^static *//' > $@
+
+qtronixmap.c: qtronixmap.map
+	set -e ; loadkeys --mktable $< | sed -e 's/^static *//' > $@
diff -u --recursive --new-file v2.4.9/linux/drivers/char/acquirewdt.c linux/drivers/char/acquirewdt.c
--- v2.4.9/linux/drivers/char/acquirewdt.c	Sat May 19 17:43:05 2001
+++ linux/drivers/char/acquirewdt.c	Thu Sep 13 15:21:32 2001
@@ -226,3 +226,6 @@
 
 module_init(acq_init);
 module_exit(acq_exit);
+
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/adbmouse.c linux/drivers/char/adbmouse.c
--- v2.4.9/linux/drivers/char/adbmouse.c	Sun Dec  3 17:48:19 2000
+++ linux/drivers/char/adbmouse.c	Thu Sep 13 15:21:32 2001
@@ -205,3 +205,5 @@
 
 module_init(adb_mouse_init);
 module_exit(adb_mouse_cleanup);
+
+MODULE_LICENSE("GPL"):
diff -u --recursive --new-file v2.4.9/linux/drivers/char/advantechwdt.c linux/drivers/char/advantechwdt.c
--- v2.4.9/linux/drivers/char/advantechwdt.c	Sat May 19 17:43:05 2001
+++ linux/drivers/char/advantechwdt.c	Thu Sep 13 15:21:32 2001
@@ -238,4 +238,7 @@
 module_init(advwdt_init);
 module_exit(advwdt_exit);
 
+MODULE_LICENSE("GPL");
+
 /* end of advantechwdt.c */
+
diff -u --recursive --new-file v2.4.9/linux/drivers/char/agp/agp.h linux/drivers/char/agp/agp.h
--- v2.4.9/linux/drivers/char/agp/agp.h	Mon Aug 27 12:41:40 2001
+++ linux/drivers/char/agp/agp.h	Mon Aug 27 07:40:33 2001
@@ -101,6 +101,7 @@
 	int num_aperture_sizes;
 	int num_of_masks;
 	int capndx;
+	int cant_use_aperture;
 
 	/* Links to driver specific functions */
 
diff -u --recursive --new-file v2.4.9/linux/drivers/char/agp/agpgart_be.c linux/drivers/char/agp/agpgart_be.c
--- v2.4.9/linux/drivers/char/agp/agpgart_be.c	Mon Aug 27 12:41:40 2001
+++ linux/drivers/char/agp/agpgart_be.c	Mon Sep 10 08:08:11 2001
@@ -305,6 +305,9 @@
 
 void agp_copy_info(agp_kern_info * info)
 {
+	unsigned long page_mask = 0;
+	int i;
+
 	memset(info, 0, sizeof(agp_kern_info));
 	if (agp_bridge.type == NOT_SUPPORTED) {
 		info->chipset = agp_bridge.type;
@@ -319,6 +322,12 @@
 	info->aper_size = agp_return_size();
 	info->max_memory = agp_bridge.max_memory_agp;
 	info->current_memory = atomic_read(&agp_bridge.current_memory_agp);
+	info->cant_use_aperture = agp_bridge.cant_use_aperture;
+
+	for(i = 0; i < agp_bridge.num_of_masks; i++)
+		page_mask |= agp_bridge.mask_memory(page_mask, i);
+
+	info->page_mask = ~page_mask;
 }
 
 /* End - Routine to copy over information structure */
@@ -428,8 +437,8 @@
 			/* adjust RQ depth */
 			command =
 			    ((command & ~0xff000000) |
-			     min(u32, (mode & 0xff000000),
-				 min(u32, (command & 0xff000000),
+			     min_t(u32, (mode & 0xff000000),
+				 min_t(u32, (command & 0xff000000),
 				     (scratch & 0xff000000))));
 
 			/* disable SBA if it's not supported */
@@ -1083,6 +1092,7 @@
 	agp_bridge.free_by_type = intel_i810_free_by_type;
 	agp_bridge.agp_alloc_page = agp_generic_alloc_page;
 	agp_bridge.agp_destroy_page = agp_generic_destroy_page;
+	agp_bridge.cant_use_aperture = 0;
 
 	return 0;
 }
@@ -1275,6 +1285,7 @@
 	agp_bridge.free_by_type = agp_generic_free_by_type;
 	agp_bridge.agp_alloc_page = agp_generic_alloc_page;
 	agp_bridge.agp_destroy_page = agp_generic_destroy_page;
+	agp_bridge.cant_use_aperture = 0;
 
 	return 0;
 	
@@ -1305,6 +1316,7 @@
 	agp_bridge.free_by_type = agp_generic_free_by_type;
 	agp_bridge.agp_alloc_page = agp_generic_alloc_page;
 	agp_bridge.agp_destroy_page = agp_generic_destroy_page;
+	agp_bridge.cant_use_aperture = 0;
 
 	return 0;
 	
@@ -1335,6 +1347,7 @@
 	agp_bridge.free_by_type = agp_generic_free_by_type;
 	agp_bridge.agp_alloc_page = agp_generic_alloc_page;
 	agp_bridge.agp_destroy_page = agp_generic_destroy_page;
+	agp_bridge.cant_use_aperture = 0;
 
 	return 0;
 	
@@ -1452,6 +1465,7 @@
 	agp_bridge.free_by_type = agp_generic_free_by_type;
 	agp_bridge.agp_alloc_page = agp_generic_alloc_page;
 	agp_bridge.agp_destroy_page = agp_generic_destroy_page;
+	agp_bridge.cant_use_aperture = 0;
 
 	return 0;
 	
@@ -1563,6 +1577,7 @@
 	agp_bridge.free_by_type = agp_generic_free_by_type;
 	agp_bridge.agp_alloc_page = agp_generic_alloc_page;
 	agp_bridge.agp_destroy_page = agp_generic_destroy_page;
+	agp_bridge.cant_use_aperture = 0;
 
 	return 0;
 }
@@ -1938,6 +1953,7 @@
 	agp_bridge.free_by_type = agp_generic_free_by_type;
 	agp_bridge.agp_alloc_page = agp_generic_alloc_page;
 	agp_bridge.agp_destroy_page = agp_generic_destroy_page;
+	agp_bridge.cant_use_aperture = 0;
 
 	return 0;
 	
@@ -2181,6 +2197,7 @@
 	agp_bridge.free_by_type = agp_generic_free_by_type;
 	agp_bridge.agp_alloc_page = ali_alloc_page;
 	agp_bridge.agp_destroy_page = ali_destroy_page;
+	agp_bridge.cant_use_aperture = 0;
 
 	return 0;
 	
@@ -2657,8 +2674,8 @@
 			/* adjust RQ depth */
 			command =
 			    ((command & ~0xff000000) |
-			     min(u32, (mode & 0xff000000),
-				 min(u32, (command & 0xff000000),
+			     min_t(u32, (mode & 0xff000000),
+				 min_t(u32, (command & 0xff000000),
 				     (scratch & 0xff000000))));
 
 			/* disable SBA if it's not supported */
@@ -2766,6 +2783,7 @@
 	agp_bridge.free_by_type = agp_generic_free_by_type;
 	agp_bridge.agp_alloc_page = agp_generic_alloc_page;
 	agp_bridge.agp_destroy_page = agp_generic_destroy_page;
+	agp_bridge.cant_use_aperture = 0;
 
 	pci_read_config_dword(agp_bridge.dev,
 			      SVWRKS_APSIZE,
diff -u --recursive --new-file v2.4.9/linux/drivers/char/amigamouse.c linux/drivers/char/amigamouse.c
--- v2.4.9/linux/drivers/char/amigamouse.c	Mon Nov 27 17:11:26 2000
+++ linux/drivers/char/amigamouse.c	Thu Sep 13 15:21:32 2001
@@ -209,3 +209,5 @@
 
 module_init(amiga_mouse_init);
 module_exit(amiga_mouse_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/amiserial.c linux/drivers/char/amiserial.c
--- v2.4.9/linux/drivers/char/amiserial.c	Fri Feb 16 16:02:35 2001
+++ linux/drivers/char/amiserial.c	Thu Sep 13 15:21:32 2001
@@ -2353,3 +2353,5 @@
 	register_console(&sercons);
 }
 #endif
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/applicom.c linux/drivers/char/applicom.c
--- v2.4.9/linux/drivers/char/applicom.c	Fri Feb  9 11:30:22 2001
+++ linux/drivers/char/applicom.c	Thu Sep 13 15:21:32 2001
@@ -1,6 +1,6 @@
 /* Derived from Applicom driver ac.c for SCO Unix                            */
 /* Ported by David Woodhouse, Axiom (Cambridge) Ltd.                         */
-/* Dave@mvhi.com  30/8/98                                                    */
+/* dwmw2@redhat.com  30/8/98                                                 */
 /* $Id: ac.c,v 1.30 2000/03/22 16:03:57 dwmw2 Exp $			     */
 /* This module is for Linux 2.1 and 2.2 series kernels.                      */
 /*****************************************************************************/
@@ -74,6 +74,7 @@
 
 MODULE_AUTHOR("David Woodhouse & Applicom International");
 MODULE_DESCRIPTION("Driver for Applicom Profibus card");
+MODULE_LICENSE("GPL");
 MODULE_PARM(irq, "i");
 MODULE_PARM_DESC(irq, "IRQ of the Applicom board");
 MODULE_PARM(mem, "i");
@@ -82,7 +83,7 @@
 MODULE_SUPPORTED_DEVICE("ac");
 
 
-struct applicom_board {
+static struct applicom_board {
 	unsigned long PhysIO;
 	unsigned long RamIO;
 	wait_queue_head_t FlagSleepSend;
@@ -100,22 +101,21 @@
 static unsigned int ReadErrorCount;	/* number of read error       */
 static unsigned int DeviceErrorCount;	/* number of device error     */
 
-static loff_t ac_llseek(struct file *, loff_t, int);
 static ssize_t ac_read (struct file *, char *, size_t, loff_t *);
 static ssize_t ac_write (struct file *, const char *, size_t, loff_t *);
 static int ac_ioctl(struct inode *, struct file *, unsigned int,
 		    unsigned long);
 static void ac_interrupt(int, void *, struct pt_regs *);
 
-struct file_operations ac_fops = {
+static struct file_operations ac_fops = {
 	owner:THIS_MODULE,
-	llseek:ac_llseek,
+	llseek:no_llseek,
 	read:ac_read,
 	write:ac_write,
 	ioctl:ac_ioctl,
 };
 
-struct miscdevice ac_miscdev = {
+static struct miscdevice ac_miscdev = {
 	AC_MINOR,
 	"ac",
 	&ac_fops
@@ -123,7 +123,7 @@
 
 static int dummy;	/* dev_id for request_irq() */
 
-int ac_register_board(unsigned long physloc, unsigned long loc, 
+static int ac_register_board(unsigned long physloc, unsigned long loc, 
 		      unsigned char boardno)
 {
 	volatile unsigned char byte_reset_it;
@@ -254,6 +254,7 @@
 
 	/* Now try the specified ISA cards */
 
+#warning "LEAK"
 	RamIO = ioremap(mem, LEN_RAM_IO * MAX_ISA_BOARD);
 
 	if (!RamIO) 
@@ -340,11 +341,6 @@
 __initcall(applicom_init);
 #endif
 
-static loff_t ac_llseek(struct file *file, loff_t offset, int origin)
-{
-	return -ESPIPE;
-}
-
 static ssize_t ac_write(struct file *file, const char *buf, size_t count, loff_t * ppos)
 {
 	unsigned int NumCard;	/* Board number 1 -> 8           */
@@ -421,7 +417,7 @@
 	}
 	
 	/* Place ourselves on the wait queue */
-	current->state = TASK_INTERRUPTIBLE;
+	set_current_state(TASK_INTERRUPTIBLE);
 	add_wait_queue(&apbs[IndexCard].FlagSleepSend, &wait);
 
 	/* Check whether the card is ready for us */
@@ -435,8 +431,9 @@
 			remove_wait_queue(&apbs[IndexCard].FlagSleepSend,
 					  &wait);
 			return -EINTR;
-	}
+		}
 		spin_lock_irqsave(&apbs[IndexCard].mutex, flags);
+		set_current_state(TASK_INTERRUPTIBLE);
 	}
 
 	/* We may not have actually slept */
@@ -521,7 +518,7 @@
 		printk("\n");
 #endif
 
-	/* Je suis stupide. DW. */
+#warning "Je suis stupide. DW. - copy*user in cli"
 
 	if (copy_to_user(buf, &st_loc, sizeof(struct st_ram_io)))
 		return -EFAULT;
@@ -550,7 +547,7 @@
 	
 	while(1) {
 		/* Stick ourself on the wait queue */
-		current->state = TASK_INTERRUPTIBLE;
+		set_current_state(TASK_INTERRUPTIBLE);
 		add_wait_queue(&FlagSleepRec, &wait);
 		
 		/* Scan each board, looking for one which has a packet for us */
@@ -565,7 +562,7 @@
 				/* Got a packet for us */
 				ret = do_ac_read(i, buf);
 				spin_unlock_irqrestore(&apbs[i].mutex, flags);
-				current->state = TASK_RUNNING;
+				set_current_state(TASK_RUNNING);
 				remove_wait_queue(&FlagSleepRec, &wait);
 				return tmp;
 			}
@@ -575,7 +572,7 @@
 				Dummy = readb(apbs[i].RamIO + VERS);
 				
 				spin_unlock_irqrestore(&apbs[i].mutex, flags);
-				current->state = TASK_RUNNING;
+				set_current_state(TASK_RUNNING);
 				remove_wait_queue(&FlagSleepRec, &wait);
 				
 				printk(KERN_WARNING "APPLICOM driver read error board %d, DataToPcReady = %d\n",
diff -u --recursive --new-file v2.4.9/linux/drivers/char/busmouse.c linux/drivers/char/busmouse.c
--- v2.4.9/linux/drivers/char/busmouse.c	Fri Feb  9 11:30:22 2001
+++ linux/drivers/char/busmouse.c	Fri Sep  7 09:28:38 2001
@@ -29,7 +29,7 @@
 
 /* Uncomment this if your mouse drivers expect the kernel to
  * return with EAGAIN if the mouse does not have any events
- * available, even if the mouse is opened in nonblocking mode.
+ * available, even if the mouse is opened in blocking mode.
  * Please report use of this "feature" to the author using the
  * above address.
  */
@@ -444,3 +444,5 @@
 EXPORT_SYMBOL(busmouse_add_buttons);
 EXPORT_SYMBOL(register_busmouse);
 EXPORT_SYMBOL(unregister_busmouse);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/cyclades.c linux/drivers/char/cyclades.c
--- v2.4.9/linux/drivers/char/cyclades.c	Mon Aug 27 12:41:40 2001
+++ linux/drivers/char/cyclades.c	Mon Sep 10 08:06:32 2001
@@ -1629,8 +1629,8 @@
 	       for performance, but because of buffer boundaries, there
 	       may be several steps to the operation */
 	    while(0 < (small_count = 
-		       min(unsigned int, (rx_bufsize - new_rx_get),
-		       min(unsigned int, (TTY_FLIPBUF_SIZE - tty->flip.count), char_count))
+		       min_t(unsigned int, (rx_bufsize - new_rx_get),
+		       min_t(unsigned int, (TTY_FLIPBUF_SIZE - tty->flip.count), char_count))
 		 )) {
 		memcpy_fromio(tty->flip.char_buf_ptr,
 			      (char *)(cinfo->base_addr
@@ -1724,9 +1724,9 @@
 	}
 #ifdef BLOCKMOVE
 	while(0 < (small_count = 
-		   min(unsigned int, (tx_bufsize - tx_put),
-		       min(unsigned int, (SERIAL_XMIT_SIZE - info->xmit_tail),
-			   min(unsigned int, info->xmit_cnt, char_count))))) {
+		   min_t(unsigned int, (tx_bufsize - tx_put),
+		       min_t(unsigned int, (SERIAL_XMIT_SIZE - info->xmit_tail),
+			   min_t(unsigned int, info->xmit_cnt, char_count))))) {
 
 	    memcpy_toio((char *)(cinfo->base_addr + tx_bufaddr + tx_put),
 			&info->xmit_buf[info->xmit_tail],
diff -u --recursive --new-file v2.4.9/linux/drivers/char/decserial.c linux/drivers/char/decserial.c
--- v2.4.9/linux/drivers/char/decserial.c	Wed Dec 31 16:00:00 1969
+++ linux/drivers/char/decserial.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,98 @@
+/*
+ * sercons.c
+ *      choose the right serial device at boot time
+ *
+ * triemer 6-SEP-1998
+ *      sercons.c is designed to allow the three different kinds 
+ *      of serial devices under the decstation world to co-exist
+ *      in the same kernel.  The idea here is to abstract 
+ *      the pieces of the drivers that are common to this file
+ *      so that they do not clash at compile time and runtime.
+ *
+ * HK 16-SEP-1998 v0.002
+ *      removed the PROM console as this is not a real serial
+ *      device. Added support for PROM console in drivers/char/tty_io.c
+ *      instead. Although it may work to enable more than one 
+ *      console device I strongly recommend to use only one.
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <asm/dec/machtype.h>
+
+#ifdef CONFIG_ZS
+extern int zs_init(void);
+#endif
+
+#ifdef CONFIG_DZ
+extern int dz_init(void);
+#endif
+
+#ifdef CONFIG_SERIAL_CONSOLE
+
+#ifdef CONFIG_ZS
+extern void zs_serial_console_init(void);
+#endif
+
+#ifdef CONFIG_DZ
+extern void dz_serial_console_init(void);
+#endif
+
+#endif
+
+/* rs_init - starts up the serial interface -
+   handle normal case of starting up the serial interface */
+
+#ifdef CONFIG_SERIAL
+
+int __init rs_init(void)
+{
+
+#if defined(CONFIG_ZS) && defined(CONFIG_DZ)
+    if (IOASIC)
+	return zs_init();
+    else
+	return dz_init();
+#else
+
+#ifdef CONFIG_ZS
+    return zs_init();
+#endif
+
+#ifdef CONFIG_DZ
+    return dz_init();
+#endif
+
+#endif
+}
+
+__initcall(rs_init);
+
+#endif
+
+#ifdef CONFIG_SERIAL_CONSOLE
+
+/* serial_console_init handles the special case of starting
+ *   up the console on the serial port
+ */
+void __init serial_console_init(void)
+{
+#if defined(CONFIG_ZS) && defined(CONFIG_DZ)
+    if (IOASIC)
+	zs_serial_console_init();
+    else
+	dz_serial_console_init();
+#else
+
+#ifdef CONFIG_ZS
+    zs_serial_console_init();
+#endif
+
+#ifdef CONFIG_DZ
+    dz_serial_console_init();
+#endif
+
+#endif
+}
+
+#endif
diff -u --recursive --new-file v2.4.9/linux/drivers/char/drm/ati_pcigart.h linux/drivers/char/drm/ati_pcigart.h
--- v2.4.9/linux/drivers/char/drm/ati_pcigart.h	Mon Aug 27 12:41:40 2001
+++ linux/drivers/char/drm/ati_pcigart.h	Thu Sep 13 16:22:31 2001
@@ -72,8 +72,6 @@
 	int i;
 	DRM_DEBUG( "%s\n", __FUNCTION__ );
 
-	if ( !address ) return;
-
 	page = virt_to_page( address );
 
 	for ( i = 0 ; i <= ATI_PCIGART_TABLE_PAGES ; i++, page++ ) {
@@ -84,23 +82,40 @@
 	free_pages( address, ATI_PCIGART_TABLE_ORDER );
 }
 
-unsigned long DRM(ati_pcigart_init)( drm_device_t *dev )
+int DRM(ati_pcigart_init)( drm_device_t *dev,
+			   unsigned long *addr,
+			   dma_addr_t *bus_addr)
 {
 	drm_sg_mem_t *entry = dev->sg;
-	unsigned long address;
+	unsigned long address = 0;
 	unsigned long pages;
-	u32 *pci_gart, page_base;
-	int i, j;
+	u32 *pci_gart, page_base, bus_address = 0;
+	int i, j, ret = 0;
 
 	if ( !entry ) {
 		DRM_ERROR( "no scatter/gather memory!\n" );
-		return 0;
+		goto done;
 	}
 
 	address = DRM(ati_alloc_pcigart_table)();
 	if ( !address ) {
 		DRM_ERROR( "cannot allocate PCI GART page!\n" );
-		return 0;
+		goto done;
+	}
+
+	if ( !dev->pdev ) {
+		DRM_ERROR( "PCI device unknown!\n" );
+		goto done;
+	}
+
+	bus_address = pci_map_single(dev->pdev, (void *)address,
+				  ATI_PCIGART_TABLE_PAGES * PAGE_SIZE,
+				  PCI_DMA_TODEVICE);
+	if (bus_address == 0) {
+		DRM_ERROR( "unable to map PCIGART pages!\n" );
+		DRM(ati_free_pcigart_table)( address );
+		address = 0;
+		goto done;
 	}
 
 	pci_gart = (u32 *)address;
@@ -111,28 +126,72 @@
 	memset( pci_gart, 0, ATI_MAX_PCIGART_PAGES * sizeof(u32) );
 
 	for ( i = 0 ; i < pages ; i++ ) {
-		page_base = page_to_bus( entry->pagelist[i] );
+		/* we need to support large memory configurations */
+		entry->busaddr[i] = pci_map_single(dev->pdev,
+					   page_address( entry->pagelist[i] ),
+					   PAGE_SIZE,
+					   PCI_DMA_TODEVICE);
+		if (entry->busaddr[i] == 0) {
+			DRM_ERROR( "unable to map PCIGART pages!\n" );
+			DRM(ati_pcigart_cleanup)( dev, address, bus_address );
+			address = 0;
+			bus_address = 0;
+			goto done;
+		}
+		page_base = (u32) entry->busaddr[i];
+
 		for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) {
 			*pci_gart++ = cpu_to_le32( page_base );
 			page_base += ATI_PCIGART_PAGE_SIZE;
 		}
 	}
 
+	ret = 1;
+
 #if __i386__
 	asm volatile ( "wbinvd" ::: "memory" );
 #else
 	mb();
 #endif
 
-	return address;
+done:
+	*addr = address;
+	*bus_addr = bus_address;
+	return ret;
 }
 
-int DRM(ati_pcigart_cleanup)( unsigned long address )
+int DRM(ati_pcigart_cleanup)( drm_device_t *dev,
+			      unsigned long addr,
+			      dma_addr_t bus_addr)
 {
+	drm_sg_mem_t *entry = dev->sg;
+	unsigned long pages;
+	int i;
 
-	if ( address ) {
-		DRM(ati_free_pcigart_table)( address );
+	/* we need to support large memory configurations */
+	if ( !entry ) {
+		DRM_ERROR( "no scatter/gather memory!\n" );
+		return 0;
+	}
+
+	if ( bus_addr ) {
+		pci_unmap_single(dev->pdev, bus_addr,
+				 ATI_PCIGART_TABLE_PAGES * PAGE_SIZE,
+				 PCI_DMA_TODEVICE);
+
+		pages = ( entry->pages <= ATI_MAX_PCIGART_PAGES )
+		        ? entry->pages : ATI_MAX_PCIGART_PAGES;
+
+		for ( i = 0 ; i < pages ; i++ ) {
+			if ( !entry->busaddr[i] ) break;
+			pci_unmap_single(dev->pdev, entry->busaddr[i],
+					 PAGE_SIZE, PCI_DMA_TODEVICE);
+		}
+	}
+
+	if ( addr ) {
+		DRM(ati_free_pcigart_table)( addr );
 	}
 
-	return 0;
+	return 1;
 }
diff -u --recursive --new-file v2.4.9/linux/drivers/char/drm/drmP.h linux/drivers/char/drm/drmP.h
--- v2.4.9/linux/drivers/char/drm/drmP.h	Sun Aug 12 13:27:59 2001
+++ linux/drivers/char/drm/drmP.h	Thu Sep 13 16:22:31 2001
@@ -76,6 +76,17 @@
 #include <asm/pgalloc.h>
 #include "drm.h"
 
+/* page_to_bus for earlier kernels, not optimal in all cases */
+#ifndef page_to_bus
+#define page_to_bus(page)	((unsigned int)(virt_to_bus(page_address(page))))
+#endif
+
+/* We just use virt_to_bus for pci_map_single on older kernels */
+#if LINUX_VERSION_CODE < 0x020400
+#define pci_map_single(hwdev, ptr, size, direction)	virt_to_bus(ptr)
+#define pci_unmap_single(hwdev, dma_addr, size, direction)
+#endif
+
 /* DRM template customization defaults
  */
 #ifndef __HAVE_AGP
@@ -616,6 +627,8 @@
 	int                acquired;
 	unsigned long      base;
    	int 		   agp_mtrr;
+	int		   cant_use_aperture;
+	unsigned long	   page_mask;
 } drm_agp_head_t;
 #endif
 
@@ -624,6 +637,7 @@
 	void            *virtual;
 	int             pages;
 	struct page     **pagelist;
+	dma_addr_t	*busaddr;
 } drm_sg_mem_t;
 
 typedef struct drm_sigdata {
@@ -714,6 +728,7 @@
 #if __REALLY_HAVE_AGP
 	drm_agp_head_t    *agp;
 #endif
+	struct pci_dev *pdev;
 #ifdef __alpha__
 #if LINUX_VERSION_CODE < 0x020403
 	struct pci_controler *hose;
@@ -1018,8 +1033,12 @@
 #endif
 
                                /* ATI PCIGART support (ati_pcigart.h) */
-extern unsigned long  DRM(ati_pcigart_init)(drm_device_t *dev);
-extern int            DRM(ati_pcigart_cleanup)(unsigned long address);
+extern int            DRM(ati_pcigart_init)(drm_device_t *dev,
+					    unsigned long *addr,
+					    dma_addr_t *bus_addr);
+extern int            DRM(ati_pcigart_cleanup)(drm_device_t *dev,
+					       unsigned long addr,
+					       dma_addr_t bus_addr);
 
 #endif /* __KERNEL__ */
 #endif
diff -u --recursive --new-file v2.4.9/linux/drivers/char/drm/drm_agpsupport.h linux/drivers/char/drm/drm_agpsupport.h
--- v2.4.9/linux/drivers/char/drm/drm_agpsupport.h	Sun Aug 12 13:27:59 2001
+++ linux/drivers/char/drm/drm_agpsupport.h	Thu Sep 13 16:22:31 2001
@@ -316,6 +316,14 @@
 
 		default:		head->chipset = "Unknown";       break;
 		}
+#if LINUX_VERSION_CODE <= 0x020408
+		head->cant_use_aperture = 0;
+		head->page_mask = ~(0xfff);
+#else
+		head->cant_use_aperture = head->agp_info.cant_use_aperture;
+		head->page_mask = head->agp_info.page_mask;
+#endif
+
 		DRM_INFO("AGP %d.%d on %s @ 0x%08lx %ZuMB\n",
 			 head->agp_info.version.major,
 			 head->agp_info.version.minor,
diff -u --recursive --new-file v2.4.9/linux/drivers/char/drm/drm_context.h linux/drivers/char/drm/drm_context.h
--- v2.4.9/linux/drivers/char/drm/drm_context.h	Mon Aug 27 12:41:40 2001
+++ linux/drivers/char/drm/drm_context.h	Thu Sep 13 16:22:31 2001
@@ -181,7 +181,7 @@
 	drm_device_t	*dev	= priv->dev;
 	drm_ctx_priv_map_t request;
 	drm_map_t *map = NULL;
-	drm_map_list_t *r_list;
+	drm_map_list_t *r_list = NULL;
 	struct list_head *list;
 
 	if (copy_from_user(&request,
diff -u --recursive --new-file v2.4.9/linux/drivers/char/drm/drm_ioctl.h linux/drivers/char/drm/drm_ioctl.h
--- v2.4.9/linux/drivers/char/drm/drm_ioctl.h	Sun Aug 12 13:27:59 2001
+++ linux/drivers/char/drm/drm_ioctl.h	Thu Sep 13 16:22:31 2001
@@ -98,7 +98,6 @@
 	}
 	sprintf(dev->devname, "%s@%s", dev->name, dev->unique);
 
-#ifdef __alpha__
 	do {
 		struct pci_dev *pci_dev;
                 int b, d, f;
@@ -114,10 +113,13 @@
                 if (*p) break;
  
                 pci_dev = pci_find_slot(b, PCI_DEVFN(d,f));
-                if (pci_dev)
-                        dev->hose = pci_dev->sysdata;
-        } while(0);
+                if (pci_dev) {
+			dev->pdev = pci_dev;
+#ifdef __alpha__
+			dev->hose = pci_dev->sysdata;
 #endif
+		}
+        } while(0);
 
 	return 0;
 }
diff -u --recursive --new-file v2.4.9/linux/drivers/char/drm/drm_scatter.h linux/drivers/char/drm/drm_scatter.h
--- v2.4.9/linux/drivers/char/drm/drm_scatter.h	Mon Aug 27 12:41:40 2001
+++ linux/drivers/char/drm/drm_scatter.h	Thu Sep 13 16:22:31 2001
@@ -47,12 +47,15 @@
 
 	vfree( entry->virtual );
 
+	DRM(free)( entry->busaddr,
+		   entry->pages * sizeof(*entry->busaddr),
+		   DRM_MEM_PAGES );
 	DRM(free)( entry->pagelist,
-		  entry->pages * sizeof(*entry->pagelist),
-		  DRM_MEM_PAGES );
+		   entry->pages * sizeof(*entry->pagelist),
+		   DRM_MEM_PAGES );
 	DRM(free)( entry,
-		  sizeof(*entry),
-		  DRM_MEM_SGLISTS );
+		   sizeof(*entry),
+		   DRM_MEM_SGLISTS );
 }
 
 int DRM(sg_alloc)( struct inode *inode, struct file *filp,
@@ -93,16 +96,31 @@
 		DRM(free)( entry, sizeof(*entry), DRM_MEM_SGLISTS );
 		return -ENOMEM;
 	}
-	memset(entry->pagelist, 0, pages * sizeof(*entry->pagelist));
+
+	entry->busaddr = DRM(alloc)( pages * sizeof(*entry->busaddr),
+				     DRM_MEM_PAGES );
+	if ( !entry->busaddr ) {
+		DRM(free)( entry->pagelist,
+			   entry->pages * sizeof(*entry->pagelist),
+			   DRM_MEM_PAGES );
+		DRM(free)( entry,
+			   sizeof(*entry),
+			   DRM_MEM_SGLISTS );
+		return -ENOMEM;
+	}
+	memset( (void *)entry->busaddr, 0, pages * sizeof(*entry->busaddr) );
 
 	entry->virtual = vmalloc_32( pages << PAGE_SHIFT );
 	if ( !entry->virtual ) {
+		DRM(free)( entry->busaddr,
+			   entry->pages * sizeof(*entry->busaddr),
+			   DRM_MEM_PAGES );
 		DRM(free)( entry->pagelist,
-			  entry->pages * sizeof(*entry->pagelist),
-			  DRM_MEM_PAGES );
+			   entry->pages * sizeof(*entry->pagelist),
+			   DRM_MEM_PAGES );
 		DRM(free)( entry,
-			  sizeof(*entry),
-			  DRM_MEM_SGLISTS );
+			   sizeof(*entry),
+			   DRM_MEM_SGLISTS );
 		return -ENOMEM;
 	}
 
diff -u --recursive --new-file v2.4.9/linux/drivers/char/drm/drm_vm.h linux/drivers/char/drm/drm_vm.h
--- v2.4.9/linux/drivers/char/drm/drm_vm.h	Mon Aug 27 12:41:40 2001
+++ linux/drivers/char/drm/drm_vm.h	Thu Sep 13 16:22:31 2001
@@ -67,6 +67,70 @@
 			    int write_access)
 #endif
 {
+#if __REALLY_HAVE_AGP
+	drm_file_t *priv  = vma->vm_file->private_data;
+	drm_device_t *dev = priv->dev;
+	drm_map_t *map    = NULL;
+	drm_map_list_t  *r_list;
+	struct list_head *list;
+
+	/*
+         * Find the right map
+         */
+
+	if(!dev->agp->cant_use_aperture) goto vm_nopage_error;
+
+	list_for_each(list, &dev->maplist->head) {
+		r_list = (drm_map_list_t *)list;
+		map = r_list->map;
+		if (!map) continue;
+		if (map->offset == VM_OFFSET(vma)) break;
+	}
+
+	if (map && map->type == _DRM_AGP) {
+		unsigned long offset = address - vma->vm_start;
+		unsigned long baddr = VM_OFFSET(vma) + offset;
+		struct drm_agp_mem *agpmem;
+		struct page *page;
+
+#if __alpha__
+		/*
+                 * Adjust to a bus-relative address
+                 */
+		baddr -= dev->hose->mem_space->start;
+#endif
+
+		/*
+                 * It's AGP memory - find the real physical page to map
+                 */
+		for(agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next) {
+			if (agpmem->bound <= baddr &&
+			    agpmem->bound + agpmem->pages * PAGE_SIZE > baddr) 
+				break;
+		}
+
+		if (!agpmem) goto vm_nopage_error;
+
+		/*
+                 * Get the page, inc the use count, and return it
+                 */
+		offset = (baddr - agpmem->bound) >> PAGE_SHIFT;
+		agpmem->memory->memory[offset] &= dev->agp->page_mask;
+		page = virt_to_page(__va(agpmem->memory->memory[offset]));
+		get_page(page);
+
+		DRM_DEBUG("baddr = 0x%lx page = 0x%p, offset = 0x%lx\n",
+			  baddr, __va(agpmem->memory->memory[offset]), offset);
+
+#if LINUX_VERSION_CODE < 0x020317
+		return page_address(page);
+#else
+		return page;
+#endif
+        }
+vm_nopage_error:
+#endif /* __REALLY_HAVE_AGP */
+
 	return NOPAGE_SIGBUS;		/* Disallow mremap */
 }
 
@@ -220,24 +284,27 @@
 	drm_file_t	 *priv	 = vma->vm_file->private_data;
 	drm_device_t	 *dev	 = priv->dev;
 	drm_device_dma_t *dma	 = dev->dma;
-	unsigned long	 physical;
 	unsigned long	 offset;
-	unsigned long	 page;
+	unsigned long	 page_nr;
+	struct page	 *page;
 
 	if (!dma)		   return NOPAGE_SIGBUS; /* Error */
 	if (address > vma->vm_end) return NOPAGE_SIGBUS; /* Disallow mremap */
 	if (!dma->pagelist)	   return NOPAGE_OOM ; /* Nothing allocated */
 
 	offset	 = address - vma->vm_start; /* vm_[pg]off[set] should be 0 */
-	page	 = offset >> PAGE_SHIFT;
-	physical = dma->pagelist[page] + (offset & (~PAGE_MASK));
-	atomic_inc(&virt_to_page(physical)->count); /* Dec. by kernel */
+	page_nr  = offset >> PAGE_SHIFT;
+	page = virt_to_page((dma->pagelist[page_nr] + 
+			     (offset & (~PAGE_MASK))));
 
-	DRM_DEBUG("0x%08lx (page %lu) => 0x%08lx\n", address, page, physical);
+	get_page(page);
+
+	DRM_DEBUG("0x%08lx (page %lu) => 0x%08x\n", address, page_nr, 
+		  page_to_bus(page));
 #if LINUX_VERSION_CODE < 0x020317
-	return physical;
+	return page_address(page);
 #else
-	return virt_to_page(physical);
+	return page;
 #endif
 }
 
@@ -274,10 +341,10 @@
 	map_offset = map->offset - dev->sg->handle;
 	page_offset = (offset >> PAGE_SHIFT) + (map_offset >> PAGE_SHIFT);
 	page = entry->pagelist[page_offset];
-	atomic_inc(&page->count);                       /* Dec. by kernel */
+	get_page(page);
 
 #if LINUX_VERSION_CODE < 0x020317
-	return (unsigned long)virt_to_phys(page->virtual);
+	return page_address(page);
 #else
 	return page;
 #endif
@@ -435,9 +502,20 @@
 	}
 
 	switch (map->type) {
+        case _DRM_AGP:
+#if defined(__alpha__)
+                /*
+                 * On Alpha we can't talk to bus dma address from the
+                 * CPU, so for memory of type DRM_AGP, we'll deal with
+                 * sorting out the real physical pages and mappings
+                 * in nopage()
+                 */
+                vma->vm_ops = &DRM(vm_ops);
+                break;
+#endif
+                /* fall through to _DRM_FRAME_BUFFER... */        
 	case _DRM_FRAME_BUFFER:
 	case _DRM_REGISTERS:
-	case _DRM_AGP:
 		if (VM_OFFSET(vma) >= __pa(high_memory)) {
 #if defined(__i386__)
 			if (boot_cpu_data.x86 > 3 && map->type != _DRM_AGP) {
diff -u --recursive --new-file v2.4.9/linux/drivers/char/drm/mga_drv.h linux/drivers/char/drm/mga_drv.h
--- v2.4.9/linux/drivers/char/drm/mga_drv.h	Sun Aug 12 13:27:59 2001
+++ linux/drivers/char/drm/mga_drv.h	Mon Aug 27 07:40:33 2001
@@ -145,14 +145,28 @@
 #define mga_flush_write_combine()	mb()
 
 
-#define MGA_BASE( reg )		((u32)(dev_priv->mmio->handle))
+#define MGA_BASE( reg )		((unsigned long)(dev_priv->mmio->handle))
 #define MGA_ADDR( reg )		(MGA_BASE(reg) + reg)
 
 #define MGA_DEREF( reg )	*(volatile u32 *)MGA_ADDR( reg )
+#define MGA_DEREF8( reg )	*(volatile u8 *)MGA_ADDR( reg )
+
+#ifdef __alpha__
+#define MGA_READ( reg )		(_MGA_READ((u32 *)MGA_ADDR(reg)))
+#define MGA_WRITE( reg, val )	do { wmb(); MGA_DEREF( reg ) = val; } while (0)
+#define MGA_WRITE8( reg, val )  do { wmb(); MGA_DEREF8( reg ) = val; } while (0)
+
+static inline u32 _MGA_READ(u32 *addr)
+{
+	mb();
+	return *(volatile u32 *)addr;
+}
+
+#else
 #define MGA_READ( reg )		MGA_DEREF( reg )
 #define MGA_WRITE( reg, val )	do { MGA_DEREF( reg ) = val; } while (0)
-#define MGA_DEREF8( reg )	*(volatile u8 *)MGA_ADDR( reg )
 #define MGA_WRITE8( reg, val )  do { MGA_DEREF8( reg ) = val; } while (0)
+#endif
 
 #define DWGREG0 	0x1c00
 #define DWGREG0_END 	0x1dff
diff -u --recursive --new-file v2.4.9/linux/drivers/char/drm/r128_cce.c linux/drivers/char/drm/r128_cce.c
--- v2.4.9/linux/drivers/char/drm/r128_cce.c	Mon Aug 27 12:41:40 2001
+++ linux/drivers/char/drm/r128_cce.c	Mon Aug 27 07:40:33 2001
@@ -351,11 +351,10 @@
 		page_ofs = tmp_ofs >> PAGE_SHIFT;
 
 		R128_WRITE( R128_PM4_BUFFER_DL_RPTR_ADDR,
-			    page_to_bus(entry->pagelist[page_ofs]));
-
-		DRM_DEBUG( "ring rptr: offset=0x%08lx handle=0x%08lx\n",
-			   page_to_bus(entry->pagelist[page_ofs]),
-			   entry->handle + tmp_ofs );
+     			    entry->busaddr[page_ofs]);
+		DRM_DEBUG( "ring rptr: offset=0x%08x handle=0x%08lx\n",
+			   entry->busaddr[page_ofs],
+     			   entry->handle + tmp_ofs );
 	}
 
 	/* Set watermark control */
@@ -599,15 +598,14 @@
 		    dev_priv->sarea_priv->last_dispatch );
 
 	if ( dev_priv->is_pci ) {
-		dev_priv->phys_pci_gart = DRM(ati_pcigart_init)( dev );
-		if ( !dev_priv->phys_pci_gart ) {
+		if (!DRM(ati_pcigart_init)( dev, &dev_priv->phys_pci_gart,
+     					    &dev_priv->bus_pci_gart) ) {
 			DRM_ERROR( "failed to init PCI GART!\n" );
 			dev->dev_private = (void *)dev_priv;
 			r128_do_cleanup_cce( dev );
 			return -ENOMEM;
 		}
-		R128_WRITE( R128_PCI_GART_PAGE,
-			    virt_to_bus( (void *)dev_priv->phys_pci_gart ) );
+		R128_WRITE( R128_PCI_GART_PAGE, dev_priv->bus_pci_gart );
 	}
 
 	r128_cce_init_ring_buffer( dev, dev_priv );
@@ -629,6 +627,11 @@
 			DRM_IOREMAPFREE( dev_priv->cce_ring );
 			DRM_IOREMAPFREE( dev_priv->ring_rptr );
 			DRM_IOREMAPFREE( dev_priv->buffers );
+		} else {
+			if (!DRM(ati_pcigart_cleanup)( dev,
+						dev_priv->phys_pci_gart,
+						dev_priv->bus_pci_gart ))
+				DRM_ERROR( "failed to cleanup PCI GART!\n" );
 		}
 
 		DRM(free)( dev->dev_private, sizeof(drm_r128_private_t),
diff -u --recursive --new-file v2.4.9/linux/drivers/char/drm/r128_drv.h linux/drivers/char/drm/r128_drv.h
--- v2.4.9/linux/drivers/char/drm/r128_drv.h	Sun Aug 12 13:27:59 2001
+++ linux/drivers/char/drm/r128_drv.h	Mon Aug 27 07:40:33 2001
@@ -72,6 +72,7 @@
 	int usec_timeout;
 	int is_pci;
 	unsigned long phys_pci_gart;
+	dma_addr_t bus_pci_gart;
 	unsigned long cce_buffers_offset;
 
 	atomic_t idle_count;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/drm/radeon_cp.c linux/drivers/char/drm/radeon_cp.c
--- v2.4.9/linux/drivers/char/drm/radeon_cp.c	Mon Aug 27 12:41:40 2001
+++ linux/drivers/char/drm/radeon_cp.c	Mon Aug 27 07:40:33 2001
@@ -624,10 +624,9 @@
 		page_ofs = tmp_ofs >> PAGE_SHIFT;
 
 		RADEON_WRITE( RADEON_CP_RB_RPTR_ADDR,
-			      page_to_bus(entry->pagelist[page_ofs]));
-
+			     entry->busaddr[page_ofs]);
 		DRM_DEBUG( "ring rptr: offset=0x%08x handle=0x%08lx\n",
-			   page_to_bus(entry->pagelist[page_ofs]),
+			   entry->busaddr[page_ofs],
 			   entry->handle + tmp_ofs );
 	}
 
@@ -929,8 +928,8 @@
 		      dev_priv->sarea_priv->last_clear );
 
 	if ( dev_priv->is_pci ) {
-		dev_priv->phys_pci_gart = DRM(ati_pcigart_init)( dev );
-		if ( !dev_priv->phys_pci_gart ) {
+		if (!DRM(ati_pcigart_init)( dev, &dev_priv->phys_pci_gart,
+					    &dev_priv->bus_pci_gart)) {
 			DRM_ERROR( "failed to init PCI GART!\n" );
 			dev->dev_private = (void *)dev_priv;
 			radeon_do_cleanup_cp(dev);
@@ -944,8 +943,7 @@
 
 		/* set PCI GART page-table base address
 		 */
-		RADEON_WRITE( RADEON_AIC_PT_BASE,
-			      virt_to_bus( (void *)dev_priv->phys_pci_gart ) );
+		RADEON_WRITE( RADEON_AIC_PT_BASE, dev_priv->bus_pci_gart );
 
 		/* set address range for PCI address translate
 		 */
@@ -990,6 +988,11 @@
 			DRM_IOREMAPFREE( dev_priv->cp_ring );
 			DRM_IOREMAPFREE( dev_priv->ring_rptr );
 			DRM_IOREMAPFREE( dev_priv->buffers );
+		} else {
+			if (!DRM(ati_pcigart_cleanup)( dev,
+						dev_priv->phys_pci_gart,
+						dev_priv->bus_pci_gart ))
+				DRM_ERROR( "failed to cleanup PCI GART!\n" );
 		}
 
 		DRM(free)( dev->dev_private, sizeof(drm_radeon_private_t),
diff -u --recursive --new-file v2.4.9/linux/drivers/char/drm/radeon_drv.h linux/drivers/char/drm/radeon_drv.h
--- v2.4.9/linux/drivers/char/drm/radeon_drv.h	Sun Aug 12 13:27:59 2001
+++ linux/drivers/char/drm/radeon_drv.h	Mon Aug 27 07:40:33 2001
@@ -84,6 +84,7 @@
 	int usec_timeout;
 	int is_pci;
 	unsigned long phys_pci_gart;
+	dma_addr_t bus_pci_gart;
 
 	atomic_t idle_count;
 
diff -u --recursive --new-file v2.4.9/linux/drivers/char/drm/tdfx_drv.c linux/drivers/char/drm/tdfx_drv.c
--- v2.4.9/linux/drivers/char/drm/tdfx_drv.c	Sun Aug 12 13:27:59 2001
+++ linux/drivers/char/drm/tdfx_drv.c	Mon Aug 27 07:40:33 2001
@@ -44,13 +44,30 @@
 #define DRIVER_MINOR		0
 #define DRIVER_PATCHLEVEL	0
 
+#ifndef PCI_VENDOR_ID_3DFX
+#define PCI_VENDOR_ID_3DFX 0x121A
+#endif
 #ifndef PCI_DEVICE_ID_3DFX_VOODOO5
 #define PCI_DEVICE_ID_3DFX_VOODOO5 0x0009
 #endif
+#ifndef PCI_DEVICE_ID_3DFX_VOODOO4
+#define PCI_DEVICE_ID_3DFX_VOODOO4 0x0007
+#endif
+#ifndef PCI_DEVICE_ID_3DFX_VOODOO3_3000 /* Voodoo3 3000 */
+#define PCI_DEVICE_ID_3DFX_VOODOO3_3000 0x0005
+#endif
+#ifndef PCI_DEVICE_ID_3DFX_VOODOO3_2000 /* Voodoo3 3000 */
+#define PCI_DEVICE_ID_3DFX_VOODOO3_2000 0x0004
+#endif
+#ifndef PCI_DEVICE_ID_3DFX_BANSHEE
+#define PCI_DEVICE_ID_3DFX_BANSHEE 0x0003
+#endif
 
 static drm_pci_list_t DRM(idlist)[] = {
 	{ PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_BANSHEE },
-	{ PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO3 },
+	{ PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO3_2000 },
+	{ PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO3_3000 },
+	{ PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO4 },
 	{ PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO5 },
 	{ 0, 0 }
 };
diff -u --recursive --new-file v2.4.9/linux/drivers/char/ds1620.c linux/drivers/char/ds1620.c
--- v2.4.9/linux/drivers/char/ds1620.c	Sun Aug 13 09:54:15 2000
+++ linux/drivers/char/ds1620.c	Thu Sep 13 15:21:32 2001
@@ -410,3 +410,5 @@
 
 module_init(ds1620_init);
 module_exit(ds1620_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/dsp56k.c linux/drivers/char/dsp56k.c
--- v2.4.9/linux/drivers/char/dsp56k.c	Mon Aug 27 12:41:40 2001
+++ linux/drivers/char/dsp56k.c	Mon Sep 10 08:06:32 2001
@@ -69,7 +69,7 @@
 { \
 	long i, t, m; \
 	while (count > 0) { \
-		m = min(unsigned long, count, maxio); \
+		m = min_t(unsigned long, count, maxio); \
 		for (i = 0; i < m; i++) { \
 			for (t = 0; t < timeout && !ENABLE; t++) \
 				wait_some(HZ/50); \
@@ -502,7 +502,7 @@
 
 static devfs_handle_t devfs_handle;
 
-static const char banner[] __initdata = KERN_INFO "DSP56k driver installed\n";
+static char banner[] __initdata = KERN_INFO "DSP56k driver installed\n";
 
 static int __init dsp56k_init_driver(void)
 {
@@ -531,3 +531,5 @@
 	devfs_unregister(devfs_handle);
 }
 module_exit(dsp56k_cleanup_driver);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/dtlk.c linux/drivers/char/dtlk.c
--- v2.4.9/linux/drivers/char/dtlk.c	Wed Jul 25 17:10:19 2001
+++ linux/drivers/char/dtlk.c	Thu Sep 13 15:21:32 2001
@@ -678,3 +678,5 @@
 #endif
 	return 0;
 }
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/dz.c linux/drivers/char/dz.c
--- v2.4.9/linux/drivers/char/dz.c	Mon Aug 27 12:41:40 2001
+++ linux/drivers/char/dz.c	Sun Sep  9 10:43:02 2001
@@ -21,15 +21,10 @@
  * [07-SEP-99] Bugfixes 
  */
 
-#define DEBUG_DZ 1
+/* #define DEBUG_DZ 1 */
 
-#ifdef MODULE
-#include <linux/module.h>
 #include <linux/version.h>
-#else
-#define MOD_INC_USE_COUNT
-#define MOD_DEC_USE_COUNT
-#endif
+#include <linux/module.h>
 
 #include <linux/config.h>
 #include <linux/kernel.h>
@@ -41,9 +36,10 @@
 #include <linux/param.h>
 #include <linux/tqueue.h>
 #include <linux/interrupt.h>
+#include <linux/serial.h>
+#include <linux/serialP.h>
 #include <asm-mips/wbflush.h>
-/* for definition of SERIAL */
-#include <asm/dec/interrupts.h>
+#include <asm/dec/interrupts.h>			/* for definition of SERIAL */
 
 /* for definition of struct console */
 #ifdef CONFIG_SERIAL_CONSOLE
@@ -91,13 +87,13 @@
  */
 static void debug_console( const char *s,int count)
 {
-    unsigned i;
+	unsigned i;
 
-    for (i = 0; i < count; i++) {
-       if (*s == 10)
-           prom_printf("%c", 13);
-       prom_printf("%c", *s++);
-    }
+	for (i = 0; i < count; i++) {
+		if (*s == 10)
+			prom_printf("%c", 13);
+		prom_printf("%c", *s++);
+	}
 }
 #endif
 
@@ -112,16 +108,16 @@
 
 static inline unsigned short dz_in (struct dz_serial *info, unsigned offset)
 {
-  volatile unsigned short *addr = (volatile unsigned short *)(info->port + offset);
-  return *addr;
+	volatile u16 *addr = (volatile u16 *)(info->port + offset);
+
+	return *addr;
 }
 
-static inline void dz_out (struct dz_serial *info, unsigned offset, unsigned short value)
+static inline void dz_out (struct dz_serial *info, unsigned offset,
+                           unsigned short value)
 {
-
-    volatile unsigned short *addr = (volatile unsigned short *)(info->port + offset);
-  *addr = value;
-
+	volatile u16 *addr = (volatile u16 *)(info->port + offset);
+	*addr = value;
 }
 
 /*
@@ -136,33 +132,32 @@
 
 static void dz_stop (struct tty_struct *tty)
 {
-  struct dz_serial *info; 
-  unsigned short mask, tmp;
+	struct dz_serial *info; 
+	unsigned short mask, tmp;
 
-  if (tty==0) 
-    return; 
+	if (!tty) 
+		return; 
  
-  info = (struct dz_serial *)tty->driver_data; 
-         
-  mask = 1 << info->line;
-  tmp = dz_in (info, DZ_TCR);       /* read the TX flag */
-
-    tmp &= ~mask;                   /* clear the TX flag */
-    dz_out (info, DZ_TCR, tmp);
-}  
+	info = (struct dz_serial *)tty->driver_data; 
+
+	mask = 1 << info->line;
+	tmp = dz_in (info, DZ_TCR);       /* read the TX flag */
+
+	tmp &= ~mask;                   /* clear the TX flag */
+	dz_out (info, DZ_TCR, tmp);
+}
 
 static void dz_start (struct tty_struct *tty)
 {
-  struct dz_serial *info = (struct dz_serial *)tty->driver_data;
-  unsigned short mask, tmp;
-
-  mask = 1 << info->line;
-  tmp = dz_in (info, DZ_TCR);      /* read the TX flag */
+	struct dz_serial *info = (struct dz_serial *)tty->driver_data;
+	unsigned short mask, tmp;
 
-    tmp |= mask;                   /* set the TX flag */
-    dz_out (info, DZ_TCR, tmp);
+	mask = 1 << info->line;
+	tmp = dz_in (info, DZ_TCR);      /* read the TX flag */
 
-}  
+	tmp |= mask;                   /* set the TX flag */
+	dz_out (info, DZ_TCR, tmp);
+}
 
 /*
  * ------------------------------------------------------------
@@ -194,9 +189,9 @@
  */
 static inline void dz_sched_event (struct dz_serial *info, int event)
 {
-  info->event |= 1 << event;
-  queue_task (&info->tqueue, &tq_serial);
-  mark_bh (SERIAL_BH);
+	info->event |= 1 << event;
+	queue_task(&info->tqueue, &tq_serial);
+	mark_bh(SERIAL_BH);
 }
 
 /*
@@ -208,98 +203,101 @@
  */
 static inline void receive_chars (struct dz_serial *info_in)
 {
+	struct dz_serial *info;
+	struct tty_struct *tty = 0;
+	struct async_icount *icount;
+	int ignore = 0;
+	unsigned short status, tmp;
+	unsigned char ch;
 
-  struct dz_serial *info;
-  struct tty_struct *tty = 0;
-  struct async_icount *icount;
-  int ignore = 0;
-  unsigned short status, tmp;
-  unsigned char ch;
-
-  /* this code is going to be a problem...
-     the call to tty_flip_buffer is going to need
-     to be rethought...
-   */
-  do
-    {
-      status = dz_in (info_in, DZ_RBUF);
-      info = lines[LINE(status)];
-
-      /* punt so we don't get duplicate characters */
-      if (!(status & DZ_DVAL))
-        goto ignore_char;
-
+	/*
+	 * This code is going to be a problem...  the call to tty_flip_buffer
+	 * is going to need to be rethought...
+	 */
+	do {
+		status = dz_in (info_in, DZ_RBUF);
+		info = lines[LINE(status)];
+
+		/* punt so we don't get duplicate characters */
+		if (!(status & DZ_DVAL))
+			goto ignore_char;
 
-    ch = UCHAR(status);                /* grab the char */
+		ch = UCHAR(status);			/* grab the char */
 
 #if 0
-    if (info->is_console) {
-      if (ch == 0) return;            /* it's a break ... */
+		if (info->is_console) {
+			if (ch == 0)
+				return;			/* it's a break ... */
 
-      wake_up (&keypress_wait);       /* It is a 'keyboard interrupt' ;-) */
-    }
+			wake_up (&keypress_wait);       /* It is a 'keyboard interrupt' ;-) */
+		}
 #endif
 
-    tty = info->tty;                  /* now tty points to the proper dev */
-    icount = &info->icount;
-
-    if (!tty) break;
-    if (tty->flip.count >= TTY_FLIPBUF_SIZE) break;
+		tty = info->tty;	/* now tty points to the proper dev */
+		icount = &info->icount;
 
-    *tty->flip.char_buf_ptr = ch;
-    *tty->flip.flag_buf_ptr = 0;
-    icount->rx++;
-
-    /* keep track of the statistics */
-    if (status & (DZ_OERR | DZ_FERR | DZ_PERR)) {
-      if (status & DZ_PERR)                /* parity error */
-        icount->parity++;
-      else if (status & DZ_FERR)           /* frame error */
-        icount->frame++;
-      if (status & DZ_OERR)                /* overrun error */
-        icount->overrun++;
-
-      /*  check to see if we should ignore the character
-	 and mask off conditions that should be ignored
-      */
-
-      if (status & info->ignore_status_mask) {
-        if (++ignore > 100 ) break;
-        goto ignore_char;
-      }
+		if (!tty)
+			break;
+		if (tty->flip.count >= TTY_FLIPBUF_SIZE) break;
+
+		*tty->flip.char_buf_ptr = ch;
+		*tty->flip.flag_buf_ptr = 0;
+		icount->rx++;
+
+		/* keep track of the statistics */
+		if (status & (DZ_OERR | DZ_FERR | DZ_PERR)) {
+			if (status & DZ_PERR)		/* parity error */
+				icount->parity++;
+			else if (status & DZ_FERR)	/* frame error */
+				icount->frame++;
+			if (status & DZ_OERR)		/* overrun error */
+				icount->overrun++;
+
+			/*
+			 * Check to see if we should ignore the character and
+			 * mask off conditions that should be ignored
+			 */
+
+			if (status & info->ignore_status_mask) {
+				if (++ignore > 100)
+					break;
+				goto ignore_char;
+			}
 
-      /* mask off the error conditions we want to ignore */
-      tmp = status & info->read_status_mask;
+			/* mask off the error conditions we want to ignore */
+			tmp = status & info->read_status_mask;
 
-      if (tmp & DZ_PERR)
-	{
-        *tty->flip.flag_buf_ptr = TTY_PARITY;
-	  debug_console("PERR\n",5);
-	}
-      else if (tmp & DZ_FERR)
-	{
-        *tty->flip.flag_buf_ptr = TTY_FRAME;
-	  debug_console("FERR\n",5);
-	}
-      if (tmp & DZ_OERR) 
-	{ 
-	  debug_console("OERR\n",5);
-	if (tty->flip.count < TTY_FLIPBUF_SIZE) {
-          tty->flip.count++;
-          tty->flip.flag_buf_ptr++;
-          tty->flip.char_buf_ptr++;
-          *tty->flip.flag_buf_ptr = TTY_OVERRUN;
-        }
-      }
-    }
-    tty->flip.flag_buf_ptr++;
-    tty->flip.char_buf_ptr++;
-    tty->flip.count++;
-  ignore_char:
-  } while (status & DZ_DVAL);
+			if (tmp & DZ_PERR) {
+				*tty->flip.flag_buf_ptr = TTY_PARITY;
+#ifdef DEBUG_DZ
+				debug_console("PERR\n",5);
+#endif /* DEBUG_DZ */
+			} else if (tmp & DZ_FERR) {
+				*tty->flip.flag_buf_ptr = TTY_FRAME;
+#ifdef DEBUG_DZ
+				debug_console("FERR\n",5);
+#endif /* DEBUG_DZ */
+			} if (tmp & DZ_OERR) { 
+#ifdef DEBUG_DZ
+				debug_console("OERR\n",5);
+#endif /* DEBUG_DZ */
+				if (tty->flip.count < TTY_FLIPBUF_SIZE) {
+					tty->flip.count++;
+					tty->flip.flag_buf_ptr++;
+					tty->flip.char_buf_ptr++;
+					*tty->flip.flag_buf_ptr = TTY_OVERRUN;
+				}
+			}
+		}
+	tty->flip.flag_buf_ptr++;
+	tty->flip.char_buf_ptr++;
+	tty->flip.count++;
+ignore_char:
+	;
+	} while (status & DZ_DVAL);
 
-  if (tty)
-    tty_flip_buffer_push(tty);
+	if (tty)
+		tty_flip_buffer_push(tty);
 }
 
 /*
@@ -311,35 +309,37 @@
  */
 static inline void transmit_chars (struct dz_serial *info)
 {
-  unsigned char tmp;
+	unsigned char tmp;
 
+	if (info->x_char) {           /* XON/XOFF chars */
+		dz_out(info, DZ_TDR, info->x_char);
+		info->icount.tx++;
+		info->x_char = 0;
+		return;
+	}
 
+	/* if nothing to do or stopped or hardware stopped */
+	if ((info->xmit_cnt <= 0) || info->tty->stopped ||
+	    info->tty->hw_stopped) {
+		dz_stop(info->tty);
+		return;
+	}
 
-  if (info->x_char) {           /* XON/XOFF chars */
-    dz_out (info, DZ_TDR, info->x_char);
-    info->icount.tx++;
-    info->x_char = 0;
-    return;
-  }
-
-  /* if nothing to do or stopped or hardware stopped */
-  if ((info->xmit_cnt <= 0) || info->tty->stopped || info->tty->hw_stopped) {
-    dz_stop (info->tty);
-    return;
-  }
-
-  /* if something to do ... (rember the dz has no output fifo so we go one char at a time :-< */
-  tmp = (unsigned short)info->xmit_buf[info->xmit_tail++];
-  dz_out (info, DZ_TDR, tmp);
-  info->xmit_tail = info->xmit_tail & (DZ_XMIT_SIZE - 1);
-  info->icount.tx++;
-
-  if (--info->xmit_cnt < WAKEUP_CHARS)
-    dz_sched_event (info, DZ_EVENT_WRITE_WAKEUP);
-
-
-  /* Are we done */
-  if (info->xmit_cnt <= 0) dz_stop (info->tty);
+	/*
+	 * If something to do ... (rember the dz has no output fifo so we go
+	 * one char at a time :-<
+	 */
+	tmp = (unsigned short) info->xmit_buf[info->xmit_tail++];
+	dz_out(info, DZ_TDR, tmp);
+	info->xmit_tail = info->xmit_tail & (DZ_XMIT_SIZE - 1);
+	info->icount.tx++;
+
+	if (--info->xmit_cnt < WAKEUP_CHARS)
+	dz_sched_event(info, DZ_EVENT_WRITE_WAKEUP);
+
+	/* Are we done */
+	if (info->xmit_cnt <= 0)
+		dz_stop(info->tty);
 }
 
 /*
@@ -351,15 +351,17 @@
  */
 static inline void check_modem_status (struct dz_serial *info)
 {
-  unsigned short status;
+	unsigned short status;
 
-  /* if not ne modem line just return */
-  if (info->line != DZ_MODEM) return;
+	/* if not ne modem line just return */
+	if (info->line != DZ_MODEM)
+		return;
 
-  status = dz_in (info, DZ_MSR);
+	status = dz_in(info, DZ_MSR);
   
-  /* it's easy, since DSR2 is the only bit in the register */
-  if (status) info->icount.dsr++;
+	/* it's easy, since DSR2 is the only bit in the register */
+	if (status)
+		info->icount.dsr++;
 }
 
 /*
@@ -372,17 +374,18 @@
  */
 static void dz_interrupt (int irq, void *dev, struct pt_regs *regs)
 {
-  struct dz_serial *info;
-  unsigned short status;
+	struct dz_serial *info;
+	unsigned short status;
 
-  status = dz_in ((struct dz_serial *)dev, DZ_CSR); /* get the reason why we just got an irq */
-  info = lines[LINE(status)];     /* re-arrange info the proper port */
+	 /* get the reason why we just got an irq */
+	status = dz_in((struct dz_serial *)dev, DZ_CSR);
+	info = lines[LINE(status)];     /* re-arrange info the proper port */
 
-  if (status & DZ_RDONE) 
-      receive_chars (info);          /* the receive function */
+	if (status & DZ_RDONE) 
+		receive_chars(info);	/* the receive function */
 
-  if (status & DZ_TRDY) 
-    transmit_chars (info);
+	if (status & DZ_TRDY) 
+		transmit_chars (info);
 }
 
 /*
@@ -402,21 +405,23 @@
  */
 static void do_serial_bh (void)
 {
-        run_task_queue (&tq_serial);
+	run_task_queue (&tq_serial);
 }
 
 static void do_softint (void *private_data)
 {
-  struct dz_serial *info = (struct dz_serial *)private_data;
-  struct tty_struct *tty = info->tty;
+	struct dz_serial *info = (struct dz_serial *) private_data;
+	struct tty_struct *tty = info->tty;
 
-  if (!tty) return;
+	if (!tty)
+		return;
 
-  if (test_and_clear_bit (DZ_EVENT_WRITE_WAKEUP, &info->event)) {
-    if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && tty->ldisc.write_wakeup)
-      (tty->ldisc.write_wakeup) (tty);
-    wake_up_interruptible (&tty->write_wait);
-  }
+	if (test_and_clear_bit(DZ_EVENT_WRITE_WAKEUP, &info->event)) {
+		if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
+		    tty->ldisc.write_wakeup)
+			(tty->ldisc.write_wakeup) (tty);
+		wake_up_interruptible (&tty->write_wait);
+	}
 }
 
 /*
@@ -431,12 +436,13 @@
  */
 static void do_serial_hangup (void *private_data)
 {
-  struct dz_serial *info = (struct dz_serial *)private_data;
-  struct tty_struct *tty = info->tty;;
+	struct dz_serial *info = (struct dz_serial *) private_data;
+	struct tty_struct *tty = info->tty;;
         
-  if (!tty) return;
+	if (!tty)
+		return;
 
-  tty_hangup (tty);
+	tty_hangup(tty);
 }
 
 /*
@@ -448,57 +454,52 @@
  */
 static int startup (struct dz_serial *info)
 {
-  unsigned long page, flags;
-  unsigned short tmp;
+	unsigned long page, flags;
+	unsigned short tmp;
 
-  if (info->is_initialized) return 0;
+	if (info->is_initialized)
+		return 0;
   
-  save_flags (flags);
-  cli ();
+	save_and_cli(flags);
 
-  if (!info->port) {
-    if (info->tty) set_bit (TTY_IO_ERROR, &info->tty->flags);
-    restore_flags (flags);
-    return -ENODEV;
-  }
-
-  if (!info->xmit_buf) {
-    page = get_free_page (GFP_KERNEL);
-    if (!page) {
-      restore_flags (flags);
-      return -ENOMEM;
-    }
-    info->xmit_buf = (unsigned char *)page;
-  }
-
-  if (info->tty) clear_bit (TTY_IO_ERROR, &info->tty->flags);
-
-  /* enable the interrupt and the scanning */
-  tmp = dz_in (info, DZ_CSR);
-  tmp |= (DZ_RIE | DZ_TIE | DZ_MSE);
-  dz_out (info, DZ_CSR, tmp);
-
-  info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
-
-  /* set up the speed */
-  change_speed (info);
-
-  /* clear the line transmitter buffer 
-     I can't figure out why I need to do this - but
-     its necessary - in order for the console portion
-     and the interrupt portion to live happily side by side.
-  */
-
-  /* clear the line transmitter buffer 
-     I can't figure out why I need to do this - but
-     its necessary - in order for the console portion
-     and the interrupt portion to live happily side by side.
-  */
+	if (!info->port) {
+		if (info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags);
+		restore_flags(flags);
+		return -ENODEV;
+	}
+
+	if (!info->xmit_buf) {
+		page = get_free_page(GFP_KERNEL);
+		if (!page) {
+			restore_flags (flags);
+		return -ENOMEM;
+		}
+		info->xmit_buf = (unsigned char *)page;
+	}
 
-  info->is_initialized = 1;
+	if (info->tty)
+		clear_bit(TTY_IO_ERROR, &info->tty->flags);
 
-  restore_flags (flags);
-  return 0;
+	/* enable the interrupt and the scanning */
+	tmp = dz_in(info, DZ_CSR);
+	tmp |= (DZ_RIE | DZ_TIE | DZ_MSE);
+	dz_out(info, DZ_CSR, tmp);
+
+	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
+
+	change_speed(info);			/* set up the speed */
+
+	/*
+	 * Clear the line transmitter buffer I can't figure out why I need to
+	 * do this - but its necessary - in order for the console portion and
+	 * the interrupt portion to live happily side by side.
+	 */
+
+	info->is_initialized = 1;
+
+	restore_flags(flags);
+
+	return 0;
 }
 
 /* 
@@ -511,38 +512,38 @@
  */
 static void shutdown (struct dz_serial *info)
 {
-  unsigned long flags;
-  unsigned short tmp;
+	unsigned long flags;
+	unsigned short tmp;
 
-  if (!info->is_initialized) return;
+	if (!info->is_initialized)
+		return;
 
-  save_flags (flags);
-  cli ();
+	save_and_cli(flags);
 
-  dz_stop (info->tty);
+	dz_stop (info->tty);
 
+	info->cflags &= ~DZ_CREAD;	/* turn off receive enable flag */
+	dz_out(info, DZ_LPR, info->cflags);
 
+	if (info->xmit_buf) {               /* free Tx buffer */
+		free_page((unsigned long)info->xmit_buf);
+		info->xmit_buf = 0;
+	}
 
-  info->cflags &= ~DZ_CREAD;          /* turn off receive enable flag */
-  dz_out (info, DZ_LPR, info->cflags);
-
-  if (info->xmit_buf) {               /* free Tx buffer */
-    free_page ((unsigned long)info->xmit_buf);
-    info->xmit_buf = 0;
-  }
+	if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
+		tmp = dz_in(info, DZ_TCR);
+		if (tmp & DZ_MODEM_DTR) {
+			tmp &= ~DZ_MODEM_DTR;
+			dz_out(info, DZ_TCR, tmp);
+		}
+	}
 
-  if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
-    tmp = dz_in (info, DZ_TCR);
-    if (tmp & DZ_MODEM_DTR) {
-      tmp &= ~DZ_MODEM_DTR;
-      dz_out (info, DZ_TCR, tmp);
-    }
-  }
+	if (info->tty)
+		set_bit (TTY_IO_ERROR, &info->tty->flags);
 
-  if (info->tty) set_bit (TTY_IO_ERROR, &info->tty->flags);
+	info->is_initialized = 0;
 
-  info->is_initialized = 0;
-  restore_flags (flags);
+	restore_flags (flags);
 }
 
 /* 
@@ -554,65 +555,104 @@
  */
 static void change_speed (struct dz_serial *info)
 {
-  unsigned long flags;
-  unsigned cflag;
-  int baud;
+	unsigned long flags;
+	unsigned cflag;
+	int baud;
 
-  if (!info->tty || !info->tty->termios) return;
+	if (!info->tty || !info->tty->termios)
+		return;
   
-  save_flags (flags);
-  cli ();
+	save_and_cli(flags);
   
-  info->cflags = info->line;
+	info->cflags = info->line;
 
-  cflag = info->tty->termios->c_cflag;
+	cflag = info->tty->termios->c_cflag;
 
-  switch (cflag & CSIZE) {
-  case CS5: info->cflags |= DZ_CS5; break;
-  case CS6: info->cflags |= DZ_CS6; break;
-  case CS7: info->cflags |= DZ_CS7; break;
-  case CS8: 
-  default:  info->cflags |= DZ_CS8;
-  }
-
-  if (cflag & CSTOPB) info->cflags |= DZ_CSTOPB;
-  if (cflag & PARENB) info->cflags |= DZ_PARENB;
-  if (cflag & PARODD) info->cflags |= DZ_PARODD;
+	switch (cflag & CSIZE) {
+		case CS5:
+			info->cflags |= DZ_CS5;
+			break;
+		case CS6:
+			info->cflags |= DZ_CS6;
+			break;
+		case CS7:
+			info->cflags |= DZ_CS7;
+			break;
+		case CS8: 
+		default:
+			info->cflags |= DZ_CS8;
+	}
+
+	if (cflag & CSTOPB)
+		info->cflags |= DZ_CSTOPB;
+	if (cflag & PARENB)
+		info->cflags |= DZ_PARENB;
+	if (cflag & PARODD)
+		info->cflags |= DZ_PARODD;
   
-  baud = tty_get_baud_rate (info->tty);
-  switch (baud) {
-  case 50  :  info->cflags |= DZ_B50;   break;
-  case 75  :  info->cflags |= DZ_B75;   break;
-  case 110 :  info->cflags |= DZ_B110;  break;
-  case 134 :  info->cflags |= DZ_B134;  break; 
-  case 150 :  info->cflags |= DZ_B150;  break;
-  case 300 :  info->cflags |= DZ_B300;  break; 
-  case 600 :  info->cflags |= DZ_B600;  break;
-  case 1200:  info->cflags |= DZ_B1200; break; 
-  case 1800:  info->cflags |= DZ_B1800; break;
-  case 2000:  info->cflags |= DZ_B2000; break;
-  case 2400:  info->cflags |= DZ_B2400; break;
-  case 3600:  info->cflags |= DZ_B3600; break; 
-  case 4800:  info->cflags |= DZ_B4800; break;
-  case 7200:  info->cflags |= DZ_B7200; break; 
-  case 9600: 
-  default  :  info->cflags |= DZ_B9600; 
-  }
-
-  info->cflags |= DZ_RXENAB;
-  dz_out (info, DZ_LPR, info->cflags);
-
-  /* setup accept flag */
-  info->read_status_mask = DZ_OERR;
-  if (I_INPCK(info->tty))
-   info->read_status_mask |= (DZ_FERR | DZ_PERR); 
+	baud = tty_get_baud_rate(info->tty);
+	switch (baud) {
+	case 50:
+		info->cflags |= DZ_B50;
+		break;
+	case 75:
+		info->cflags |= DZ_B75;
+		break;
+	case 110:
+		info->cflags |= DZ_B110;
+		break;
+	case 134:
+		info->cflags |= DZ_B134;
+		break; 
+	case 150:
+		info->cflags |= DZ_B150;
+		break;
+	case 300:
+		info->cflags |= DZ_B300;
+		break; 
+	case 600:
+		info->cflags |= DZ_B600;
+		break;
+	case 1200:
+		info->cflags |= DZ_B1200;
+		break; 
+	case 1800:
+		info->cflags |= DZ_B1800;
+		break;
+	case 2000:
+		info->cflags |= DZ_B2000;
+		break;
+	case 2400:
+		info->cflags |= DZ_B2400;
+		break;
+	case 3600:
+		info->cflags |= DZ_B3600;
+		break; 
+	case 4800:
+		info->cflags |= DZ_B4800;
+		break;
+	case 7200:
+		info->cflags |= DZ_B7200;
+		break; 
+	case 9600: 
+	default:
+		info->cflags |= DZ_B9600; 
+	}
+
+	info->cflags |= DZ_RXENAB;
+	dz_out(info, DZ_LPR, info->cflags);
+
+	/* setup accept flag */
+	info->read_status_mask = DZ_OERR;
+	if (I_INPCK(info->tty))
+		info->read_status_mask |= (DZ_FERR | DZ_PERR); 
   
-  /* characters to ignore */
-  info->ignore_status_mask = 0;
-  if (I_IGNPAR(info->tty))
-    info->ignore_status_mask |= (DZ_FERR | DZ_PERR);
+	/* characters to ignore */
+	info->ignore_status_mask = 0;
+	if (I_IGNPAR(info->tty))
+		info->ignore_status_mask |= (DZ_FERR | DZ_PERR);
 
-  restore_flags (flags);
+	restore_flags(flags);
 }
 
 /* 
@@ -624,18 +664,16 @@
  */
 static void dz_flush_chars (struct tty_struct *tty)
 {
-  struct dz_serial *info = (struct dz_serial *)tty->driver_data;
-  unsigned long flags;
-
- if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || !info->xmit_buf)
-    return;
+	struct dz_serial *info = (struct dz_serial *)tty->driver_data;
+	unsigned long flags;
 
- save_flags (flags);
- cli ();  
-
- dz_start (info->tty);
-
- restore_flags (flags);
+	if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
+	    !info->xmit_buf)
+		return;
+
+	save_and_cli(flags);
+	dz_start (info->tty);
+	restore_flags(flags);
 }
 
 
@@ -646,83 +684,81 @@
  * main output routine.
  * ------------------------------------------------------------------- 
  */
-static int dz_write (struct tty_struct *tty, int from_user, const unsigned char *buf, int count)
+static int dz_write (struct tty_struct *tty, int from_user,
+                     const unsigned char *buf, int count)
 {
-  struct dz_serial *info = (struct dz_serial *)tty->driver_data;
-  unsigned long flags;
-  int c, ret = 0;
-
-  if (!tty ) return ret;
-  if (!info->xmit_buf) return ret;
-  if (!tmp_buf) tmp_buf = tmp_buffer;
-
-
-
-  if (from_user) {
-
-    down (&tmp_buf_sem);
-    while (1) {
-      c = MIN(count, MIN(DZ_XMIT_SIZE - info->xmit_cnt - 1, DZ_XMIT_SIZE - info->xmit_head));
-      if (c <= 0) break;
-
-      c -= copy_from_user (tmp_buf, buf, c);
-      if (!c) {
-        if (!ret) ret = -EFAULT;
-        break;
-      }
-
-      save_flags (flags);
-      cli ();
-
-      c = MIN(c, MIN(DZ_XMIT_SIZE - info->xmit_cnt - 1, DZ_XMIT_SIZE - info->xmit_head));
-      memcpy(info->xmit_buf + info->xmit_head, tmp_buf, c);
-      info->xmit_head = ((info->xmit_head + c) & (DZ_XMIT_SIZE-1));
-      info->xmit_cnt += c;
-
-      restore_flags(flags);
-
-      buf += c;
-      count -= c;
-      ret += c;
-    }
-    
-    up (&tmp_buf_sem);
-  } else {
-
+	struct dz_serial *info = (struct dz_serial *)tty->driver_data;
+	unsigned long flags;
+	int c, ret = 0;
+
+	if (!tty )
+		return ret;
+	if (!info->xmit_buf)
+		return ret;
+	if (!tmp_buf)
+		tmp_buf = tmp_buffer;
+
+	if (from_user) {
+		down (&tmp_buf_sem);
+		while (1) {
+			c = MIN(count, MIN(DZ_XMIT_SIZE - info->xmit_cnt - 1,
+			                   DZ_XMIT_SIZE - info->xmit_head));
+			if (c <= 0)
+				break;
+
+			c -= copy_from_user (tmp_buf, buf, c);
+			if (!c) {
+				if (!ret)
+					ret = -EFAULT;
+				break;
+			}
+
+			save_and_cli(flags);
+
+			c = MIN(c, MIN(DZ_XMIT_SIZE - info->xmit_cnt - 1,
+			               DZ_XMIT_SIZE - info->xmit_head));
+			memcpy(info->xmit_buf + info->xmit_head, tmp_buf, c);
+			info->xmit_head = ((info->xmit_head + c) &
+					   (DZ_XMIT_SIZE - 1));
+			info->xmit_cnt += c;
+			restore_flags(flags);
+
+			buf += c;
+			count -= c;
+			ret += c;
+		}
+		up(&tmp_buf_sem);
+	} else {
+		while (1) {
+			save_and_cli(flags);
+
+			c = MIN(count, MIN(DZ_XMIT_SIZE - info->xmit_cnt - 1,
+			                   DZ_XMIT_SIZE - info->xmit_head));
+			if (c <= 0) {
+				restore_flags (flags);
+				break;
+			}
+			memcpy(info->xmit_buf + info->xmit_head, buf, c);
+			info->xmit_head = ((info->xmit_head + c) &
+			                   (DZ_XMIT_SIZE-1));
+			info->xmit_cnt += c;
+			restore_flags(flags);
+
+			buf += c;
+			count -= c;
+			ret += c;
+		}
+	}
 
-    while (1) {
-      save_flags (flags);
-      cli ();     
-
-      c = MIN(count, MIN(DZ_XMIT_SIZE - info->xmit_cnt - 1, DZ_XMIT_SIZE - info->xmit_head));
-      if (c <= 0) {
-        restore_flags (flags);
-        break;
-      }
-      memcpy (info->xmit_buf + info->xmit_head, buf, c);
-      info->xmit_head = ((info->xmit_head + c) & (DZ_XMIT_SIZE-1));
-      info->xmit_cnt += c;
-
-      restore_flags (flags);
-
-      buf += c;
-      count -= c;
-      ret += c;
-    }
-  }
-
-
-  if (info->xmit_cnt)
-    {
-      if (!tty->stopped) 
-	{
-	  if (!tty->hw_stopped)
-	    {
-	      dz_start (info->tty);
-	    }
+	if (info->xmit_cnt) {
+		if (!tty->stopped) {
+			if (!tty->hw_stopped) {
+				dz_start (info->tty);
+			}
+		}
 	}
-    }
-  return ret;
+
+	return ret;
 }
 
 /* 
@@ -734,12 +770,14 @@
  */
 static int dz_write_room (struct tty_struct *tty)
 {
-  struct dz_serial *info = (struct dz_serial *)tty->driver_data;
-  int ret;
-                                
-  ret = DZ_XMIT_SIZE - info->xmit_cnt - 1;
-  if (ret < 0) ret = 0;
-  return ret;
+	struct dz_serial *info = (struct dz_serial *)tty->driver_data;
+	int ret;
+
+	ret = DZ_XMIT_SIZE - info->xmit_cnt - 1;
+	if (ret < 0)
+		ret = 0;
+
+	return ret;
 }
 
 /* 
@@ -751,9 +789,9 @@
  */
 static int dz_chars_in_buffer (struct tty_struct *tty)
 {
-  struct dz_serial *info = (struct dz_serial *)tty->driver_data;
+	struct dz_serial *info = (struct dz_serial *)tty->driver_data;
   
-  return info->xmit_cnt;
+	return info->xmit_cnt;
 }
 
 /* 
@@ -765,16 +803,17 @@
  */
 static void dz_flush_buffer (struct tty_struct *tty)
 {
-  struct dz_serial *info = (struct dz_serial *)tty->driver_data;
+	struct dz_serial *info = (struct dz_serial *)tty->driver_data;
                                 
-  cli ();
-  info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
-  sti ();
-
-  wake_up_interruptible (&tty->write_wait);
-
-  if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && tty->ldisc.write_wakeup)
-    (tty->ldisc.write_wakeup)(tty);
+	cli();
+	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
+	sti();
+
+	wake_up_interruptible (&tty->write_wait);
+
+	if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
+	     tty->ldisc.write_wakeup)
+		tty->ldisc.write_wakeup(tty);
 }
 
 /*
@@ -787,31 +826,32 @@
  */
 static void dz_throttle (struct tty_struct *tty)
 {
-  struct dz_serial *info = (struct dz_serial *)tty->driver_data;  
+	struct dz_serial *info = (struct dz_serial *)tty->driver_data;  
 
-  if (I_IXOFF(tty))
-    info->x_char = STOP_CHAR(tty);
+	if (I_IXOFF(tty))
+		info->x_char = STOP_CHAR(tty);
 }
 
 static void dz_unthrottle (struct tty_struct *tty)
 {
-  struct dz_serial *info = (struct dz_serial *)tty->driver_data;  
+	struct dz_serial *info = (struct dz_serial *)tty->driver_data;  
 
-  if (I_IXOFF(tty)) {
-    if (info->x_char)
-      info->x_char = 0;
-    else
-      info->x_char = START_CHAR(tty);
-  }
+	if (I_IXOFF(tty)) {
+		if (info->x_char)
+			info->x_char = 0;
+		else
+			info->x_char = START_CHAR(tty);
+	}
 }
 
 static void dz_send_xchar (struct tty_struct *tty, char ch)
 {
-  struct dz_serial *info = (struct dz_serial *)tty->driver_data;
+	struct dz_serial *info = (struct dz_serial *)tty->driver_data;
 
-  info->x_char = ch;
+	info->x_char = ch;
 
-  if (ch) dz_start (info->tty);
+	if (ch)
+		dz_start(info->tty);
 }
 
 /*
@@ -819,59 +859,62 @@
  * rs_ioctl () and friends
  * ------------------------------------------------------------
  */
-static int get_serial_info (struct dz_serial *info, struct serial_struct *retinfo)
+static int get_serial_info(struct dz_serial *info,
+                           struct serial_struct *retinfo)
 {
-  struct serial_struct tmp;
+	struct serial_struct tmp;
   
-  if (!retinfo)
-    return -EFAULT;
+	if (!retinfo)
+		return -EFAULT;
 
-  memset (&tmp, 0, sizeof(tmp));
+	memset (&tmp, 0, sizeof(tmp));
 
-  tmp.type = info->type;
-  tmp.line = info->line;
-  tmp.port = info->port;
-  tmp.irq = SERIAL;
-  tmp.flags = info->flags;
-  tmp.baud_base = info->baud_base;
-  tmp.close_delay = info->close_delay;
-  tmp.closing_wait = info->closing_wait;
-  
-  return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0;
+	tmp.type = info->type;
+	tmp.line = info->line;
+	tmp.port = info->port;
+	tmp.irq = SERIAL;
+	tmp.flags = info->flags;
+	tmp.baud_base = info->baud_base;
+	tmp.close_delay = info->close_delay;
+	tmp.closing_wait = info->closing_wait;
+
+	return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0;
 }
 
-static int set_serial_info (struct dz_serial *info, struct serial_struct *new_info)
+static int set_serial_info (struct dz_serial *info,
+                            struct serial_struct *new_info)
 {
-  struct serial_struct new_serial;
-  struct dz_serial old_info;
-  int retval = 0;
+	struct serial_struct new_serial;
+	struct dz_serial old_info;
+	int retval = 0;
 
-  if (!new_info)
-    return -EFAULT;
+	if (!new_info)
+		return -EFAULT;
 
-  if(copy_from_user (&new_serial, new_info, sizeof(new_serial)))
-    return -EFAULT;
-    
-  old_info = *info;
+	if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
+		return -EFAULT;
 
-  if (!capable(CAP_SYS_ADMIN))
-    return -EPERM;
+	old_info = *info;
 
-  if (info->count > 1)
-    return -EBUSY;
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
 
-  /*
-   * OK, past this point, all the error checking has been done.
-   * At this point, we start making changes.....
-   */
-  
-  info->baud_base = new_serial.baud_base;
-  info->type = new_serial.type;
-  info->close_delay = new_serial.close_delay;
-  info->closing_wait = new_serial.closing_wait;
+	if (info->count > 1)
+		return -EBUSY;
+
+	/*
+	 * OK, past this point, all the error checking has been done.
+	 * At this point, we start making changes.....
+	 */
 
-  retval = startup (info);
-  return retval;
+	info->baud_base = new_serial.baud_base;
+	info->type = new_serial.type;
+	info->close_delay = new_serial.close_delay;
+	info->closing_wait = new_serial.closing_wait;
+
+	retval = startup(info);
+
+	return retval;
 }
 
 /*
@@ -886,9 +929,9 @@
  */
 static int get_lsr_info (struct dz_serial *info, unsigned int *value)
 {
-  unsigned short status = dz_in (info, DZ_LPR);
+	unsigned short status = dz_in (info, DZ_LPR);
 
-  return put_user (status, value);
+	return put_user (status, value);
 }
 
 /*
@@ -896,106 +939,112 @@
  */
 static void send_break (struct dz_serial *info, int duration)
 {
-  unsigned long flags;
-  unsigned short tmp, mask;
-
-  if (!info->port)
-    return;
-
-  mask = 1 << info->line;
-  tmp = dz_in (info, DZ_TCR);
-  tmp |= mask;
+	unsigned long flags;
+	unsigned short tmp, mask;
 
-  current->state = TASK_INTERRUPTIBLE;
+	if (!info->port)
+		return;
 
-  save_flags (flags);
-  cli();
-  
-  dz_out (info, DZ_TCR, tmp);
-  
-  schedule_timeout(duration);
-  
-  tmp &= ~mask;
-  dz_out (info, DZ_TCR, tmp);
-  
-  restore_flags (flags);
-}
-
-static int dz_ioctl (struct tty_struct *tty, struct file *file,
-		     unsigned int cmd, unsigned long arg)
-{
-  struct dz_serial * info = (struct dz_serial *)tty->driver_data;
-  int retval;
+	mask = 1 << info->line;
+	tmp = dz_in (info, DZ_TCR);
+	tmp |= mask;
+
+	current->state = TASK_INTERRUPTIBLE;
+
+	save_and_cli(flags);
+	dz_out(info, DZ_TCR, tmp);
+	schedule_timeout(duration);
+	tmp &= ~mask;
+	dz_out(info, DZ_TCR, tmp);
+	restore_flags(flags);
+}
+
+static int dz_ioctl(struct tty_struct *tty, struct file *file,
+                    unsigned int cmd, unsigned long arg)
+{
+	int error;
+	struct dz_serial * info = (struct dz_serial *)tty->driver_data;
+	int retval;
+
+	if (cmd != TIOCGSERIAL && cmd != TIOCSSERIAL &&
+	    cmd != TIOCSERCONFIG && cmd != TIOCSERGWILD  &&
+	    cmd != TIOCSERSWILD && cmd != TIOCSERGSTRUCT) {
+		if (tty->flags & (1 << TTY_IO_ERROR))
+			return -EIO;
+	}
 
-  if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
-      (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGWILD)  &&
-      (cmd != TIOCSERSWILD) && (cmd != TIOCSERGSTRUCT)) {
-    if (tty->flags & (1 << TTY_IO_ERROR))
-      return -EIO;
-  }
-
-  switch (cmd) {
-  case TCSBRK:    /* SVID version: non-zero arg --> no break */
-    retval = tty_check_change (tty);
-    if (retval)
-      return retval;
-    tty_wait_until_sent (tty, 0);
-    if (!arg)
-      send_break (info, HZ/4); /* 1/4 second */
-    return 0;
-
-  case TCSBRKP:   /* support for POSIX tcsendbreak() */
-    retval = tty_check_change (tty);
-    if (retval)
-      return retval;
-    tty_wait_until_sent (tty, 0);
-    send_break (info, arg ? arg*(HZ/10) : HZ/4);
-    return 0;
-
-  case TIOCGSOFTCAR:
-    return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long *)arg);
-
-  case TIOCSSOFTCAR:
-    if (get_user (arg, (unsigned long *)arg))
-      return -EFAULT;
-    tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0));
-    return 0;
-
-  case TIOCGSERIAL:
-    return get_serial_info (info, (struct serial_struct *)arg);
-
-  case TIOCSSERIAL:
-    return set_serial_info (info, (struct serial_struct *) arg);
-
-  case TIOCSERGETLSR: /* Get line status register */
-    return get_lsr_info (info, (unsigned int *)arg);
-
-  case TIOCSERGSTRUCT:
-    return copy_to_user((struct dz_serial *)arg, info,
-		        sizeof(struct dz_serial)) ? -EFAULT : 0;
-    
-  default:
-    return -ENOIOCTLCMD;
-  }
+	switch (cmd) {
+	case TCSBRK:		/* SVID version: non-zero arg --> no break */
+		retval = tty_check_change(tty);
+		if (retval)
+			return retval;
+		tty_wait_until_sent(tty, 0);
+		if (!arg)
+			send_break(info, HZ/4); /* 1/4 second */
+		return 0;
+
+	case TCSBRKP:		/* support for POSIX tcsendbreak() */
+		retval = tty_check_change(tty);
+		if (retval)
+			return retval;
+		tty_wait_until_sent(tty, 0);
+		send_break(info, arg ? arg*(HZ/10) : HZ/4);
+		return 0;
+
+	case TIOCGSOFTCAR:
+		error = verify_area (VERIFY_WRITE, (void *)arg, sizeof(long));
+		if (error)
+			return error;
+		put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long *)arg);
+		return 0;
+
+	case TIOCSSOFTCAR:
+		if (get_user (arg, (unsigned long *)arg))
+			return -EFAULT;
+
+		tty->termios->c_cflag = (tty->termios->c_cflag & ~CLOCAL) |
+		                        (arg ? CLOCAL : 0);
+		return 0;
+
+	case TIOCGSERIAL:
+		error = verify_area(VERIFY_WRITE, (void *)arg,
+		                    sizeof(struct serial_struct));
+		if (error)
+			return error;
+		return get_serial_info(info, (struct serial_struct *)arg);
+
+	case TIOCSSERIAL:
+		return set_serial_info(info, (struct serial_struct *) arg);
+
+	case TIOCSERGETLSR:		/* Get line status register */
+		return get_lsr_info (info, (unsigned int *)arg);
+
+	case TIOCSERGSTRUCT:
+		return copy_to_user((struct dz_serial *)arg, info,
+		                    sizeof(struct dz_serial)) ? -EFAULT : 0;
+ 
+	default:
+		return -ENOIOCTLCMD;
+	}
 
-  return 0;
+	return 0;
 }
 
 static void dz_set_termios (struct tty_struct *tty,
 			    struct termios *old_termios)
 {
-  struct dz_serial *info = (struct dz_serial *)tty->driver_data;
+	struct dz_serial *info = (struct dz_serial *)tty->driver_data;
 
-  if (tty->termios->c_cflag == old_termios->c_cflag)
-    return;
+	if (tty->termios->c_cflag == old_termios->c_cflag)
+		return;
 
-  change_speed (info);
+	change_speed (info);
 
-  if ((old_termios->c_cflag & CRTSCTS) &&
-      !(tty->termios->c_cflag & CRTSCTS)) {
-    tty->hw_stopped = 0;
-    dz_start (tty);
-  }
+	if ((old_termios->c_cflag & CRTSCTS) &&
+	    !(tty->termios->c_cflag & CRTSCTS)) {
+		tty->hw_stopped = 0;
+		dz_start(tty);
+	}
 }
 
 /*
@@ -1007,97 +1056,95 @@
  * the transmit enable and receive enable flags.
  * ------------------------------------------------------------
  */
-static void dz_close (struct tty_struct *tty, struct file *filp)
+static void dz_close(struct tty_struct *tty, struct file *filp)
 {
-  struct dz_serial * info = (struct dz_serial *)tty->driver_data;
-  unsigned long flags;
+	struct dz_serial * info = (struct dz_serial *)tty->driver_data;
+	unsigned long flags;
 
-  if (!info) return;
-        
-  save_flags (flags); 
-  cli();
-        
-  if (tty_hung_up_p (filp)) {
-    restore_flags (flags);
-    return;
-  }
-
-  if ((tty->count == 1) && (info->count != 1)) {
-    /*
-     * Uh, oh.  tty->count is 1, which means that the tty
-     * structure will be freed.  Info->count should always
-     * be one in these conditions.  If it's greater than
-     * one, we've got real problems, since it means the
-     * serial port won't be shutdown.
-     */
-    printk("dz_close: bad serial port count; tty->count is 1, "
-                       "info->count is %d\n", info->count);
-                info->count = 1;
-  }
-
-  if (--info->count < 0) {
-    printk("ds_close: bad serial port count for ttys%d: %d\n",
-	   info->line, info->count);
-    info->count = 0;
-  }
-
-  if (info->count) {
-    restore_flags (flags);
-    return;
-  }
-  info->flags |= DZ_CLOSING;
-  /*
-   * Save the termios structure, since this port may have
-   * separate termios for callout and dialin.
-   */
-  if (info->flags & DZ_NORMAL_ACTIVE)
-    info->normal_termios = *tty->termios;
-  if (info->flags & DZ_CALLOUT_ACTIVE)
-    info->callout_termios = *tty->termios;
-  /*
-   * Now we wait for the transmit buffer to clear; and we notify 
-   * the line discipline to only process XON/XOFF characters.
-   */
-  tty->closing = 1;
-
-  if (info->closing_wait != DZ_CLOSING_WAIT_NONE)
-    tty_wait_until_sent (tty, info->closing_wait);
-
-  /*
-   * At this point we stop accepting input.  To do this, we
-   * disable the receive line status interrupts.
-   */
-
-  shutdown (info);
-
-  if (tty->driver.flush_buffer)
-    tty->driver.flush_buffer (tty);
-  if (tty->ldisc.flush_buffer)
-    tty->ldisc.flush_buffer (tty);
-  tty->closing = 0;
-  info->event = 0;
-  info->tty = 0;
-
-  if (tty->ldisc.num != ldiscs[N_TTY].num) {
-    if (tty->ldisc.close)
-      (tty->ldisc.close)(tty);
-    tty->ldisc = ldiscs[N_TTY];
-    tty->termios->c_line = N_TTY;
-    if (tty->ldisc.open)
-      (tty->ldisc.open)(tty);
-  }
-  if (info->blocked_open) {
-    if (info->close_delay) {
-      current->state = TASK_INTERRUPTIBLE;
-      schedule_timeout(info->close_delay);
-    }
-    wake_up_interruptible (&info->open_wait);
-  }
+	if (!info)
+		return;
+ 
+	save_and_cli(flags); 
+
+	if (tty_hung_up_p(filp)) {
+		restore_flags(flags);
+		return;
+	}
 
-  info->flags &= ~(DZ_NORMAL_ACTIVE | DZ_CALLOUT_ACTIVE | DZ_CLOSING);
-  wake_up_interruptible (&info->close_wait);
+	if ((tty->count == 1) && (info->count != 1)) {
+		/*
+		 * Uh, oh.  tty->count is 1, which means that the tty structure
+		 * will be freed.  Info->count should always be one in these
+		 * conditions.  If it's greater than one, we've got real
+		 * problems, since it means the serial port won't be shutdown.
+		 */
+		printk("dz_close: bad serial port count; tty->count is 1, "
+		       "info->count is %d\n", info->count);
+		info->count = 1;
+	}
 
-  restore_flags (flags);
+	if (--info->count < 0) {
+		printk("ds_close: bad serial port count for ttyS%02d: %d\n",
+		       info->line, info->count);
+		info->count = 0;
+	}
+
+	if (info->count) {
+		restore_flags(flags);
+		return;
+	}
+	info->flags |= DZ_CLOSING;
+	/*
+	 * Save the termios structure, since this port may have
+	 * separate termios for callout and dialin.
+	 */
+	if (info->flags & DZ_NORMAL_ACTIVE)
+		info->normal_termios = *tty->termios;
+	if (info->flags & DZ_CALLOUT_ACTIVE)
+		info->callout_termios = *tty->termios;
+	/*
+	 * Now we wait for the transmit buffer to clear; and we notify the line
+	 * discipline to only process XON/XOFF characters.
+	 */
+	tty->closing = 1;
+
+	if (info->closing_wait != DZ_CLOSING_WAIT_NONE)
+		tty_wait_until_sent(tty, info->closing_wait);
+
+	/*
+	 * At this point we stop accepting input.  To do this, we disable the
+	 * receive line status interrupts.
+	 */
+	shutdown(info);
+
+	if (tty->driver.flush_buffer)
+		tty->driver.flush_buffer (tty);
+	if (tty->ldisc.flush_buffer)
+		tty->ldisc.flush_buffer (tty);
+	tty->closing = 0;
+	info->event = 0;
+	info->tty = 0;
+
+	if (tty->ldisc.num != ldiscs[N_TTY].num) {
+		if (tty->ldisc.close)
+			tty->ldisc.close(tty);
+		tty->ldisc = ldiscs[N_TTY];
+		tty->termios->c_line = N_TTY;
+		if (tty->ldisc.open)
+			tty->ldisc.open(tty);
+	}
+	if (info->blocked_open) {
+		if (info->close_delay) {
+			current->state = TASK_INTERRUPTIBLE;
+			schedule_timeout(info->close_delay);
+		}
+		wake_up_interruptible(&info->open_wait);
+	}
+
+	info->flags &= ~(DZ_NORMAL_ACTIVE | DZ_CALLOUT_ACTIVE | DZ_CLOSING);
+	wake_up_interruptible(&info->close_wait);
+
+	restore_flags(flags);
 }
 
 /*
@@ -1105,15 +1152,15 @@
  */
 static void dz_hangup (struct tty_struct *tty)
 {
-  struct dz_serial *info = (struct dz_serial *)tty->driver_data;
+	struct dz_serial *info = (struct dz_serial *) tty->driver_data;
   
-  dz_flush_buffer (tty);
-  shutdown (info);
-  info->event = 0;
-  info->count = 0;
-  info->flags &= ~(DZ_NORMAL_ACTIVE | DZ_CALLOUT_ACTIVE);
-  info->tty = 0;
-  wake_up_interruptible (&info->open_wait);
+	dz_flush_buffer(tty);
+	shutdown(info);
+	info->event = 0;
+	info->count = 0;
+	info->flags &= ~(DZ_NORMAL_ACTIVE | DZ_CALLOUT_ACTIVE);
+	info->tty = 0;
+	wake_up_interruptible(&info->open_wait);
 }
 
 /*
@@ -1121,101 +1168,103 @@
  * rs_open() and friends
  * ------------------------------------------------------------
  */
-static int block_til_ready (struct tty_struct *tty, struct file *filp, struct dz_serial *info)
+static int block_til_ready(struct tty_struct *tty, struct file *filp,
+                           struct dz_serial *info)
 {
-  DECLARE_WAITQUEUE(wait, current); 
-  int retval;
-  int do_clocal = 0;
-
-  /*
-   * If the device is in the middle of being closed, then block
-   * until it's done, and then try again.
-   */
-  if (info->flags & DZ_CLOSING) {
-    interruptible_sleep_on (&info->close_wait);
-    return -EAGAIN;
-  }
-
-  /*
-   * If this is a callout device, then just make sure the normal
-   * device isn't being used.
-   */
-  if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
-    if (info->flags & DZ_NORMAL_ACTIVE)
-      return -EBUSY;
+	DECLARE_WAITQUEUE(wait, current); 
+	int retval;
+	int do_clocal = 0;
+
+	/*
+	 * If the device is in the middle of being closed, then block
+	 * until it's done, and then try again.
+	 */
+	if (info->flags & DZ_CLOSING) {
+		interruptible_sleep_on(&info->close_wait);
+		return -EAGAIN;
+	}
+
+	/*
+	 * If this is a callout device, then just make sure the normal
+	 * device isn't being used.
+	 */
+	if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+		if (info->flags & DZ_NORMAL_ACTIVE)
+			return -EBUSY;
     
-    if ((info->flags & DZ_CALLOUT_ACTIVE) &&
-	(info->flags & DZ_SESSION_LOCKOUT) &&
-	(info->session != current->session))
-      return -EBUSY;
+		if ((info->flags & DZ_CALLOUT_ACTIVE) &&
+		    (info->flags & DZ_SESSION_LOCKOUT) &&
+		    (info->session != current->session))
+			return -EBUSY;
     
-    if ((info->flags & DZ_CALLOUT_ACTIVE) &&
-	(info->flags & DZ_PGRP_LOCKOUT) &&
-	(info->pgrp != current->pgrp))
-      return -EBUSY;
-    info->flags |= DZ_CALLOUT_ACTIVE;
-    return 0;
-  }
-
-  /*
-   * If non-blocking mode is set, or the port is not enabled,
-   * then make the check up front and then exit.
-   */
-  if ((filp->f_flags & O_NONBLOCK) ||
-      (tty->flags & (1 << TTY_IO_ERROR))) {
-    if (info->flags & DZ_CALLOUT_ACTIVE)
-      return -EBUSY;
-    info->flags |= DZ_NORMAL_ACTIVE;
-    return 0;
-  }
-
-  if (info->flags & DZ_CALLOUT_ACTIVE) {
-    if (info->normal_termios.c_cflag & CLOCAL)
-      do_clocal = 1;
-  } else {
-    if (tty->termios->c_cflag & CLOCAL)
-      do_clocal = 1;
-  }
-
-  /*
-   * Block waiting for the carrier detect and the line to become
-   * free (i.e., not in use by the callout).  While we are in
-   * this loop, info->count is dropped by one, so that
-   * dz_close() knows when to free things.  We restore it upon
-   * exit, either normal or abnormal.
-   */
-  retval = 0;
-  add_wait_queue (&info->open_wait, &wait);
-
-  info->count--;
-  info->blocked_open++;
-  while (1) {
-    set_current_state(TASK_INTERRUPTIBLE);
-    if (tty_hung_up_p (filp) || !(info->is_initialized)) {
-      retval = -EAGAIN;
-      break;
-    }
-    if (!(info->flags & DZ_CALLOUT_ACTIVE) &&
-	!(info->flags & DZ_CLOSING) && do_clocal)
-      break;
-    if (signal_pending (current)) {
-      retval = -ERESTARTSYS;
-      break;
-    }
-    schedule();
-  }
+		if ((info->flags & DZ_CALLOUT_ACTIVE) &&
+		    (info->flags & DZ_PGRP_LOCKOUT) &&
+		    (info->pgrp != current->pgrp))
+			return -EBUSY;
+
+		info->flags |= DZ_CALLOUT_ACTIVE;
+		return 0;
+	}
+
+	/*
+	 * If non-blocking mode is set, or the port is not enabled, then make
+	 * the check up front and then exit.
+	 */
+	if ((filp->f_flags & O_NONBLOCK) ||
+	    (tty->flags & (1 << TTY_IO_ERROR))) {
+		if (info->flags & DZ_CALLOUT_ACTIVE)
+			return -EBUSY;
+		info->flags |= DZ_NORMAL_ACTIVE;
+
+		return 0;
+	}
+
+	if (info->flags & DZ_CALLOUT_ACTIVE) {
+		if (info->normal_termios.c_cflag & CLOCAL)
+			do_clocal = 1;
+	} else {
+		if (tty->termios->c_cflag & CLOCAL)
+		do_clocal = 1;
+	}
+
+	/*
+	 * Block waiting for the carrier detect and the line to become free
+	 * (i.e., not in use by the callout).  While we are in this loop,
+	 * info->count is dropped by one, so that dz_close() knows when to free
+	 * things.  We restore it upon exit, either normal or abnormal.
+	 */
+	retval = 0;
+	add_wait_queue(&info->open_wait, &wait);
+
+	info->count--;
+	info->blocked_open++;
+	while (1) {
+		set_current_state(TASK_INTERRUPTIBLE);
+		if (tty_hung_up_p (filp) || !(info->is_initialized)) {
+			retval = -EAGAIN;
+			break;
+		}
+		if (!(info->flags & DZ_CALLOUT_ACTIVE) &&
+		    !(info->flags & DZ_CLOSING) && do_clocal)
+			break;
+		if (signal_pending(current)) {
+			retval = -ERESTARTSYS;
+			break;
+		}
+		schedule();
+	}
 		
-  current->state = TASK_RUNNING;
-  remove_wait_queue (&info->open_wait, &wait);
-  if (!tty_hung_up_p(filp))
-    info->count++;
-  info->blocked_open--;
-
-  if (retval)
-    return retval;
-  info->flags |= DZ_NORMAL_ACTIVE;
-  return 0;
-}       
+	current->state = TASK_RUNNING;
+	remove_wait_queue (&info->open_wait, &wait);
+	if (!tty_hung_up_p(filp))
+		info->count++;
+	info->blocked_open--;
+
+	if (retval)
+		return retval;
+	info->flags |= DZ_NORMAL_ACTIVE;
+	return 0;
+}
 
 /*
  * This routine is called whenever a serial port is opened.  It
@@ -1224,201 +1273,220 @@
  */
 static int dz_open (struct tty_struct *tty, struct file *filp)
 {
-  struct dz_serial *info;
-  int retval, line;
-
-  line = MINOR(tty->device) - tty->driver.minor_start;
-
-  /* The dz lines for the mouse/keyboard must be
-   * opened using their respective drivers.
-   */
-  if ((line < 0) || (line >= DZ_NB_PORT))
-    return -ENODEV;
+	struct dz_serial *info;
+	int retval, line;
 
-  if ((line == DZ_KEYBOARD) || (line == DZ_MOUSE))
-    return -ENODEV;
+	line = MINOR(tty->device) - tty->driver.minor_start;
 
-  info = lines[line];
-  info->count++;
-
-  tty->driver_data = info;
-  info->tty = tty;
-
-  /*
-   * Start up serial port
-   */
-  retval = startup (info);
-  if (retval)
-    return retval;
+	/*
+	 * The dz lines for the mouse/keyboard must be opened using their
+	 * respective drivers.
+	 */
+	if ((line < 0) || (line >= DZ_NB_PORT))
+		return -ENODEV;
 
+	if ((line == DZ_KEYBOARD) || (line == DZ_MOUSE))
+		return -ENODEV;
 
+	info = lines[line];
+	info->count++;
 
-  retval = block_til_ready (tty, filp, info);
-  if (retval)
-    return retval;
+	tty->driver_data = info;
+	info->tty = tty;
 
-  if ((info->count == 1) && (info->flags & DZ_SPLIT_TERMIOS)) {
-    if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
-      *tty->termios = info->normal_termios;
-    else 
-      *tty->termios = info->callout_termios;
-    change_speed (info);
+	/*
+	 * Start up serial port
+	 */
+	retval = startup (info);
+	if (retval)
+		return retval;
+
+	retval = block_til_ready (tty, filp, info);
+	if (retval)
+		return retval;
+
+	if ((info->count == 1) && (info->flags & DZ_SPLIT_TERMIOS)) {
+		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+			*tty->termios = info->normal_termios;
+		else 
+			*tty->termios = info->callout_termios;
+		change_speed(info);
+	}
 
-  }
+	info->session = current->session;
+	info->pgrp = current->pgrp;
 
-  info->session = current->session;
-  info->pgrp = current->pgrp;
-  return 0;
+	return 0;
 }
 
 static void show_serial_version (void)
 {
-  printk("%s%s\n", dz_name, dz_version);
+	printk("%s%s\n", dz_name, dz_version);
 }
 
 
 int __init dz_init(void)
 {
-  int i;
-  unsigned long flags;
-  struct dz_serial *info;
-
-  /* Setup base handler, and timer table. */
-  init_bh (SERIAL_BH, do_serial_bh);
-
-  show_serial_version ();
-
-  memset(&serial_driver, 0, sizeof(struct tty_driver));
-  serial_driver.magic = TTY_DRIVER_MAGIC;
-  serial_driver.name = "ttyS";
-  serial_driver.major = TTY_MAJOR;
-  serial_driver.minor_start = 64;
-  serial_driver.num = DZ_NB_PORT;
-  serial_driver.type = TTY_DRIVER_TYPE_SERIAL;
-  serial_driver.subtype = SERIAL_TYPE_NORMAL;
-  serial_driver.init_termios = tty_std_termios;
-
-  serial_driver.init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
-  serial_driver.flags = TTY_DRIVER_REAL_RAW;
-  serial_driver.refcount = &serial_refcount;
-  serial_driver.table = serial_table;
-  serial_driver.termios = serial_termios;
-  serial_driver.termios_locked = serial_termios_locked;
-
-  serial_driver.open = dz_open;
-  serial_driver.close = dz_close;
-  serial_driver.write = dz_write;
-  serial_driver.flush_chars = dz_flush_chars;
-  serial_driver.write_room = dz_write_room;
-  serial_driver.chars_in_buffer = dz_chars_in_buffer;
-  serial_driver.flush_buffer = dz_flush_buffer;
-  serial_driver.ioctl = dz_ioctl;
-  serial_driver.throttle = dz_throttle;
-  serial_driver.unthrottle = dz_unthrottle;
-  serial_driver.send_xchar = dz_send_xchar;
-  serial_driver.set_termios = dz_set_termios;
-  serial_driver.stop = dz_stop;
-  serial_driver.start = dz_start;
-  serial_driver.hangup = dz_hangup;
-
-  /*
-   * The callout device is just like normal device except for
-   * major number and the subtype code.
-   */
-  callout_driver = serial_driver;
-  callout_driver.name = "cua";
-  callout_driver.major = TTYAUX_MAJOR;
-  callout_driver.subtype = SERIAL_TYPE_CALLOUT;
-
-  if (tty_register_driver (&serial_driver))
-    panic("Couldn't register serial driver\n");
-  if (tty_register_driver (&callout_driver))
-    panic("Couldn't register callout driver\n");
-  save_flags(flags); cli();
- 
-  for (i=0; i < DZ_NB_PORT;  i++)  
-    {
-      info = &multi[i]; 
-      lines[i] = info;
-    info->magic = SERIAL_MAGIC;
-
-      if ((mips_machtype == MACH_DS23100) || (mips_machtype == MACH_DS5100)) 
-      info->port = (unsigned long) KN01_DZ11_BASE;
-      else 
-      info->port = (unsigned long) KN02_DZ11_BASE;
-
-    info->line = i;
-    info->tty = 0;
-    info->close_delay = 50;
-    info->closing_wait = 3000;
-    info->x_char = 0;
-    info->event = 0;
-    info->count = 0;
-    info->blocked_open = 0;
-    info->tqueue.routine = do_softint;
-    info->tqueue.data = info;
-    info->tqueue_hangup.routine = do_serial_hangup;
-    info->tqueue_hangup.data = info;
-    info->callout_termios = callout_driver.init_termios;
-    info->normal_termios = serial_driver.init_termios;
-    init_waitqueue_head(&info->open_wait); 
-    init_waitqueue_head(&info->close_wait); 
-
-    /* If we are pointing to address zero then punt - not correctly
-       set up in setup.c to handle this. */
-    if (! info->port)
-      return 0;
+	int i, flags;
+	struct dz_serial *info;
 
-    printk("ttyS%02d at 0x%04x (irq = %d)\n", info->line, info->port, SERIAL);
-  }
+	/* Setup base handler, and timer table. */
+	init_bh(SERIAL_BH, do_serial_bh);
 
-  /* reset the chip */
+	show_serial_version();
+
+	memset(&serial_driver, 0, sizeof(struct tty_driver));
+	serial_driver.magic = TTY_DRIVER_MAGIC;
+#if (LINUX_VERSION_CODE > 0x2032D && defined(CONFIG_DEVFS_FS))
+	serial_driver.name = "ttyS";
+#else
+	serial_driver.name = "tts/%d";
+#endif
+	serial_driver.major = TTY_MAJOR;
+	serial_driver.minor_start = 64;
+	serial_driver.num = DZ_NB_PORT;
+	serial_driver.type = TTY_DRIVER_TYPE_SERIAL;
+	serial_driver.subtype = SERIAL_TYPE_NORMAL;
+	serial_driver.init_termios = tty_std_termios;
+
+	serial_driver.init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL |
+	                                     CLOCAL;
+	serial_driver.flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS;
+	serial_driver.refcount = &serial_refcount;
+	serial_driver.table = serial_table;
+	serial_driver.termios = serial_termios;
+	serial_driver.termios_locked = serial_termios_locked;
+
+	serial_driver.open = dz_open;
+	serial_driver.close = dz_close;
+	serial_driver.write = dz_write;
+	serial_driver.flush_chars = dz_flush_chars;
+	serial_driver.write_room = dz_write_room;
+	serial_driver.chars_in_buffer = dz_chars_in_buffer;
+	serial_driver.flush_buffer = dz_flush_buffer;
+	serial_driver.ioctl = dz_ioctl;
+	serial_driver.throttle = dz_throttle;
+	serial_driver.unthrottle = dz_unthrottle;
+	serial_driver.send_xchar = dz_send_xchar;
+	serial_driver.set_termios = dz_set_termios;
+	serial_driver.stop = dz_stop;
+	serial_driver.start = dz_start;
+	serial_driver.hangup = dz_hangup;
+
+	/*
+	 * The callout device is just like normal device except for major
+	 * number and the subtype code.
+	 */
+	callout_driver = serial_driver;
+#if (LINUX_VERSION_CODE > 0x2032D && defined(CONFIG_DEVFS_FS))
+	callout_driver.name = "cua";
+#else
+	callout_driver.name = "cua/%d";
+#endif
+	callout_driver.major = TTYAUX_MAJOR;
+	callout_driver.subtype = SERIAL_TYPE_CALLOUT;
+
+	if (tty_register_driver (&serial_driver))
+		panic("Couldn't register serial driver\n");
+	if (tty_register_driver (&callout_driver))
+		panic("Couldn't register callout driver\n");
+
+	save_flags(flags); cli();
+	for (i=0; i < DZ_NB_PORT;  i++) {
+		info = &multi[i]; 
+		lines[i] = info;
+		info->magic = SERIAL_MAGIC;
+
+		if ((mips_machtype == MACH_DS23100) ||
+		    (mips_machtype == MACH_DS5100)) 
+			info->port = (unsigned long) KN01_DZ11_BASE;
+		else 
+			info->port = (unsigned long) KN02_DZ11_BASE;
+
+		info->line = i;
+		info->tty = 0;
+		info->close_delay = 50;
+		info->closing_wait = 3000;
+		info->x_char = 0;
+		info->event = 0;
+		info->count = 0;
+		info->blocked_open = 0;
+		info->tqueue.routine = do_softint;
+		info->tqueue.data = info;
+		info->tqueue_hangup.routine = do_serial_hangup;
+		info->tqueue_hangup.data = info;
+		info->callout_termios = callout_driver.init_termios;
+		info->normal_termios = serial_driver.init_termios;
+		init_waitqueue_head(&info->open_wait); 
+		init_waitqueue_head(&info->close_wait); 
+
+		/*
+		 * If we are pointing to address zero then punt - not correctly
+		 * set up in setup.c to handle this.
+		 */
+		if (! info->port)
+			return 0;
+
+		printk("ttyS%02d at 0x%08x (irq = %d)\n", info->line,
+		       info->port, SERIAL);
+
+		tty_register_devfs(&serial_driver, 0,
+		                   serial_driver.minor_start + info->line);
+		tty_register_devfs(&callout_driver, 0,
+		                   callout_driver.minor_start + info->line);
+	}
+
+	/* Reset the chip */
 #ifndef CONFIG_SERIAL_CONSOLE
-  dz_out(info, DZ_CSR, DZ_CLR);
-  while ((tmp = dz_in(info,DZ_CSR)) & DZ_CLR) ;
-  wbflush();
+	{
+		int tmp;
+		dz_out(info, DZ_CSR, DZ_CLR);
+		while ((tmp = dz_in(info,DZ_CSR)) & DZ_CLR);
+		wbflush();
   
-  /* enable scanning */
-   dz_out(info, DZ_CSR, DZ_MSE); 
+		/* Enable scanning */
+		dz_out(info, DZ_CSR, DZ_MSE); 
+	}
 #endif
   
-  /* order matters here... the trick is that flags
-     is updated... in request_irq - to immediatedly obliterate
-     it is unwise. */
-  restore_flags(flags);
- 
+	/*
+	 * Order matters here... the trick is that flags is updated... in
+	 * request_irq - to immediatedly obliterate it is unwise.
+	 */
+	restore_flags(flags);
 
-  if (request_irq (SERIAL, dz_interrupt, SA_INTERRUPT, "DZ", lines[0]))
-    panic ("Unable to register DZ interrupt\n");
+	if (request_irq(SERIAL, dz_interrupt, SA_INTERRUPT, "DZ", lines[0]))
+		panic("Unable to register DZ interrupt\n");
  
-  return 0;
+	return 0;
 }
 
 #ifdef CONFIG_SERIAL_CONSOLE
 static void dz_console_put_char (unsigned char ch)
 {
-  unsigned long flags;
-  int  loops = 2500;
-  unsigned short tmp = ch;
-  /* this code sends stuff out to serial device - spinning its
-      wheels and waiting. */
+	unsigned long flags;
+	int  loops = 2500;
+	unsigned short tmp = ch;
+	/*
+	 * this code sends stuff out to serial device - spinning its wheels and
+	 * waiting.
+	 */
 
-  /* force the issue - point it at lines[3]*/
-  dz_console=&multi[CONSOLE_LINE];
+	/* force the issue - point it at lines[3]*/
+	dz_console = &multi[CONSOLE_LINE];
 
-  save_flags(flags);
-  cli();
-  
+	save_and_cli(flags);
 
-  /* spin our wheels */
-  while (((dz_in(dz_console,DZ_CSR) & DZ_TRDY) != DZ_TRDY) &&  loops--)
-    ;
+	/* spin our wheels */
+	while (((dz_in(dz_console, DZ_CSR) & DZ_TRDY) != DZ_TRDY) &&  loops--)
+		;
   
-  /* Actually transmit the character. */
-  dz_out (dz_console, DZ_TDR, tmp);
+	/* Actually transmit the character. */
+	dz_out(dz_console, DZ_TDR, tmp);
 
-  restore_flags(flags); 
+	restore_flags(flags); 
 }
+
 /* 
  * -------------------------------------------------------------------
  * dz_console_print ()
@@ -1432,19 +1500,18 @@
 			      unsigned int count)
 {
 #ifdef DEBUG_DZ
-  prom_printf((char *)str);
+	prom_printf((char *)str);
 #endif
-  while (count--) 
-    {
-    if (*str == '\n')
-	dz_console_put_char ('\r');
-      dz_console_put_char (*str++);
-  }
+	while (count--) {
+		if (*str == '\n')
+			dz_console_put_char('\r');
+		dz_console_put_char(*str++);
+	}
 }
 
 static int dz_console_wait_key(struct console *co)
 {
-    return 0;
+	return 0;
 }
 
 static kdev_t dz_console_device(struct console *c)
@@ -1454,17 +1521,17 @@
 
 static int __init dz_console_setup(struct console *co, char *options)
 {
-  	int	baud = 9600;
-	int	bits = 8;
-	int	parity = 'n';
-	int	cflag = CREAD | HUPCL | CLOCAL;
-	char	*s;
+	int baud = 9600;
+	int bits = 8;
+	int parity = 'n';
+	int cflag = CREAD | HUPCL | CLOCAL;
+	char *s;
 	unsigned short mask,tmp;
 
 	if (options) {
 		baud = simple_strtoul(options, NULL, 10);
 		s = options;
-		while(*s >= '0' && *s <= '9')
+		while (*s >= '0' && *s <= '9')
 			s++;
 		if (*s)
 			parity = *s++;
@@ -1473,9 +1540,9 @@
 	}
 
 	/*
-	 *	Now construct a cflag setting.
+	 * Now construct a cflag setting.
 	 */
-	switch(baud) {
+	switch (baud) {
 	case 1200:
 		cflag |= DZ_B1200;
 		break;
@@ -1490,7 +1557,7 @@
 		cflag |= DZ_B9600;
 		break;
 	}
-	switch(bits) {
+	switch (bits) {
 	case 7:
 		cflag |= DZ_CS7;
 		break;
@@ -1499,11 +1566,13 @@
 		cflag |= DZ_CS8;
 		break;
 	}
-	switch(parity) {
-	case 'o': case 'O':
+	switch (parity) {
+	case 'o':
+	case 'O':
 		cflag |= DZ_PARODD;
 		break;
-	case 'e': case 'E':
+	case 'e':
+	case 'E':
 		cflag |= DZ_PARENB;
 		break;
 	}
@@ -1511,45 +1580,44 @@
 
 	/* TOFIX: force to console line */
 	dz_console = &multi[CONSOLE_LINE];
-    	if ((mips_machtype == MACH_DS23100) || (mips_machtype == MACH_DS5100)) 
-	dz_console->port = KN01_DZ11_BASE;
-       	else 
-       		dz_console->port = KN02_DZ11_BASE; 
+	if ((mips_machtype == MACH_DS23100) || (mips_machtype == MACH_DS5100)) 
+		dz_console->port = KN01_DZ11_BASE;
+	else 
+		dz_console->port = KN02_DZ11_BASE; 
 	dz_console->line = CONSOLE_LINE;
 
 	dz_out(dz_console, DZ_CSR, DZ_CLR);
 	while ((tmp = dz_in(dz_console,DZ_CSR)) & DZ_CLR)
-	  ;
+		;
 
 	/* enable scanning */
 	dz_out(dz_console, DZ_CSR, DZ_MSE); 
 
-        /*  Set up flags... */
+	/*  Set up flags... */
 	dz_console->cflags = 0;
 	dz_console->cflags |= DZ_B9600;
 	dz_console->cflags |= DZ_CS8;
 	dz_console->cflags |= DZ_PARENB;
-	dz_out (dz_console, DZ_LPR, dz_console->cflags);
+	dz_out(dz_console, DZ_LPR, dz_console->cflags);
 
 	mask = 1 << dz_console->line;
-	tmp = dz_in (dz_console, DZ_TCR);       /* read the TX flag */
+	tmp = dz_in (dz_console, DZ_TCR);		/* read the TX flag */
 	if (!(tmp & mask)) {
-	  tmp |= mask;                   /* set the TX flag */
-	  dz_out (dz_console, DZ_TCR, tmp); 
+		tmp |= mask;				/* set the TX flag */
+		dz_out (dz_console, DZ_TCR, tmp); 
 	}
-	
 
 	return 0;
 }
 
 static struct console dz_sercons = {
-	name:		"ttyS",
-	write:		dz_console_print,
-	device:		dz_console_device,
-	wait_key:	dz_console_wait_key,
-	setup:		dz_console_setup,
-	flags:		CON_CONSDEV | CON_PRINTBUFFER,
-	index:		CONSOLE_LINE,
+    name:	"ttyS",
+    write:	dz_console_print,
+    device:	dz_console_device,
+    wait_key:	dz_console_wait_key,
+    setup:	dz_console_setup,
+    flags:	CON_CONSDEV | CON_PRINTBUFFER,
+    index:	CONSOLE_LINE,
 };
 
 void __init dz_serial_console_init(void)
@@ -1559,3 +1627,4 @@
 
 #endif /* ifdef CONFIG_SERIAL_CONSOLE */
 
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/ec3104_keyb.c linux/drivers/char/ec3104_keyb.c
--- v2.4.9/linux/drivers/char/ec3104_keyb.c	Fri Apr 13 20:31:32 2001
+++ linux/drivers/char/ec3104_keyb.c	Thu Sep 13 15:21:32 2001
@@ -40,7 +40,7 @@
 #include <linux/random.h>
 #include <linux/poll.h>
 #include <linux/miscdevice.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
 #include <linux/kbd_kern.h>
 #include <linux/smp_lock.h>
 
diff -u --recursive --new-file v2.4.9/linux/drivers/char/efirtc.c linux/drivers/char/efirtc.c
--- v2.4.9/linux/drivers/char/efirtc.c	Mon Sep 18 14:57:01 2000
+++ linux/drivers/char/efirtc.c	Thu Sep 13 15:21:32 2001
@@ -403,3 +403,5 @@
 
 module_init(efi_rtc_init);
 module_exit(efi_rtc_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/epca.c linux/drivers/char/epca.c
--- v2.4.9/linux/drivers/char/epca.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/char/epca.c	Sun Sep  9 10:43:02 2001
@@ -610,9 +610,7 @@
 		                      ASYNC_CALLOUT_ACTIVE | ASYNC_CLOSING);
 		wake_up_interruptible(&ch->close_wait);
 
-#ifdef MODULE
 		MOD_DEC_USE_COUNT;
-#endif
 
 		restore_flags(flags);
 
@@ -700,10 +698,8 @@
 
 		shutdown(ch);
 
-#ifdef MODULE
 		if (ch->count)
 			MOD_DEC_USE_COUNT;
-#endif /* MODULE */
 		
 
 		ch->tty   = NULL;
@@ -1397,12 +1393,9 @@
 		return(-ENODEV);
 	}
 
-#ifdef MODULE
 
 	MOD_INC_USE_COUNT;
 
-#endif
-
 	ch = &digi_channels[line];
 	boardnum = ch->boardnum;
 
@@ -4106,3 +4099,5 @@
 } /* End init_PCI */
 
 #endif /* ENABLE_PCI */
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/esp.c linux/drivers/char/esp.c
--- v2.4.9/linux/drivers/char/esp.c	Wed Jul 25 17:10:19 2001
+++ linux/drivers/char/esp.c	Thu Sep 13 15:21:32 2001
@@ -83,6 +83,8 @@
 static unsigned int rx_timeout = ESP_RX_TMOUT;
 static unsigned int pio_threshold = ESP_PIO_THRESHOLD;
 
+MODULE_LICENSE("GPL");
+
 MODULE_PARM(irq, "1-8i");
 MODULE_PARM(divisor, "1-8i");
 MODULE_PARM(dma, "i");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/ftape/compressor/zftape-compress.c linux/drivers/char/ftape/compressor/zftape-compress.c
--- v2.4.9/linux/drivers/char/ftape/compressor/zftape-compress.c	Tue Nov 23 10:29:15 1999
+++ linux/drivers/char/ftape/compressor/zftape-compress.c	Thu Sep 13 15:21:32 2001
@@ -1258,14 +1258,13 @@
 	TRACE_EXIT 0;
 }
 
-
 #ifdef MODULE
-#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,18)
+
 MODULE_AUTHOR(
 	"(c) 1996, 1997 Claus-Justus Heine (claus@momo.math.rwth-aachen.de");
 MODULE_DESCRIPTION(
 "Compression routines for zftape. Uses the lzrw3 algorithm by Ross Williams");
-#endif
+MODULE_LICENSE("GPL");
 
 #if LINUX_VERSION_CODE >= KERNEL_VER(2,1,18)
 static int can_unload(void)
diff -u --recursive --new-file v2.4.9/linux/drivers/char/ftape/lowlevel/ftape-init.c linux/drivers/char/ftape/lowlevel/ftape-init.c
--- v2.4.9/linux/drivers/char/ftape/lowlevel/ftape-init.c	Tue Nov 23 10:29:15 1999
+++ linux/drivers/char/ftape/lowlevel/ftape-init.c	Thu Sep 13 15:21:32 2001
@@ -153,6 +153,7 @@
 	"(c) 1996, 1997 Claus-Justus Heine (claus@momo.math.rwth-aachen.de)");
 MODULE_DESCRIPTION(
 	"QIC-117 driver for QIC-40/80/3010/3020 floppy tape drives.");
+MODULE_LICENSE("GPL");
 #endif
 
 /*  Called by modules package when installing the driver
diff -u --recursive --new-file v2.4.9/linux/drivers/char/ftape/zftape/zftape-init.c linux/drivers/char/ftape/zftape/zftape-init.c
--- v2.4.9/linux/drivers/char/ftape/zftape/zftape-init.c	Fri Feb  9 11:30:22 2001
+++ linux/drivers/char/ftape/zftape/zftape-init.c	Thu Sep 13 15:21:32 2001
@@ -59,6 +59,7 @@
 		   "Support for QIC-113 compatible volume table "
 		   "and builtin compression (lzrw3 algorithm)");
 MODULE_SUPPORTED_DEVICE("char-major-27");
+MODULE_LICENSE("GPL");
 
 /*      Global vars.
  */
diff -u --recursive --new-file v2.4.9/linux/drivers/char/generic_serial.c linux/drivers/char/generic_serial.c
--- v2.4.9/linux/drivers/char/generic_serial.c	Wed Jul 25 17:10:19 2001
+++ linux/drivers/char/generic_serial.c	Thu Sep 13 15:21:32 2001
@@ -1088,3 +1088,5 @@
 EXPORT_SYMBOL(gs_setserial);
 EXPORT_SYMBOL(gs_getserial);
 EXPORT_SYMBOL(gs_got_break);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/h8.c linux/drivers/char/h8.c
--- v2.4.9/linux/drivers/char/h8.c	Wed Jul 25 17:10:19 2001
+++ linux/drivers/char/h8.c	Thu Sep 13 15:21:32 2001
@@ -1176,3 +1176,6 @@
 	h8_event_mask &= (~mask);
 	restore_flags(flags);
 }
+
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/hp600_keyb.c linux/drivers/char/hp600_keyb.c
--- v2.4.9/linux/drivers/char/hp600_keyb.c	Wed Apr 11 21:24:52 2001
+++ linux/drivers/char/hp600_keyb.c	Thu Sep 13 15:21:32 2001
@@ -336,3 +336,4 @@
 #endif
 
 
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/i810-tco.c linux/drivers/char/i810-tco.c
--- v2.4.9/linux/drivers/char/i810-tco.c	Wed Jul 25 17:10:19 2001
+++ linux/drivers/char/i810-tco.c	Thu Sep 13 15:21:32 2001
@@ -363,3 +363,5 @@
 
 module_init(watchdog_init);
 module_exit(watchdog_cleanup);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/ip2.c linux/drivers/char/ip2.c
--- v2.4.9/linux/drivers/char/ip2.c	Thu Apr 12 12:16:35 2001
+++ linux/drivers/char/ip2.c	Thu Sep 13 15:21:32 2001
@@ -71,6 +71,8 @@
 {
 }
 
+MODULE_LICENSE("GPL");
+
 #else	// !MODULE 
 
 #ifndef NULL
diff -u --recursive --new-file v2.4.9/linux/drivers/char/ip2main.c linux/drivers/char/ip2main.c
--- v2.4.9/linux/drivers/char/ip2main.c	Fri Feb 16 16:02:35 2001
+++ linux/drivers/char/ip2main.c	Thu Sep 13 15:21:32 2001
@@ -418,6 +418,7 @@
 	rirqs[iindx++] = irq;
 }
 
+#ifdef MODULE
 static int __init
 clear_requested_irq( char irq )
 {
@@ -430,6 +431,7 @@
 	}
 	return 0;
 }
+#endif
 
 static int __init
 have_requested_irq( char irq )
diff -u --recursive --new-file v2.4.9/linux/drivers/char/isicom.c linux/drivers/char/isicom.c
--- v2.4.9/linux/drivers/char/isicom.c	Fri Apr  6 10:42:55 2001
+++ linux/drivers/char/isicom.c	Thu Sep 13 15:21:32 2001
@@ -1927,6 +1927,7 @@
 
 MODULE_AUTHOR("MultiTech");
 MODULE_DESCRIPTION("Driver for the ISI series of cards by MultiTech");
+MODULE_LICENSE("GPL");
 MODULE_PARM(io, "1-4i");
 MODULE_PARM_DESC(io, "I/O ports for the cards");
 MODULE_PARM(irq, "1-4i");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/ite_gpio.c linux/drivers/char/ite_gpio.c
--- v2.4.9/linux/drivers/char/ite_gpio.c	Wed Dec 31 16:00:00 1969
+++ linux/drivers/char/ite_gpio.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,430 @@
+/*
+ * FILE NAME ite_gpio.c
+ *
+ * BRIEF MODULE DESCRIPTION
+ *  API for ITE GPIO device.
+ *  Driver for ITE GPIO device.
+ *
+ *  Author: MontaVista Software, Inc.  <source@mvista.com>
+ *          Hai-Pao Fan <haipao@mvista.com>
+ *
+ * Copyright 2001 MontaVista Software Inc.
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE	LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/miscdevice.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <asm/uaccess.h>
+#include <asm/addrspace.h>
+#include <asm/it8172/it8172_int.h>
+#include <linux/sched.h>
+#include <linux/ite_gpio.h>
+
+#define ite_gpio_base 0x14013800
+
+#define	ITE_GPADR	(*(volatile __u8 *)(0x14013800 + KSEG1))
+#define	ITE_GPBDR	(*(volatile __u8 *)(0x14013808 + KSEG1))
+#define	ITE_GPCDR	(*(volatile __u8 *)(0x14013810 + KSEG1))
+#define	ITE_GPACR	(*(volatile __u16 *)(0x14013802 + KSEG1))
+#define	ITE_GPBCR	(*(volatile __u16 *)(0x1401380a + KSEG1))
+#define	ITE_GPCCR	(*(volatile __u16 *)(0x14013812 + KSEG1))
+#define ITE_GPAICR	(*(volatile __u16 *)(0x14013804 + KSEG1))
+#define	ITE_GPBICR	(*(volatile __u16 *)(0x1401380c + KSEG1))
+#define	ITE_GPCICR	(*(volatile __u16 *)(0x14013814 + KSEG1))
+#define	ITE_GPAISR	(*(volatile __u8 *)(0x14013806 + KSEG1))
+#define	ITE_GPBISR	(*(volatile __u8 *)(0x1401380e + KSEG1))
+#define	ITE_GPCISR	(*(volatile __u8 *)(0x14013816 + KSEG1))
+#define	ITE_GCR		(*(volatile __u8 *)(0x14013818 + KSEG1))
+
+#define MAX_GPIO_LINE		21
+static int ite_gpio_irq=IT8172_GPIO_IRQ;
+
+static long ite_irq_counter[MAX_GPIO_LINE];
+wait_queue_head_t ite_gpio_wait[MAX_GPIO_LINE];
+static int ite_gpio_irq_pending[MAX_GPIO_LINE];
+
+static int ite_gpio_debug=0;
+#define DEB(x)  if (ite_gpio_debug>=1) x
+
+int ite_gpio_in(__u32 device, __u32 mask, volatile __u32 *data)
+{
+	DEB(printk("ite_gpio_in mask=0x%x\n",mask)); 
+
+	switch (device) {
+	case ITE_GPIO_PORTA:
+		ITE_GPACR = (__u16)mask;	/* 0xffff */
+		*data = ITE_GPADR;
+		break;
+	case ITE_GPIO_PORTB:
+		ITE_GPBCR = (__u16)mask;	/* 0xffff */
+		*data = ITE_GPBDR;
+		break;
+	case ITE_GPIO_PORTC:
+		ITE_GPCCR = (__u16)mask;	/* 0x03ff */
+		*data = ITE_GPCDR;
+		break;
+	default:
+		return -EFAULT;
+	}
+
+	return 0;
+}
+
+
+int ite_gpio_out(__u32 device, __u32 mask, __u32 data)
+{
+	switch (device) {
+	case ITE_GPIO_PORTA:
+		ITE_GPACR = (__u16)mask;	/* 0x5555 */
+		ITE_GPADR = (__u8)data;
+		break;
+	case ITE_GPIO_PORTB:
+		ITE_GPBCR = (__u16)mask;	/* 0x5555 */
+		ITE_GPBDR = (__u8)data;
+		break;
+	case ITE_GPIO_PORTC:
+		ITE_GPCCR = (__u16)mask;	/* 0x0155 */
+		ITE_GPCDR = (__u8)data;
+		break;
+	default:
+		return -EFAULT;
+	}
+
+	return 0;
+}
+
+int ite_gpio_int_ctrl(__u32 device, __u32 mask, __u32 data)
+{
+	switch (device) {
+	case ITE_GPIO_PORTA:
+		ITE_GPAICR = (ITE_GPAICR & ~mask) | (data & mask);
+		break;
+	case ITE_GPIO_PORTB:
+		ITE_GPBICR = (ITE_GPBICR & ~mask) | (data & mask);
+		break;
+	case ITE_GPIO_PORTC:
+		ITE_GPCICR = (ITE_GPCICR & ~mask) | (data & mask);
+		break;
+	default:
+		return -EFAULT;
+	}
+
+	return 0;
+}
+
+int ite_gpio_in_status(__u32 device, __u32 mask, volatile __u32 *data)
+{
+	int ret=-1;
+
+	if (MAX_GPIO_LINE > *data >= 0) 
+		ret=ite_gpio_irq_pending[*data];
+ 
+	DEB(printk("ite_gpio_in_status %d ret=%d\n",*data, ret));
+
+	switch (device) {
+	case ITE_GPIO_PORTA:
+		*data = ITE_GPAISR & mask;
+		break;
+	case ITE_GPIO_PORTB:
+		*data = ITE_GPBISR & mask;
+		break;
+	case ITE_GPIO_PORTC:
+		*data = ITE_GPCISR & mask;
+		break;
+	default:
+		return -EFAULT;
+	}
+
+	return ret;
+}
+
+int ite_gpio_out_status(__u32 device, __u32 mask, __u32 data)
+{
+	switch (device) {
+	case ITE_GPIO_PORTA:
+		ITE_GPAISR = (ITE_GPAISR & ~mask) | (data & mask);
+		break;
+	case ITE_GPIO_PORTB:
+		ITE_GPBISR = (ITE_GPBISR & ~mask) | (data & mask);
+		break;
+	case ITE_GPIO_PORTC:
+		ITE_GPCISR = (ITE_GPCISR & ~mask) | (data & mask);
+		break;
+	default:
+		return -EFAULT;
+	}
+
+	return 0;
+}
+
+int ite_gpio_gen_ctrl(__u32 device, __u32 mask, __u32 data)
+{
+	ITE_GCR = (ITE_GCR & ~mask) | (data & mask);
+
+	return 0;
+}
+
+int ite_gpio_int_wait (__u32 device, __u32 mask, __u32 data)
+{
+	int i,line=0, ret=0;
+	unsigned long flags;
+
+	switch (device) {
+	case ITE_GPIO_PORTA:
+		line = data & mask;
+		break;
+	case ITE_GPIO_PORTB:
+		line = (data & mask) <<8;
+		break;
+	case ITE_GPIO_PORTC:
+		line = (data & mask) <<16;
+		break;
+	}
+	for (i=MAX_GPIO_LINE-1; i >= 0; i--) {
+		if ( (line) & (1 << i))
+			break;
+	}
+
+	DEB(printk("wait device=0x%d mask=0x%x data=0x%x index %d\n", 
+		device, mask, data, i));
+
+	if (line & ~(1<<i))
+		return -EFAULT;
+
+	if (ite_gpio_irq_pending[i]==1)
+		return -EFAULT;
+
+	save_flags (flags);
+	cli();
+	ite_gpio_irq_pending[i] = 1;
+	ret = interruptible_sleep_on_timeout(&ite_gpio_wait[i], 3*HZ);
+	restore_flags (flags);
+	ite_gpio_irq_pending[i] = 0;
+
+	return ret;
+}
+
+EXPORT_SYMBOL(ite_gpio_in);
+EXPORT_SYMBOL(ite_gpio_out);
+EXPORT_SYMBOL(ite_gpio_int_ctrl);
+EXPORT_SYMBOL(ite_gpio_in_status);
+EXPORT_SYMBOL(ite_gpio_out_status);
+EXPORT_SYMBOL(ite_gpio_gen_ctrl);
+EXPORT_SYMBOL(ite_gpio_int_wait);
+
+static int ite_gpio_open(struct inode *inode, struct file *file)
+{
+	unsigned int minor = MINOR(inode->i_rdev); 
+	if (minor != GPIO_MINOR)
+		return -ENODEV;
+
+#ifdef MODULE
+	MOD_INC_USE_COUNT;
+#endif
+
+	return 0;
+}
+
+
+static int ite_gpio_release(struct inode *inode, struct file *file)
+{
+
+#ifdef MODULE
+	MOD_DEC_USE_COUNT;
+#endif
+
+	return 0;
+}
+
+
+static int ite_gpio_ioctl(struct inode *inode, struct file *file,
+	unsigned int cmd, unsigned long arg)
+{
+
+	static struct ite_gpio_ioctl_data ioctl_data;
+
+	if (copy_from_user(&ioctl_data, (struct ite_gpio_ioctl_data *)arg,
+			sizeof(ioctl_data)))
+		return -EFAULT;
+	if ((ioctl_data.device < ITE_GPIO_PORTA) ||
+			(ioctl_data.device > ITE_GPIO_PORTC) )
+				return -EFAULT;
+
+	switch(cmd) {
+		case ITE_GPIO_IN:
+			if (ite_gpio_in(ioctl_data.device, ioctl_data.mask,
+					   &ioctl_data.data))
+				return -EFAULT;
+
+			if (copy_to_user((struct ite_gpio_ioctl_data *)arg,
+					 &ioctl_data, sizeof(ioctl_data)))
+				return -EFAULT;
+			break;
+
+		case ITE_GPIO_OUT:
+			return ite_gpio_out(ioctl_data.device,
+					ioctl_data.mask, ioctl_data.data);
+			break;
+
+		case ITE_GPIO_INT_CTRL:
+			return ite_gpio_int_ctrl(ioctl_data.device,
+					ioctl_data.mask, ioctl_data.data);
+			break;
+
+		case ITE_GPIO_IN_STATUS:
+			if (ite_gpio_in_status(ioctl_data.device, ioctl_data.mask,
+					&ioctl_data.data))
+				return -EFAULT;
+			if (copy_to_user((struct ite_gpio_ioctl_data *)arg,
+					&ioctl_data, sizeof(ioctl_data))) 
+				return -EFAULT;
+			break;
+
+		case ITE_GPIO_OUT_STATUS:
+			return ite_gpio_out_status(ioctl_data.device,
+					ioctl_data.mask, ioctl_data.data);
+			break;
+
+		case ITE_GPIO_GEN_CTRL:
+			return ite_gpio_gen_ctrl(ioctl_data.device,
+					ioctl_data.mask, ioctl_data.data);
+			break;
+
+		case ITE_GPIO_INT_WAIT:
+			return ite_gpio_int_wait(ioctl_data.device,
+					ioctl_data.mask, ioctl_data.data);
+			break;
+
+		default:
+			return -ENOIOCTLCMD;
+
+	}
+	return 0;
+}
+
+static void ite_gpio_irq_handler(int this_irq, void *dev_id, struct pt_regs *regs)
+{
+	int i,line;
+
+	line = ITE_GPCISR & 0x1f;
+	for (i=4; i >=0; i--) {
+		if ( line & (1 << i)) { 
+			++ite_irq_counter[i+16];
+			ite_gpio_irq_pending[i+16] = 2;
+			wake_up_interruptible(&ite_gpio_wait[i+16]);
+
+DEB(printk("interrupt 0x%x %d\n", &ite_gpio_wait[i+16], i+16));
+
+			ITE_GPCISR = ITE_GPCISR & (1<<i);
+			return;
+		}
+	}
+	line = ITE_GPBISR;
+	for (i=7; i >= 0; i--) {
+		if ( line & (1 << i)) {
+			++ite_irq_counter[i+8];
+			ite_gpio_irq_pending[i+8] = 2;
+			wake_up_interruptible(&ite_gpio_wait[i+8]);
+
+DEB(printk("interrupt 0x%x %d\n",ITE_GPBISR, i+8));
+
+			ITE_GPBISR = ITE_GPBISR & (1<<i);
+			return;
+		}
+	}
+	line = ITE_GPAISR;
+	for (i=7; i >= 0; i--) {
+		if ( line & (1 << i)) {
+			++ite_irq_counter[i];
+			ite_gpio_irq_pending[i] = 2;
+			wake_up_interruptible(&ite_gpio_wait[i]);
+
+DEB(printk("interrupt 0x%x %d\n",ITE_GPAISR, i));
+
+			ITE_GPAISR = ITE_GPAISR & (1<<i);
+			return;
+		}
+	}
+}
+
+static struct file_operations ite_gpio_fops =
+{
+	owner:		THIS_MODULE,
+	ioctl:		ite_gpio_ioctl,
+	open:		ite_gpio_open,
+	release:	ite_gpio_release,
+};
+
+/* GPIO_MINOR in include/linux/miscdevice.h */
+static struct miscdevice ite_gpio_miscdev =
+{
+	GPIO_MINOR,
+	"ite_gpio",
+	&ite_gpio_fops
+};
+
+int __init ite_gpio_init(void)
+{
+	int i;
+
+	misc_register(&ite_gpio_miscdev);
+
+	if (check_region(ite_gpio_base, 0x1c) < 0 ) {
+           return -ENODEV;
+        } else {
+           request_region(ite_gpio_base, 0x1c, "ITE GPIO");
+        }     
+
+	/* initialize registers */
+        ITE_GPACR = 0xffff;
+        ITE_GPBCR = 0xffff;
+        ITE_GPCCR = 0xffff;
+        ITE_GPAICR = 0x00ff;
+        ITE_GPBICR = 0x00ff;
+        ITE_GPCICR = 0x00ff;
+        ITE_GCR = 0;
+
+	for (i = 0; i < MAX_GPIO_LINE; i++) {
+		ite_gpio_irq_pending[i]=0;	
+		init_waitqueue_head(&ite_gpio_wait[i]);
+	}
+	if (request_irq(ite_gpio_irq, ite_gpio_irq_handler, SA_SHIRQ, "gpio", 0) < 0)
+		return 0;
+	printk("GPIO at 0x%x (irq = %d)\n", ite_gpio_base, ite_gpio_irq);
+
+	return 0;
+}	
+
+void __exit ite_gpio_exit(void)
+{
+	misc_deregister(&ite_gpio_miscdev);
+}
+
+module_init(ite_gpio_init);
+module_exit(ite_gpio_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/Config.in linux/drivers/char/joystick/Config.in
--- v2.4.9/linux/drivers/char/joystick/Config.in	Wed Apr 11 19:02:30 2001
+++ linux/drivers/char/joystick/Config.in	Wed Sep 12 15:34:06 2001
@@ -5,48 +5,45 @@
 mainmenu_option next_comment
 comment 'Joysticks'
 
-dep_mbool 'Joystick support' CONFIG_JOYSTICK $CONFIG_INPUT
-if [ "$CONFIG_JOYSTICK" != "n" ]; then
-   comment 'Game port support'
-      dep_tristate '  ns558 gameports' CONFIG_INPUT_NS558 $CONFIG_INPUT
-      dep_tristate '  PDPI Lightning 4 gamecard' CONFIG_INPUT_LIGHTNING $CONFIG_INPUT
-      dep_tristate '  Aureal Vortex and Trident 4DWave gameports' CONFIG_INPUT_PCIGAME $CONFIG_INPUT
-      dep_tristate '  Crystal SoundFusion gameports' CONFIG_INPUT_CS461X $CONFIG_INPUT
+if [ "$CONFIG_INPUT" != "n" ]; then
+   dep_tristate 'Game port support' CONFIG_INPUT_GAMEPORT $CONFIG_INPUT
+      dep_tristate '  Classic ISA/PnP gameports' CONFIG_INPUT_NS558 $CONFIG_INPUT_GAMEPORT
+      dep_tristate '  PDPI Lightning 4 gamecard' CONFIG_INPUT_LIGHTNING $CONFIG_INPUT_GAMEPORT
+      dep_tristate '  Aureal Vortex and Trident 4DWave gameports' CONFIG_INPUT_PCIGAME $CONFIG_INPUT_GAMEPORT
+      dep_tristate '  Crystal SoundFusion gameports' CONFIG_INPUT_CS461X  $CONFIG_INPUT_GAMEPORT
+      dep_tristate '  SoundBlaster Live! gameports' CONFIG_INPUT_EMU10K1 $CONFIG_INPUT_GAMEPORT
+   tristate 'Serial port device support' CONFIG_INPUT_SERIO
+      dep_tristate '  Serial port input line discipline' CONFIG_INPUT_SERPORT $CONFIG_INPUT_SERIO
+else
+   # Must explicitly set to n for drivers/sound/Config.in
+   define_tristate CONFIG_INPUT_GAMEPORT n
+   comment 'Input core support is needed for gameports'
+fi
 
-   comment 'Gameport joysticks'
-      dep_tristate '  Classic PC analog joysticks and gamepads' CONFIG_INPUT_ANALOG $CONFIG_INPUT
-      dep_tristate '  Assasin 3D and MadCatz Panther devices' CONFIG_INPUT_A3D $CONFIG_INPUT
-      dep_tristate '  Logitech ADI digital joysticks and gamepads' CONFIG_INPUT_ADI $CONFIG_INPUT
-      dep_tristate '  Creative Labs Blaster Cobra gamepad' CONFIG_INPUT_COBRA $CONFIG_INPUT
-      dep_tristate '  Genius Flight2000 Digital joysticks and gamepads' CONFIG_INPUT_GF2K $CONFIG_INPUT
-      dep_tristate '  Gravis GrIP joysticks and gamepads' CONFIG_INPUT_GRIP $CONFIG_INPUT
-      dep_tristate '  InterAct digital joysticks and gamepads' CONFIG_INPUT_INTERACT $CONFIG_INPUT
-      dep_tristate '  ThrustMaster DirectConnect joysticks and gamepads' CONFIG_INPUT_TMDC $CONFIG_INPUT
-      dep_tristate '  Microsoft SideWinder digital joysticks and gamepads' CONFIG_INPUT_SIDEWINDER $CONFIG_INPUT
+if [ "$CONFIG_INPUT" != "n" ]; then
+   comment 'Joysticks'
 
-   comment 'Serial port support'
-      dep_tristate '  Serial port input line discipline' CONFIG_INPUT_SERPORT $CONFIG_INPUT
-
-   comment 'Serial port joysticks'
-      dep_tristate '  Logitech WingMan Warrior joystick' CONFIG_INPUT_WARRIOR $CONFIG_INPUT
-      dep_tristate '  LogiCad3d Magellan/SpaceMouse 6dof controller' CONFIG_INPUT_MAGELLAN $CONFIG_INPUT
-      dep_tristate '  SpaceTec SpaceOrb/Avenger 6dof controller' CONFIG_INPUT_SPACEORB $CONFIG_INPUT
-      dep_tristate '  SpaceTec SpaceBall 4000 FLX 6dof controller' CONFIG_INPUT_SPACEBALL $CONFIG_INPUT
-      dep_tristate '  Gravis Stinger gamepad' CONFIG_INPUT_STINGER $CONFIG_INPUT
-      dep_tristate '  I-Force/Serial controllers' CONFIG_INPUT_IFORCE_232 $CONFIG_INPUT
-      dep_tristate '  I-Force/USB controllers' CONFIG_INPUT_IFORCE_USB $CONFIG_INPUT $CONFIG_USB
-
-   comment 'Parallel port joysticks'
-   if [ "$CONFIG_PARPORT" != "n" ]; then
-      dep_tristate '  Multisystem, Sega Genesis, Saturn joysticks and gamepads' CONFIG_INPUT_DB9 $CONFIG_INPUT $CONFIG_PARPORT
-      dep_tristate '  Multisystem, NES, SNES, N64, PSX joysticks and gamepads' CONFIG_INPUT_GAMECON $CONFIG_INPUT $CONFIG_PARPORT
-      dep_tristate '  Multisystem joysticks via TurboGraFX device' CONFIG_INPUT_TURBOGRAFX $CONFIG_INPUT $CONFIG_PARPORT
-   else
-      comment '  Parport support is needed for parallel port joysticks'
-   fi
+   dep_tristate '  Classic PC analog joysticks and gamepads' CONFIG_INPUT_ANALOG $CONFIG_INPUT $CONFIG_INPUT_GAMEPORT
+   dep_tristate '  Assasin 3D and MadCatz Panther devices' CONFIG_INPUT_A3D $CONFIG_INPUT $CONFIG_INPUT_GAMEPORT
+   dep_tristate '  Logitech ADI digital joysticks and gamepads' CONFIG_INPUT_ADI $CONFIG_INPUT $CONFIG_INPUT_GAMEPORT
+   dep_tristate '  Creative Labs Blaster Cobra gamepad' CONFIG_INPUT_COBRA $CONFIG_INPUT $CONFIG_INPUT_GAMEPORT
+   dep_tristate '  Genius Flight2000 Digital joysticks and gamepads' CONFIG_INPUT_GF2K $CONFIG_INPUT $CONFIG_INPUT_GAMEPORT
+   dep_tristate '  Gravis GrIP joysticks and gamepads' CONFIG_INPUT_GRIP $CONFIG_INPUT $CONFIG_INPUT_GAMEPORT
+   dep_tristate '  InterAct digital joysticks and gamepads' CONFIG_INPUT_INTERACT $CONFIG_INPUT $CONFIG_INPUT_GAMEPORT
+   dep_tristate '  ThrustMaster DirectConnect joysticks and gamepads' CONFIG_INPUT_TMDC $CONFIG_INPUT $CONFIG_INPUT_GAMEPORT
+   dep_tristate '  Microsoft SideWinder digital joysticks and gamepads' CONFIG_INPUT_SIDEWINDER $CONFIG_INPUT $CONFIG_INPUT_GAMEPORT
+   dep_tristate '  I-Force USB joysticks and wheels' CONFIG_INPUT_IFORCE_USB $CONFIG_INPUT $CONFIG_USB
+   dep_tristate '  I-Force Serial joysticks and wheels' CONFIG_INPUT_IFORCE_232 $CONFIG_INPUT $CONFIG_INPUT_SERIO
+   dep_tristate '  Logitech WingMan Warrior joystick' CONFIG_INPUT_WARRIOR $CONFIG_INPUT $CONFIG_INPUT_SERIO
+   dep_tristate '  LogiCad3d Magellan/SpaceMouse 6dof controller' CONFIG_INPUT_MAGELLAN $CONFIG_INPUT $CONFIG_INPUT_SERIO
+   dep_tristate '  SpaceTec SpaceOrb/Avenger 6dof controller' CONFIG_INPUT_SPACEORB $CONFIG_INPUT $CONFIG_INPUT_SERIO
+   dep_tristate '  SpaceTec SpaceBall 4000 FLX 6dof controller' CONFIG_INPUT_SPACEBALL $CONFIG_INPUT $CONFIG_INPUT_SERIO
+   dep_tristate '  Gravis Stinger gamepad' CONFIG_INPUT_STINGER $CONFIG_INPUT $CONFIG_INPUT_SERIO
+   dep_tristate '  Multisystem, Sega Genesis, Saturn joysticks and gamepads' CONFIG_INPUT_DB9 $CONFIG_INPUT $CONFIG_PARPORT
+   dep_tristate '  Multisystem, NES, SNES, N64, PSX joysticks and gamepads' CONFIG_INPUT_GAMECON $CONFIG_INPUT $CONFIG_PARPORT
+   dep_tristate '  Multisystem joysticks via TurboGraFX device' CONFIG_INPUT_TURBOGRAFX $CONFIG_INPUT $CONFIG_PARPORT
 
    if [ "$CONFIG_AMIGA" = "y" ]; then
-   comment 'System joysticks'
       dep_tristate '  Amiga joysticks' CONFIG_INPUT_AMIJOY $CONFIG_INPUT
    fi
 else
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/Makefile linux/drivers/char/joystick/Makefile
--- v2.4.9/linux/drivers/char/joystick/Makefile	Wed Apr 11 19:02:30 2001
+++ linux/drivers/char/joystick/Makefile	Wed Sep 12 15:34:06 2001
@@ -30,30 +30,34 @@
 
 # Each configuration option enables a list of files.
 
-obj-$(CONFIG_INPUT_SERPORT)	+= serport.o serio.o
+obj-$(CONFIG_INPUT_GAMEPORT)	+= gameport.o
+obj-$(CONFIG_INPUT_SERIO)	+= serio.o
 
-obj-$(CONFIG_INPUT_NS558)	+= ns558.o gameport.o
-obj-$(CONFIG_INPUT_LIGHTNING)	+= lightning.o gameport.o
-obj-$(CONFIG_INPUT_PCIGAME)	+= pcigame.o gameport.o
-obj-$(CONFIG_INPUT_CS461X)	+= cs461x.o gameport.o
+obj-$(CONFIG_INPUT_SERPORT)	+= serport.o
 
-obj-$(CONFIG_INPUT_WARRIOR)	+= warrior.o serio.o
-obj-$(CONFIG_INPUT_MAGELLAN)	+= magellan.o serio.o
-obj-$(CONFIG_INPUT_SPACEORB)	+= spaceorb.o serio.o
-obj-$(CONFIG_INPUT_SPACEBALL)	+= spaceball.o serio.o
-obj-$(CONFIG_INPUT_STINGER)	+= stinger.o serio.o
-obj-$(CONFIG_INPUT_IFORCE_232)	+= iforce.o serio.o
+obj-$(CONFIG_INPUT_NS558)	+= ns558.o
+obj-$(CONFIG_INPUT_LIGHTNING)	+= lightning.o
+obj-$(CONFIG_INPUT_PCIGAME)	+= pcigame.o
+obj-$(CONFIG_INPUT_CS461X)	+= cs461x.o
+obj-$(CONFIG_INPUT_EMU10K1)	+= emu10k1-gp.o
+
+obj-$(CONFIG_INPUT_WARRIOR)	+= warrior.o
+obj-$(CONFIG_INPUT_MAGELLAN)	+= magellan.o
+obj-$(CONFIG_INPUT_SPACEORB)	+= spaceorb.o
+obj-$(CONFIG_INPUT_SPACEBALL)	+= spaceball.o
+obj-$(CONFIG_INPUT_STINGER)	+= stinger.o
+obj-$(CONFIG_INPUT_IFORCE_232)	+= iforce.o
 obj-$(CONFIG_INPUT_IFORCE_USB)	+= iforce.o
 
-obj-$(CONFIG_INPUT_ANALOG)	+= analog.o gameport.o
-obj-$(CONFIG_INPUT_A3D)		+= a3d.o gameport.o
-obj-$(CONFIG_INPUT_ADI)		+= adi.o gameport.o
-obj-$(CONFIG_INPUT_COBRA)	+= cobra.o gameport.o
-obj-$(CONFIG_INPUT_GF2K)	+= gf2k.o gameport.o
-obj-$(CONFIG_INPUT_GRIP)	+= grip.o gameport.o
-obj-$(CONFIG_INPUT_INTERACT)	+= interact.o gameport.o
-obj-$(CONFIG_INPUT_TMDC)	+= tmdc.o gameport.o
-obj-$(CONFIG_INPUT_SIDEWINDER)	+= sidewinder.o gameport.o
+obj-$(CONFIG_INPUT_ANALOG)	+= analog.o
+obj-$(CONFIG_INPUT_A3D)		+= a3d.o
+obj-$(CONFIG_INPUT_ADI)		+= adi.o
+obj-$(CONFIG_INPUT_COBRA)	+= cobra.o
+obj-$(CONFIG_INPUT_GF2K)	+= gf2k.o
+obj-$(CONFIG_INPUT_GRIP)	+= grip.o
+obj-$(CONFIG_INPUT_INTERACT)	+= interact.o
+obj-$(CONFIG_INPUT_TMDC)	+= tmdc.o
+obj-$(CONFIG_INPUT_SIDEWINDER)	+= sidewinder.o
 
 obj-$(CONFIG_INPUT_DB9)		+= db9.o
 obj-$(CONFIG_INPUT_GAMECON)	+= gamecon.o
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/a3d.c linux/drivers/char/joystick/a3d.c
--- v2.4.9/linux/drivers/char/joystick/a3d.c	Fri Feb  9 11:30:23 2001
+++ linux/drivers/char/joystick/a3d.c	Wed Sep 12 15:34:06 2001
@@ -1,7 +1,7 @@
 /*
- * $Id: a3d.c,v 1.10 2000/05/29 11:19:50 vojtech Exp $
+ * $Id: a3d.c,v 1.14 2001/04/26 10:24:46 vojtech Exp $
  *
- *  Copyright (c) 1998-2000 Vojtech Pavlik
+ *  Copyright (c) 1998-2001 Vojtech Pavlik
  *
  *  Sponsored by SuSE
  */
@@ -190,7 +190,7 @@
 
 int a3d_adc_cooked_read(struct gameport *gameport, int *axes, int *buttons)
 {
-	struct a3d *a3d = gameport->driver;
+	struct a3d *a3d = gameport->private;
 	int i;
 	for (i = 0; i < 4; i++)
 		axes[i] = (a3d->axes[i] < 254) ? a3d->axes[i] : -1;
@@ -205,7 +205,7 @@
 
 int a3d_adc_open(struct gameport *gameport, int mode)
 {
-	struct a3d *a3d = gameport->driver;
+	struct a3d *a3d = gameport->private;
 	if (mode != GAMEPORT_MODE_COOKED)
 		return -1;
 	if (!a3d->used++)
@@ -219,7 +219,7 @@
 
 static void a3d_adc_close(struct gameport *gameport)
 {
-	struct a3d *a3d = gameport->driver;
+	struct a3d *a3d = gameport->private;
 	if (!--a3d->used)
 		del_timer(&a3d->timer);
 }
@@ -323,12 +323,11 @@
 		a3d->dev.relbit[0] |= BIT(REL_X) | BIT(REL_Y);
 		a3d->dev.keybit[LONG(BTN_MOUSE)] |= BIT(BTN_RIGHT) | BIT(BTN_LEFT) | BIT(BTN_MIDDLE);
 
-		a3d->adc.driver = a3d;
+		a3d->adc.private = a3d;
 		a3d->adc.open = a3d_adc_open;
 		a3d->adc.close = a3d_adc_close;
 		a3d->adc.cooked_read = a3d_adc_cooked_read;
 		a3d->adc.fuzz = 1; 
-		a3d->adc.type = GAMEPORT_EXT; 
 
 		a3d_read(a3d, data);
 
@@ -385,3 +384,5 @@
 
 module_init(a3d_init);
 module_exit(a3d_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/adi.c linux/drivers/char/joystick/adi.c
--- v2.4.9/linux/drivers/char/joystick/adi.c	Wed Apr 11 19:02:30 2001
+++ linux/drivers/char/joystick/adi.c	Wed Sep 12 15:34:06 2001
@@ -553,3 +553,5 @@
 
 module_init(adi_init);
 module_exit(adi_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/amijoy.c linux/drivers/char/joystick/amijoy.c
--- v2.4.9/linux/drivers/char/joystick/amijoy.c	Fri Feb 16 16:02:35 2001
+++ linux/drivers/char/joystick/amijoy.c	Wed Sep 12 15:34:06 2001
@@ -42,6 +42,7 @@
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
 MODULE_PARM(amijoy, "1-2i");
+MODULE_LICENSE("GPL");
 
 static int amijoy[2] = { 0, 1 };
 static int amijoy_used[2] = { 0, 0 };
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/analog.c linux/drivers/char/joystick/analog.c
--- v2.4.9/linux/drivers/char/joystick/analog.c	Fri Feb  9 11:30:23 2001
+++ linux/drivers/char/joystick/analog.c	Wed Sep 12 15:34:06 2001
@@ -42,6 +42,7 @@
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
 MODULE_DESCRIPTION("Analog joystick and gamepad driver for Linux");
+MODULE_LICENSE("GPL");
 
 /*
  * Option parsing.
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/cobra.c linux/drivers/char/joystick/cobra.c
--- v2.4.9/linux/drivers/char/joystick/cobra.c	Wed Apr 11 19:02:30 2001
+++ linux/drivers/char/joystick/cobra.c	Wed Sep 12 15:34:06 2001
@@ -248,3 +248,5 @@
 
 module_init(cobra_init);
 module_exit(cobra_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/cs461x.c linux/drivers/char/joystick/cs461x.c
--- v2.4.9/linux/drivers/char/joystick/cs461x.c	Wed Apr 11 19:02:30 2001
+++ linux/drivers/char/joystick/cs461x.c	Wed Sep 12 15:34:06 2001
@@ -10,21 +10,24 @@
 
 #include <linux/module.h>
 #include <linux/ioport.h>
+#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/gameport.h>
 #include <linux/slab.h>
 #include <linux/pci.h>
 
 MODULE_AUTHOR("Victor Krapivin <vik@belcaf.minsk.by>");
+MODULE_LICENSE("GPL");
 
 /*
 	These options are experimental
 
-#define COOKED_MODE
 #define CS461X_FULL_MAP
-
 */
 
+#define COOKED_MODE
+
+
 #ifndef PCI_VENDOR_ID_CIRRUS
 #define PCI_VENDOR_ID_CIRRUS            0x1013
 #endif
@@ -281,8 +284,6 @@
 	}
 	memset(port, 0, sizeof(struct gameport));
 
-	port->io = -1;
-	port->size = -1;
 	pdev->driver_data = port;
 	
 	port->open = cs461x_gameport_open;
@@ -297,9 +298,8 @@
 
 	gameport_register_port(port);
 
-	printk(KERN_INFO "gameport%d: CS461x PCI", port->number);
-	if (port->size > 1) printk(" size %d", port->size);
-	printk(" speed %d kHz\n", port->speed);
+	printk(KERN_INFO "gameport%d: CS461x Gameport speed %d kHz\n",
+		port->number, port->speed);
 
 	return 0;
 }
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/db9.c linux/drivers/char/joystick/db9.c
--- v2.4.9/linux/drivers/char/joystick/db9.c	Mon Aug 14 13:55:01 2000
+++ linux/drivers/char/joystick/db9.c	Wed Sep 12 15:34:06 2001
@@ -41,6 +41,7 @@
 #include <linux/input.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
+MODULE_LICENSE("GPL");
 MODULE_PARM(db9, "2i");
 MODULE_PARM(db9_2, "2i");
 MODULE_PARM(db9_3, "2i");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/emu10k1-gp.c linux/drivers/char/joystick/emu10k1-gp.c
--- v2.4.9/linux/drivers/char/joystick/emu10k1-gp.c	Wed Dec 31 16:00:00 1969
+++ linux/drivers/char/joystick/emu10k1-gp.c	Wed Sep 12 15:34:06 2001
@@ -0,0 +1,125 @@
+/*
+ * $Id: emu10k1-gp.c,v 1.2 2001/04/24 07:48:56 vojtech Exp $
+ *
+ *  Copyright (c) 2001 Vojtech Pavlik
+ *
+ *  Sponsored by SuSE
+ */
+
+/*
+ * EMU10k1 - SB Live! - gameport driver for Linux
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or 
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * 
+ * Should you need to contact me, the author, you can do so either by
+ * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
+ * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
+ */
+
+#include <asm/io.h>
+
+#include <linux/module.h>
+#include <linux/ioport.h>
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/gameport.h>
+#include <linux/slab.h>
+#include <linux/pci.h>
+
+MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
+MODULE_LICENSE("GPL");
+
+struct emu {
+	struct pci_dev *dev;
+	struct emu *next;
+	struct gameport gameport;
+	int size;
+};
+	
+static struct pci_device_id emu_tbl[] __devinitdata = {
+	{ 0x1102, 0x7002, PCI_ANY_ID, PCI_ANY_ID }, /* SB Live! gameport */
+	{ 0, }
+};
+
+MODULE_DEVICE_TABLE(pci, emu_tbl);
+
+static int __devinit emu_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+	int ioport, iolen;
+	int rc;
+	struct emu *port;
+        
+	rc = pci_enable_device(pdev);
+	if (rc) {
+		printk(KERN_ERR "emu10k1-gp: Cannot enable emu10k1 gameport (bus %d, devfn %d) error=%d\n",
+			pdev->bus->number, pdev->devfn, rc);
+		return rc;
+	}
+
+	ioport = pci_resource_start(pdev, 0);
+	iolen = pci_resource_len(pdev, 0);
+
+	if (!request_region(ioport, iolen, "emu10k1-gp"))
+		return -EBUSY;
+
+	if (!(port = kmalloc(sizeof(struct emu), GFP_KERNEL))) {
+		printk(KERN_ERR "emu10k1-gp: Memory allocation failed.\n");
+		release_region(ioport, iolen);
+		return -ENOMEM;
+	}
+	memset(port, 0, sizeof(struct emu));
+
+	port->gameport.io = ioport;
+	port->size = iolen;
+	port->dev = pdev;
+	pdev->driver_data = port;
+
+	gameport_register_port(&port->gameport);
+
+	printk(KERN_INFO "gameport%d: Emu10k1 Gameport at %#x size %d speed %d kHz\n",
+		port->gameport.number, port->gameport.io, iolen, port->gameport.speed);
+
+	return 0;
+}
+
+static void __devexit emu_remove(struct pci_dev *pdev)
+{
+	struct emu *port = (struct emu *)pdev->driver_data;
+	gameport_unregister_port(&port->gameport);
+	release_region(port->gameport.io, port->size);
+	kfree(port);
+}
+
+static struct pci_driver emu_driver = {
+        name:           "Emu10k1 Gameport",
+        id_table:       emu_tbl,
+        probe:          emu_probe,
+        remove:         emu_remove,
+};
+
+int __init emu_init(void)
+{
+	return pci_module_init(&emu_driver);
+}
+
+void __exit emu_exit(void)
+{
+	pci_unregister_driver(&emu_driver);
+}
+
+module_init(emu_init);
+module_exit(emu_exit);
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/gamecon.c linux/drivers/char/joystick/gamecon.c
--- v2.4.9/linux/drivers/char/joystick/gamecon.c	Wed Apr 11 19:02:30 2001
+++ linux/drivers/char/joystick/gamecon.c	Wed Sep 12 15:34:06 2001
@@ -1,7 +1,7 @@
 /*
- * $Id: gamecon.c,v 1.11 2000/11/01 12:38:53 vojtech Exp $
+ * $Id: gamecon.c,v 1.14 2001/04/29 22:42:14 vojtech Exp $
  *
- *  Copyright (c) 1999-2000 Vojtech Pavlik
+ *  Copyright (c) 1999-2001 Vojtech Pavlik
  *
  *  Based on the work of:
  *  	Andree Borrmann		John Dahlstrom
@@ -42,6 +42,7 @@
 #include <linux/input.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
+MODULE_LICENSE("GPL");
 MODULE_PARM(gc, "2-6i");
 MODULE_PARM(gc_2,"2-6i");
 MODULE_PARM(gc_3,"2-6i");
@@ -62,7 +63,7 @@
 	struct pardevice *pd;
 	struct input_dev dev[5];
 	struct timer_list timer;
-	unsigned char pads[GC_PSX + 1];
+	unsigned char pads[GC_MAX + 1];
 	int used;
 };
 
@@ -231,7 +232,7 @@
 
 static short gc_psx_abs[] = { ABS_X, ABS_Y, ABS_RX, ABS_RY, ABS_HAT0X, ABS_HAT0Y };
 static short gc_psx_btn[] = { BTN_TL, BTN_TR, BTN_TL2, BTN_TR2, BTN_A, BTN_B, BTN_X, BTN_Y,
-				BTN_START, BTN_SELECT, BTN_THUMB, BTN_THUMB2 };
+				BTN_START, BTN_SELECT, BTN_THUMBL, BTN_THUMBR };
 
 /*
  * gc_psx_command() writes 8bit command and reads 8bit data from
@@ -345,8 +346,8 @@
 			s = gc_status_bit[i];
 
 			if (s & (gc->pads[GC_NES] | gc->pads[GC_SNES])) {
-				input_report_abs(dev + i, ABS_X, ! - !(s & data[6]) - !(s & data[7]));
-				input_report_abs(dev + i, ABS_Y, ! - !(s & data[4]) - !(s & data[5]));
+				input_report_abs(dev + i, ABS_X, !(s & data[6]) - !(s & data[7]));
+				input_report_abs(dev + i, ABS_Y, !(s & data[4]) - !(s & data[5]));
 			}
 
 			if (s & gc->pads[GC_NES])
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/gameport.c linux/drivers/char/joystick/gameport.c
--- v2.4.9/linux/drivers/char/joystick/gameport.c	Fri Feb  9 11:30:23 2001
+++ linux/drivers/char/joystick/gameport.c	Wed Sep 12 15:34:06 2001
@@ -41,6 +41,7 @@
 #include <linux/delay.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
+MODULE_LICENSE("GPL");
 
 EXPORT_SYMBOL(gameport_register_port);
 EXPORT_SYMBOL(gameport_unregister_port);
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/gf2k.c linux/drivers/char/joystick/gf2k.c
--- v2.4.9/linux/drivers/char/joystick/gf2k.c	Fri Feb  9 11:30:23 2001
+++ linux/drivers/char/joystick/gf2k.c	Wed Sep 12 15:34:06 2001
@@ -357,3 +357,5 @@
 
 module_init(gf2k_init);
 module_exit(gf2k_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/grip.c linux/drivers/char/joystick/grip.c
--- v2.4.9/linux/drivers/char/joystick/grip.c	Fri Feb  9 11:30:23 2001
+++ linux/drivers/char/joystick/grip.c	Wed Sep 12 15:34:06 2001
@@ -421,3 +421,5 @@
 
 module_init(grip_init);
 module_exit(grip_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/iforce.c linux/drivers/char/joystick/iforce.c
--- v2.4.9/linux/drivers/char/joystick/iforce.c	Wed Apr 11 19:02:30 2001
+++ linux/drivers/char/joystick/iforce.c	Wed Sep 12 15:34:06 2001
@@ -1,7 +1,8 @@
 /*
- * $Id: iforce.c,v 1.7 2000/06/04 14:03:36 vojtech Exp $
+ * $Id: iforce.c,v 1.56 2001/05/27 14:41:26 jdeneux Exp $
  *
- *  Copyright (c) 2000 Vojtech Pavlik
+ *  Copyright (c) 2000-2001 Vojtech Pavlik <vojtech@suse.cz>
+ *  Copyright (c) 2001 Johann Deneux <deneux@ifrance.com>
  *
  *  USB/RS232 I-Force joysticks and wheels.
  *
@@ -11,18 +12,18 @@
 /*
  * 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 
+ * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * 
+ *
  * Should you need to contact me, the author, you can do so either by
  * e-mail - mail your message to <vojtech@suse.cz>, or by paper mail:
  * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
@@ -38,46 +39,216 @@
 #include <linux/serio.h>
 #include <linux/config.h>
 
-MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
-MODULE_DESCRIPTION("USB/RS232 I-Force joysticks and wheels driver");
+/* FF: This module provides arbitrary resource management routines.
+ * I use it to manage the device's memory.
+ * Despite the name of this module, I am *not* going to access the ioports.
+ */
+#include <linux/ioport.h>
 
-#define USB_VENDOR_ID_LOGITECH		0x046d
-#define USB_DEVICE_ID_LOGITECH_WMFORCE	0xc281
+MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>, Johann Deneux <deneux@ifrance.com>");
+MODULE_DESCRIPTION("USB/RS232 I-Force joysticks and wheels driver");
+MODULE_LICENSE("GPL");
 
-#define IFORCE_MAX_LENGTH		16
+#define IFORCE_MAX_LENGTH	16
 
 #if defined(CONFIG_INPUT_IFORCE_232) || defined(CONFIG_INPUT_IFORCE_232_MODULE)
-#define IFORCE_232
+#define IFORCE_232	1
 #endif
 #if defined(CONFIG_INPUT_IFORCE_USB) || defined(CONFIG_INPUT_IFORCE_USB_MODULE)
-#define IFORCE_USB
+#define IFORCE_USB	2
 #endif
 
+#define FF_EFFECTS_MAX	32
+
+/* Each force feedback effect is made of one core effect, which can be
+ * associated to at most to effect modifiers
+ */
+#define FF_MOD1_IS_USED		0
+#define FF_MOD2_IS_USED		1
+#define FF_CORE_IS_USED		2
+#define FF_CORE_IS_PLAYED	3
+#define FF_MODCORE_MAX		3
+
+struct iforce_core_effect {
+	/* Information about where modifiers are stored in the device's memory */
+	struct resource mod1_chunk;
+	struct resource mod2_chunk;
+	unsigned long flags[NBITS(FF_MODCORE_MAX)];
+};
+
+#define FF_CMD_EFFECT		0x010e
+#define FF_CMD_SHAPE		0x0208
+#define FF_CMD_MAGNITUDE	0x0303
+#define FF_CMD_PERIOD		0x0407
+#define FF_CMD_INTERACT		0x050a
+
+#define FF_CMD_AUTOCENTER	0x4002
+#define FF_CMD_PLAY		0x4103
+#define FF_CMD_ENABLE		0x4201
+#define FF_CMD_GAIN		0x4301
+
+#define FF_CMD_QUERY		0xff01
+
+static signed short btn_joystick[] = { BTN_TRIGGER, BTN_TOP, BTN_THUMB, BTN_TOP2, BTN_BASE,
+	BTN_BASE2, BTN_BASE3, BTN_BASE4, BTN_BASE5, BTN_A, BTN_B, BTN_C, BTN_DEAD, -1 };
+static signed short btn_wheel[] =    { BTN_TRIGGER, BTN_TOP, BTN_THUMB, BTN_TOP2, BTN_BASE,
+	BTN_BASE2, BTN_BASE3, BTN_BASE4, BTN_BASE5, BTN_A, BTN_B, BTN_C, -1 };
+static signed short abs_joystick[] = { ABS_X, ABS_Y, ABS_THROTTLE, ABS_HAT0X, ABS_HAT0Y, -1 };
+static signed short abs_wheel[] =    { ABS_WHEEL, ABS_GAS, ABS_BRAKE, ABS_HAT0X, ABS_HAT0Y, -1 };
+static signed short ff_iforce[] =    { FF_PERIODIC, FF_CONSTANT, FF_SPRING, FF_FRICTION,
+	FF_SQUARE, FF_TRIANGLE, FF_SINE, FF_SAW_UP, FF_SAW_DOWN, FF_GAIN, FF_AUTOCENTER, -1 };
+
+static struct iforce_device {
+	u16 idvendor;
+	u16 idproduct;
+	char *name;
+	signed short *btn;
+	signed short *abs;
+	signed short *ff;
+} iforce_device[] = {
+	{ 0x046d, 0xc281, "Logitech WingMan Force",			btn_joystick, abs_joystick, ff_iforce },
+	{ 0x046d, 0xc291, "Logitech WingMan Formula Force",		btn_wheel, abs_wheel, ff_iforce },
+	{ 0x05ef, 0x020a, "AVB Top Shot Pegasus",			btn_joystick, abs_joystick, ff_iforce },
+	{ 0x05ef, 0x8884, "AVB Mag Turbo Force",			btn_wheel, abs_wheel, ff_iforce },
+	{ 0x06f8, 0x0001, "Guillemot Race Leader Force Feedback",	btn_wheel, abs_wheel, ff_iforce },
+	{ 0x0000, 0x0000, "Unknown I-Force Device [%04x:%04x]",		btn_joystick, abs_joystick, ff_iforce }
+};
+
 struct iforce {
-	signed char data[IFORCE_MAX_LENGTH];
-	struct usb_device *usbdev;
-	struct input_dev dev;
-	struct urb irq;
+	struct input_dev dev;		/* Input device interface */
+	struct iforce_device *type;
+	char name[64];
 	int open;
+	int bus;
+
+	unsigned char data[IFORCE_MAX_LENGTH];
+	unsigned char edata[IFORCE_MAX_LENGTH];
+	u16 ecmd;
+	u16 expect_packet;
+
+#ifdef IFORCE_232
+	struct serio *serio;		/* RS232 transfer */
 	int idx, pkt, len, id;
 	unsigned char csum;
+#endif
+#ifdef IFORCE_USB
+	struct usb_device *usbdev;	/* USB transfer */
+	struct urb irq, out, ctrl;
+	devrequest dr;
+#endif
+					/* Force Feedback */
+	wait_queue_head_t wait;
+	struct resource device_memory;
+	struct iforce_core_effect core_effects[FF_EFFECTS_MAX];
 };
 
 static struct {
-        __s32 x;
-        __s32 y;
+	__s32 x;
+	__s32 y;
 } iforce_hat_to_axis[16] = {{ 0,-1}, { 1,-1}, { 1, 0}, { 1, 1}, { 0, 1}, {-1, 1}, {-1, 0}, {-1,-1}};
 
-static char *iforce_name = "I-Force joystick/wheel";
+/* Get hi and low bytes of a 16-bits int */
+#define HI(a)	((unsigned char)((a) >> 8))
+#define LO(a)	((unsigned char)((a) & 0xff))
+
+/* Encode a time value */
+#define TIME_SCALE(a)	((a) == 0xffff ? 0xffff : (a) * 1000 / 256)
 
-static void iforce_process_packet(struct input_dev *dev, unsigned char id, int idx, unsigned char *data)
+static void dump_packet(char *msg, u16 cmd, unsigned char *data)
 {
-	switch (id) {
+	int i;
 
-		case 1:	/* joystick position data */
-		case 3: /* wheel position data */
+	printk(KERN_DEBUG "iforce.c: %s ( cmd = %04x, data = ", msg, cmd);
+	for (i = 0; i < LO(cmd); i++)
+		printk("%02x ", data[i]);
+	printk(")\n");
+}
 
-			if (id == 1) {
+/*
+ * Send a packet of bytes to the device
+ */
+static void send_packet(struct iforce *iforce, u16 cmd, unsigned char* data)
+{
+	switch (iforce->bus) {
+
+#ifdef IFORCE_232
+		case IFORCE_232: {
+
+			int i;
+			unsigned char csum = 0x2b ^ HI(cmd) ^ LO(cmd);
+
+			serio_write(iforce->serio, 0x2b);
+			serio_write(iforce->serio, HI(cmd));
+			serio_write(iforce->serio, LO(cmd));
+
+			for (i = 0; i < LO(cmd); i++) {
+				serio_write(iforce->serio, data[i]);
+				csum = csum ^ data[i];
+			}
+
+			serio_write(iforce->serio, csum);
+			return;
+		}
+#endif
+#ifdef IFORCE_USB
+		case IFORCE_USB: {
+
+			DECLARE_WAITQUEUE(wait, current);
+			int timeout = HZ; /* 1 second */
+
+			memcpy(iforce->out.transfer_buffer + 1, data, LO(cmd));
+			((char*)iforce->out.transfer_buffer)[0] = HI(cmd);
+			iforce->out.transfer_buffer_length = LO(cmd) + 2;
+			iforce->out.dev = iforce->usbdev;
+
+			set_current_state(TASK_INTERRUPTIBLE);
+			add_wait_queue(&iforce->wait, &wait);
+
+			if (usb_submit_urb(&iforce->out)) {
+				set_current_state(TASK_RUNNING);
+				remove_wait_queue(&iforce->wait, &wait);
+				return;
+			}
+
+			while (timeout && iforce->out.status == -EINPROGRESS)
+				timeout = schedule_timeout(timeout);
+
+			set_current_state(TASK_RUNNING);
+			remove_wait_queue(&iforce->wait, &wait);
+
+			if (!timeout)
+				usb_unlink_urb(&iforce->out);
+
+			return;
+		}
+#endif
+	}
+}
+
+static void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data)
+{
+	struct input_dev *dev = &iforce->dev;
+	int i;
+
+#ifdef IFORCE_232
+	if (HI(iforce->expect_packet) == HI(cmd)) {
+		iforce->expect_packet = 0;
+		iforce->ecmd = cmd;
+		memcpy(iforce->edata, data, IFORCE_MAX_LENGTH);
+		if (waitqueue_active(&iforce->wait))
+			wake_up(&iforce->wait);
+	}
+#endif
+
+	if (!iforce->type)
+		return;
+
+	switch (HI(cmd)) {
+
+		case 0x01:	/* joystick position data */
+		case 0x03:	/* wheel position data */
+
+			if (HI(cmd) == 1) {
 				input_report_abs(dev, ABS_X, (__s16) (((__s16)data[1] << 8) | data[0]));
 				input_report_abs(dev, ABS_Y, (__s16) (((__s16)data[3] << 8) | data[2]));
 				input_report_abs(dev, ABS_THROTTLE, 255 - data[4]);
@@ -90,37 +261,95 @@
 			input_report_abs(dev, ABS_HAT0X, iforce_hat_to_axis[data[6] >> 4].x);
 			input_report_abs(dev, ABS_HAT0Y, iforce_hat_to_axis[data[6] >> 4].y);
 
-			input_report_key(dev, BTN_TRIGGER, data[5] & 0x01);
-			input_report_key(dev, BTN_TOP,     data[5] & 0x02);
-			input_report_key(dev, BTN_THUMB,   data[5] & 0x04);
-			input_report_key(dev, BTN_TOP2,    data[5] & 0x08);
-			input_report_key(dev, BTN_BASE,    data[5] & 0x10);
-			input_report_key(dev, BTN_BASE2,   data[5] & 0x20);
-			input_report_key(dev, BTN_BASE3,   data[5] & 0x40);
-			input_report_key(dev, BTN_BASE4,   data[5] & 0x80);
-			input_report_key(dev, BTN_BASE5,   data[6] & 0x01);
-			input_report_key(dev, BTN_A,       data[6] & 0x02);
-			input_report_key(dev, BTN_B,       data[6] & 0x04);
-			input_report_key(dev, BTN_C,       data[6] & 0x08);
+			for (i = 0; iforce->type->btn[i] >= 0; i++)
+				input_report_key(dev, iforce->type->btn[i], data[(i >> 3) + 5] & (1 << (i & 7)));
+
 			break;
 
-		case 2: /* force feedback effect status */
+		case 0x02:	/* status report */
+
+			input_report_key(dev, BTN_DEAD, data[0] & 0x02);
 			break;
 	}
 }
 
+static int get_id_packet(struct iforce *iforce, char *packet)
+{
+	DECLARE_WAITQUEUE(wait, current);
+	int timeout = HZ; /* 1 second */
+
+	switch (iforce->bus) {
+
 #ifdef IFORCE_USB
+		case IFORCE_USB:
+
+			iforce->dr.request = packet[0];
+			iforce->ctrl.dev = iforce->usbdev;
+
+			set_current_state(TASK_INTERRUPTIBLE);
+			add_wait_queue(&iforce->wait, &wait);
+
+			if (usb_submit_urb(&iforce->ctrl)) {
+				set_current_state(TASK_RUNNING);
+				remove_wait_queue(&iforce->wait, &wait);
+				return -1;
+			}
+
+			while (timeout && iforce->ctrl.status == -EINPROGRESS)
+				timeout = schedule_timeout(timeout);
+
+			set_current_state(TASK_RUNNING);
+			remove_wait_queue(&iforce->wait, &wait);
+
+			if (!timeout) {
+				usb_unlink_urb(&iforce->ctrl);
+				return -1;
+			}
+
+			break;
+#endif
+#ifdef IFORCE_232
+		case IFORCE_232:
+
+			iforce->expect_packet = FF_CMD_QUERY;
+			send_packet(iforce, FF_CMD_QUERY, packet);
+
+			set_current_state(TASK_INTERRUPTIBLE);
+			add_wait_queue(&iforce->wait, &wait);
+
+			while (timeout && iforce->expect_packet)
+				timeout = schedule_timeout(timeout);
+
+			set_current_state(TASK_RUNNING);
+			remove_wait_queue(&iforce->wait, &wait);
+
+			if (!timeout) {
+				iforce->expect_packet = 0;
+				return -1;
+			}
+
+			break;
+#endif
+	}
+
+	return -(iforce->edata[0] != packet[0]);
+}
 
 static int iforce_open(struct input_dev *dev)
 {
 	struct iforce *iforce = dev->private;
 
-	if (dev->idbus == BUS_USB && !iforce->open++) {
-		iforce->irq.dev = iforce->usbdev;
-		if (usb_submit_urb(&iforce->irq))
-			return -EIO;
+	switch (iforce->bus) {
+#ifdef IFORCE_USB
+		case IFORCE_USB:
+			if (iforce->open++)
+				break;
+			iforce->irq.dev = iforce->usbdev;
+			if (usb_submit_urb(&iforce->irq))
+					return -EIO;
+			break;
+#endif
 	}
-
 	return 0;
 }
 
@@ -128,48 +357,632 @@
 {
 	struct iforce *iforce = dev->private;
 
-	if (dev->idbus == BUS_USB && !--iforce->open)
-		usb_unlink_urb(&iforce->irq);
+	switch (iforce->bus) {
+#ifdef IFORCE_USB
+		case IFORCE_USB:
+			if (!--iforce->open)
+				usb_unlink_urb(&iforce->irq);
+			break;
+#endif
+	}
 }
 
-#endif
+/*
+ * Start or stop playing an effect
+ */
+
+static int iforce_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
+{
+	struct iforce* iforce = (struct iforce*)(dev->private);
+	unsigned char data[3];
+
+	printk(KERN_DEBUG "iforce.c: input_event(type = %d, code = %d, value = %d)\n", type, code, value);
+
+	if (type != EV_FF)
+		return -1;
+
+	switch (code) {
+
+		case FF_GAIN:
+
+			data[0] = value >> 9;
+			send_packet(iforce, FF_CMD_GAIN, data);
+
+			return 0;
+
+		case FF_AUTOCENTER:
+
+			data[0] = 0x03;
+			data[1] = value >> 9;
+			send_packet(iforce, FF_CMD_AUTOCENTER, data);
+
+			data[0] = 0x04;
+			data[1] = 0x01;
+			send_packet(iforce, FF_CMD_AUTOCENTER, data);
+
+			return 0;
+
+		default: /* Play an effect */
+
+			if (code >= iforce->dev.ff_effects_max)
+				return -1;
+
+			data[0] = LO(code);
+			data[1] = (value > 0) ? ((value > 1) ? 0x41 : 0x01) : 0;
+			data[2] = LO(value);
+			send_packet(iforce, FF_CMD_PLAY, data);
+
+			return 0;
+	}
+
+	return -1;
+}
+
+/*
+ * Set the magnitude of a constant force effect
+ * Return error code
+ *
+ * Note: caller must ensure exclusive access to device
+ */
+
+static int make_magnitude_modifier(struct iforce* iforce,
+	struct resource* mod_chunk, __s16 level)
+{
+	unsigned char data[3];
+
+	if (allocate_resource(&(iforce->device_memory), mod_chunk, 2,
+		iforce->device_memory.start, iforce->device_memory.end, 2L,
+		NULL, NULL)) {
+		return -ENOMEM;
+	}
+
+	data[0] = LO(mod_chunk->start);
+	data[1] = HI(mod_chunk->start);
+	data[2] = HI(level);
+
+	send_packet(iforce, FF_CMD_MAGNITUDE, data);
+
+	return 0;
+}
+
+/*
+ * Upload the component of an effect dealing with the period, phase and magnitude
+ */
+
+static int make_period_modifier(struct iforce* iforce, struct resource* mod_chunk,
+	__s16 magnitude, __s16 offset, u16 period, u16 phase)
+{
+	unsigned char data[7];
+
+	period = TIME_SCALE(period);
+
+	if (allocate_resource(&(iforce->device_memory), mod_chunk, 0x0c,
+		iforce->device_memory.start, iforce->device_memory.end, 2L,
+		NULL, NULL)) {
+		return -ENOMEM;
+	}
+
+	data[0] = LO(mod_chunk->start);
+	data[1] = HI(mod_chunk->start);
+
+	data[2] = HI(magnitude);
+	data[3] = HI(offset);
+	data[4] = HI(phase);
+
+	data[5] = LO(period);
+	data[6] = HI(period);
+
+	send_packet(iforce, FF_CMD_PERIOD, data);
+
+	return 0;
+}
+
+/*
+ * Uploads the part of an effect setting the shape of the force
+ */
+
+static int make_shape_modifier(struct iforce* iforce, struct resource* mod_chunk,
+	u16 attack_duration, __s16 initial_level,
+	u16 fade_duration, __s16 final_level)
+{
+	unsigned char data[8];
+
+	attack_duration = TIME_SCALE(attack_duration);
+	fade_duration = TIME_SCALE(fade_duration);
+
+	if (allocate_resource(&(iforce->device_memory), mod_chunk, 0x0e,
+		iforce->device_memory.start, iforce->device_memory.end, 2L,
+		NULL, NULL)) {
+		return -ENOMEM;
+	}
+
+	data[0] = LO(mod_chunk->start);
+	data[1] = HI(mod_chunk->start);
+
+	data[2] = LO(attack_duration);
+	data[3] = HI(attack_duration);
+	data[4] = HI(initial_level);
+
+	data[5] = LO(fade_duration);
+	data[6] = HI(fade_duration);
+	data[7] = HI(final_level);
+
+	send_packet(iforce, FF_CMD_SHAPE, data);
+
+	return 0;
+}
+
+/*
+ * Component of spring, friction, inertia... effects
+ */
+
+static int make_interactive_modifier(struct iforce* iforce,
+	struct resource* mod_chunk,
+	__s16 rsat, __s16 lsat, __s16 rk, __s16 lk, u16 db, __s16 center)
+{
+	unsigned char data[10];
+
+	if (allocate_resource(&(iforce->device_memory), mod_chunk, 8,
+		iforce->device_memory.start, iforce->device_memory.end, 2L,
+		NULL, NULL)) {
+		return -ENOMEM;
+	}
+
+	data[0] = LO(mod_chunk->start);
+	data[1] = HI(mod_chunk->start);
+
+	data[2] = HI(rk);
+	data[3] = HI(lk);
+
+	data[4] = LO(center);
+	data[5] = HI(center);
+
+	data[6] = LO(db);
+	data[7] = HI(db);
 
-static void iforce_input_setup(struct iforce *iforce)
+	data[8] = HI(rsat);
+	data[9] = HI(lsat);
+
+	send_packet(iforce, FF_CMD_INTERACT, data);
+
+	return 0;
+}
+
+static unsigned char find_button(struct iforce *iforce, signed short button)
 {
 	int i;
+	for (i = 1; iforce->type->btn[i] >= 0; i++)
+		if (iforce->type->btn[i] == button)
+			return i + 1;
+	return 0;
+}
+
+/*
+ * Send the part common to all effects to the device
+ */
+
+static int make_core(struct iforce* iforce, u16 id, u16 mod_id1, u16 mod_id2,
+	u8 effect_type, u8 axes, u16 duration, u16 delay, u16 button,
+	u16 interval, u16 direction)
+{
+	unsigned char data[14];
+
+	duration = TIME_SCALE(duration);
+	delay    = TIME_SCALE(delay);
+	interval = TIME_SCALE(interval);
+
+	data[0]  = LO(id);
+	data[1]  = effect_type;
+	data[2]  = LO(axes) | find_button(iforce, button);
+
+	data[3]  = LO(duration);
+	data[4]  = HI(duration);
+
+	data[5]  = HI(direction);
+
+	data[6]  = LO(interval);
+	data[7]  = HI(interval);
 
-	iforce->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
-	iforce->dev.keybit[LONG(BTN_JOYSTICK)] |= BIT(BTN_TRIGGER) | BIT(BTN_TOP) | BIT(BTN_THUMB) | BIT(BTN_TOP2) |
-					BIT(BTN_BASE) | BIT(BTN_BASE2) | BIT(BTN_BASE3) | BIT(BTN_BASE4) | BIT(BTN_BASE5);
-	iforce->dev.keybit[LONG(BTN_GAMEPAD)] |= BIT(BTN_A) | BIT(BTN_B) | BIT(BTN_C);
-	iforce->dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_THROTTLE) | BIT(ABS_HAT0X) | BIT(ABS_HAT0Y)
-				| BIT(ABS_WHEEL) | BIT(ABS_GAS) | BIT(ABS_BRAKE);
-
-	for (i = ABS_X; i <= ABS_Y; i++) {
-		iforce->dev.absmax[i] =  1920;
-		iforce->dev.absmin[i] = -1920;
-		iforce->dev.absflat[i] = 128;
-		iforce->dev.absfuzz[i] = 16;
-	}
-
-	for (i = ABS_THROTTLE; i <= ABS_RUDDER; i++) {
-		iforce->dev.absmax[i] = 255;
-		iforce->dev.absmin[i] = 0;
-	}
-
-	for (i = ABS_HAT0X; i <= ABS_HAT0Y; i++) {
-		iforce->dev.absmax[i] =  1;
-		iforce->dev.absmin[i] = -1;
+	data[8]  = LO(mod_id1);
+	data[9]  = HI(mod_id1);
+	data[10] = LO(mod_id2);
+	data[11] = HI(mod_id2);
+
+	data[12] = LO(delay);
+	data[13] = HI(delay);
+
+	send_packet(iforce, FF_CMD_EFFECT, data);
+
+	return 0;
+}
+
+/*
+ * Upload a periodic effect to the device
+ */
+
+static int iforce_upload_periodic(struct iforce* iforce, struct ff_effect* effect)
+{
+	u8 wave_code;
+	int core_id = effect->id;
+	struct iforce_core_effect* core_effect = iforce->core_effects + core_id;
+	struct resource* mod1_chunk = &(iforce->core_effects[core_id].mod1_chunk);
+	struct resource* mod2_chunk = &(iforce->core_effects[core_id].mod2_chunk);
+	int err = 0;
+
+	err = make_period_modifier(iforce, mod1_chunk,
+		effect->u.periodic.magnitude, effect->u.periodic.offset,
+		effect->u.periodic.period, effect->u.periodic.phase);
+	if (err) return err;
+	set_bit(FF_MOD1_IS_USED, core_effect->flags);
+
+	err = make_shape_modifier(iforce, mod2_chunk,
+		effect->u.periodic.shape.attack_length,
+		effect->u.periodic.shape.attack_level,
+		effect->u.periodic.shape.fade_length,
+		effect->u.periodic.shape.fade_level);
+	if (err) return err;
+	set_bit(FF_MOD2_IS_USED, core_effect->flags);
+
+	switch (effect->u.periodic.waveform) {
+		case FF_SQUARE:		wave_code = 0x20; break;
+		case FF_TRIANGLE:	wave_code = 0x21; break;
+		case FF_SINE:		wave_code = 0x22; break;
+		case FF_SAW_UP:		wave_code = 0x23; break;
+		case FF_SAW_DOWN:	wave_code = 0x24; break;
+		default:		wave_code = 0x20; break;
 	}
 
-	iforce->dev.private = iforce;
+	err = make_core(iforce, effect->id,
+		mod1_chunk->start,
+		mod2_chunk->start,
+		wave_code,
+		0x20,
+		effect->replay.length,
+		effect->replay.delay,
+		effect->trigger.button,
+		effect->trigger.interval,
+		effect->u.periodic.direction);
 
-#ifdef IFORCE_USB
+	return err;
+}
+
+/*
+ * Upload a constant force effect
+ */
+static int iforce_upload_constant(struct iforce* iforce, struct ff_effect* effect)
+{
+	int core_id = effect->id;
+	struct iforce_core_effect* core_effect = iforce->core_effects + core_id;
+	struct resource* mod1_chunk = &(iforce->core_effects[core_id].mod1_chunk);
+	struct resource* mod2_chunk = &(iforce->core_effects[core_id].mod2_chunk);
+	int err = 0;
+
+	printk(KERN_DEBUG "iforce.c: make constant effect\n");
+
+	err = make_magnitude_modifier(iforce, mod1_chunk, effect->u.constant.level);
+	if (err) return err;
+	set_bit(FF_MOD1_IS_USED, core_effect->flags);
+
+	err = make_shape_modifier(iforce, mod2_chunk,
+		effect->u.constant.shape.attack_length,
+		effect->u.constant.shape.attack_level,
+		effect->u.constant.shape.fade_length,
+		effect->u.constant.shape.fade_level);
+	if (err) return err;
+	set_bit(FF_MOD2_IS_USED, core_effect->flags);
+
+	err = make_core(iforce, effect->id,
+		mod1_chunk->start,
+		mod2_chunk->start,
+		0x00,
+		0x20,
+		effect->replay.length,
+		effect->replay.delay,
+		effect->trigger.button,
+		effect->trigger.interval,
+		effect->u.constant.direction);
+
+	return err;
+}
+
+/*
+ * Upload an interactive effect. Those are for example friction, inertia, springs...
+ */
+static int iforce_upload_interactive(struct iforce* iforce, struct ff_effect* effect)
+{
+	int core_id = effect->id;
+	struct iforce_core_effect* core_effect = iforce->core_effects + core_id;
+	struct resource* mod_chunk = &(core_effect->mod1_chunk);
+	u8 type, axes;
+	u16 mod1, mod2, direction;
+	int err = 0;
+
+	printk(KERN_DEBUG "iforce.c: make interactive effect\n");
+
+	switch (effect->type) {
+		case FF_SPRING:		type = 0x40; break;
+		case FF_FRICTION:	type = 0x41; break;
+		default: return -1;
+	}
+
+	err = make_interactive_modifier(iforce, mod_chunk,
+		effect->u.interactive.right_saturation,
+		effect->u.interactive.left_saturation,
+		effect->u.interactive.right_coeff,
+		effect->u.interactive.left_coeff,
+		effect->u.interactive.deadband,
+		effect->u.interactive.center);
+	if (err) return err;
+	set_bit(FF_MOD1_IS_USED, core_effect->flags);
+
+	switch ((test_bit(ABS_X, &effect->u.interactive.axis) ||
+		test_bit(ABS_WHEEL, &effect->u.interactive.axis)) |
+		(!!test_bit(ABS_Y, &effect->u.interactive.axis) << 1)) {
+
+		case 0: /* Only one axis, choose orientation */
+			mod1 = mod_chunk->start;
+			mod2 = 0xffff;
+			direction = effect->u.interactive.direction;
+			axes = 0x20;
+			break;
+
+		case 1:	/* Only X axis */
+			mod1 = mod_chunk->start;
+			mod2 = 0xffff;
+			direction = 0x5a00;
+			axes = 0x40;
+			break;
+
+		case 2: /* Only Y axis */
+			mod1 = 0xffff;
+			mod2 = mod_chunk->start;
+			direction = 0xb400;
+			axes = 0x80;
+			break;
+
+		case 3:	/* Both X and Y axes */
+			/* TODO: same setting for both axes is not mandatory */
+			mod1 = mod_chunk->start;
+			mod2 = mod_chunk->start;
+			direction = 0x6000;
+			axes = 0xc0;
+			break;
+
+		default:
+			return -1;
+	}
+
+	err = make_core(iforce, effect->id,
+		mod1, mod2,
+		type, axes,
+		effect->replay.length, effect->replay.delay,
+		effect->trigger.button, effect->trigger.interval,
+		direction);
+
+	return err;
+}
+
+/*
+ * Function called when an ioctl is performed on the event dev entry.
+ * It uploads an effect to the device
+ */
+static int iforce_upload_effect(struct input_dev *dev, struct ff_effect *effect)
+{
+	struct iforce* iforce = (struct iforce*)(dev->private);
+	int id;
+
+	printk(KERN_DEBUG "iforce.c: upload effect\n");
+
+/*
+ * Get a free id
+ */
+
+	for (id=0; id < FF_EFFECTS_MAX; ++id)
+		if (!test_bit(FF_CORE_IS_USED, iforce->core_effects[id].flags)) break;
+
+	if ( id == FF_EFFECTS_MAX || id >= iforce->dev.ff_effects_max)
+		return -ENOMEM;
+
+	effect->id = id;
+	set_bit(FF_CORE_IS_USED, iforce->core_effects[id].flags);
+
+/*
+ * Upload the effect
+ */
+
+	switch (effect->type) {
+
+		case FF_PERIODIC:
+			return iforce_upload_periodic(iforce, effect);
+
+		case FF_CONSTANT:
+			return iforce_upload_constant(iforce, effect);
+
+		case FF_SPRING:
+		case FF_FRICTION:
+			return iforce_upload_interactive(iforce, effect);
+
+		default:
+			return -1;
+	}
+}
+
+/*
+ * Erases an effect: it frees the effect id and mark as unused the memory
+ * allocated for the parameters
+ */
+static int iforce_erase_effect(struct input_dev *dev, int effect_id)
+{
+	struct iforce* iforce = (struct iforce*)(dev->private);
+	int err = 0;
+	struct iforce_core_effect* core_effect;
+
+	printk(KERN_DEBUG "iforce.c: erase effect %d\n", effect_id);
+
+	if (effect_id < 0 || effect_id >= FF_EFFECTS_MAX)
+		return -EINVAL;
+
+	core_effect = iforce->core_effects + effect_id;
+
+	if (test_bit(FF_MOD1_IS_USED, core_effect->flags))
+		err = release_resource(&(iforce->core_effects[effect_id].mod1_chunk));
+
+	if (!err && test_bit(FF_MOD2_IS_USED, core_effect->flags))
+		err = release_resource(&(iforce->core_effects[effect_id].mod2_chunk));
+
+	/*TODO: remember to change that if more FF_MOD* bits are added */
+	core_effect->flags[0] = 0;
+
+	return err;
+}
+static int iforce_init_device(struct iforce *iforce)
+{
+	unsigned char c[] = "CEOV";
+	int i;
+
+	init_waitqueue_head(&iforce->wait);
+	iforce->dev.ff_effects_max = 10;
+
+/*
+ * Input device fields.
+ */
+
+	iforce->dev.idbus = BUS_USB;
+	iforce->dev.private = iforce;
+	iforce->dev.name = iforce->name;
 	iforce->dev.open = iforce_open;
 	iforce->dev.close = iforce_close;
-#endif
+	iforce->dev.event = iforce_input_event;
+	iforce->dev.upload_effect = iforce_upload_effect;
+	iforce->dev.erase_effect = iforce_erase_effect;
+
+/*
+ * On-device memory allocation.
+ */
+
+	iforce->device_memory.name = "I-Force device effect memory";
+	iforce->device_memory.start = 0;
+	iforce->device_memory.end = 200;
+	iforce->device_memory.flags = IORESOURCE_MEM;
+	iforce->device_memory.parent = NULL;
+	iforce->device_memory.child = NULL;
+	iforce->device_memory.sibling = NULL;
+
+/*
+ * Wait until device ready - until it sends its first response.
+ */
+
+	for (i = 0; i < 20; i++)
+		if (!get_id_packet(iforce, "O"))
+			break;
+
+	if (i == 20) { /* 5 seconds */
+		printk(KERN_ERR "iforce.c: Timeout waiting for response from device.\n");
+		iforce_close(&iforce->dev);
+		return -1;
+	}
+
+/*
+ * Get device info.
+ */
+
+	if (!get_id_packet(iforce, "M"))
+		iforce->dev.idvendor = (iforce->edata[2] << 8) | iforce->edata[1];
+	if (!get_id_packet(iforce, "P"))
+		iforce->dev.idproduct = (iforce->edata[2] << 8) | iforce->edata[1];
+	if (!get_id_packet(iforce, "B"))
+		iforce->device_memory.end = (iforce->edata[2] << 8) | iforce->edata[1];
+	if (!get_id_packet(iforce, "N"))
+		iforce->dev.ff_effects_max = iforce->edata[1];
+
+/*
+ * Display additional info.
+ */
+
+	for (i = 0; c[i]; i++)
+		if (!get_id_packet(iforce, c + i))
+			dump_packet("info", iforce->ecmd, iforce->edata);
+
+/*
+ * Disable spring, enable force feedback.
+ * FIXME: We should use iforce_set_autocenter() et al here.
+ */
+
+	send_packet(iforce, FF_CMD_AUTOCENTER, "\004\000");
+	send_packet(iforce, FF_CMD_ENABLE, "\004");
+
+/*
+ * Find appropriate device entry
+ */
+
+	for (i = 0; iforce_device[i].idvendor; i++)
+		if (iforce_device[i].idvendor == iforce->dev.idvendor &&
+		    iforce_device[i].idproduct == iforce->dev.idproduct)
+			break;
+
+	iforce->type = iforce_device + i;
+
+	sprintf(iforce->name, iforce->type->name,
+		iforce->dev.idproduct, iforce->dev.idvendor);
+
+/*
+ * Set input device bitfields and ranges.
+ */
+
+	iforce->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_FF);
+
+	for (i = 0; iforce->type->btn[i] >= 0; i++) {
+		signed short t = iforce->type->btn[i];
+		set_bit(t, iforce->dev.keybit);
+		if (t != BTN_DEAD)
+			set_bit(FF_BTN(t), iforce->dev.ffbit);
+	}
+
+	for (i = 0; iforce->type->abs[i] >= 0; i++) {
+
+		signed short t = iforce->type->abs[i];
+		set_bit(t, iforce->dev.absbit);
+
+		switch (t) {
+
+			case ABS_X:
+			case ABS_Y:
+			case ABS_WHEEL:
+
+				iforce->dev.absmax[t] =  1920;
+				iforce->dev.absmin[t] = -1920;
+				iforce->dev.absflat[t] = 128;
+				iforce->dev.absfuzz[t] = 16;
+
+				set_bit(FF_ABS(t), iforce->dev.ffbit);
+				break;
+
+			case ABS_THROTTLE:
+			case ABS_GAS:
+			case ABS_BRAKE:
+
+				iforce->dev.absmax[t] = 255;
+				iforce->dev.absmin[t] = 0;
+				break;
+
+			case ABS_HAT0X:
+			case ABS_HAT0Y:
+				iforce->dev.absmax[t] =  1;
+				iforce->dev.absmin[t] = -1;
+				break;
+		}
+	}
+
+	for (i = 0; iforce->type->ff[i] >= 0; i++)
+		set_bit(iforce->type->ff[i], iforce->dev.ffbit);
+
+/*
+ * Register input device.
+ */
 
 	input_register_device(&iforce->dev);
+
+	return 0;
 }
 
 #ifdef IFORCE_USB
@@ -178,33 +991,63 @@
 {
 	struct iforce *iforce = urb->context;
 	if (urb->status) return;
-	iforce_process_packet(&iforce->dev, iforce->data[0], 8, iforce->data + 1);
+	iforce_process_packet(iforce,
+		(iforce->data[0] << 8) | (urb->actual_length - 1), iforce->data + 1);
+}
+
+static void iforce_usb_out(struct urb *urb)
+{
+	struct iforce *iforce = urb->context;
+	if (urb->status) return;
+	if (waitqueue_active(&iforce->wait))
+		wake_up(&iforce->wait);
+}
+
+static void iforce_usb_ctrl(struct urb *urb)
+{
+	struct iforce *iforce = urb->context;
+	if (urb->status) return;
+	iforce->ecmd = 0xff00 | urb->actual_length;
+	if (waitqueue_active(&iforce->wait))
+		wake_up(&iforce->wait);
 }
 
 static void *iforce_usb_probe(struct usb_device *dev, unsigned int ifnum,
-			      const struct usb_device_id *id)
+				const struct usb_device_id *id)
 {
-	struct usb_endpoint_descriptor *endpoint;
+	struct usb_endpoint_descriptor *epirq, *epout;
 	struct iforce *iforce;
 
-	endpoint = dev->config[0].interface[ifnum].altsetting[0].endpoint + 0;
+	epirq = dev->config[0].interface[ifnum].altsetting[0].endpoint + 0;
+	epout = dev->config[0].interface[ifnum].altsetting[0].endpoint + 1;
 
-	if (!(iforce = kmalloc(sizeof(struct iforce), GFP_KERNEL))) return NULL;
+	if (!(iforce = kmalloc(sizeof(struct iforce) + 32, GFP_KERNEL))) return NULL;
 	memset(iforce, 0, sizeof(struct iforce));
 
-	iforce->dev.name = iforce_name;
-	iforce->dev.idbus = BUS_USB;
-	iforce->dev.idvendor = dev->descriptor.idVendor;
-	iforce->dev.idproduct = dev->descriptor.idProduct;
-	iforce->dev.idversion = dev->descriptor.bcdDevice;
+	iforce->bus = IFORCE_USB;
+	iforce->usbdev = dev;
+
+	iforce->dr.requesttype = USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_INTERFACE;
+	iforce->dr.index = 0;
+	iforce->dr.length = 16;
+
+	FILL_INT_URB(&iforce->irq, dev, usb_rcvintpipe(dev, epirq->bEndpointAddress),
+			iforce->data, 16, iforce_usb_irq, iforce, epirq->bInterval);
 
-	FILL_INT_URB(&iforce->irq, dev, usb_rcvintpipe(dev, endpoint->bEndpointAddress),
-			iforce->data, 8, iforce_usb_irq, iforce, endpoint->bInterval);
+	FILL_BULK_URB(&iforce->out, dev, usb_sndbulkpipe(dev, epout->bEndpointAddress),
+			iforce + 1, 32, iforce_usb_out, iforce);
 
-	iforce_input_setup(iforce);
+	FILL_CONTROL_URB(&iforce->ctrl, dev, usb_rcvctrlpipe(dev, 0),
+			(void*) &iforce->dr, iforce->edata, 16, iforce_usb_ctrl, iforce);
 
-	printk(KERN_INFO "input%d: %s on usb%d:%d.%d\n",
-		 iforce->dev.number, iforce_name, dev->bus->busnum, dev->devnum, ifnum);
+	if (iforce_init_device(iforce)) {
+		kfree(iforce);
+		return NULL;
+	}
+
+	printk(KERN_INFO "input%d: %s [%d effects, %ld bytes memory] on usb%d:%d.%d\n",
+		iforce->dev.number, iforce->dev.name, iforce->dev.ff_effects_max,
+		iforce->device_memory.end, dev->bus->busnum, dev->devnum, ifnum);
 
 	return iforce;
 }
@@ -218,8 +1061,12 @@
 }
 
 static struct usb_device_id iforce_usb_ids [] = {
-	{ USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WMFORCE) },
-	{ }						/* Terminating entry */
+	{ USB_DEVICE(0x046d, 0xc281) },		/* Logitech WingMan Force */
+	{ USB_DEVICE(0x046d, 0xc291) },		/* Logitech WingMan Formula Force */
+	{ USB_DEVICE(0x05ef, 0x020a) },		/* AVB Top Shot Pegasus */
+	{ USB_DEVICE(0x05ef, 0x8884) },		/* AVB Mag Turbo Force */
+	{ USB_DEVICE(0x06f8, 0x0001) },		/* Guillemot Race Leader Force Feedback */
+	{ }					/* Terminating entry */
 };
 
 MODULE_DEVICE_TABLE (usb, iforce_usb_ids);
@@ -237,7 +1084,7 @@
 
 static void iforce_serio_irq(struct serio *serio, unsigned char data, unsigned int flags)
 {
-        struct iforce* iforce = serio->private;
+	struct iforce* iforce = serio->private;
 
 	if (!iforce->pkt) {
 		if (data != 0x2b) {
@@ -247,14 +1094,14 @@
 		return;
 	}
 
-        if (!iforce->id) {
-		if (data > 3) {
+	if (!iforce->id) {
+		if (data > 3 && data != 0xff) {
 			iforce->pkt = 0;
 			return;
 		}
-                iforce->id = data;
+		iforce->id = data;
 		return;
-        }
+	}
 
 	if (!iforce->len) {
 		if (data > IFORCE_MAX_LENGTH) {
@@ -266,37 +1113,32 @@
 		return;
 	}
 
-        if (iforce->idx < iforce->len) {
-                iforce->csum += iforce->data[iforce->idx++] = data;
+	if (iforce->idx < iforce->len) {
+		iforce->csum += iforce->data[iforce->idx++] = data;
 		return;
 	}
 
-        if (iforce->idx == iforce->len) {
-		iforce_process_packet(&iforce->dev, iforce->id, iforce->idx, iforce->data);
+	if (iforce->idx == iforce->len) {
+		iforce_process_packet(iforce, (iforce->id << 8) | iforce->idx, iforce->data);
 		iforce->pkt = 0;
 		iforce->id  = 0;
-                iforce->len = 0;
-                iforce->idx = 0;
+		iforce->len = 0;
+		iforce->idx = 0;
 		iforce->csum = 0;
-        }
+	}
 }
 
 static void iforce_serio_connect(struct serio *serio, struct serio_dev *dev)
 {
 	struct iforce *iforce;
-
 	if (serio->type != (SERIO_RS232 | SERIO_IFORCE))
 		return;
 
 	if (!(iforce = kmalloc(sizeof(struct iforce), GFP_KERNEL))) return;
 	memset(iforce, 0, sizeof(struct iforce));
 
-	iforce->dev.name = iforce_name;
-	iforce->dev.idbus = BUS_RS232;
-	iforce->dev.idvendor = SERIO_IFORCE;
-	iforce->dev.idproduct = 0x0001;
-	iforce->dev.idversion = 0x0100;
-
+	iforce->bus = IFORCE_232;
+	iforce->serio = serio;
 	serio->private = iforce;
 
 	if (serio_open(serio, dev)) {
@@ -304,15 +1146,21 @@
 		return;
 	}
 
-	iforce_input_setup(iforce);
+	if (iforce_init_device(iforce)) {
+		serio_close(serio);
+		kfree(iforce);
+		return;
+	}
 
-	printk(KERN_INFO "input%d: %s on serio%d\n",
-		 iforce->dev.number, iforce_name, serio->number);
+	printk(KERN_INFO "input%d: %s [%d effects, %ld bytes memory] on serio%d\n",
+		iforce->dev.number, iforce->dev.name, iforce->dev.ff_effects_max,
+		iforce->device_memory.end, serio->number);
 }
 
 static void iforce_serio_disconnect(struct serio *serio)
 {
 	struct iforce* iforce = serio->private;
+
 	input_unregister_device(&iforce->dev);
 	serio_close(serio);
 	kfree(iforce);
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/interact.c linux/drivers/char/joystick/interact.c
--- v2.4.9/linux/drivers/char/joystick/interact.c	Fri Feb  9 11:30:23 2001
+++ linux/drivers/char/joystick/interact.c	Wed Sep 12 15:34:06 2001
@@ -304,3 +304,5 @@
 
 module_init(interact_init);
 module_exit(interact_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/lightning.c linux/drivers/char/joystick/lightning.c
--- v2.4.9/linux/drivers/char/joystick/lightning.c	Fri Feb  9 11:30:23 2001
+++ linux/drivers/char/joystick/lightning.c	Wed Sep 12 15:34:06 2001
@@ -1,7 +1,7 @@
 /*
- * $Id: lightning.c,v 1.7 2000/05/24 19:36:03 vojtech Exp $
+ * $Id: lightning.c,v 1.13 2001/04/26 10:24:46 vojtech Exp $
  *
- *  Copyright (c) 1998-2000 Vojtech Pavlik
+ *  Copyright (c) 1998-2001 Vojtech Pavlik
  *
  *  Sponsored by SuSE
  */
@@ -52,6 +52,7 @@
 #define L4_TIMEOUT		80	/* 80 us */
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
+MODULE_LICENSE("GPL");
 
 struct l4 {
 	struct gameport gameport;
@@ -76,7 +77,7 @@
 
 static int l4_cooked_read(struct gameport *gameport, int *axes, int *buttons)
 {
-	struct l4 *l4 = gameport->driver;
+	struct l4 *l4 = gameport->private;
 	unsigned char status;
 	int i, result = -1;
 
@@ -109,7 +110,7 @@
 
 static int l4_open(struct gameport *gameport, int mode)
 {
-	struct l4 *l4 = gameport->driver;
+	struct l4 *l4 = gameport->private;
         if (l4->port != 0 && mode != GAMEPORT_MODE_COOKED)
 		return -1;
 	outb(L4_SELECT_ANALOG, L4_PORT);
@@ -187,7 +188,7 @@
 {
 	int i, t;
 	int cal[4];
-	struct l4 *l4 = gameport->driver;
+	struct l4 *l4 = gameport->private;
 
 	if (l4_getcal(l4->port, cal))
 		return -1;
@@ -247,16 +248,13 @@
 			l4->port = i * 4 + j;
 
 			gameport = &l4->gameport;
-			gameport->driver = l4;
+			gameport->private = l4;
 			gameport->open = l4_open;
 			gameport->cooked_read = l4_cooked_read;
 			gameport->calibrate = l4_calibrate;
-			gameport->type = GAMEPORT_EXT;
 
-			if (!i && !j) {
+			if (!i && !j)
 				gameport->io = L4_PORT;
-				gameport->size = 1;
-			}
 
 			if (rev > 0x28)		/* on 2.9+ the setcal command works correctly */
 				l4_setcal(l4->port, cal);
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/magellan.c linux/drivers/char/joystick/magellan.c
--- v2.4.9/linux/drivers/char/joystick/magellan.c	Fri Feb  9 11:30:23 2001
+++ linux/drivers/char/joystick/magellan.c	Wed Sep 12 15:34:06 2001
@@ -208,3 +208,5 @@
 
 module_init(magellan_init);
 module_exit(magellan_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/ns558.c linux/drivers/char/joystick/ns558.c
--- v2.4.9/linux/drivers/char/joystick/ns558.c	Wed Apr 11 19:02:30 2001
+++ linux/drivers/char/joystick/ns558.c	Wed Sep 12 15:34:06 2001
@@ -1,7 +1,7 @@
 /*
- * $Id: ns558.c,v 1.27 2001/03/28 09:25:05 vojtech Exp $
+ * $Id: ns558.c,v 1.29 2001/04/24 07:48:56 vojtech Exp $
  *
- *  Copyright (c) 1999-2000 Vojtech Pavlik
+ *  Copyright (c) 1999-2001 Vojtech Pavlik
  *  Copyright (c) 1999 Brian Gerst
  *
  *  Sponsored by SuSE
@@ -42,23 +42,23 @@
 #include <linux/isapnp.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
+MODULE_LICENSE("GPL");
 
 #define NS558_ISA	1
 #define NS558_PNP	2
-#define NS558_PCI	3
 
 static int ns558_isa_portlist[] = { 0x200, 0x201, 0x202, 0x203, 0x204, 0x205, 0x207, 0x209,
 				    0x20b, 0x20c, 0x20e, 0x20f, 0x211, 0x219, 0x101, 0 };
 
 struct ns558 {
 	int type;
+	int size;
 	struct pci_dev *dev;
 	struct ns558 *next;
 	struct gameport gameport;
 };
 	
 static struct ns558 *ns558;
-static int ns558_pci;
 
 /*
  * ns558_isa_probe() tries to find an isa gameport at the
@@ -132,122 +132,43 @@
 	i--;
 
 	if (!(port = kmalloc(sizeof(struct ns558), GFP_KERNEL))) {
-		printk(KERN_ERR "Memory allocation failed.\n");
+		printk(KERN_ERR "ns558: Memory allocation failed.\n");
 		return next;
 	}
        	memset(port, 0, sizeof(struct ns558));
 	
 	port->next = next;
 	port->type = NS558_ISA;
+	port->size = (1 << i);
 	port->gameport.io = io & (-1 << i);
-	port->gameport.size = (1 << i);
 
-	request_region(port->gameport.io, port->gameport.size, "ns558-isa");
+	request_region(port->gameport.io, (1 << i), "ns558-isa");
 
 	gameport_register_port(&port->gameport);
 
 	printk(KERN_INFO "gameport%d: NS558 ISA at %#x", port->gameport.number, port->gameport.io);
-	if (port->gameport.size > 1) printk(" size %d", port->gameport.size);
+	if (port->size > 1) printk(" size %d", port->size);
 	printk(" speed %d kHz\n", port->gameport.speed);
 
 	return port;
 }
 
-#ifdef CONFIG_PCI
-static struct pci_device_id ns558_pci_tbl[] __devinitdata = {
-	{ 0x1102, 0x7002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB Live! gameport */
-	{ 0x125d, 0x1969, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 }, /* ESS Solo 1 */
-	{ 0x5333, 0xca00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 }, /* S3 SonicVibes */
-	{ 0, }
-};
-MODULE_DEVICE_TABLE(pci, ns558_pci_tbl);
-
-static int __devinit ns558_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
-{
-	int ioport, iolen;
-	int rc;
-	struct ns558 *port;
-        
-	rc = pci_enable_device(pdev);
-	if (rc) {
-		printk(KERN_ERR "ns558: Cannot enable PCI gameport (bus %d, devfn %d) error=%d\n",
-			pdev->bus->number, pdev->devfn, rc);
-		return rc;
-	}
-
-	ioport = pci_resource_start(pdev, ent->driver_data);
-	iolen = pci_resource_len(pdev, ent->driver_data);
-
-	if (!request_region(ioport, iolen, "ns558-pci"))
-		return -EBUSY;
-
-	if (!(port = kmalloc(sizeof(struct ns558), GFP_KERNEL))) {
-		printk(KERN_ERR "Memory allocation failed.\n");
-		release_region(ioport, iolen);
-		return -ENOMEM;
-	}
-	memset(port, 0, sizeof(struct ns558));
-
-	port->type = NS558_PCI;
-	port->gameport.io = ioport;
-	port->gameport.size = iolen;
-	port->dev = pdev;
-
-	pdev->driver_data = port;
-
-	gameport_register_port(&port->gameport);
-
-	printk(KERN_INFO "gameport%d: NS558 PCI at %#x", port->gameport.number, port->gameport.io);
-	if (port->gameport.size > 1) printk(" size %d", port->gameport.size);
-	printk(" speed %d kHz\n", port->gameport.speed);
-
-	return 0;
-}
-
-static void __devexit ns558_pci_remove(struct pci_dev *pdev)
-{
-	struct ns558 *port = (struct ns558 *)pdev->driver_data;
-	release_region(port->gameport.io, port->gameport.size);
-	kfree(port);
-}
-
-static struct pci_driver ns558_pci_driver = {
-        name:           "PCI Gameport",
-        id_table:       ns558_pci_tbl,
-        probe:          ns558_pci_probe,
-        remove:         ns558_pci_remove,
-};
-#else
-static struct pci_driver ns558_pci_driver;
-#endif /* CONFIG_PCI */
-
-
 #if defined(CONFIG_ISAPNP) || (defined(CONFIG_ISAPNP_MODULE) && defined(MODULE))
 #define NSS558_ISAPNP
 #endif
 
 #ifdef NSS558_ISAPNP
-/*
- * PnP IDs:
- *
- * @P@0001 - ALS 100 (no comp. ID)
- * CTL00c1 - SB AWE32 PnP
- * CTL00c3 - SB AWE64 PnP
- * CTL00f0 - SB16 PnP / Vibra 16x
- * CTL7001 - SB Vibra16C PnP (no comp. ID)
- * CTL7002 - SB AWE32 (no comp. ID)
- * CSC0b35 - Crystal (no comp. ID)
- * TER1141 - Terratec AD1818
- * YMM0800 - Yamaha OPL3-SA3
- *
- * PNPb02f - Generic gameport
- */
 
 static struct isapnp_device_id pnp_devids[] = {
 	{ ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('@','P','@'), ISAPNP_DEVICE(0x0001), 0 },
+	{ ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('@','P','@'), ISAPNP_DEVICE(0x2001), 0 },
 	{ ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('C','T','L'), ISAPNP_DEVICE(0x7001), 0 },
 	{ ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('C','T','L'), ISAPNP_DEVICE(0x7002), 0 },
+	{ ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('C','S','C'), ISAPNP_DEVICE(0x0010), 0 },
+	{ ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('C','S','C'), ISAPNP_DEVICE(0x0110), 0 },
 	{ ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('C','S','C'), ISAPNP_DEVICE(0x0b35), 0 },
+	{ ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('C','S','C'), ISAPNP_DEVICE(0x0010), 0 },
+	{ ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('C','S','C'), ISAPNP_DEVICE(0x0110), 0 },
 	{ ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('P','N','P'), ISAPNP_DEVICE(0xb02f), 0 },
 	{ 0, },
 };
@@ -263,12 +184,12 @@
 		return next;
 
 	if (!(dev->resource[0].flags & IORESOURCE_IO)) {
-		printk(KERN_WARNING "No i/o ports on a gameport? Weird\n");
+		printk(KERN_WARNING "ns558: No i/o ports on a gameport? Weird\n");
 		return next;
 	}
 
 	if (dev->activate && dev->activate(dev) < 0) {
-		printk(KERN_ERR "PnP resource allocation failed\n");
+		printk(KERN_ERR "ns558: PnP resource allocation failed\n");
 		return next;
 	}
 	
@@ -279,7 +200,7 @@
 		goto deactivate;
 
 	if (!(port = kmalloc(sizeof(struct ns558), GFP_KERNEL))) {
-		printk(KERN_ERR "Memory allocation failed.\n");
+		printk(KERN_ERR "ns558: Memory allocation failed.\n");
 		goto deactivate;
 	}
 	memset(port, 0, sizeof(struct ns558));
@@ -287,13 +208,13 @@
 	port->next = next;
 	port->type = NS558_PNP;
 	port->gameport.io = ioport;
-	port->gameport.size = iolen;
+	port->size = iolen;
 	port->dev = dev;
 
 	gameport_register_port(&port->gameport);
 
 	printk(KERN_INFO "gameport%d: NS558 PnP at %#x", port->gameport.number, port->gameport.io);
-	if (port->gameport.size > 1) printk(" size %d", port->gameport.size);
+	if (iolen > 1) printk(" size %d", iolen);
 	printk(" speed %d kHz\n", port->gameport.speed);
 
 	return port;
@@ -309,18 +230,11 @@
 {
 	int i = 0;
 #ifdef NSS558_ISAPNP
-	struct pci_dev *dev = NULL;
 	struct isapnp_device_id *devid;
+	struct pci_dev *dev = NULL;
 #endif
 
 /*
- * Probe for PCI ports.  Always probe for PCI first,
- * it is the least-invasive probe.
- */
-
-	ns558_pci = !pci_module_init(&ns558_pci_driver);
-
-/*
  * Probe for ISA ports.
  */
 
@@ -339,7 +253,7 @@
 	}
 #endif
 
-	return (ns558 || ns558_pci) ? 0 : -ENODEV;
+	return ns558 ? 0 : -ENODEV;
 }
 
 void __exit ns558_exit(void)
@@ -358,7 +272,7 @@
 #endif
 
 			case NS558_ISA:
-				release_region(port->gameport.io, port->gameport.size);
+				release_region(port->gameport.io, port->size);
 				break;
 		
 			default:
@@ -369,9 +283,6 @@
 		kfree(port);
 		port = next;
 	}
-
-	if (ns558_pci)
-		pci_unregister_driver(&ns558_pci_driver);
 }
 
 module_init(ns558_init);
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/pcigame.c linux/drivers/char/joystick/pcigame.c
--- v2.4.9/linux/drivers/char/joystick/pcigame.c	Fri Sep 22 14:21:17 2000
+++ linux/drivers/char/joystick/pcigame.c	Wed Sep 12 15:34:06 2001
@@ -1,7 +1,7 @@
 /*
- * $Id: pcigame.c,v 1.6 2000/05/25 12:05:24 vojtech Exp $
+ * $Id: pcigame.c,v 1.10 2001/04/26 10:24:46 vojtech Exp $
  *
- *  Copyright (c) 2000 Vojtech Pavlik
+ *  Copyright (c) 2000-2001 Vojtech Pavlik
  *
  *  Based on the work of:
  *	Raymond Ingles
@@ -76,19 +76,19 @@
 
 static unsigned char pcigame_read(struct gameport *gameport)
 {
-	struct pcigame *pcigame = gameport->driver;
+	struct pcigame *pcigame = gameport->private;
 	return readb(pcigame->base + pcigame->data->legacy);
 }
 
 static void pcigame_trigger(struct gameport *gameport)
 {
-	struct pcigame *pcigame = gameport->driver;
+	struct pcigame *pcigame = gameport->private;
 	writeb(0xff, pcigame->base + pcigame->data->legacy);
 }
 
 static int pcigame_cooked_read(struct gameport *gameport, int *axes, int *buttons)
 {
-        struct pcigame *pcigame = gameport->driver;
+        struct pcigame *pcigame = gameport->private;
 	int i;
 
 	*buttons = (~readb(pcigame->base + pcigame->data->legacy) >> 4) & 0xf;
@@ -103,7 +103,7 @@
 
 static int pcigame_open(struct gameport *gameport, int mode)
 {
-	struct pcigame *pcigame = gameport->driver;
+	struct pcigame *pcigame = gameport->private;
 
 	switch (mode) {
 		case GAMEPORT_MODE_COOKED:
@@ -135,8 +135,7 @@
 	pcigame->dev = dev;
 	dev->driver_data = pcigame;
 
-	pcigame->gameport.driver = pcigame;
-	pcigame->gameport.type = GAMEPORT_EXT;
+	pcigame->gameport.private = pcigame;
 	pcigame->gameport.fuzz = 64;
 	
 	pcigame->gameport.read = pcigame_read;
@@ -196,3 +195,5 @@
 
 module_init(pcigame_init);
 module_exit(pcigame_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/serio.c linux/drivers/char/joystick/serio.c
--- v2.4.9/linux/drivers/char/joystick/serio.c	Mon Oct 16 12:58:51 2000
+++ linux/drivers/char/joystick/serio.c	Wed Sep 12 15:34:06 2001
@@ -35,6 +35,7 @@
 #include <linux/serio.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
+MODULE_LICENSE("GPL");
 
 EXPORT_SYMBOL(serio_register_port);
 EXPORT_SYMBOL(serio_unregister_port);
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/serport.c linux/drivers/char/joystick/serport.c
--- v2.4.9/linux/drivers/char/joystick/serport.c	Fri Feb  9 11:30:23 2001
+++ linux/drivers/char/joystick/serport.c	Wed Sep 12 15:34:06 2001
@@ -1,7 +1,7 @@
 /*
- * $Id: serport.c,v 1.4 2000/05/29 10:54:53 vojtech Exp $
+ * $Id: serport.c,v 1.7 2001/05/25 19:00:27 jdeneux Exp $
  *
- *  Copyright (c) 1999-2000 Vojtech Pavlik
+ *  Copyright (c) 1999-2001 Vojtech Pavlik
  *
  *  Sponsored by SuSE
  */
@@ -148,7 +148,11 @@
 	DECLARE_WAITQUEUE(wait, current);
 	char name[32];
 
+#ifdef CONFIG_DEVFS_FS
 	sprintf(name, tty->driver.name, MINOR(tty->device) - tty->driver.minor_start);
+#else
+	sprintf(name, "%s%d", tty->driver.name, MINOR(tty->device) - tty->driver.minor_start);
+#endif
 
 	serio_register_port(&serport->serio);
 
@@ -218,3 +222,5 @@
 
 module_init(serport_init);
 module_exit(serport_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/sidewinder.c linux/drivers/char/joystick/sidewinder.c
--- v2.4.9/linux/drivers/char/joystick/sidewinder.c	Wed Apr 11 19:02:30 2001
+++ linux/drivers/char/joystick/sidewinder.c	Wed Sep 12 15:34:06 2001
@@ -1,7 +1,7 @@
 /*
- * $Id: sidewinder.c,v 1.18 2001/02/28 07:09:30 vojtech Exp $
+ * $Id: sidewinder.c,v 1.20 2001/05/19 08:14:54 vojtech Exp $
  *
- *  Copyright (c) 1998-2000 Vojtech Pavlik
+ *  Copyright (c) 1998-2001 Vojtech Pavlik
  *
  *  Sponsored by SuSE
  */
@@ -582,6 +582,9 @@
 	if (gameport_open(gameport, dev, GAMEPORT_MODE_RAW))
 		goto fail1;
 
+	dbg("Init 0: Opened gameport %d, io %#x, speed %d",
+		gameport->number, gameport->io, gameport->speed);
+
 	i = sw_read_packet(gameport, buf, SW_LENGTH, 0);		/* Read normal packet */
 	m |= sw_guess_mode(buf, i);					/* Data packet (1-bit) can carry mode info [FSP] */
 	udelay(SW_TIMEOUT);
@@ -754,3 +757,5 @@
 
 module_init(sw_init);
 module_exit(sw_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/spaceball.c linux/drivers/char/joystick/spaceball.c
--- v2.4.9/linux/drivers/char/joystick/spaceball.c	Wed Apr 11 19:02:30 2001
+++ linux/drivers/char/joystick/spaceball.c	Wed Sep 12 15:34:06 2001
@@ -234,3 +234,5 @@
 
 module_init(spaceball_init);
 module_exit(spaceball_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/spaceorb.c linux/drivers/char/joystick/spaceorb.c
--- v2.4.9/linux/drivers/char/joystick/spaceorb.c	Fri Feb  9 11:30:23 2001
+++ linux/drivers/char/joystick/spaceorb.c	Wed Sep 12 15:34:06 2001
@@ -223,3 +223,5 @@
 
 module_init(spaceorb_init);
 module_exit(spaceorb_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/stinger.c linux/drivers/char/joystick/stinger.c
--- v2.4.9/linux/drivers/char/joystick/stinger.c	Wed Apr 11 19:02:30 2001
+++ linux/drivers/char/joystick/stinger.c	Wed Sep 12 15:34:06 2001
@@ -1,7 +1,7 @@
 /*
- * $Id: stinger.c,v 1.1 2000/07/17 10:42:14 vojtech Exp $
+ * $Id: stinger.c,v 1.4 2001/05/23 09:25:02 vojtech Exp $
  *
- *  Copyright (c) 2000 Vojtech Pavlik
+ *  Copyright (c) 2000-2001 Vojtech Pavlik
  *  Copyright (c) 2000 Mark Fletcher
  *
  *  Sponsored by SuSE
@@ -79,8 +79,8 @@
 	input_report_key(dev, BTN_SELECT, ((data[3] & 0x02) >> 1));
 	input_report_key(dev, BTN_START,   (data[3] & 0x01));
 
-	input_report_abs(dev, ABS_X, ((data[1] & 0x3F) - ((data[0] & 0x01) << 6)));
-	input_report_abs(dev, ABS_Y, ((data[2] & 0x3F) - ((data[0] & 0x02) << 5)));
+	input_report_abs(dev, ABS_X, (data[1] & 0x3F) - ((data[0] & 0x01) << 6));
+	input_report_abs(dev, ABS_Y, ((data[0] & 0x02) << 5) - (data[2] & 0x3F));
 
 	return;
 }
@@ -198,3 +198,5 @@
 
 module_init(stinger_init);
 module_exit(stinger_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/tmdc.c linux/drivers/char/joystick/tmdc.c
--- v2.4.9/linux/drivers/char/joystick/tmdc.c	Wed Apr 11 19:02:30 2001
+++ linux/drivers/char/joystick/tmdc.c	Wed Sep 12 15:34:06 2001
@@ -374,3 +374,5 @@
 
 module_init(tmdc_init);
 module_exit(tmdc_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/turbografx.c linux/drivers/char/joystick/turbografx.c
--- v2.4.9/linux/drivers/char/joystick/turbografx.c	Wed Jun 21 08:22:21 2000
+++ linux/drivers/char/joystick/turbografx.c	Wed Sep 12 15:34:06 2001
@@ -40,6 +40,7 @@
 #include <linux/init.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
+MODULE_LICENSE("GPL");
 MODULE_PARM(tgfx, "2-8i");
 MODULE_PARM(tgfx_2, "2-8i");
 MODULE_PARM(tgfx_3, "2-8i");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/joystick/warrior.c linux/drivers/char/joystick/warrior.c
--- v2.4.9/linux/drivers/char/joystick/warrior.c	Fri Feb  9 11:30:23 2001
+++ linux/drivers/char/joystick/warrior.c	Wed Sep 12 15:34:06 2001
@@ -210,3 +210,5 @@
 
 module_init(warrior_init);
 module_exit(warrior_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/logibusmouse.c linux/drivers/char/logibusmouse.c
--- v2.4.9/linux/drivers/char/logibusmouse.c	Mon Jun 19 13:25:06 2000
+++ linux/drivers/char/logibusmouse.c	Thu Sep 13 15:21:32 2001
@@ -158,3 +158,6 @@
 
 module_init(logi_busmouse_init);
 module_exit(logi_busmouse_cleanup);
+
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/lp.c linux/drivers/char/lp.c
--- v2.4.9/linux/drivers/char/lp.c	Mon Aug 27 12:41:40 2001
+++ linux/drivers/char/lp.c	Thu Sep 13 15:21:32 2001
@@ -838,3 +838,6 @@
 __setup("lp=", lp_setup);
 module_init(lp_init_module);
 module_exit(lp_cleanup_module);
+
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/machzwd.c linux/drivers/char/machzwd.c
--- v2.4.9/linux/drivers/char/machzwd.c	Wed Jul 25 17:10:19 2001
+++ linux/drivers/char/machzwd.c	Thu Sep 13 15:21:32 2001
@@ -36,7 +36,7 @@
 #include <linux/sched.h>
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/fcntl.h>
 #include <linux/smp_lock.h>
@@ -99,6 +99,7 @@
 
 MODULE_AUTHOR("Fernando Fuganti <fuganti@conectiva.com.br>");
 MODULE_DESCRIPTION("MachZ ZF-Logic Watchdog driver");
+MODULE_LICENSE("GPL");
 MODULE_PARM(action, "i");
 MODULE_PARM_DESC(action, "after watchdog resets, generate: 0 = RESET(*)  1 = SMI  2 = NMI  3 = SCI");
 
diff -u --recursive --new-file v2.4.9/linux/drivers/char/mem.c linux/drivers/char/mem.c
--- v2.4.9/linux/drivers/char/mem.c	Sun Aug 12 13:27:59 2001
+++ linux/drivers/char/mem.c	Sun Sep  9 10:52:35 2001
@@ -153,8 +153,6 @@
 	/* Use no-cache mode, serialized */
 	else if (MMU_IS_040 || MMU_IS_060)
 		prot = (prot & _CACHEMASK040) | _PAGE_NOCACHE_S;
-#elif defined(__mips__)
-	prot = (prot & ~_CACHE_MASK) | _CACHE_UNCACHED;
 #endif
 
 	return __pgprot(prot);
diff -u --recursive --new-file v2.4.9/linux/drivers/char/misc.c linux/drivers/char/misc.c
--- v2.4.9/linux/drivers/char/misc.c	Thu May 24 15:14:08 2001
+++ linux/drivers/char/misc.c	Fri Sep  7 09:28:38 2001
@@ -273,9 +273,6 @@
 #ifdef CONFIG_SGI_NEWPORT_GFX
 	gfx_register ();
 #endif
-#ifdef CONFIG_SGI
-	streamable_init ();
-#endif
 #ifdef CONFIG_TOSHIBA
 	tosh_init();
 #endif
diff -u --recursive --new-file v2.4.9/linux/drivers/char/mixcomwd.c linux/drivers/char/mixcomwd.c
--- v2.4.9/linux/drivers/char/mixcomwd.c	Tue May 22 10:23:16 2001
+++ linux/drivers/char/mixcomwd.c	Thu Sep 13 15:21:32 2001
@@ -269,3 +269,6 @@
 
 module_init(mixcomwd_init);
 module_exit(mixcomwd_exit);
+
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/moxa.c linux/drivers/char/moxa.c
--- v2.4.9/linux/drivers/char/moxa.c	Sun Aug 12 13:27:59 2001
+++ linux/drivers/char/moxa.c	Sun Sep  9 10:43:02 2001
@@ -205,6 +205,7 @@
 
 MODULE_AUTHOR("William Chen");
 MODULE_DESCRIPTION("MOXA Intellio Family Multiport Board Device Driver");
+MODULE_LICENSE("GPL");
 MODULE_PARM(type, "1-4i");
 MODULE_PARM(baseaddr, "1-4i");
 MODULE_PARM(numports, "1-4i");
@@ -212,6 +213,8 @@
 MODULE_PARM(calloutmajor, "i");
 MODULE_PARM(verbose, "i");
 
+EXPORT_NO_SYMBOLS;
+
 #endif				//MODULE
 
 static struct tty_driver moxaDriver;
@@ -1717,27 +1720,6 @@
 		if(copy_to_user((void *)arg, temp_queue, sizeof(struct moxaq_str) * MAX_PORTS))
 			return -EFAULT;
 		return (0);
-	case MOXA_LOAD_BIOS:
-		if(copy_from_user(&dltmp, (void *)arg, sizeof(struct dl_str)))
-			return -EFAULT;
-		i = moxaloadbios(dltmp.cardno, dltmp.buf, dltmp.len);
-		return (i);
-	case MOXA_FIND_BOARD:
-		if(copy_from_user(&dltmp, (void *)arg, sizeof(struct dl_str)))
-			return -EFAULT;
-		return moxafindcard(dltmp.cardno);
-	case MOXA_LOAD_C320B:
-		if(copy_from_user(&dltmp, (void *)arg, sizeof(struct dl_str)))
-			return -EFAULT;
-		moxaload320b(dltmp.cardno, dltmp.buf, dltmp.len);
-		return (0);
-	case MOXA_LOAD_CODE:
-		if(copy_from_user(&dltmp, (void *)arg, sizeof(struct dl_str)))
-			return -EFAULT; 
-		i = moxaloadcode(dltmp.cardno, dltmp.buf, dltmp.len);
-		if (i == -1)
-			return (-EFAULT);
-		return (i);
 	case MOXA_GET_OQUEUE:
 		i = MoxaPortTxQueue(port);
 		return put_user(i, (unsigned long *) arg);
@@ -1778,9 +1760,38 @@
 		if(copy_to_user((void *)arg, GMStatus, sizeof(struct mxser_mstatus) * MAX_PORTS))
 			return -EFAULT;
 		return 0;
+	default:
+		return (-ENOIOCTLCMD);
+	case MOXA_LOAD_BIOS:
+	case MOXA_FIND_BOARD:
+	case MOXA_LOAD_C320B:
+	case MOXA_LOAD_CODE:
+		break;
+	}
+
+	if(copy_from_user(&dltmp, (void *)arg, sizeof(struct dl_str)))
+		return -EFAULT;
+	if(dltmp.cardno < 0 || dltmp.cardno >= MAX_BOARDS)
+		return -EINVAL;
+
+	switch(cmd)
+	{
+	case MOXA_LOAD_BIOS:
+		i = moxaloadbios(dltmp.cardno, dltmp.buf, dltmp.len);
+		return (i);
+	case MOXA_FIND_BOARD:
+		return moxafindcard(dltmp.cardno);
+	case MOXA_LOAD_C320B:
+		moxaload320b(dltmp.cardno, dltmp.buf, dltmp.len);
+	default: /* to keep gcc happy */
+		return (0);
+	case MOXA_LOAD_CODE:
+		i = moxaloadcode(dltmp.cardno, dltmp.buf, dltmp.len);
+		if (i == -1)
+			return (-EFAULT);
+		return (i);
 
 	}
-	return (-ENOIOCTLCMD);
 }
 
 int MoxaDriverPoll(void)
diff -u --recursive --new-file v2.4.9/linux/drivers/char/msbusmouse.c linux/drivers/char/msbusmouse.c
--- v2.4.9/linux/drivers/char/msbusmouse.c	Mon Jun 19 13:25:06 2000
+++ linux/drivers/char/msbusmouse.c	Thu Sep 13 15:21:32 2001
@@ -167,3 +167,6 @@
 
 module_init(ms_bus_mouse_init)
 module_exit(ms_bus_mouse_exit)
+
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/mxser.c linux/drivers/char/mxser.c
--- v2.4.9/linux/drivers/char/mxser.c	Sun Aug 12 13:27:59 2001
+++ linux/drivers/char/mxser.c	Thu Sep 13 15:21:32 2001
@@ -180,10 +180,13 @@
 
 MODULE_AUTHOR("William Chen");
 MODULE_DESCRIPTION("MOXA Smartio Family Multiport Board Device Driver");
+MODULE_LICENSE("GPL");
 MODULE_PARM(ioaddr, "1-4i");
 MODULE_PARM(ttymajor, "i");
 MODULE_PARM(calloutmajor, "i");
 MODULE_PARM(verbose, "i");
+
+EXPORT_NO_SYMBOLS;
 
 struct mxser_hwconf {
 	int board_type;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/n_hdlc.c linux/drivers/char/n_hdlc.c
--- v2.4.9/linux/drivers/char/n_hdlc.c	Fri Feb  9 11:30:22 2001
+++ linux/drivers/char/n_hdlc.c	Thu Sep 13 15:21:32 2001
@@ -1031,3 +1031,6 @@
 
 module_init(n_hdlc_init);
 module_exit(n_hdlc_exit);
+
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/n_r3964.c linux/drivers/char/n_r3964.c
--- v2.4.9/linux/drivers/char/n_r3964.c	Mon Aug 27 12:41:40 2001
+++ linux/drivers/char/n_r3964.c	Thu Sep 13 15:21:32 2001
@@ -1473,3 +1473,7 @@
    return -1;
 }
 
+
+MODULE_LICENSE("GPL");
+
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/nvram.c linux/drivers/char/nvram.c
--- v2.4.9/linux/drivers/char/nvram.c	Sun Aug 12 13:27:59 2001
+++ linux/drivers/char/nvram.c	Thu Sep 13 15:21:32 2001
@@ -695,9 +695,14 @@
 
 #endif /* MACH == ATARI */
 
+MODULE_LICENSE("GPL");
+
+EXPORT_NO_SYMBOLS;
+
 /*
  * Local variables:
  *  c-indent-level: 4
  *  tab-width: 4
  * End:
  */
+
diff -u --recursive --new-file v2.4.9/linux/drivers/char/nwflash.c linux/drivers/char/nwflash.c
--- v2.4.9/linux/drivers/char/nwflash.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/char/nwflash.c	Thu Sep 13 15:21:32 2001
@@ -688,6 +688,8 @@
 
 EXPORT_NO_SYMBOLS;
 
+MODULE_LICENSE("GPL");
+
 MODULE_PARM(flashdebug, "i");
 
 module_init(nwflash_init);
diff -u --recursive --new-file v2.4.9/linux/drivers/char/pc110pad.c linux/drivers/char/pc110pad.c
--- v2.4.9/linux/drivers/char/pc110pad.c	Tue May 22 10:23:16 2001
+++ linux/drivers/char/pc110pad.c	Fri Sep  7 09:28:38 2001
@@ -798,7 +798,7 @@
  *	asked to open it by an application.
  */
 
-static const char banner[] __initdata = KERN_INFO "PC110 digitizer pad at 0x%X, irq %d.\n";
+static char banner[] __initdata = KERN_INFO "PC110 digitizer pad at 0x%X, irq %d.\n";
 
 static int __init pc110pad_init_driver(void)
 {
@@ -840,3 +840,9 @@
 
 module_init(pc110pad_init_driver);
 module_exit(pc110pad_exit_driver);
+
+MODULE_AUTHOR("Alan Cox, Robin O'Leary");
+MODULE_DESCRIPTION("Driver for the touchpad on the IBM PC110 palmtop");
+MODULE_LICENSE("GPL");
+
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/pc_keyb.c linux/drivers/char/pc_keyb.c
--- v2.4.9/linux/drivers/char/pc_keyb.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/char/pc_keyb.c	Tue Aug 28 07:09:44 2001
@@ -31,6 +31,7 @@
 #include <linux/miscdevice.h>
 #include <linux/slab.h>
 #include <linux/kbd_kern.h>
+#include <linux/vt_kern.h>
 #include <linux/smp_lock.h>
 
 #include <asm/keyboard.h>
@@ -602,7 +603,7 @@
 		return 1;
 }
 
-int pckbd_rate(struct kbd_repeat *rep)
+static int pckbd_rate(struct kbd_repeat *rep)
 {
 	if (rep == NULL)
 		return -EINVAL;
@@ -834,6 +835,8 @@
 #if defined CONFIG_PSMOUSE
 	psaux_init();
 #endif
+
+	kbd_rate = pckbd_rate;
 
 	/* Ok, finally allocate the IRQ, and off we go.. */
 	kbd_request_irq(keyboard_interrupt);
diff -u --recursive --new-file v2.4.9/linux/drivers/char/pcmcia/serial_cs.c linux/drivers/char/pcmcia/serial_cs.c
--- v2.4.9/linux/drivers/char/pcmcia/serial_cs.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/char/pcmcia/serial_cs.c	Thu Sep 13 15:21:32 2001
@@ -663,3 +663,5 @@
 
 module_init(init_serial_cs);
 module_exit(exit_serial_cs);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/pcwd.c linux/drivers/char/pcwd.c
--- v2.4.9/linux/drivers/char/pcwd.c	Thu May 24 15:14:08 2001
+++ linux/drivers/char/pcwd.c	Thu Sep 13 15:21:32 2001
@@ -656,3 +656,7 @@
 
 module_init(pcwatchdog_init);
 module_exit(pcwatchdog_exit);
+
+MODULE_LICENSE("GPL");
+
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/pcxx.c linux/drivers/char/pcxx.c
--- v2.4.9/linux/drivers/char/pcxx.c	Tue May 22 10:23:16 2001
+++ linux/drivers/char/pcxx.c	Thu Sep 13 15:21:32 2001
@@ -113,6 +113,7 @@
 # if (LINUX_VERSION_CODE > 0x020111)
 MODULE_AUTHOR("Bernhard Kaindl");
 MODULE_DESCRIPTION("Digiboard PC/X{i,e,eve} driver");
+MODULE_LICENSE("GPL");
 MODULE_PARM(verbose,     "i");
 MODULE_PARM(debug,       "i");
 MODULE_PARM(io,          "1-4i");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/ppdev.c linux/drivers/char/ppdev.c
--- v2.4.9/linux/drivers/char/ppdev.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/char/ppdev.c	Thu Sep 13 15:21:32 2001
@@ -118,7 +118,7 @@
 		return -EINVAL;
 	}
 
-	kbuffer = kmalloc(min(unsigned int, count, PP_BUFFER_SIZE), GFP_KERNEL);
+	kbuffer = kmalloc(min_t(size_t, count, PP_BUFFER_SIZE), GFP_KERNEL);
 	if (!kbuffer) {
 		return -ENOMEM;
 	}
@@ -126,7 +126,7 @@
 	mode = pport->ieee1284.mode & ~(IEEE1284_DEVICEID | IEEE1284_ADDR);
 
 	while (bytes_read < count) {
-		ssize_t need = min(unsigned long, count - bytes_read, PP_BUFFER_SIZE);
+		ssize_t need = min_t(unsigned long, count - bytes_read, PP_BUFFER_SIZE);
 
 		if (mode == IEEE1284_MODE_EPP) {
 			/* various specials for EPP mode */
@@ -198,7 +198,7 @@
 		return -EINVAL;
 	}
 
-	kbuffer = kmalloc(min(unsigned int, count, PP_BUFFER_SIZE), GFP_KERNEL);
+	kbuffer = kmalloc(min_t(size_t, count, PP_BUFFER_SIZE), GFP_KERNEL);
 	if (!kbuffer) {
 		return -ENOMEM;
 	}
@@ -206,7 +206,7 @@
 	mode = pport->ieee1284.mode & ~(IEEE1284_DEVICEID | IEEE1284_ADDR);
 
 	while (bytes_written < count) {
-		ssize_t n = min(unsigned long, count - bytes_written, PP_BUFFER_SIZE);
+		ssize_t n = min_t(unsigned long, count - bytes_written, PP_BUFFER_SIZE);
 
 		if (copy_from_user (kbuffer, buf + bytes_written, n)) {
 			bytes_written = -EFAULT;
@@ -754,3 +754,7 @@
 
 module_init(ppdev_init);
 module_exit(ppdev_cleanup);
+
+MODULE_LICENSE("GPL");
+
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/qpmouse.c linux/drivers/char/qpmouse.c
--- v2.4.9/linux/drivers/char/qpmouse.c	Fri Apr 13 20:26:07 2001
+++ linux/drivers/char/qpmouse.c	Fri Sep  7 09:28:38 2001
@@ -338,8 +338,8 @@
 	return 1;
 }
 
-static const char msg_banner[] __initdata = KERN_INFO "82C710 type pointing device detected -- driver installed.\n";
-static const char msg_nomem[]  __initdata = KERN_ERR "qpmouse: no queue memory.\n";
+static char msg_banner[] __initdata = KERN_INFO "82C710 type pointing device detected -- driver installed.\n";
+static char msg_nomem[]  __initdata = KERN_ERR "qpmouse: no queue memory.\n";
 
 static int __init qpmouse_init_driver(void)
 {
@@ -371,3 +371,6 @@
 module_init(qpmouse_init_driver);
 module_exit(qpmouse_exit_driver);
 
+
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/qtronix.c linux/drivers/char/qtronix.c
--- v2.4.9/linux/drivers/char/qtronix.c	Fri Apr 13 20:26:07 2001
+++ linux/drivers/char/qtronix.c	Sun Sep  9 10:43:02 2001
@@ -6,7 +6,7 @@
  *
  * Copyright 2001 MontaVista Software Inc.
  * Author: MontaVista Software, Inc.
- *         	ppopov@mvista.com or support@mvista.com
+ *         	ppopov@mvista.com or source@mvista.com
  *
  *
  *  The bottom portion of this driver was take from 
@@ -71,7 +71,7 @@
 #include <linux/random.h>
 #include <linux/poll.h>
 #include <linux/miscdevice.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
 #include <linux/kbd_kern.h>
 #include <linux/smp_lock.h>
 #include <asm/io.h>
@@ -353,19 +353,19 @@
 static unsigned char handle_kbd_event(void);
 
 
-int pckbd_setkeycode(unsigned int scancode, unsigned int keycode)
+int kbd_setkeycode(unsigned int scancode, unsigned int keycode)
 {
-	printk("pckbd_setkeycode scancode %x keycode %x\n", scancode, keycode);
+	printk("kbd_setkeycode scancode %x keycode %x\n", scancode, keycode);
 	return 0;
 }
 
-int pckbd_getkeycode(unsigned int scancode)
+int kbd_getkeycode(unsigned int scancode)
 {
 	return scancode;
 }
 
 
-int pckbd_translate(unsigned char scancode, unsigned char *keycode,
+int kbd_translate(unsigned char scancode, unsigned char *keycode,
 		    char raw_mode)
 {
 	static int prev_scancode = 0;
@@ -406,9 +406,9 @@
  	return 1;
 }
 
-char pckbd_unexpected_up(unsigned char keycode)
+char kbd_unexpected_up(unsigned char keycode)
 {
-	//printk("pckbd_unexpected_up\n");
+	//printk("kbd_unexpected_up\n");
 	return 0;
 }
 
@@ -422,12 +422,12 @@
 }	
 
 
-void pckbd_leds(unsigned char leds)
+void kbd_leds(unsigned char leds)
 {
 }
 
 /* dummy */
-void pckbd_init_hw(void)
+void kbd_init_hw(void)
 {
 }
 
diff -u --recursive --new-file v2.4.9/linux/drivers/char/rio/rio_linux.c linux/drivers/char/rio/rio_linux.c
--- v2.4.9/linux/drivers/char/rio/rio_linux.c	Wed Jul 25 17:10:19 2001
+++ linux/drivers/char/rio/rio_linux.c	Fri Sep  7 09:28:38 2001
@@ -248,6 +248,7 @@
 #ifndef TWO_ZERO
 MODULE_AUTHOR("Rogier Wolff <R.E.Wolff@bitwizard.nl>, Patrick van de Lageweg <patrick@bitwizard.nl>");
 MODULE_DESCRIPTION("RIO driver");
+MODULE_LICENSE("GPL");
 MODULE_PARM(rio_poll, "i");
 MODULE_PARM(rio_debug, "i");
 MODULE_PARM(rio_irqmask, "i");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/rio/riocmd.c linux/drivers/char/rio/riocmd.c
--- v2.4.9/linux/drivers/char/rio/riocmd.c	Wed Jul 25 17:10:19 2001
+++ linux/drivers/char/rio/riocmd.c	Fri Sep  7 09:28:38 2001
@@ -481,7 +481,7 @@
 	   			not freed. */
 			/* Call tmgr HANGUP HERE */
 			/* Fix this later when every thing works !!!! RAMRAJ */
-			gs_got_break (PortP);
+			gs_got_break (&PortP->gs);
 			break;
 
 		case COMPLETE:
diff -u --recursive --new-file v2.4.9/linux/drivers/char/rio/riointr.c linux/drivers/char/rio/riointr.c
--- v2.4.9/linux/drivers/char/rio/riointr.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/char/rio/riointr.c	Mon Sep 10 09:04:53 2001
@@ -819,7 +819,7 @@
 	  ** and available space.
 	  */
 			
-	  transCount = min(unsigned int, PacketP->len & PKT_LEN_MASK,
+	  transCount = min_t(unsigned int, PacketP->len & PKT_LEN_MASK,
 			   TTY_FLIPBUF_SIZE - TtyP->flip.count);
 	  rio_dprintk (RIO_DEBUG_REC,  "port %d: Copy %d bytes\n", 
 				      PortP->PortNum, transCount);
diff -u --recursive --new-file v2.4.9/linux/drivers/char/riscom8.c linux/drivers/char/riscom8.c
--- v2.4.9/linux/drivers/char/riscom8.c	Sun Aug 12 13:27:59 2001
+++ linux/drivers/char/riscom8.c	Thu Sep 13 15:21:32 2001
@@ -1906,6 +1906,8 @@
 MODULE_PARM(iobase1, "i");
 MODULE_PARM(iobase2, "i");
 MODULE_PARM(iobase3, "i");
+
+MODULE_LICENSE("GPL");
 #endif /* MODULE */
 
 /*
diff -u --recursive --new-file v2.4.9/linux/drivers/char/rocket.c linux/drivers/char/rocket.c
--- v2.4.9/linux/drivers/char/rocket.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/char/rocket.c	Thu Sep 13 15:21:32 2001
@@ -157,6 +157,7 @@
 #if ((LINUX_VERSION_CODE > 0x020111) && defined(MODULE))
 MODULE_AUTHOR("Theodore Ts'o");
 MODULE_DESCRIPTION("Comtrol Rocketport driver");
+MODULE_LICENSE("GPL");
 MODULE_PARM(board1,     "i");
 MODULE_PARM_DESC(board1, "I/O port for (ISA) board #1");
 MODULE_PARM(board2,     "i");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/rtc.c linux/drivers/char/rtc.c
--- v2.4.9/linux/drivers/char/rtc.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/char/rtc.c	Sun Sep  9 10:43:02 2001
@@ -40,9 +40,10 @@
  *	1.10b	Andrew Morton: SMP lock fix
  *	1.10c	Cesar Barros: SMP locking fixes and cleanup
  *	1.10d	Paul Gortmaker: delete paranoia check in rtc_exit
+ *	1.10e	Maciej W. Rozycki: Handle DECstation's year weirdness.
  */
 
-#define RTC_VERSION		"1.10d"
+#define RTC_VERSION		"1.10e"
 
 #define RTC_IO_EXTENT	0x10	/* Only really two ports, but...	*/
 
@@ -361,6 +362,9 @@
 		unsigned char mon, day, hrs, min, sec, leap_yr;
 		unsigned char save_control, save_freq_select;
 		unsigned int yrs;
+#ifdef CONFIG_DECSTATION
+		unsigned int real_yrs;
+#endif
 
 		if (!capable(CAP_SYS_TIME))
 			return -EACCES;
@@ -394,6 +398,20 @@
 			return -EINVAL;
 
 		spin_lock_irq(&rtc_lock);
+#ifdef CONFIG_DECSTATION
+		real_yrs = yrs;
+		yrs = 72;
+
+		/*
+		 * We want to keep the year set to 73 until March
+		 * for non-leap years, so that Feb, 29th is handled
+		 * correctly.
+		 */
+		if (!leap_yr && mon < 3) {
+			real_yrs--;
+			yrs = 73;
+		}
+#endif
 		if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY)
 		    || RTC_ALWAYS_BCD) {
 			if (yrs > 169) {
@@ -416,6 +434,9 @@
 		save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
 		CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
 
+#ifdef CONFIG_DECSTATION
+		CMOS_WRITE(real_yrs, RTC_DEC_YEAR);
+#endif
 		CMOS_WRITE(yrs, RTC_YEAR);
 		CMOS_WRITE(mon, RTC_MONTH);
 		CMOS_WRITE(day, RTC_DAY_OF_MONTH);
@@ -469,7 +490,7 @@
 		spin_unlock_irq(&rtc_lock);
 		return 0;
 	}
-#elif !defined(CONFIG_DECSTATION)
+#endif
 	case RTC_EPOCH_READ:	/* Read the epoch.	*/
 	{
 		return put_user (epoch, (unsigned long *)arg);
@@ -488,7 +509,6 @@
 		epoch = arg;
 		return 0;
 	}
-#endif
 	default:
 		return -EINVAL;
 	}
@@ -709,12 +729,12 @@
 	} else if (year >= 20 && year < 48) {
 		epoch = 1980;
 		guess = "ARC console";
-	} else if (year >= 48 && year < 70) {
+	} else if (year >= 48 && year < 72) {
 		epoch = 1952;
 		guess = "Digital UNIX";
 #if defined(__mips__)
-	} else if (year >= 70 && year < 100) {
-		epoch = 1928;
+	} else if (year >= 72 && year < 74) {
+		epoch = 2000;
 		guess = "Digital DECstation";
 #else
 	} else if (year >= 70) {
@@ -911,6 +931,9 @@
 {
 	unsigned long uip_watchdog = jiffies;
 	unsigned char ctrl;
+#ifdef CONFIG_DECSTATION
+	unsigned int real_year;
+#endif
 
 	/*
 	 * read RTC once any update in progress is done. The update
@@ -939,6 +962,9 @@
 	rtc_tm->tm_mday = CMOS_READ(RTC_DAY_OF_MONTH);
 	rtc_tm->tm_mon = CMOS_READ(RTC_MONTH);
 	rtc_tm->tm_year = CMOS_READ(RTC_YEAR);
+#ifdef CONFIG_DECSTATION
+	real_year = CMOS_READ(RTC_DEC_YEAR);
+#endif
 	ctrl = CMOS_READ(RTC_CONTROL);
 	spin_unlock_irq(&rtc_lock);
 
@@ -952,6 +978,10 @@
 		BCD_TO_BIN(rtc_tm->tm_year);
 	}
 
+#ifdef CONFIG_DECSTATION
+	rtc_tm->tm_year += real_year - 72;
+#endif
+
 	/*
 	 * Account for differences between how the RTC uses the values
 	 * and how they are defined in a struct rtc_time;
@@ -1024,3 +1054,6 @@
 	spin_unlock_irq(&rtc_lock);
 }
 #endif
+
+MODULE_AUTHOR("Paul Gortmaker");
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/sbc60xxwdt.c linux/drivers/char/sbc60xxwdt.c
--- v2.4.9/linux/drivers/char/sbc60xxwdt.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/char/sbc60xxwdt.c	Thu Sep 13 15:21:32 2001
@@ -340,3 +340,6 @@
 
 module_init(sbc60xxwdt_init);
 module_exit(sbc60xxwdt_unload);
+
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/selection.c linux/drivers/char/selection.c
--- v2.4.9/linux/drivers/char/selection.c	Fri Feb  9 11:30:22 2001
+++ linux/drivers/char/selection.c	Fri Sep  7 09:28:38 2001
@@ -96,11 +96,7 @@
 /* set inwordLut contents. Invoked by ioctl(). */
 int sel_loadlut(const unsigned long arg)
 {
-	int err = -EFAULT;
-
-	if (!copy_from_user(inwordLut, (u32 *)(arg+4), 32))
-		err = 0;
-	return err;
+	return copy_from_user(inwordLut, (u32 *)(arg+4), 32) ? -EFAULT : 0;
 }
 
 /* does screen address p correspond to character at LH/RH edge of screen? */
@@ -130,15 +126,13 @@
 
 	  args = (unsigned short *)(arg + 1);
 	  if (user) {
-	  	  int err;
-		  err = verify_area(VERIFY_READ, args, sizeof(short) * 5);
-		  if (err)
-		  	return err;
-		  get_user(xs, args++);
-		  get_user(ys, args++);
-		  get_user(xe, args++);
-		  get_user(ye, args++);
-		  get_user(sel_mode, args);
+		  if (verify_area(VERIFY_READ, args, sizeof(short) * 5))
+		  	return -EFAULT;
+		  __get_user(xs, args++);
+		  __get_user(ys, args++);
+		  __get_user(xe, args++);
+		  __get_user(ye, args++);
+		  __get_user(sel_mode, args);
 	  } else {
 		  xs = *(args++); /* set selection from kernel */
 		  ys = *(args++);
diff -u --recursive --new-file v2.4.9/linux/drivers/char/ser_a2232.c linux/drivers/char/ser_a2232.c
--- v2.4.9/linux/drivers/char/ser_a2232.c	Wed Jul 25 17:10:20 2001
+++ linux/drivers/char/ser_a2232.c	Thu Sep 13 15:21:32 2001
@@ -878,3 +878,7 @@
 }
 #endif
 /***************************** End of Functions *********************/
+
+MODULE_AUTHOR("Enver Haase");
+MODULE_DESCRIPTION("Amiga A2232 multi-serial board driver");
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/serial.c linux/drivers/char/serial.c
--- v2.4.9/linux/drivers/char/serial.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/char/serial.c	Thu Sep 13 15:21:32 2001
@@ -5719,6 +5719,7 @@
 module_exit(rs_fini);
 MODULE_DESCRIPTION("Standard/generic (dumb) serial driver");
 MODULE_AUTHOR("Theodore Ts'o <tytso@mit.edu>");
+MODULE_LICENSE("GPL");
 
 
 /*
diff -u --recursive --new-file v2.4.9/linux/drivers/char/serial167.c linux/drivers/char/serial167.c
--- v2.4.9/linux/drivers/char/serial167.c	Wed May 16 10:31:27 2001
+++ linux/drivers/char/serial167.c	Thu Sep 13 15:21:32 2001
@@ -3084,3 +3084,5 @@
 } /* debug_setup */
 
 #endif
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/serial_21285.c linux/drivers/char/serial_21285.c
--- v2.4.9/linux/drivers/char/serial_21285.c	Fri Feb  9 11:30:22 2001
+++ linux/drivers/char/serial_21285.c	Thu Sep 13 15:21:32 2001
@@ -505,3 +505,6 @@
 }
 
 #endif	/* CONFIG_SERIAL_21285_CONSOLE */
+
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/serial_amba.c linux/drivers/char/serial_amba.c
--- v2.4.9/linux/drivers/char/serial_amba.c	Fri Feb  9 11:30:22 2001
+++ linux/drivers/char/serial_amba.c	Thu Sep 13 15:21:32 2001
@@ -2027,3 +2027,6 @@
 }
 
 #endif /* CONFIG_SERIAL_AMBA_CONSOLE */
+
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/serial_tx3912.c linux/drivers/char/serial_tx3912.c
--- v2.4.9/linux/drivers/char/serial_tx3912.c	Wed Dec 31 16:00:00 1969
+++ linux/drivers/char/serial_tx3912.c	Fri Sep  7 09:28:38 2001
@@ -0,0 +1,1079 @@
+/*
+ *  drivers/char/serial_tx3912.c
+ *
+ *  Copyright (C) 1999 Harald Koerfgen
+ *  Copyright (C) 2000 Jim Pick <jim@jimpick.com>
+ *  Copyright (C) 2001 Steven J. Hill (sjhill@realitydiluted.com)
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *  
+ *  Serial driver for TMPR3912/05 and PR31700 processors
+ */
+#include <linux/init.h>
+#include <linux/config.h>
+#include <linux/tty.h>
+#include <linux/major.h>
+#include <linux/ptrace.h>
+#include <linux/init.h>
+#include <linux/console.h>
+#include <linux/fs.h>
+#include <linux/mm.h>
+#include <linux/malloc.h>
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/pm.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <asm/delay.h>
+#include <asm/wbflush.h>
+#include <asm/tx3912.h>
+#include "serial_tx3912.h"
+
+/*
+ * Forward declarations for serial routines
+ */
+static void rs_disable_tx_interrupts (void * ptr);
+static void rs_enable_tx_interrupts (void * ptr); 
+static void rs_disable_rx_interrupts (void * ptr); 
+static void rs_enable_rx_interrupts (void * ptr); 
+static int rs_get_CD (void * ptr); 
+static void rs_shutdown_port (void * ptr); 
+static int rs_set_real_termios (void *ptr);
+static int rs_chars_in_buffer (void * ptr); 
+static void rs_hungup (void *ptr);
+static void rs_close (void *ptr);
+
+/*
+ * Used by generic serial driver to access hardware
+ */
+static struct real_driver rs_real_driver = { 
+	disable_tx_interrupts: rs_disable_tx_interrupts, 
+	enable_tx_interrupts:  rs_enable_tx_interrupts, 
+	disable_rx_interrupts: rs_disable_rx_interrupts, 
+	enable_rx_interrupts:  rs_enable_rx_interrupts, 
+	get_CD:                rs_get_CD, 
+	shutdown_port:         rs_shutdown_port,  
+	set_real_termios:      rs_set_real_termios,  
+	chars_in_buffer:       rs_chars_in_buffer, 
+	close:                 rs_close, 
+	hungup:                rs_hungup,
+}; 
+
+/*
+ * Structures and such for TTY sessions and usage counts
+ */
+static struct tty_driver rs_driver, rs_callout_driver;
+static struct tty_struct * rs_table[TX3912_UART_NPORTS] = { NULL, };
+static struct termios ** rs_termios;
+static struct termios ** rs_termios_locked;
+struct rs_port *rs_ports;
+int rs_refcount;
+int rs_initialized = 0;
+
+/*
+ * ----------------------------------------------------------------------
+ *
+ * Here starts the interrupt handling routines.  All of the following
+ * subroutines are declared as inline and are folded into
+ * rs_interrupt().  They were separated out for readability's sake.
+ *
+ * Note: rs_interrupt() is a "fast" interrupt, which means that it
+ * runs with interrupts turned off.  People who may want to modify
+ * rs_interrupt() should try to keep the interrupt handler as fast as
+ * possible.  After you are done making modifications, it is not a bad
+ * idea to do:
+ * 
+ * gcc -S -DKERNEL -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer serial.c
+ *
+ * and look at the resulting assemble code in serial.s.
+ *
+ * 				- Ted Ts'o (tytso@mit.edu), 7-Mar-93
+ * -----------------------------------------------------------------------
+ */
+static inline void receive_char_pio(struct rs_port *port)
+{
+	struct tty_struct *tty = port->gs.tty;
+	unsigned char ch;
+	int counter = 2048;
+
+	/* While there are characters, get them ... */
+	while (counter>0) {
+		if (!(inl(port->base + TX3912_UART_CTRL1) & UART_RX_HOLD_FULL))
+			break;
+		ch = inb(port->base + TX3912_UART_DATA);
+		if (tty->flip.count < TTY_FLIPBUF_SIZE) {
+			*tty->flip.char_buf_ptr++ = ch;
+			*tty->flip.flag_buf_ptr++ = 0;
+			tty->flip.count++;
+		}
+		udelay(1); /* Allow things to happen - it take a while */
+		counter--;
+	}
+	if (!counter)
+		printk( "Ugh, looped in receive_char_pio!\n" );
+
+	tty_flip_buffer_push(tty);
+
+#if 0
+	/* Now handle error conditions */
+	if (*status & (INTTYPE(UART_RXOVERRUN_INT) |
+			INTTYPE(UART_FRAMEERR_INT) |
+			INTTYPE(UART_PARITYERR_INT) |
+			INTTYPE(UART_BREAK_INT))) {
+
+		/*
+		 * Now check to see if character should be
+		 * ignored, and mask off conditions which
+		 * should be ignored.
+	       	 */
+		if (*status & port->ignore_status_mask) {
+			goto ignore_char;
+		}
+		*status &= port->read_status_mask;
+		
+		if (*status & INTTYPE(UART_BREAK_INT)) {
+			rs_dprintk(TX3912_UART_DEBUG_INTERRUPTS, "handling break....");
+			*tty->flip.flag_buf_ptr = TTY_BREAK;
+		}
+		else if (*status & INTTYPE(UART_PARITYERR_INT)) {
+			*tty->flip.flag_buf_ptr = TTY_PARITY;
+		}
+		else if (*status & INTTYPE(UART_FRAMEERR_INT)) {
+			*tty->flip.flag_buf_ptr = TTY_FRAME;
+		}
+		if (*status & INTTYPE(UART_RXOVERRUN_INT)) {
+			/*
+			 * Overrun is special, since it's
+			 * reported immediately, and doesn't
+			 * affect the current character
+			 */
+			if (tty->flip.count < TTY_FLIPBUF_SIZE) {
+				tty->flip.count++;
+				tty->flip.flag_buf_ptr++;
+				tty->flip.char_buf_ptr++;
+				*tty->flip.flag_buf_ptr = TTY_OVERRUN;
+			}
+		}
+	}
+
+	tty->flip.flag_buf_ptr++;
+	tty->flip.char_buf_ptr++;
+	tty->flip.count++;
+
+ignore_char:
+	tty_flip_buffer_push(tty);
+#endif
+}
+
+static inline void transmit_char_pio(struct rs_port *port)
+{
+	/* While I'm able to transmit ... */
+	for (;;) {
+		if (!(inl(port->base + TX3912_UART_CTRL1) & UART_TX_EMPTY))
+			break;
+		else if (port->x_char) {
+			outb(port->x_char, port->base + TX3912_UART_DATA);
+			port->icount.tx++;
+			port->x_char = 0;
+		}
+		else if (port->gs.xmit_cnt <= 0 || port->gs.tty->stopped ||
+		    port->gs.tty->hw_stopped) {
+			break;
+		}
+		else {
+			outb(port->gs.xmit_buf[port->gs.xmit_tail++],
+				port->base + TX3912_UART_DATA);
+			port->icount.tx++;
+			port->gs.xmit_tail &= SERIAL_XMIT_SIZE-1;
+			if (--port->gs.xmit_cnt <= 0) {
+				break;
+			}
+		}
+		udelay(10); /* Allow things to happen - it take a while */
+	}
+
+	if (port->gs.xmit_cnt <= 0 || port->gs.tty->stopped ||
+	     port->gs.tty->hw_stopped) {
+		rs_disable_tx_interrupts(port);
+	}
+	
+        if (port->gs.xmit_cnt <= port->gs.wakeup_chars) {
+                if ((port->gs.tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
+                    port->gs.tty->ldisc.write_wakeup)
+                        (port->gs.tty->ldisc.write_wakeup)(port->gs.tty);
+                rs_dprintk (TX3912_UART_DEBUG_TRANSMIT, "Waking up.... ldisc (%d)....\n",
+                            port->gs.wakeup_chars); 
+                wake_up_interruptible(&port->gs.tty->write_wait);
+       	}	
+}
+
+
+
+static inline void check_modem_status(struct rs_port *port)
+{
+        /* We don't have a carrier detect line - but just respond
+           like we had one anyways so that open() becomes unblocked */
+	wake_up_interruptible(&port->gs.open_wait);
+}
+
+int count = 0;
+
+/*
+ * This is the serial driver's interrupt routine (inlined, because
+ * there are two different versions of this, one for each serial port,
+ * differing only by the bits used in interrupt status 2 register)
+ */
+
+static inline void rs_rx_interrupt(int irq, void *dev_id,
+				  struct pt_regs * regs, int intshift)
+{
+	struct rs_port * port;
+	unsigned long int2status;
+	unsigned long flags;
+	unsigned long ints;
+
+	save_and_cli(flags);
+
+	port = (struct rs_port *)dev_id;
+	rs_dprintk (TX3912_UART_DEBUG_INTERRUPTS, "rs_interrupt (port %p, shift %d)...", port, intshift);
+
+	/* Get the interrrupts we have enabled */
+	int2status = IntStatus2 & IntEnable2;
+
+	/* Get interrupts in easy to use form */
+	ints = int2status >> intshift;
+
+	/* Clear any interrupts we might be about to handle */
+	IntClear2 = int2status & (
+		(INTTYPE(UART_RXOVERRUN_INT) |
+		 INTTYPE(UART_FRAMEERR_INT) |
+		 INTTYPE(UART_BREAK_INT) |
+		 INTTYPE(UART_PARITYERR_INT) |
+		 INTTYPE(UART_RX_INT)) << intshift);
+
+	if (!port || !port->gs.tty) {
+		restore_flags(flags);
+		return;
+	}
+
+	/* RX Receiver Holding Register Overrun */
+	if (ints & INTTYPE(UART_RXOVERRUN_INT)) {
+		rs_dprintk (TX3912_UART_DEBUG_INTERRUPTS, "overrun");
+		port->icount.overrun++;
+	}
+
+	/* RX Frame Error */
+	if (ints & INTTYPE(UART_FRAMEERR_INT)) {
+		rs_dprintk (TX3912_UART_DEBUG_INTERRUPTS, "frame error");
+		port->icount.frame++;
+	}
+
+	/* Break signal received */
+	if (ints & INTTYPE(UART_BREAK_INT)) {
+		rs_dprintk (TX3912_UART_DEBUG_INTERRUPTS, "break");
+		port->icount.brk++;
+      	}
+
+	/* RX Parity Error */
+	if (ints & INTTYPE(UART_PARITYERR_INT)) {
+		rs_dprintk (TX3912_UART_DEBUG_INTERRUPTS, "parity error");
+		port->icount.parity++;
+	}
+
+	/* Receive byte (non-DMA) */
+	if (ints & INTTYPE(UART_RX_INT)) {
+		receive_char_pio(port);
+	}
+
+	restore_flags(flags);
+
+	rs_dprintk (TX3912_UART_DEBUG_INTERRUPTS, "end.\n");
+}
+
+static inline void rs_tx_interrupt(int irq, void *dev_id,
+				  struct pt_regs * regs, int intshift)
+{
+	struct rs_port * port;
+	unsigned long int2status;
+	unsigned long flags;
+	unsigned long ints;
+
+	save_and_cli(flags);
+
+	port = (struct rs_port *)dev_id;
+	rs_dprintk (TX3912_UART_DEBUG_INTERRUPTS, "rs_interrupt (port %p, shift %d)...", port, intshift);
+
+	/* Get the interrrupts we have enabled */
+	int2status = IntStatus2 & IntEnable2;
+
+	if (!port || !port->gs.tty) {
+		restore_flags(flags);
+		return;
+	}
+
+	/* Get interrupts in easy to use form */
+	ints = int2status >> intshift;
+
+	/* Clear any interrupts we might be about to handle */
+	IntClear2 = int2status & (
+		(INTTYPE(UART_TX_INT) |
+		 INTTYPE(UART_EMPTY_INT) |
+		 INTTYPE(UART_TXOVERRUN_INT)) << intshift);
+
+	/* TX holding register empty, so transmit byte (non-DMA) */
+	if (ints & (INTTYPE(UART_TX_INT) | INTTYPE(UART_EMPTY_INT))) {
+		transmit_char_pio(port);
+	}
+
+	/* TX Transmit Holding Register Overrun (shouldn't happen) */
+	if (ints & INTTYPE(UART_TXOVERRUN_INT)) {
+		printk ( "rs: TX overrun\n");
+	}
+
+	/*
+	check_modem_status();
+	*/
+
+	restore_flags(flags);
+
+	rs_dprintk (TX3912_UART_DEBUG_INTERRUPTS, "end.\n");
+}
+
+static void rs_rx_interrupt_uarta(int irq, void *dev_id,
+					 struct pt_regs * regs)
+{
+	rs_rx_interrupt(irq, dev_id, regs, UARTA_SHIFT);
+}
+
+static void rs_tx_interrupt_uarta(int irq, void *dev_id,
+					 struct pt_regs * regs)
+{
+	rs_tx_interrupt(irq, dev_id, regs, UARTA_SHIFT);
+}
+
+/*
+ ***********************************************************************
+ *                Here are the routines that actually                  *
+ *              interface with the generic_serial driver               *
+ ***********************************************************************
+ */
+static void rs_disable_tx_interrupts (void * ptr) 
+{
+	struct rs_port *port = ptr; 
+	unsigned long flags;
+
+	save_and_cli(flags);
+        port->gs.flags &= ~GS_TX_INTEN;
+
+	IntEnable2 &= ~((INTTYPE(UART_TX_INT) |
+			INTTYPE(UART_EMPTY_INT) |
+			INTTYPE(UART_TXOVERRUN_INT)) << port->intshift);
+
+	IntClear2 = (INTTYPE(UART_TX_INT) |
+			INTTYPE(UART_EMPTY_INT) |
+			INTTYPE(UART_TXOVERRUN_INT)) << port->intshift;
+
+	restore_flags(flags);
+}
+
+static void rs_enable_tx_interrupts (void * ptr) 
+{
+	struct rs_port *port = ptr; 
+	unsigned long flags;
+
+	save_and_cli(flags);
+
+	IntClear2 = (INTTYPE(UART_TX_INT) |
+			INTTYPE(UART_EMPTY_INT) |
+			INTTYPE(UART_TXOVERRUN_INT)) << port->intshift;
+
+	IntEnable2 |= (INTTYPE(UART_TX_INT) |
+			INTTYPE(UART_EMPTY_INT) |
+			INTTYPE(UART_TXOVERRUN_INT)) << port->intshift;
+
+	/* Send a char to start TX interrupts happening */
+	transmit_char_pio(port);
+
+	restore_flags(flags);
+}
+
+static void rs_disable_rx_interrupts (void * ptr) 
+{
+	struct rs_port *port = ptr;
+	unsigned long flags;
+
+	save_and_cli(flags);
+
+	IntEnable2 &= ~((INTTYPE(UART_RX_INT) |
+			 INTTYPE(UART_RXOVERRUN_INT) |
+			 INTTYPE(UART_FRAMEERR_INT) |
+			 INTTYPE(UART_BREAK_INT) |
+			 INTTYPE(UART_PARITYERR_INT)) << port->intshift);
+
+	IntClear2 = (INTTYPE(UART_RX_INT) |
+			 INTTYPE(UART_RXOVERRUN_INT) |
+			 INTTYPE(UART_FRAMEERR_INT) |
+			 INTTYPE(UART_BREAK_INT) |
+			 INTTYPE(UART_PARITYERR_INT)) << port->intshift;
+
+	restore_flags(flags);
+}
+
+static void rs_enable_rx_interrupts (void * ptr) 
+{
+	struct rs_port *port = ptr;
+	unsigned long flags;
+
+	save_and_cli(flags);
+
+	IntEnable2 |= (INTTYPE(UART_RX_INT) |
+			 INTTYPE(UART_RXOVERRUN_INT) |
+			 INTTYPE(UART_FRAMEERR_INT) |
+			 INTTYPE(UART_BREAK_INT) |
+			 INTTYPE(UART_PARITYERR_INT)) << port->intshift;
+
+	/* Empty the input buffer - apparently this is *vital* */
+	while (inl(port->base + TX3912_UART_CTRL1) & UART_RX_HOLD_FULL) { 
+		inb(port->base + TX3912_UART_DATA);
+	}
+
+	IntClear2 = (INTTYPE(UART_RX_INT) |
+			 INTTYPE(UART_RXOVERRUN_INT) |
+			 INTTYPE(UART_FRAMEERR_INT) |
+			 INTTYPE(UART_BREAK_INT) |
+			 INTTYPE(UART_PARITYERR_INT)) << port->intshift;
+
+	restore_flags(flags);
+}
+
+
+static int rs_get_CD (void * ptr) 
+{
+	/* No Carried Detect in Hardware - just return true */
+	func_exit();
+	return (1);
+}
+
+static void rs_shutdown_port (void * ptr) 
+{
+	struct rs_port *port = ptr; 
+
+	func_enter();
+
+	port->gs.flags &= ~GS_ACTIVE;
+
+	func_exit();
+}
+
+static int rs_set_real_termios (void *ptr)
+{
+	struct rs_port *port = ptr;
+	int t;
+
+	switch (port->gs.baud) {
+		/* Save some typing work... */
+#define e(x) case x:t= TX3912_UART_CTRL2_B ## x ; break
+		e(300);e(600);e(1200);e(2400);e(4800);e(9600);
+		e(19200);e(38400);e(57600);e(76800);e(115200);e(230400);
+	case 0      :t = -1;
+		break;
+	default:
+		/* Can I return "invalid"? */
+		t = TX3912_UART_CTRL2_B9600;
+		printk (KERN_INFO "rs: unsupported baud rate: %d.\n", port->gs.baud);
+		break;
+	}
+#undef e
+	if (t >= 0) {
+		/* Jim: Set Hardware Baud rate - there is some good
+		   code in drivers/char/serial.c */
+
+	  	/* Program hardware for parity, data bits, stop bits (note: these are hardcoded to 8N1 */
+		UartA_Ctrl1 &= 0xf000000f;
+		UartA_Ctrl1 &= ~(UART_DIS_TXD | SER_SEVEN_BIT | SER_EVEN_PARITY | SER_TWO_STOP);
+
+#define CFLAG port->gs.tty->termios->c_cflag
+		if (C_PARENB(port->gs.tty)) {
+			if (!C_PARODD(port->gs.tty))
+				UartA_Ctrl1 |= SER_EVEN_PARITY;
+			else
+				UartA_Ctrl1 |= SER_ODD_PARITY;
+		}
+		if ((CFLAG & CSIZE)==CS6)
+			printk(KERN_ERR "6 bits not supported\n");
+		if ((CFLAG & CSIZE)==CS5)
+			printk(KERN_ERR "5 bits not supported\n");
+		if ((CFLAG & CSIZE)==CS7)
+			UartA_Ctrl1 |= SER_SEVEN_BIT;
+		if (C_CSTOPB(port->gs.tty))
+			UartA_Ctrl1 |= SER_TWO_STOP;
+
+		outl(t, port->base + TX3912_UART_CTRL2);
+		outl(0, port->base + TX3912_UART_DMA_CTRL1);
+		outl(0, port->base + TX3912_UART_DMA_CTRL2);
+        	UartA_Ctrl1 |= TX3912_UART_CTRL1_UARTON;
+
+        /* wait until UARTA is stable */
+        while (~UartA_Ctrl1 & TX3912_UART_CTRL1_UARTON);
+	}
+
+	func_exit ();
+        return 0;
+}
+
+static int rs_chars_in_buffer (void * ptr) 
+{
+	struct rs_port *port = ptr;
+	int scratch;
+
+	scratch = inl(port->base + TX3912_UART_CTRL1);
+
+	return ((scratch & UART_TX_EMPTY) ? 0 : 1);
+}
+
+/* ********************************************************************** *
+ *                Here are the routines that actually                     *
+ *               interface with the rest of the system                    *
+ * ********************************************************************** */
+static int rs_open  (struct tty_struct * tty, struct file * filp)
+{
+	struct rs_port *port;
+	int retval, line;
+
+	func_enter();
+
+	if (!rs_initialized) {
+		return -EIO;
+	}
+
+	line = MINOR(tty->device) - tty->driver.minor_start;
+	rs_dprintk (TX3912_UART_DEBUG_OPEN, "%d: opening line %d. tty=%p ctty=%p)\n", 
+	            (int) current->pid, line, tty, current->tty);
+
+	if ((line < 0) || (line >= TX3912_UART_NPORTS))
+		return -ENODEV;
+
+	/* Pre-initialized already */
+	port = & rs_ports[line];
+
+	rs_dprintk (TX3912_UART_DEBUG_OPEN, "port = %p\n", port);
+
+	tty->driver_data = port;
+	port->gs.tty = tty;
+	port->gs.count++;
+
+	rs_dprintk (TX3912_UART_DEBUG_OPEN, "starting port\n");
+
+	/*
+	 * Start up serial port
+	 */
+	retval = gs_init_port(&port->gs);
+	rs_dprintk (TX3912_UART_DEBUG_OPEN, "done gs_init\n");
+	if (retval) {
+		port->gs.count--;
+		return retval;
+	}
+
+	port->gs.flags |= GS_ACTIVE;
+
+	rs_dprintk (TX3912_UART_DEBUG_OPEN, "before inc_use_count (count=%d.\n", 
+	            port->gs.count);
+	if (port->gs.count == 1) {
+		MOD_INC_USE_COUNT;
+	}
+	rs_dprintk (TX3912_UART_DEBUG_OPEN, "after inc_use_count\n");
+
+	/* Jim: Initialize port hardware here */
+
+	/* Enable high-priority interrupts for UARTA */
+	IntEnable6 |= INT6_UARTARXINT; 
+	rs_enable_rx_interrupts(&rs_ports[0]); 
+
+	retval = gs_block_til_ready(&port->gs, filp);
+	rs_dprintk (TX3912_UART_DEBUG_OPEN, "Block til ready returned %d. Count=%d\n", 
+	            retval, port->gs.count);
+
+	if (retval) {
+		MOD_DEC_USE_COUNT;
+		port->gs.count--;
+		return retval;
+	}
+	/* tty->low_latency = 1; */
+
+	if ((port->gs.count == 1) && (port->gs.flags & ASYNC_SPLIT_TERMIOS)) {
+		if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+			*tty->termios = port->gs.normal_termios;
+		else 
+			*tty->termios = port->gs.callout_termios;
+		rs_set_real_termios (port);
+	}
+
+	port->gs.session = current->session;
+	port->gs.pgrp = current->pgrp;
+	func_exit();
+
+	/* Jim */
+/*	cli(); */
+
+	return 0;
+
+}
+
+
+
+static void rs_close (void *ptr)
+{
+	func_enter ();
+
+	/* Anything to do here? */
+
+	MOD_DEC_USE_COUNT;
+	func_exit ();
+}
+
+
+/* I haven't the foggiest why the decrement use count has to happen
+   here. The whole linux serial drivers stuff needs to be redesigned.
+   My guess is that this is a hack to minimize the impact of a bug
+   elsewhere. Thinking about it some more. (try it sometime) Try
+   running minicom on a serial port that is driven by a modularized
+   driver. Have the modem hangup. Then remove the driver module. Then
+   exit minicom.  I expect an "oops".  -- REW */
+static void rs_hungup (void *ptr)
+{
+	func_enter ();
+	MOD_DEC_USE_COUNT;
+	func_exit ();
+}
+
+static int rs_ioctl (struct tty_struct * tty, struct file * filp, 
+                     unsigned int cmd, unsigned long arg)
+{
+	int rc;
+	struct rs_port *port = tty->driver_data;
+	int ival;
+
+	rc = 0;
+	switch (cmd) {
+	case TIOCGSOFTCAR:
+		rc = put_user(((tty->termios->c_cflag & CLOCAL) ? 1 : 0),
+		              (unsigned int *) arg);
+		break;
+	case TIOCSSOFTCAR:
+		if ((rc = verify_area(VERIFY_READ, (void *) arg,
+		                      sizeof(int))) == 0) {
+			get_user(ival, (unsigned int *) arg);
+			tty->termios->c_cflag =
+				(tty->termios->c_cflag & ~CLOCAL) |
+				(ival ? CLOCAL : 0);
+		}
+		break;
+	case TIOCGSERIAL:
+		if ((rc = verify_area(VERIFY_WRITE, (void *) arg,
+		                      sizeof(struct serial_struct))) == 0)
+			gs_getserial(&port->gs, (struct serial_struct *) arg);
+		break;
+	case TIOCSSERIAL:
+		if ((rc = verify_area(VERIFY_READ, (void *) arg,
+		                      sizeof(struct serial_struct))) == 0)
+			rc = gs_setserial(&port->gs, (struct serial_struct *) arg);
+		break;
+	default:
+		rc = -ENOIOCTLCMD;
+		break;
+	}
+
+	/* func_exit(); */
+	return rc;
+}
+
+
+/*
+ * This function is used to send a high-priority XON/XOFF character to
+ * the device
+ */
+static void rs_send_xchar(struct tty_struct * tty, char ch)
+{
+	struct rs_port *port = (struct rs_port *)tty->driver_data;
+	func_enter ();
+	
+	port->x_char = ch;
+	if (ch) {
+		/* Make sure transmit interrupts are on */
+		rs_enable_tx_interrupts(tty);
+	}
+
+	func_exit();
+}
+
+
+/*
+ * ------------------------------------------------------------
+ * rs_throttle()
+ * 
+ * This routine is called by the upper-layer tty layer to signal that
+ * incoming characters should be throttled.
+ * ------------------------------------------------------------
+ */
+static void rs_throttle(struct tty_struct * tty)
+{
+#ifdef TX3912_UART_DEBUG_THROTTLE
+	char	buf[64];
+	
+	printk("throttle %s: %d....\n", tty_name(tty, buf),
+	       tty->ldisc.chars_in_buffer(tty));
+#endif
+
+	func_enter ();
+	
+	if (I_IXOFF(tty))
+		rs_send_xchar(tty, STOP_CHAR(tty));
+
+	func_exit ();
+}
+
+static void rs_unthrottle(struct tty_struct * tty)
+{
+	struct rs_port *port = (struct rs_port *)tty->driver_data;
+#ifdef TX3912_UART_DEBUG_THROTTLE
+	char	buf[64];
+	
+	printk("unthrottle %s: %d....\n", tty_name(tty, buf),
+	       tty->ldisc.chars_in_buffer(tty));
+#endif
+
+	func_enter();
+	
+	if (I_IXOFF(tty)) {
+		if (port->x_char)
+			port->x_char = 0;
+		else
+			rs_send_xchar(tty, START_CHAR(tty));
+	}
+
+	func_exit();
+}
+
+
+
+
+
+/* ********************************************************************** *
+ *                    Here are the initialization routines.               *
+ * ********************************************************************** */
+
+void * ckmalloc (int size)
+{
+        void *p;
+
+        p = kmalloc(size, GFP_KERNEL);
+        if (p) 
+                memset(p, 0, size);
+        return p;
+}
+
+
+
+static int rs_init_portstructs(void)
+{
+	struct rs_port *port;
+	int i;
+
+	/* Debugging */
+	func_enter();
+
+	rs_ports          = ckmalloc(TX3912_UART_NPORTS * sizeof (struct rs_port));
+	if (!rs_ports)
+		return -ENOMEM;
+
+	rs_termios        = ckmalloc(TX3912_UART_NPORTS * sizeof (struct termios *));
+	if (!rs_termios) {
+		kfree (rs_ports);
+		return -ENOMEM;
+	}
+
+	rs_termios_locked = ckmalloc(TX3912_UART_NPORTS * sizeof (struct termios *));
+	if (!rs_termios_locked) {
+		kfree (rs_ports);
+		kfree (rs_termios);
+		return -ENOMEM;
+	}
+
+	/* Adjust the values in the "driver" */
+	rs_driver.termios = rs_termios;
+	rs_driver.termios_locked = rs_termios_locked;
+
+	port = rs_ports;
+	for (i=0; i < TX3912_UART_NPORTS;i++) {
+		rs_dprintk (TX3912_UART_DEBUG_INIT, "initing port %d\n", i);
+		port->gs.callout_termios = tty_std_termios;
+		port->gs.normal_termios	= tty_std_termios;
+		port->gs.magic = SERIAL_MAGIC;
+		port->gs.close_delay = HZ/2;
+		port->gs.closing_wait = 30 * HZ;
+		port->gs.rd = &rs_real_driver;
+#ifdef NEW_WRITE_LOCKING
+		port->gs.port_write_sem = MUTEX;
+#endif
+#ifdef DECLARE_WAITQUEUE
+		init_waitqueue_head(&port->gs.open_wait);
+		init_waitqueue_head(&port->gs.close_wait);
+#endif
+		port->base = (i == 0) ? TX3912_UARTA_BASE : TX3912_UARTB_BASE;
+		port->intshift = (i == 0) ? UARTA_SHIFT : UARTB_SHIFT;
+		rs_dprintk (TX3912_UART_DEBUG_INIT, "base 0x%08lx intshift %d\n",
+			    port->base, port->intshift);
+		port++;
+	}
+
+	func_exit();
+	return 0;
+}
+
+static int rs_init_drivers(void)
+{
+	int error;
+
+	func_enter();
+
+	memset(&rs_driver, 0, sizeof(rs_driver));
+	rs_driver.magic = TTY_DRIVER_MAGIC;
+	rs_driver.driver_name = "serial";
+	rs_driver.name = "ttyS";
+	rs_driver.major = TTY_MAJOR;
+	rs_driver.minor_start = 64;
+	rs_driver.num = TX3912_UART_NPORTS;
+	rs_driver.type = TTY_DRIVER_TYPE_SERIAL;
+	rs_driver.subtype = SERIAL_TYPE_NORMAL;
+	rs_driver.init_termios = tty_std_termios;
+	rs_driver.init_termios.c_cflag =
+		B115200 | CS8 | CREAD | HUPCL | CLOCAL;
+	rs_driver.refcount = &rs_refcount;
+	rs_driver.table = rs_table;
+	rs_driver.termios = rs_termios;
+	rs_driver.termios_locked = rs_termios_locked;
+
+	rs_driver.open	= rs_open;
+	rs_driver.close = gs_close;
+	rs_driver.write = gs_write;
+	rs_driver.put_char = gs_put_char; 
+	rs_driver.flush_chars = gs_flush_chars;
+	rs_driver.write_room = gs_write_room;
+	rs_driver.chars_in_buffer = gs_chars_in_buffer;
+	rs_driver.flush_buffer = gs_flush_buffer;
+	rs_driver.ioctl = rs_ioctl;
+	rs_driver.throttle = rs_throttle;
+	rs_driver.unthrottle = rs_unthrottle;
+	rs_driver.set_termios = gs_set_termios;
+	rs_driver.stop = gs_stop;
+	rs_driver.start = gs_start;
+	rs_driver.hangup = gs_hangup;
+
+	rs_callout_driver = rs_driver;
+	rs_callout_driver.name = "cua";
+	rs_callout_driver.major = TTYAUX_MAJOR;
+	rs_callout_driver.subtype = SERIAL_TYPE_CALLOUT;
+
+	if ((error = tty_register_driver(&rs_driver))) {
+		printk(KERN_ERR "Couldn't register serial driver, error = %d\n",
+		       error);
+		return 1;
+	}
+	if ((error = tty_register_driver(&rs_callout_driver))) {
+		tty_unregister_driver(&rs_driver);
+		printk(KERN_ERR "Couldn't register callout driver, error = %d\n",
+		       error);
+		return 1;
+	}
+
+	func_exit();
+	return 0;
+}
+
+
+void __init tx3912_rs_init(void)
+{
+	int rc;
+
+
+	func_enter();
+	rs_dprintk (TX3912_UART_DEBUG_INIT, "Initing serial module... (rs_debug=%d)\n", rs_debug);
+
+	rc = rs_init_portstructs ();
+	rs_init_drivers ();
+	if (request_irq(2, rs_tx_interrupt_uarta, SA_SHIRQ | SA_INTERRUPT,
+			"serial", &rs_ports[0])) {
+		printk(KERN_ERR "rs: Cannot allocate irq for UARTA.\n");
+		rc = 0;
+	}
+	if (request_irq(3, rs_rx_interrupt_uarta, SA_SHIRQ | SA_INTERRUPT,
+			"serial", &rs_ports[0])) {
+		printk(KERN_ERR "rs: Cannot allocate irq for UARTA.\n");
+		rc = 0;
+	}
+
+	IntEnable6 |= INT6_UARTARXINT; 
+	rs_enable_rx_interrupts(&rs_ports[0]); 
+
+#ifndef CONFIG_SERIAL_TX3912_CONSOLE
+{
+	unsigned int scratch = 0;
+
+	/* Setup master clock for UART */
+	scratch = inl(TX3912_CLK_CTRL_BASE);
+	scratch &= ~TX3912_CLK_CTRL_SIBMCLKDIV_MASK;
+	scratch |= ((0x2 << TX3912_CLK_CTRL_SIBMCLKDIV_SHIFT) &
+				TX3912_CLK_CTRL_SIBMCLKDIV_MASK)
+			| TX3912_CLK_CTRL_SIBMCLKDIR
+			| TX3912_CLK_CTRL_ENSIBMCLK
+			| TX3912_CLK_CTRL_CSERSEL;
+	outl(scratch, TX3912_CLK_CTRL_BASE);
+
+	/* Configure UARTA clock */
+	scratch = inl(TX3912_CLK_CTRL_BASE);
+	scratch |= ((0x3 << TX3912_CLK_CTRL_CSERDIV_SHIFT) &
+				TX3912_CLK_CTRL_CSERDIV_MASK)
+			| TX3912_CLK_CTRL_ENCSERCLK
+			| TX3912_CLK_CTRL_ENUARTACLK;
+	outl(scratch, TX3912_CLK_CTRL_BASE);
+		
+	/* Setup UARTA for 115200,8N1 */
+	outl(0, TX3912_UARTA_BASE + TX3912_UART_CTRL1);
+	outl(TX3912_UART_CTRL2_B115200, TX3912_UARTA_BASE + TX3912_UART_CTRL2);
+	outl(0, TX3912_UARTA_BASE + TX3912_UART_DMA_CTRL1);
+	outl(0, TX3912_UARTA_BASE + TX3912_UART_DMA_CTRL2);
+
+	/* Enable UARTA */
+	outl(TX3912_UART_CTRL1_ENUART, TX3912_UARTA_BASE + TX3912_UART_CTRL1);
+	while (~inl(TX3912_UARTA_BASE + TX3912_UART_CTRL1) &
+		TX3912_UART_CTRL1_UARTON);
+}
+#endif
+
+	/* Note: I didn't do anything to enable the second UART */
+	if (rc >= 0) 
+		rs_initialized++;
+
+	func_exit();
+}
+
+/*
+ * Begin serial console routines
+ */
+#ifdef CONFIG_SERIAL_TX3912_CONSOLE
+
+void serial_outc(unsigned char c)
+{
+	int i;
+	unsigned long int2;
+	#define BUSY_WAIT 10000
+
+	/*
+	 * Turn UARTA interrupts off
+	 */
+	int2 = IntEnable2;
+	IntEnable2 &=
+		~(INT2_UARTATXINT | INT2_UARTATXOVERRUN | INT2_UARTAEMPTY);
+
+	/*
+	 * The UART_TX_EMPTY bit in UartA_Ctrl1 seems
+	 * not to be very reliable :-(
+	 *
+	 * Wait for the Tx register to become empty
+	 */
+	for (i = 0; !(IntStatus2 & INT2_UARTATXINT) && (i < BUSY_WAIT); i++);
+
+	IntClear2 = INT2_UARTATXINT | INT2_UARTATXOVERRUN | INT2_UARTAEMPTY;
+	UartA_Data = c;
+	for (i = 0; !(IntStatus2 & INT2_UARTATXINT) && (i < BUSY_WAIT); i++);
+	IntClear2 = INT2_UARTATXINT | INT2_UARTATXOVERRUN | INT2_UARTAEMPTY;
+
+	IntEnable2 = int2;
+}
+
+static int serial_console_wait_key(struct console *co)
+{
+	unsigned int int2, res;
+
+	int2 = IntEnable2;
+	IntEnable2 = 0;
+
+	while (!(UartA_Ctrl1 & UART_RX_HOLD_FULL));
+	res = UartA_Data;
+	udelay(10);
+	
+	IntEnable2 = int2;
+	return res;
+}
+
+static void serial_console_write(struct console *co, const char *s,
+		unsigned count)
+{
+    	unsigned int i;
+
+	for (i = 0; i < count; i++) {
+		if (*s == '\n')
+			serial_outc('\r');
+		serial_outc(*s++);
+    	}
+}
+
+static kdev_t serial_console_device(struct console *c)
+{
+	return MKDEV(TTY_MAJOR, 64 + c->index);
+}
+
+static __init int serial_console_setup(struct console *co, char *options)
+{
+	unsigned int scratch = 0;
+
+	/* Setup master clock for UART */
+	scratch = inl(TX3912_CLK_CTRL_BASE);
+	scratch &= ~TX3912_CLK_CTRL_SIBMCLKDIV_MASK;
+	scratch |= ((0x2 << TX3912_CLK_CTRL_SIBMCLKDIV_SHIFT) &
+				TX3912_CLK_CTRL_SIBMCLKDIV_MASK)
+			| TX3912_CLK_CTRL_SIBMCLKDIR
+			| TX3912_CLK_CTRL_ENSIBMCLK
+			| TX3912_CLK_CTRL_CSERSEL;
+	outl(scratch, TX3912_CLK_CTRL_BASE);
+
+	/* Configure UARTA clock */
+	scratch = inl(TX3912_CLK_CTRL_BASE);
+	scratch |= ((0x3 << TX3912_CLK_CTRL_CSERDIV_SHIFT) &
+				TX3912_CLK_CTRL_CSERDIV_MASK)
+			| TX3912_CLK_CTRL_ENCSERCLK
+			| TX3912_CLK_CTRL_ENUARTACLK;
+	outl(scratch, TX3912_CLK_CTRL_BASE);
+		
+	/* Setup UARTA for 115200,8N1 */
+	outl(0, TX3912_UARTA_BASE + TX3912_UART_CTRL1);
+	outl(TX3912_UART_CTRL2_B115200, TX3912_UARTA_BASE + TX3912_UART_CTRL2);
+	outl(0, TX3912_UARTA_BASE + TX3912_UART_DMA_CTRL1);
+	outl(0, TX3912_UARTA_BASE + TX3912_UART_DMA_CTRL2);
+
+	/* Enable UARTA */
+	outl(TX3912_UART_CTRL1_ENUART, TX3912_UARTA_BASE + TX3912_UART_CTRL1);
+	while (~inl(TX3912_UARTA_BASE + TX3912_UART_CTRL1) &
+		TX3912_UART_CTRL1_UARTON);
+
+	return 0;
+}
+
+static struct console sercons = {
+	name:     "ttyS",
+	write:    serial_console_write,
+	device:   serial_console_device,
+	wait_key: serial_console_wait_key,
+	setup:    serial_console_setup,
+	flags:    CON_PRINTBUFFER,
+	index:    -1
+};
+
+void __init tx3912_console_init(void)
+{
+	register_console(&sercons);
+}
+
+#endif
diff -u --recursive --new-file v2.4.9/linux/drivers/char/serial_tx3912.h linux/drivers/char/serial_tx3912.h
--- v2.4.9/linux/drivers/char/serial_tx3912.h	Wed Dec 31 16:00:00 1969
+++ linux/drivers/char/serial_tx3912.h	Fri Sep  7 09:28:38 2001
@@ -0,0 +1,92 @@
+/*
+ *  drivers/char/serial_tx3912.h
+ *
+ *  Copyright (C) 1999 Harald Koerfgen
+ *  Copyright (C) 2000 Jim Pick <jim@jimpick.com>
+ *  Copyright (C) 2001 Steven J. Hill (sjhill@realitydiluted.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  Serial driver for TMPR3912/05 and PR31700 processors
+ */
+#include <linux/serialP.h>
+#include <linux/generic_serial.h>
+
+/* UART Interrupt (Interrupt 2) bits (UARTA,UARTB) */
+#define UART_RX_INT         9  /* receiver holding register full  (31, 21) */
+#define UART_RXOVERRUN_INT  8  /* receiver overrun error          (30, 20) */
+#define UART_FRAMEERR_INT   7  /* receiver frame error            (29, 19) */
+#define UART_BREAK_INT      6  /* received break signal           (28, 18) */
+#define UART_PARITYERR_INT  5  /* receiver parity error           (27, 17) */
+#define UART_TX_INT         4  /* transmit holding register empty (26, 16) */
+#define UART_TXOVERRUN_INT  3  /* transmit overrun error          (25, 15) */
+#define UART_EMPTY_INT      2  /* both trans/recv regs empty      (24, 14) */
+#define UART_DMAFULL_INT    1  /* DMA at end of buffer            (23, 13) */
+#define UART_DMAHALF_INT    0  /* DMA halfway through buffer */   (22, 12) */
+
+#define UARTA_SHIFT        22
+#define UARTB_SHIFT        12
+
+#define INTTYPE(interrupttype)            (1 << interrupttype)
+
+/* 
+ * This driver can spew a whole lot of debugging output at you. If you
+ * need maximum performance, you should disable the DEBUG define.
+ */
+#undef TX3912_UART_DEBUG
+
+#ifdef TX3912_UART_DEBUG
+#define TX3912_UART_DEBUG_OPEN		0x00000001
+#define TX3912_UART_DEBUG_SETTING	0x00000002
+#define TX3912_UART_DEBUG_FLOW		0x00000004
+#define TX3912_UART_DEBUG_MODEMSIGNALS	0x00000008
+#define TX3912_UART_DEBUG_TERMIOS	0x00000010
+#define TX3912_UART_DEBUG_TRANSMIT	0x00000020
+#define TX3912_UART_DEBUG_RECEIVE	0x00000040
+#define TX3912_UART_DEBUG_INTERRUPTS	0x00000080
+#define TX3912_UART_DEBUG_PROBE		0x00000100
+#define TX3912_UART_DEBUG_INIT		0x00000200
+#define TX3912_UART_DEBUG_CLEANUP	0x00000400
+#define TX3912_UART_DEBUG_CLOSE		0x00000800
+#define TX3912_UART_DEBUG_FIRMWARE	0x00001000
+#define TX3912_UART_DEBUG_MEMTEST	0x00002000
+#define TX3912_UART_DEBUG_THROTTLE	0x00004000
+#define TX3912_UART_DEBUG_ALL		0xffffffff
+
+int rs_debug = TX3912_UART_DEBUG_ALL & ~TX3912_UART_DEBUG_TRANSMIT;
+
+#define rs_dprintk(f, str...) if (rs_debug & f) printk (str)
+#define func_enter() rs_dprintk (TX3912_UART_DEBUG_FLOW,	\
+				"rs: enter " __FUNCTION__ "\n")
+#define func_exit() rs_dprintk (TX3912_UART_DEBUG_FLOW,	\
+				"rs: exit " __FUNCTION__ "\n")
+
+#else
+#define rs_dprintk(f, str...)
+#define func_enter()
+#define func_exit()
+
+#endif	/* TX3912_UART_DEBUG */
+
+/*
+ * Number of serial ports
+ */
+#define TX3912_UART_NPORTS  2
+
+/*
+ * Hardware specific serial port structure
+ */
+struct rs_port { 	
+	struct gs_port		gs;		/* Must be first field! */
+
+	unsigned long		base;
+	int			intshift;	/* Register shift */
+	struct wait_queue	*shutdown_wait; 
+	int			stat_flags;
+        struct async_icount	icount;		/* Counters for 4 input IRQs */
+	int			read_status_mask;
+	int			ignore_status_mask;
+	int			x_char;		/* XON/XOFF character */
+}; 
diff -u --recursive --new-file v2.4.9/linux/drivers/char/sh-sci.c linux/drivers/char/sh-sci.c
--- v2.4.9/linux/drivers/char/sh-sci.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/char/sh-sci.c	Sat Sep  8 12:29:09 2001
@@ -44,7 +44,7 @@
 
 #include <linux/generic_serial.h>
 
-#ifdef CONFIG_DEBUG_KERNEL_WITH_GDB_STUB
+#ifdef CONFIG_SH_STANDARD_BIOS
 #include <asm/sh_bios.h>
 #endif
 
@@ -94,6 +94,7 @@
 
 #define dprintk(x...) do { if (sci_debug) printk(x); } while(0)
 
+#ifdef CONFIG_SERIAL_CONSOLE
 static void put_char(struct sci_port *port, char c)
 {
 	unsigned long flags;
@@ -111,8 +112,9 @@
 
 	restore_flags(flags);
 }
+#endif
 
-#ifdef CONFIG_DEBUG_KERNEL_WITH_GDB_STUB
+#ifdef CONFIG_SH_STANDARD_BIOS
 
 static void handle_error(struct sci_port *port)
 {				/* Clear error flags */
@@ -161,12 +163,12 @@
  * This routine does not wait for a positive acknowledge.
  */
 
-static void put_string(struct sci_port *port,
-				  const char *buffer, int count)
+#ifdef CONFIG_SERIAL_CONSOLE
+static void put_string(struct sci_port *port, const char *buffer, int count)
 {
 	int i;
 	const unsigned char *p = buffer;
-#ifdef CONFIG_DEBUG_KERNEL_WITH_GDB_STUB
+#ifdef CONFIG_SH_STANDARD_BIOS
 	int checksum;
 
     	/* This call only does a trap the first time it is
@@ -202,7 +204,7 @@
 		put_char(port, *p++);
 	}
 }
-
+#endif
 
 
 static struct real_driver sci_real_driver = {
@@ -1159,7 +1161,7 @@
 
 	sci_init_drivers();
 
-#ifdef CONFIG_DEBUG_KERNEL_WITH_GDB_STUB
+#ifdef CONFIG_SH_STANDARD_BIOS
 	sh_bios_gdb_detach();
 #endif
 	return 0;		/* Return -EIO when not detected */
diff -u --recursive --new-file v2.4.9/linux/drivers/char/softdog.c linux/drivers/char/softdog.c
--- v2.4.9/linux/drivers/char/softdog.c	Sat May 19 17:43:05 2001
+++ linux/drivers/char/softdog.c	Fri Sep  7 09:28:38 2001
@@ -160,7 +160,7 @@
 	fops:		&softdog_fops,
 };
 
-static const char banner[] __initdata = KERN_INFO "Software Watchdog Timer: 0.05, timer margin: %d sec\n";
+static char banner[] __initdata = KERN_INFO "Software Watchdog Timer: 0.05, timer margin: %d sec\n";
 
 static int __init watchdog_init(void)
 {
diff -u --recursive --new-file v2.4.9/linux/drivers/char/specialix.c linux/drivers/char/specialix.c
--- v2.4.9/linux/drivers/char/specialix.c	Wed May 16 10:31:27 2001
+++ linux/drivers/char/specialix.c	Thu Sep 13 15:21:32 2001
@@ -2440,3 +2440,5 @@
 	
 }
 #endif /* MODULE */
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/stallion.c linux/drivers/char/stallion.c
--- v2.4.9/linux/drivers/char/stallion.c	Fri Mar  2 11:12:07 2001
+++ linux/drivers/char/stallion.c	Thu Sep 13 15:21:32 2001
@@ -314,6 +314,7 @@
  */
 MODULE_AUTHOR("Greg Ungerer");
 MODULE_DESCRIPTION("Stallion Multiport Serial Driver");
+MODULE_LICENSE("GPL");
 
 MODULE_PARM(board0, "1-4s");
 MODULE_PARM_DESC(board0, "Board 0 config -> name[,ioaddr[,ioaddr2][,irq]]");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/sx.c linux/drivers/char/sx.c
--- v2.4.9/linux/drivers/char/sx.c	Wed Jul 25 17:10:20 2001
+++ linux/drivers/char/sx.c	Fri Sep  7 09:28:38 2001
@@ -365,6 +365,8 @@
 MODULE_PARM(sx_debug, "i");
 MODULE_PARM(sx_irqmask, "i");
 
+MODULE_LICENSE("GPL");
+
 static struct real_driver sx_real_driver = {
 	sx_disable_tx_interrupts,
 	sx_enable_tx_interrupts,
@@ -1139,7 +1141,7 @@
 		sx_dprintk (SX_DEBUG_MODEMSIGNALS, "got a break.\n");
 
 		sx_write_channel_byte (port, hi_state, hi_state);
-		gs_got_break (port);
+		gs_got_break (&port->gs);
 	}
 	if (hi_state & ST_DCD) {
 		hi_state &= ~ST_DCD;
@@ -1614,6 +1616,7 @@
 #define R0         if (read_sx_word (board, i) != 0x55aa) return 1
 #define R1         if (read_sx_word (board, i) != 0xaa55) return 1
 
+#if 0
 /* This memtest takes a human-noticable time. You normally only do it
    once a boot, so I guess that it is worth it. */
 static int do_memtest_w (struct sx_board *board, int min, int max)
@@ -1628,6 +1631,7 @@
 
 	return 0;
 }
+#endif
 
 
 static int sx_fw_ioctl (struct inode *inode, struct file *filp,
diff -u --recursive --new-file v2.4.9/linux/drivers/char/synclink.c linux/drivers/char/synclink.c
--- v2.4.9/linux/drivers/char/synclink.c	Sun Aug 12 13:27:59 2001
+++ linux/drivers/char/synclink.c	Thu Sep 13 15:21:32 2001
@@ -934,6 +934,8 @@
 };
 MODULE_DEVICE_TABLE(pci, synclink_pci_tbl);
 
+MODULE_LICENSE("GPL");
+
 static struct pci_driver synclink_pci_driver = {
 	name:		"synclink",
 	id_table:	synclink_pci_tbl,
diff -u --recursive --new-file v2.4.9/linux/drivers/char/toshiba.c linux/drivers/char/toshiba.c
--- v2.4.9/linux/drivers/char/toshiba.c	Fri Apr  6 10:42:55 2001
+++ linux/drivers/char/toshiba.c	Thu Sep 13 15:21:32 2001
@@ -82,6 +82,8 @@
 
 MODULE_PARM(tosh_fn, "i");
 
+MODULE_LICENSE("GPL");
+
 
 static int tosh_get_info(char *, char **, off_t, int);
 static int tosh_ioctl(struct inode *, struct file *, unsigned int,
diff -u --recursive --new-file v2.4.9/linux/drivers/char/tpqic02.c linux/drivers/char/tpqic02.c
--- v2.4.9/linux/drivers/char/tpqic02.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/char/tpqic02.c	Fri Sep  7 09:28:38 2001
@@ -92,7 +92,7 @@
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/smp_lock.h>
-#include <linux/devfs_fs_kernel.h> 
+#include <linux/devfs_fs_kernel.h>
 
 #include <asm/dma.h>
 #include <asm/system.h>
@@ -116,8 +116,8 @@
  * card+drive info if runtime configuration has been selected.
  */
 
-static struct mtconfiginfo qic02_tape_dynconf = 	/* user settable */
-    { 0, 0, BOGUS_IRQ, 0, 0, TPQD_DEFAULT_FLAGS, };
+static struct mtconfiginfo qic02_tape_dynconf =	/* user settable */
+{ 0, 0, BOGUS_IRQ, 0, 0, TPQD_DEFAULT_FLAGS, };
 static struct qic02_ccb qic02_tape_ccb;	/* private stuff */
 
 #else
@@ -127,11 +127,11 @@
 # if ((QIC02_TAPE_IFC!=WANGTEK) && (QIC02_TAPE_IFC!=ARCHIVE) && (QIC02_TAPE_IFC!=MOUNTAIN))
 #  error No valid interface card specified
 # endif
-#endif /* CONFIG_QIC02_DYNCONF */
+#endif				/* CONFIG_QIC02_DYNCONF */
 
-static volatile int ctlbits;     /* control reg bits for tape interface */
+static volatile int ctlbits;	/* control reg bits for tape interface */
 
-static wait_queue_head_t qic02_tape_transfer; /* sync rw with interrupts */
+static wait_queue_head_t qic02_tape_transfer;	/* sync rw with interrupts */
 
 static volatile struct mtget ioctl_status;	/* current generic status */
 
@@ -146,15 +146,15 @@
  * by an interrupt.
  */
 static volatile flag status_dead = YES;	/* device is legally dead until proven alive */
-static 		flag status_zombie = YES; /* it's `zombie' until irq/dma allocated */
+static flag status_zombie = YES;	/* it's `zombie' until irq/dma allocated */
 
 static volatile flag status_bytes_wr = NO;	/* write FM at close or not */
 static volatile flag status_bytes_rd = NO;	/* (rd|wr) used for rewinding */
 
-static volatile unsigned long status_cmd_pending; /* cmd in progress */
+static volatile unsigned long status_cmd_pending;	/* cmd in progress */
 static volatile flag status_expect_int = NO;	/* ready for interrupts */
-static volatile flag status_timer_on = NO; 	/* using time-out */
-static volatile int  status_error;		/* int handler may detect error */
+static volatile flag status_timer_on = NO;	/* using time-out */
+static volatile int status_error;	/* int handler may detect error */
 static volatile flag status_eof_detected = NO;	/* end of file */
 static volatile flag status_eom_detected = NO;	/* end of recorded media */
 static volatile flag status_eot_detected = NO;	/* end of tape */
@@ -163,8 +163,8 @@
 
 static volatile unsigned long dma_bytes_todo;
 static volatile unsigned long dma_bytes_done;
-static volatile unsigned dma_mode;		/* !=0 also means DMA in use */
-static 		flag need_rewind = YES;
+static volatile unsigned dma_mode;	/* !=0 also means DMA in use */
+static flag need_rewind = YES;
 
 static kdev_t current_tape_dev;
 static int extra_blocks_left = BLOCKS_BEYOND_EW;
@@ -198,7 +198,7 @@
  * mode is allowed as long as no actual writing has been done. After writing
  * the File Mark, repositioning and reading are allowed again.
  */
-static int  mode_access;	/* access mode: READ or WRITE */
+static int mode_access;		/* access mode: READ or WRITE */
 
 static int qic02_get_resources(void);
 static void qic02_release_resources(void);
@@ -210,17 +210,17 @@
  * must ensure that a large enough buffer is passed to the kernel, in order
  * to reduce tape repositioning wear and tear.
  */
-static void *buffaddr;	/* virtual address of buffer */
+static void *buffaddr;		/* virtual address of buffer */
 
 /* This translates minor numbers to the corresponding recording format: */
 static const char *format_names[] = {
-	"not set",	/* for dumb drives unable to handle format selection */
-	"11",		/* extinct */
+	"not set",		/* for dumb drives unable to handle format selection */
+	"11",			/* extinct */
 	"24",
 	"120",
 	"150",
-	"300",		/* untested. */
-	"600"		/* untested. */
+	"300",			/* untested. */
+	"600"			/* untested. */
 };
 
 
@@ -248,52 +248,72 @@
 	const char *msg;
 	/* EXC_nr attribute should match with tpqic02.h */
 } exception_list[] = {
-	{0, 0,
-		"Unknown exception status code",		/* extra: 0 */},
-	{~(0), TP_ST0|TP_CNI|TP_USL|TP_WRP,
-		"Drive not online"				/* 1 */},
-		/* Drive presence goes before cartridge presence. */
-	{~(TP_WRP|TP_USL), TP_ST0|TP_CNI,
-		/* My Wangtek 5150EQ sometimes reports a status code
-		 * of 0x00e0, which is not a valid exception code, but
-		 * I think it should be recognized as "NO CARTRIDGE".
-		 */
-		"Cartridge not in place"			/* 2 */},
-	{(unsigned short) ~(TP_ST1|TP_BOM), (TP_ST0|TP_WRP),
-		"Write protected cartridge"			/* 3 */},
-	{(unsigned short) ~(TP_ST1|TP_EOR), (TP_ST0|TP_EOM),
-		"End of media"					/* 4 */},
-	{~TP_WRP, TP_ST0|TP_UDA| TP_ST1|TP_BOM,
-		"Read or Write abort. Rewind tape."		/* 5 */},
-	{~TP_WRP, TP_ST0|TP_UDA,
-		"Read error. Bad block transferred."		/* 6 */},
-	{~TP_WRP, TP_ST0|TP_UDA|TP_BNL,
-		"Read error. Filler block transferred."		/* 7 */},
-	{~TP_WRP, TP_ST0|TP_UDA|TP_BNL |TP_ST1|TP_NDT,
-		"Read error. No data detected."			/* 8 */},
-	{~TP_WRP, TP_ST0|TP_EOM|TP_UDA|TP_BNL |TP_ST1|TP_NDT,
-		"Read error. No data detected. EOM."		/* 9 */},
-	{~(TP_WRP|TP_MBD|TP_PAR|TP_EOR), TP_ST0|TP_UDA|TP_BNL |TP_ST1|TP_NDT|TP_BOM,
-		"Read error. No data detected. BOM."		/* 10 */},
-	{~(TP_WRP|TP_EOM), TP_ST0|TP_FIL,
-		/* Status 0x0089 (EOM & FM) is viewed as an FM,
-		 * because it can only happen during a read.
-		 * EOM is checked separately for an FM condition.
-		 */
-		"File mark detected"				/* 11 */},
-	{~(TP_ST0|TP_CNI|TP_USL|TP_WRP|TP_BOM), TP_ST1|TP_ILL,
-		"Illegal command"				/* 12 */},
-	{~(TP_ST0|TP_CNI|TP_USL|TP_WRP|TP_BOM), TP_ST1|TP_POR,
-		"Reset occurred"					/* 13 */},
-	{~TP_WRP, TP_ST0|TP_FIL|TP_MBD,		/* NOTE: ST1 not set! */
-		"Marginal block detected"			/* 14 */},
-	{~(TP_ST0|TP_WRP|TP_EOM|TP_UDA|TP_BNL|TP_FIL |TP_NDT), TP_ST1|TP_EOR,
+	{
+	0, 0, "Unknown exception status code", /* extra: 0 */ },
+	{
+	~(0), TP_ST0 | TP_CNI | TP_USL | TP_WRP,
+		    "Drive not online" /* 1 */ },
+	    /* Drive presence goes before cartridge presence. */
+	{
+		~(TP_WRP | TP_USL), TP_ST0 | TP_CNI,
+		    /* My Wangtek 5150EQ sometimes reports a status code
+		     * of 0x00e0, which is not a valid exception code, but
+		     * I think it should be recognized as "NO CARTRIDGE".
+		     */
+	"Cartridge not in place" /* 2 */ },
+	{
+	(unsigned short) ~(TP_ST1 | TP_BOM), (TP_ST0 | TP_WRP),
+		    "Write protected cartridge" /* 3 */ },
+	{
+	(unsigned short) ~(TP_ST1 | TP_EOR), (TP_ST0 | TP_EOM),
+		    "End of media" /* 4 */ },
+	{
+	~TP_WRP, TP_ST0 | TP_UDA | TP_ST1 | TP_BOM,
+		    "Read or Write abort. Rewind tape." /* 5 */ },
+	{
+	~TP_WRP, TP_ST0 | TP_UDA,
+		    "Read error. Bad block transferred." /* 6 */ },
+	{
+	~TP_WRP, TP_ST0 | TP_UDA | TP_BNL,
+		    "Read error. Filler block transferred." /* 7 */ },
+	{
+	~TP_WRP, TP_ST0 | TP_UDA | TP_BNL | TP_ST1 | TP_NDT,
+		    "Read error. No data detected." /* 8 */ },
+	{
+	~TP_WRP,
+		    TP_ST0 | TP_EOM | TP_UDA | TP_BNL | TP_ST1 |
+		    TP_NDT, "Read error. No data detected. EOM." /* 9 */ },
+	{
+	~(TP_WRP | TP_MBD | TP_PAR | TP_EOR),
+		    TP_ST0 | TP_UDA | TP_BNL | TP_ST1 | TP_NDT |
+		    TP_BOM,
+		    "Read error. No data detected. BOM." /* 10 */ },
+	{
+		~(TP_WRP | TP_EOM), TP_ST0 | TP_FIL,
+		    /* Status 0x0089 (EOM & FM) is viewed as an FM,
+		     * because it can only happen during a read.
+		     * EOM is checked separately for an FM condition.
+		     */
+	"File mark detected" /* 11 */ },
+	{
+	~(TP_ST0 | TP_CNI | TP_USL | TP_WRP | TP_BOM),
+		    TP_ST1 | TP_ILL, "Illegal command" /* 12 */ },
+	{
+	~(TP_ST0 | TP_CNI | TP_USL | TP_WRP | TP_BOM),
+		    TP_ST1 | TP_POR, "Reset occurred" /* 13 */ },
+	{
+		~TP_WRP, TP_ST0 | TP_FIL | TP_MBD,	/* NOTE: ST1 not set! */
+	"Marginal block detected" /* 14 */ },
+	{
+		~(TP_ST0 | TP_WRP | TP_EOM | TP_UDA | TP_BNL | TP_FIL |
+		  TP_NDT), TP_ST1 | TP_EOR,
 		/********** Is the extra TP_NDT really needed Eddy? **********/
-		"End of recorded media"				/* extra: 15 */},
-		/* 15 is returned when SEEKEOD completes successfully */
-	{~(TP_WRP|TP_ST0), TP_ST1|TP_BOM,
-		"Beginning of media"				/* extra: 16 */}
+	"End of recorded media" /* extra: 15 */ },
+	    /* 15 is returned when SEEKEOD completes successfully */
+	{
+	~(TP_WRP | TP_ST0), TP_ST1 | TP_BOM, "Beginning of media" /* extra: 16 */ }
 };
+
 #define NR_OF_EXC	(sizeof(exception_list)/sizeof(struct exception_list_type))
 
 /* Compare expected struct size and actual struct size. This
@@ -310,7 +330,7 @@
 {
 	if ((flags & TPQD_ALWAYS) || (flags & QIC02_TAPE_DEBUG))
 		printk(TPQIC02_NAME ": %s\n", s);
-} /* tpqputs */
+}				/* tpqputs */
 
 
 /* Perform byte order swapping for a 16-bit word.
@@ -318,11 +338,10 @@
  * [FIXME] This should probably be in include/asm/
  * ([FIXME] i486 can do this faster)
  */
-static inline void byte_swap_w(volatile unsigned short * w)
+static inline void byte_swap_w(volatile unsigned short *w)
 {
 	int t = *w;
-
-	*w = (t>>8) | ((t & 0xff)<<8);
+	*w = (t >> 8) | ((t & 0xff) << 8);
 }
 
 
@@ -334,37 +353,32 @@
  */
 static void ifc_init(void)
 {
-    if (QIC02_TAPE_IFC == WANGTEK) /* || (QIC02_TAPE_IFC == EVEREX) */
-    {
-	ctlbits = WT_CTL_ONLINE;	/* online */
-	outb_p(ctlbits, QIC02_CTL_PORT);
-    }
-    else if (QIC02_TAPE_IFC == ARCHIVE)
-    {
-	ctlbits = 0;			/* no interrupts yet */
-	outb_p(ctlbits, QIC02_CTL_PORT);
-	outb_p(0, AR_RESET_DMA_PORT);	/* dummy write to reset DMA */
-    }
-    else /* MOUNTAIN */
-    {
-	ctlbits = MTN_CTL_ONLINE;       /* online, and logic enabled */
-	outb_p(ctlbits, QIC02_CTL_PORT);
-    }
-} /* ifc_init */
+	if (QIC02_TAPE_IFC == WANGTEK) {	/* || (QIC02_TAPE_IFC == EVEREX) */
+		ctlbits = WT_CTL_ONLINE;	/* online */
+		outb_p(ctlbits, QIC02_CTL_PORT);
+	} else if (QIC02_TAPE_IFC == ARCHIVE) {
+		ctlbits = 0;	/* no interrupts yet */
+		outb_p(ctlbits, QIC02_CTL_PORT);
+		outb_p(0, AR_RESET_DMA_PORT);	/* dummy write to reset DMA */
+	} else {		/* MOUNTAIN */
+
+		ctlbits = MTN_CTL_ONLINE;	/* online, and logic enabled */
+		outb_p(ctlbits, QIC02_CTL_PORT);
+	}
+}				/* ifc_init */
 
 
 static void report_qic_exception(unsigned n)
 {
-    if (n >= NR_OF_EXC)
-    {
-	tpqputs(TPQD_ALWAYS, "Oops -- report_qic_exception");
-	n = 0;
-    }
-    if (TPQDBG(SENSE_TEXT) || n==0)
-    {
-	printk(TPQIC02_NAME ": sense: %s\n", exception_list[n].msg);
-    }
-} /* report_qic_exception */
+	if (n >= NR_OF_EXC) {
+		tpqputs(TPQD_ALWAYS, "Oops -- report_qic_exception");
+		n = 0;
+	}
+	if (TPQDBG(SENSE_TEXT) || n == 0) {
+		printk(TPQIC02_NAME ": sense: %s\n",
+		       exception_list[n].msg);
+	}
+}				/* report_qic_exception */
 
 
 /* Try to map the drive-exception bits `s' to a predefined "exception number",
@@ -374,18 +388,18 @@
  */
 static int decode_qic_exception_nr(unsigned s)
 {
-    int i;
+	int i;
 
-    for (i=1; i<NR_OF_EXC; i++)
-    {
-	if ((s & exception_list[i].mask)==exception_list[i].code)
-	{
-	    return i;
+	for (i = 1; i < NR_OF_EXC; i++) {
+		if ((s & exception_list[i].mask) == exception_list[i].code) {
+			return i;
+		}
 	}
-    }
-    printk(TPQIC02_NAME ": decode_qic_exception_nr: exception(%x) not recognized\n", s);
-    return 0;
-} /* decode_qic_exception_nr */
+	printk(TPQIC02_NAME
+	       ": decode_qic_exception_nr: exception(%x) not recognized\n",
+	       s);
+	return 0;
+}				/* decode_qic_exception_nr */
 
 
 
@@ -394,44 +408,36 @@
  */
 static void handle_qic_exception(int exnr, int exbits)
 {
-    if (exnr==EXC_NCART)
-    {
-	/* Cartridge was changed. Redo sense().
-	 * EXC_NCART should be handled in open().
-	 * It is not permitted to remove the tape while
-	 * the tape driver has open files. 
-	 */
-	need_rewind = YES;
-	status_eof_detected = NO;
-	status_eom_detected = NO;
-    }
-    else if (exnr==EXC_XFILLER)
-    {
-	tpqputs(TPQD_ALWAYS, "[Bad block -- filler data transferred.]");
-    }
-    else if (exnr==EXC_XBAD)
-    {
-	tpqputs(TPQD_ALWAYS, "[CRC failed!]");
-    }
-    else if (exnr==EXC_MARGINAL)
-    {
-	/* A marginal block behaves much like a FM.
-	 * User may continue reading, if desired.
-	 */
-	tpqputs(TPQD_ALWAYS, "[Marginal block]");
-	doing_read = NO;
-    }
-    else if (exnr==EXC_FM)
-    {
-	doing_read = NO;
-    }
-} /* handle_qic_exception */
+	if (exnr == EXC_NCART) {
+		/* Cartridge was changed. Redo sense().
+		 * EXC_NCART should be handled in open().
+		 * It is not permitted to remove the tape while
+		 * the tape driver has open files. 
+		 */
+		need_rewind = YES;
+		status_eof_detected = NO;
+		status_eom_detected = NO;
+	} else if (exnr == EXC_XFILLER) {
+		tpqputs(TPQD_ALWAYS,
+			"[Bad block -- filler data transferred.]");
+	} else if (exnr == EXC_XBAD) {
+		tpqputs(TPQD_ALWAYS, "[CRC failed!]");
+	} else if (exnr == EXC_MARGINAL) {
+		/* A marginal block behaves much like a FM.
+		 * User may continue reading, if desired.
+		 */
+		tpqputs(TPQD_ALWAYS, "[Marginal block]");
+		doing_read = NO;
+	} else if (exnr == EXC_FM) {
+		doing_read = NO;
+	}
+}				/* handle_qic_exception */
 
 
 static inline int is_exception(void)
 {
-    return (inb(QIC02_STAT_PORT) & QIC02_STAT_EXCEPTION) == 0;
-} /* is_exception */
+	return (inb(QIC02_STAT_PORT) & QIC02_STAT_EXCEPTION) == 0;
+}				/* is_exception */
 
 
 /* Reset the tape drive and controller.
@@ -440,54 +446,49 @@
  */
 static int tape_reset(int verbose)
 {
-    ifc_init();				/* reset interface card */
+	ifc_init();		/* reset interface card */
 
-    /* assert reset */
-    if (QIC02_TAPE_IFC == MOUNTAIN)
-    {
-	outb_p(ctlbits & ~MTN_QIC02_CTL_RESET_NOT, QIC02_CTL_PORT);
-    }
-    else /* WANGTEK, ARCHIVE */
-    {
-	outb_p(ctlbits | QIC02_CTL_RESET, QIC02_CTL_PORT);
-    }
-    
-    /* Next, we need to wait >=25 usec. */
-    udelay(30);
-
-    /* after reset, we will be at BOT (modulo an automatic rewind) */
-    status_eof_detected = NO;
-    status_eom_detected = NO;
-    status_cmd_pending = 0;
-    need_rewind = YES;
-    doing_read = doing_write = NO;
-    ioctl_status.mt_fileno = ioctl_status.mt_blkno = 0;
-    
-    /* de-assert reset */
-    if (QIC02_TAPE_IFC == MOUNTAIN)
-    {
-	outb_p(ctlbits | MTN_QIC02_CTL_RESET_NOT, QIC02_CTL_PORT);
-    }
-    else
-    {
-	outb_p(ctlbits & ~QIC02_CTL_RESET, QIC02_CTL_PORT);
-    }
-    
-    /* KLUDGE FOR G++ BUG */
-    { int stat = inb_p(QIC02_STAT_PORT);
-	status_dead = ((stat & QIC02_STAT_RESETMASK) != QIC02_STAT_RESETVAL); }
-    /* if successful, inb(STAT) returned RESETVAL */
-    if (status_dead == YES)
-    {
-	printk(TPQIC02_NAME ": reset failed!\n");
-    }
-    else if (verbose)
-    {
-	printk(TPQIC02_NAME ": reset successful\n");
-    }
-    
-    return (status_dead == YES)? TE_DEAD : TE_OK;
-} /* tape_reset */
+	/* assert reset */
+	if (QIC02_TAPE_IFC == MOUNTAIN) {
+		outb_p(ctlbits & ~MTN_QIC02_CTL_RESET_NOT, QIC02_CTL_PORT);
+	} else {		/* WANGTEK, ARCHIVE */
+
+		outb_p(ctlbits | QIC02_CTL_RESET, QIC02_CTL_PORT);
+	}
+
+	/* Next, we need to wait >=25 usec. */
+	udelay(30);
+
+	/* after reset, we will be at BOT (modulo an automatic rewind) */
+	status_eof_detected = NO;
+	status_eom_detected = NO;
+	status_cmd_pending = 0;
+	need_rewind = YES;
+	doing_read = doing_write = NO;
+	ioctl_status.mt_fileno = ioctl_status.mt_blkno = 0;
+
+	/* de-assert reset */
+	if (QIC02_TAPE_IFC == MOUNTAIN) {
+		outb_p(ctlbits | MTN_QIC02_CTL_RESET_NOT, QIC02_CTL_PORT);
+	} else {
+		outb_p(ctlbits & ~QIC02_CTL_RESET, QIC02_CTL_PORT);
+	}
+
+	/* KLUDGE FOR G++ BUG */
+	{
+		int stat = inb_p(QIC02_STAT_PORT);
+		status_dead =
+		    ((stat & QIC02_STAT_RESETMASK) != QIC02_STAT_RESETVAL);
+	}
+	/* if successful, inb(STAT) returned RESETVAL */
+	if (status_dead == YES) {
+		printk(TPQIC02_NAME ": reset failed!\n");
+	} else if (verbose) {
+		printk(TPQIC02_NAME ": reset successful\n");
+	}
+
+	return (status_dead == YES) ? TE_DEAD : TE_OK;
+}				/* tape_reset */
 
 
 
@@ -504,7 +505,7 @@
 {
 	int i;
 
-	outb_p(cmd, QIC02_CMD_PORT);    /* output the command */
+	outb_p(cmd, QIC02_CMD_PORT);	/* output the command */
 
 	/* wait 1 usec before asserting /REQUEST */
 	udelay(1);
@@ -512,7 +513,7 @@
 	if ((!ignore_ex) && is_exception()) {
 		tpqputs(TPQD_ALWAYS, "*** exception detected in notify_cmd");
 		/** force a reset here **/
-		if (tape_reset(1)==TE_DEAD)
+		if (tape_reset(1) == TE_DEAD)
 			return TE_DEAD;
 		if (is_exception()) {
 			tpqputs(TPQD_ALWAYS, "exception persists after reset.");
@@ -520,33 +521,36 @@
 		}
 	}
 
-	outb_p(ctlbits | QIC02_CTL_REQUEST, QIC02_CTL_PORT);  /* set request bit */
+	outb_p(ctlbits | QIC02_CTL_REQUEST, QIC02_CTL_PORT);	/* set request bit */
 	i = TAPE_NOTIFY_TIMEOUT;
 	/* The specs say this takes about 500 usec, but there is no upper limit!
 	 * If the drive were busy retensioning or something like that,
 	 * it could be *much* longer!
 	 */
-	while ((inb_p(QIC02_STAT_PORT) & QIC02_STAT_READY) && (--i>0))
-		/*skip*/;			  /* wait for ready */
-	if (i==0) {
-		tpqputs(TPQD_ALWAYS, "timed out waiting for ready in notify_cmd");
+	while ((inb_p(QIC02_STAT_PORT) & QIC02_STAT_READY) && (--i > 0))
+		/*skip */ ;
+	/* wait for ready */
+	if (i == 0) {
+		tpqputs(TPQD_ALWAYS,
+			"timed out waiting for ready in notify_cmd");
 		status_dead = YES;
 		return TE_TIM;
 	}
 
-	outb_p(ctlbits & ~QIC02_CTL_REQUEST, QIC02_CTL_PORT); /* reset request bit */
+	outb_p(ctlbits & ~QIC02_CTL_REQUEST, QIC02_CTL_PORT);	/* reset request bit */
 	i = TAPE_NOTIFY_TIMEOUT;
 	/* according to the specs this one should never time-out */
-	while (((inb_p(QIC02_STAT_PORT) & QIC02_STAT_READY) == 0) && (--i>0))
-		/*skip*/;			  /* wait for not ready */
-	if (i==0) {
+	while (((inb_p(QIC02_STAT_PORT) & QIC02_STAT_READY) == 0) && (--i > 0))
+		/*skip */ ;
+	/* wait for not ready */
+	if (i == 0) {
 		tpqputs(TPQD_ALWAYS, "timed out waiting for !ready in notify_cmd");
 		status_dead = YES;
 		return TE_TIM;
 	}
 	/* command accepted */
 	return TE_OK;
-} /* notify_cmd */
+}				/* notify_cmd */
 
 
 
@@ -563,20 +567,22 @@
 	 * First, busy wait a few usec:
 	 */
 	spin_t = 50;
-	while (((stat = inb_p(QIC02_STAT_PORT) & QIC02_STAT_MASK) == QIC02_STAT_MASK) && (--spin_t>0))
+	while (((stat = inb_p(QIC02_STAT_PORT) & QIC02_STAT_MASK) == QIC02_STAT_MASK) && (--spin_t > 0))
 		/*SKIP*/;
 	if ((stat & QIC02_STAT_READY) == 0)
-		return TE_OK;			/* covers 99.99% of all calls */
+		return TE_OK;	/* covers 99.99% of all calls */
 
 	/* Then use schedule() a few times */
-	spin_t = 3;	/* max 0.03 sec busy waiting */
+	spin_t = 3;		/* max 0.03 sec busy waiting */
 	if (spin_t > timeout)
 		spin_t = timeout;
 	timeout -= spin_t;
 	spin_t += jiffies;
 
-	while (((stat = inb_p(QIC02_STAT_PORT) & QIC02_STAT_MASK) == QIC02_STAT_MASK) && time_before(jiffies, spin_t))
-		schedule();		/* don't waste all the CPU time */
+	/* FIXME...*/
+	while (((stat = inb_p(QIC02_STAT_PORT) & QIC02_STAT_MASK) == QIC02_STAT_MASK) 
+		&& time_before(jiffies, spin_t))
+		schedule();	/* don't waste all the CPU time */
 	if ((stat & QIC02_STAT_READY) == 0)
 		return TE_OK;
 
@@ -589,13 +595,13 @@
 	spin_t += timeout;
 	TPQDEB({printk("wait_for_ready: additional timeout: %d\n", spin_t);})
 
-		/* not ready and no exception && timeout not expired yet */
+	    /* not ready and no exception && timeout not expired yet */
 	while (((stat = inb_p(QIC02_STAT_PORT) & QIC02_STAT_MASK) == QIC02_STAT_MASK) && time_before(jiffies, spin_t)) {
 		/* be `nice` to other processes on long operations... */
 		current->state = TASK_INTERRUPTIBLE;
 		/* nap 0.30 sec between checks, */
 		/* but could be woken up earlier by signals... */
-		schedule_timeout(3*HZ/10);
+		schedule_timeout(3 * HZ / 10);
 	}
 
 	/* don't use jiffies for this test because it may have changed by now */
@@ -605,12 +611,13 @@
 	}
 
 	if ((stat & QIC02_STAT_EXCEPTION) == 0) {
-		tpqputs(TPQD_ALWAYS, "exception detected after waiting_for_ready");
+		tpqputs(TPQD_ALWAYS,
+			"exception detected after waiting_for_ready");
 		return TE_EX;
 	} else {
 		return TE_OK;
 	}
-} /* wait_for_ready */
+}				/* wait_for_ready */
 
 
 
@@ -619,7 +626,7 @@
 {
 	int i, stat;
 
-	for (i=0; i<size; i++) {
+	for (i = 0; i < size; i++) {
 
 		stat = wait_for_ready(TIM_S);
 		if (stat != TE_OK)
@@ -630,8 +637,8 @@
 			return stat;
 	}
 	return TE_OK;
-	
-} /* send_qic02_data */
+
+}				/* send_qic02_data */
 
 
 /* Send a QIC-02 command (`cmd') to the tape drive, with
@@ -650,7 +657,7 @@
 		tpqputs(TPQD_ALWAYS, "send_qic02_cmd: Exception!");
 		return TE_EX;
 	}
-	if (stat & QIC02_STAT_READY) {			/* if not ready */
+	if (stat & QIC02_STAT_READY) {	/* if not ready */
 		tpqputs(TPQD_ALWAYS, "send_qic02_cmd: not Ready!");
 		return TE_ERR;
 	}
@@ -662,8 +669,8 @@
 	 */
 	status_cmd_pending = cmd;
 
-	stat = notify_cmd(cmd, ignore_ex); /* tell drive new command was loaded, */
-					   /* inherit exception check. */
+	stat = notify_cmd(cmd, ignore_ex);	/* tell drive new command was loaded, */
+	/* inherit exception check. */
 	if (TP_HAVE_SEEK && (cmd == AR_QCMDV_SEEK_BLK)) {
 		/* This one needs to send 3 more bytes, MSB first */
 		stat = send_qic02_data(seek_addr_buf, sizeof(seek_addr_buf), ignore_ex);
@@ -673,7 +680,7 @@
 		tpqputs(TPQD_ALWAYS, "send_qic02_cmd failed");
 	}
 	return stat;
-} /* send_qic02_cmd */
+}				/* send_qic02_cmd */
 
 
 
@@ -683,8 +690,8 @@
  */
 static int rdstatus(char *stp, unsigned size, char qcmd)
 {
-	int	s, n;
-	char	*q = stp;
+	int s, n;
+	char *q = stp;
 
 	/* Try to busy-wait a few (700) usec, after that de-schedule.
 	 *
@@ -693,21 +700,22 @@
 	 * de-schedule immediately, we waste a lot of time because a
 	 * task switch is much longer than we usually have to wait here.
 	 */
-	n = 1000;	/* 500 is not enough on a 486/33 */
-	while ((n>0) && ((inb_p(QIC02_STAT_PORT) & QIC02_STAT_MASK) == QIC02_STAT_MASK))
-		n--;  /* wait for ready or exception or timeout */
-	if (n==0) {
+	n = 1000;		/* 500 is not enough on a 486/33 */
+	while ((n > 0) && ((inb_p(QIC02_STAT_PORT) & QIC02_STAT_MASK) == QIC02_STAT_MASK))
+		n--;		/* wait for ready or exception or timeout */
+	if (n == 0) {
 		/* n (above) should be chosen such that on your machine
 		 * you rarely ever see the message below, and it should
 		 * be small enough to give reasonable response time.]
 		 */
+	 	/* FIXME */
 		tpqputs(TPQD_ALWAYS, "waiting looong in rdstatus() -- drive dead?");
 		while ((inb_p(QIC02_STAT_PORT) & QIC02_STAT_MASK) == QIC02_STAT_MASK)
 			schedule();
 		tpqputs(TPQD_ALWAYS, "finished waiting in rdstatus()");
 	}
 
-	(void) notify_cmd(qcmd, 1);			/* send read status command */
+	(void) notify_cmd(qcmd, 1);	/* send read status command */
 	/* ignore return code -- should always be ok, STAT may contain 
 	 * exception flag from previous exception which we are trying to clear.
 	 */
@@ -715,21 +723,22 @@
 	if (TP_DIAGS(current_tape_dev))
 		printk(TPQIC02_NAME ": reading status bytes: ");
 
-	for (q=stp; q<stp+size; q++)
-	{
-		do s = inb_p(QIC02_STAT_PORT);
+	for (q = stp; q < stp + size; q++) {
+		do
+			s = inb_p(QIC02_STAT_PORT);
 		while ((s & QIC02_STAT_MASK) == QIC02_STAT_MASK);	/* wait for ready or exception */
 
-		if ((s & QIC02_STAT_EXCEPTION) == 0) {		/* if exception */
+		if ((s & QIC02_STAT_EXCEPTION) == 0) {	/* if exception */
 			tpqputs(TPQD_ALWAYS, "rdstatus: exception error");
-			ioctl_status.mt_erreg = 0;		/* dunno... */
-			return TE_NS;				/* error, shouldn't happen... */
+			ioctl_status.mt_erreg = 0;	/* dunno... */
+			return TE_NS;	/* error, shouldn't happen... */
 		}
 
-		*q = inb_p(QIC02_DATA_PORT);			/* read status byte */
+		*q = inb_p(QIC02_DATA_PORT);	/* read status byte */
 
 		if (TP_DIAGS(current_tape_dev))
-			printk("[%1d]=0x%x  ", q-stp, (unsigned) (*q) & 0xff);
+			printk("[%1d]=0x%x  ", q - stp,
+			       (unsigned) (*q) & 0xff);
 
 		outb_p(ctlbits | QIC02_CTL_REQUEST, QIC02_CTL_PORT);	/* set request */
 
@@ -745,13 +754,14 @@
 	 * My drive doesn't seem to need it here yet, but others do?
 	 */
 	while (inb_p(QIC02_STAT_PORT) & QIC02_STAT_READY)
-		/*skip*/;			  /* wait for ready */
+		/*skip */ ;
+	/* wait for ready */
 
 	if (TP_DIAGS(current_tape_dev))
 		printk("\n");
 
 	return TE_OK;
-} /* rdstatus */
+}				/* rdstatus */
 
 
 
@@ -769,7 +779,7 @@
 	/* should probably swap status bytes #definition */
 #endif
 	return stat;
-} /* get_status */
+}				/* get_status */
 
 
 #if 0
@@ -782,7 +792,7 @@
  */
 static int get_ext_status3(void)
 {
-	char vus[64];	/* vendor unique status */
+	char vus[64];		/* vendor unique status */
 	int stat, i;
 
 	tpqputs(TPQD_ALWAYS, "Attempting to read Extended Status 3...");
@@ -791,15 +801,15 @@
 		return stat;
 
 	tpqputs(TPQD_ALWAYS, "Returned status bytes:");
-	for (i=0; i<sizeof(vus); i++) {
-		if ( i % 8 == 0 )
+	for (i = 0; i < sizeof(vus); i++) {
+		if (i % 8 == 0)
 			printk("\n" TPQIC02_NAME ": %2d:");
 		printk(" %2x", vus[i] & 0xff);
 	}
 	printk("\n");
 
 	return TE_OK;
-} /* get_ext_status3 */
+}				/* get_ext_status3 */
 #endif
 
 
@@ -812,13 +822,14 @@
 	static void finish_rw(int cmd);
 
 	if (TPQDBG(SENSE_TEXT))
-		printk(TPQIC02_NAME ": tp_sense(ignore=0x%x) enter\n", ignore);
+		printk(TPQIC02_NAME ": tp_sense(ignore=0x%x) enter\n",
+		       ignore);
 
 	/* sense() is not allowed during a read or write cycle */
 	if (doing_write == YES)
 		tpqputs(TPQD_ALWAYS, "Warning: File Mark inserted because of sense() request");
 	/* The extra test is to avoid calling finish_rw during booting */
-	if ((doing_read!=NO) || (doing_write!=NO))
+	if ((doing_read != NO) || (doing_write != NO))
 		finish_rw(QCMD_RD_STAT);
 
 	if (get_status(&tperror) != TE_OK) {
@@ -827,27 +838,29 @@
 	}
 
 	err = tperror.exs;	/* get exception status bits */
-	if (err & (TP_ST0|TP_ST1))
+	if (err & (TP_ST0 | TP_ST1))
 		printk(TPQIC02_NAME ": tp_sense: status: %x, error count: %d, underruns: %d\n",
-			tperror.exs, tperror.dec, tperror.urc);
-	else if ((tperror.dec!=0) || (tperror.urc!=0) || TPQDBG(SENSE_CNTS))
-		printk(TPQIC02_NAME ": tp_sense: no hard errors, soft error count: %d, underruns: %d\n",
-			tperror.dec, tperror.urc);
+		       tperror.exs, tperror.dec, tperror.urc);
+	else if ((tperror.dec != 0) || (tperror.urc != 0)
+		 || TPQDBG(SENSE_CNTS))
+		printk(TPQIC02_NAME
+		       ": tp_sense: no hard errors, soft error count: %d, underruns: %d\n",
+		       tperror.dec, tperror.urc);
 
 	/* Set generic status. HP-UX defines these, but some extra would 
 	 * be useful. Problem is to remain compatible. [Do we want to be
 	 * compatible??]
 	 */
 	if (err & TP_ST0) {
-		if (err & TP_CNI)		/* no cartridge */
+		if (err & TP_CNI)	/* no cartridge */
 			gs |= GMT_DR_OPEN(-1);
 		if (status_dead == NO)
 			gs |= GMT_ONLINE(-1);	/* always online */
-		if (err & TP_USL)		/* not online */
+		if (err & TP_USL)	/* not online */
 			gs &= ~GMT_ONLINE(-1);
 		if (err & TP_WRP)
 			gs |= GMT_WR_PROT(-1);
-		if (err & TP_EOM) {		/* end of media */
+		if (err & TP_EOM) {	/* end of media */
 			gs |= GMT_EOT(-1);	/* not sure this is correct for writes */
 			status_eom_detected = YES;
 			/* I don't know whether drive always reports EOF at or before EOM. */
@@ -871,10 +884,10 @@
 	ioctl_status.mt_dsreg = tperror.exs;	/* "drive status" */
 	ioctl_status.mt_erreg = tperror.dec;	/* "sense key error" */
 
-	if (err & (TP_ST0|TP_ST1)) {
+	if (err & (TP_ST0 | TP_ST1)) {
 		/* My Wangtek occasionally reports `status' 1212 which should be ignored. */
 		exnr = decode_qic_exception_nr(err);
-		handle_qic_exception(exnr, err);		/* update driver state wrt drive status */
+		handle_qic_exception(exnr, err);	/* update driver state wrt drive status */
 		report_qic_exception(exnr);
 	}
 	err &= ~ignore;		/* mask unwanted errors -- not the correct way, use exception nrs?? */
@@ -882,7 +895,7 @@
 	    ((err & TP_ST1) && (err & REPORT_ERR1)))
 		return TE_ERR;
 	return TE_OK;
-} /* tp_sense */
+}				/* tp_sense */
 
 
 
@@ -895,15 +908,17 @@
 
 	stat = inb(QIC02_STAT_PORT) & QIC02_STAT_MASK;
 	if (TPQDBG(REWIND))
-		printk(TPQIC02_NAME ": Waiting for (re-)wind to finish: stat=0x%x\n", stat);
+		printk(TPQIC02_NAME
+		       ": Waiting for (re-)wind to finish: stat=0x%x\n",
+		       stat);
 
 	stat = wait_for_ready(timeout);
 
 	if (stat != TE_OK) {
-			tpqputs(TPQD_ALWAYS, "(re-) winding failed\n");
+		tpqputs(TPQD_ALWAYS, "(re-) winding failed\n");
 	}
 	return stat;
-} /* wait_for_rewind */
+}				/* wait_for_rewind */
 
 
 
@@ -919,22 +934,21 @@
 
 	if (status_dead == YES) {
 		tpqputs(TPQD_ALWAYS, "Drive is dead. Do a `mt reset`.");
-		return -ENXIO;			/* User should do an MTRESET. */
+		return -ENXIO;	/* User should do an MTRESET. */
 	}
 
-	stat = wait_for_ready(timeout);		/* wait for ready or exception */
+	stat = wait_for_ready(timeout);	/* wait for ready or exception */
 	if (stat == TE_EX) {
-		if (tp_sense(TP_WRP|TP_BOM|TP_EOM|TP_FIL)!=TE_OK)
+		if (tp_sense(TP_WRP | TP_BOM | TP_EOM | TP_FIL) != TE_OK)
 			return -EIO;
 		/* else nothing to worry about, I hope */
 		stat = TE_OK;
 	}
 	if (stat != TE_OK) {
-		printk(TPQIC02_NAME ": ll_do_qic_cmd(%x, %ld) failed\n", cmd, (long) timeout);
+		printk(TPQIC02_NAME ": ll_do_qic_cmd(%x, %ld) failed\n",
+		       cmd, (long) timeout);
 		return -EIO;
 	}
-
-
 #if OBSOLETE
 	/* wait for ready since it may not be active immediately after reading status */
 	while ((inb_p(QIC02_STAT_PORT) & QIC02_STAT_READY) != 0);
@@ -942,16 +956,17 @@
 
 	stat = send_qic02_cmd(cmd, timeout, 0);	/* (checks for exceptions) */
 
-	if (cmd==QCMD_RD_FM) {
+	if (cmd == QCMD_RD_FM) {
 		status_eof_detected = NO;
 		ioctl_status.mt_fileno++;
 		/* Should update block count as well, but can't.
 		 * Can do a `read address' for some drives, when MTNOP is done.
 		 */
-	} else if (cmd==QCMD_WRT_FM) {
+	} else if (cmd == QCMD_WRT_FM) {
 		status_eof_detected = NO;
 		ioctl_status.mt_fileno++;
-	} else if ((cmd==QCMD_REWIND) || (cmd==QCMD_ERASE) || (cmd==QCMD_RETEN)) {
+	} else if ((cmd == QCMD_REWIND) || (cmd == QCMD_ERASE)
+		   || (cmd == QCMD_RETEN)) {
 		status_eof_detected = NO;
 		status_eom_detected = NO;
 		status_eot_detected = NO;
@@ -964,16 +979,19 @@
 		reported_write_eof = NO;
 	}
 	/* sense() will set eof/eom as required */
-	if (stat==TE_EX) {
-		if (tp_sense(TP_WRP|TP_BOM|TP_EOM|TP_FIL)!=TE_OK) {
-			printk(TPQIC02_NAME ": Exception persist in ll_do_qic_cmd[1](%x, %ld)", cmd, (long) timeout);
+	if (stat == TE_EX) {
+		if (tp_sense(TP_WRP | TP_BOM | TP_EOM | TP_FIL) != TE_OK) {
+			printk(TPQIC02_NAME
+			       ": Exception persist in ll_do_qic_cmd[1](%x, %ld)",
+			       cmd, (long) timeout);
 			status_dead = YES;
 			return -ENXIO;
 			/* if rdstatus fails too, we're in trouble */
 		}
-	}
-	else if (stat!=TE_OK) {
-		printk(TPQIC02_NAME ": ll_do_qic_cmd: send_qic02_cmd failed, stat = 0x%x\n", stat);
+	} else if (stat != TE_OK) {
+		printk(TPQIC02_NAME
+		       ": ll_do_qic_cmd: send_qic02_cmd failed, stat = 0x%x\n",
+		       stat);
 		return -EIO;	/*** -EIO is probably not always appropriate */
 	}
 
@@ -983,23 +1001,27 @@
 	else
 		stat = wait_for_ready(timeout);
 
-	if (stat==TE_EX) {
-		if (tp_sense((cmd==QCMD_SEEK_EOD ?		/*****************************/
-		      TP_EOR|TP_NDT|TP_UDA|TP_BNL|TP_WRP|TP_BOM|TP_EOM|TP_FIL :
-		      TP_WRP|TP_BOM|TP_EOM|TP_FIL))!=TE_OK) {
-			printk(TPQIC02_NAME ": Exception persist in ll_do_qic_cmd[2](%x, %ld)\n", cmd, (long) timeout);
-			if (cmd!=QCMD_RD_FM)
+	if (stat == TE_EX) {
+		if (tp_sense((cmd == QCMD_SEEK_EOD ?		/*****************************/
+			      TP_EOR | TP_NDT | TP_UDA | TP_BNL | TP_WRP |
+			      TP_BOM | TP_EOM | TP_FIL : TP_WRP | TP_BOM |
+			      TP_EOM | TP_FIL)) != TE_OK) {
+			printk(TPQIC02_NAME
+			       ": Exception persist in ll_do_qic_cmd[2](%x, %ld)\n",
+			       cmd, (long) timeout);
+			if (cmd != QCMD_RD_FM)
 				status_dead = YES;
 			return -ENXIO;
 			/* if rdstatus fails too, we're in trouble */
 		}
-	}
-	else if (stat!=TE_OK) {
-		printk(TPQIC02_NAME ": ll_do_qic_cmd %x: wait failed, stat == 0x%x\n", cmd, stat);
+	} else if (stat != TE_OK) {
+		printk(TPQIC02_NAME
+		       ": ll_do_qic_cmd %x: wait failed, stat == 0x%x\n",
+		       cmd, stat);
 		return -EIO;
 	}
 	return 0;
-} /* ll_do_qic_cmd */
+}				/* ll_do_qic_cmd */
 
 
 /* 
@@ -1042,17 +1064,20 @@
 				/* Mountain reference says can terminate by de-asserting online */
 				ctlbits &= ~MTN_QIC02_CTL_ONLINE;
 			}
- 
-			if (tp_sense(TP_FIL|TP_EOM|TP_WRP) != TE_OK) {
-				tpqputs(TPQD_ALWAYS, "finish_rw[read1]: ignore the 2 lines above");
+
+			if (tp_sense(TP_FIL | TP_EOM | TP_WRP) != TE_OK) {
+				tpqputs(TPQD_ALWAYS,
+					"finish_rw[read1]: ignore the 2 lines above");
 				if (is_exception()) {
-					if (tp_sense(TP_ILL|TP_FIL|TP_EOM|TP_WRP) != TE_OK)
-						tpqputs(TPQD_ALWAYS, "finish_rw[read2]: read cycle error");
+					if (tp_sense
+					    (TP_ILL | TP_FIL | TP_EOM |
+					     TP_WRP) != TE_OK)
+						tpqputs(TPQD_ALWAYS,"finish_rw[read2]: read cycle error");
 				}
 			}
 		}
 	}
-} /* terminate_read */
+}				/* terminate_read */
 
 
 static void terminate_write(int cmd)
@@ -1066,28 +1091,30 @@
 			/* finish off write cycle */
 			stat = ll_do_qic_cmd(QCMD_WRT_FM, TIM_M);
 			if (stat != TE_OK)
-				tpqputs(TPQD_ALWAYS, "Couldn't finish write cycle properly");
+				tpqputs(TPQD_ALWAYS,
+					"Couldn't finish write cycle properly");
 			(void) tp_sense(0);
 		}
 		/* If there is an EOF token waiting to be returned to
 		 * the (writing) application, discard it now.
 		 * We could be at EOT, so don't reset return_write_eof.
 		 */
-		reported_write_eof=YES;
+		reported_write_eof = YES;
 	}
-} /* terminate_write */
+}				/* terminate_write */
 
 
 /* terminate read or write cycle because of command `cmd' */
 static void finish_rw(int cmd)
 {
 	if (wait_for_ready(TIM_S) != TE_OK) {
-		tpqputs(TPQD_ALWAYS, "error: drive not ready in finish_rw() !");
+		tpqputs(TPQD_ALWAYS,
+			"error: drive not ready in finish_rw() !");
 		return;
 	}
 	terminate_read(cmd);
 	terminate_write(cmd);
-} /* finish_rw */
+}				/* finish_rw */
 
 
 /* Perform a QIC command through ll_do_qic_cmd().
@@ -1109,12 +1136,12 @@
 			return stat;
 		}
 		need_rewind = NO;
-		if (cmd==QCMD_REWIND)	/* don't wind beyond BOT ;-) */
+		if (cmd == QCMD_REWIND)	/* don't wind beyond BOT ;-) */
 			return 0;
 	}
 
 	return ll_do_qic_cmd(cmd, timeout);
-} /* do_qic_cmd */
+}				/* do_qic_cmd */
 
 
 /* Not all ioctls are supported for all drives. Some rely on
@@ -1132,217 +1159,218 @@
 	 */
 
 	switch (cmd) {
-		case MTRESET:
-			/* reset verbose */
-			return (tape_reset(1)==TE_OK)? 0 : -EIO;
-
-		case MTFSF:
-			tpqputs(TPQD_IOCTLS, "MTFSF forward searching filemark");
-			if ((mode_access==WRITE) && status_bytes_wr)
+	case MTRESET:
+		/* reset verbose */
+		return (tape_reset(1) == TE_OK) ? 0 : -EIO;
+
+	case MTFSF:
+		tpqputs(TPQD_IOCTLS, "MTFSF forward searching filemark");
+		if ((mode_access == WRITE) && status_bytes_wr)
+			return -EACCES;
+		return do_qic_cmd(QCMD_RD_FM, TIM_F);
+
+	case MTBSF:
+		if (TP_HAVE_BSF) {
+			tpqputs(TPQD_IOCTLS,
+				"MTBSF backward searching filemark -- optional command");
+			if ((mode_access == WRITE) && status_bytes_wr)
 				return -EACCES;
-			return do_qic_cmd(QCMD_RD_FM, TIM_F);
-
-		case MTBSF:
-			if (TP_HAVE_BSF) {
-				tpqputs(TPQD_IOCTLS, "MTBSF backward searching filemark -- optional command");
-				if ((mode_access==WRITE) && status_bytes_wr)
-					return -EACCES;
-				stat = do_qic_cmd(QCMD_RD_FM_BCK, TIM_F);
-			} else {
-				stat = -ENXIO;
-			}
-			status_eom_detected = status_eof_detected = NO;
-			return stat;
-
-		case MTFSR:
-			if (TP_HAVE_FSR) { /* This is an optional QIC-02 command */
-				tpqputs(TPQD_IOCTLS, "MTFSR forward space record");
-				if ((mode_access==WRITE) && status_bytes_wr)
-					return -EACCES;
-				stat = do_qic_cmd(QCMD_SPACE_FWD, TIM_F);
-			} else {
-				/**** fake it by doing a read data block command? ******/
-				tpqputs(TPQD_IOCTLS, "MTFSR not supported");
-				stat = -ENXIO;
-			}
-			return stat;
-
-		case MTBSR:
-			if (TP_HAVE_BSR) { /* This is an optional QIC-02 command */
-				/* we need this for appending files with GNU tar!! */
-				tpqputs(TPQD_IOCTLS, "MTFSR backward space record");
-				if ((mode_access==WRITE) && status_bytes_wr)
-					return -EACCES;
-				stat = do_qic_cmd(QCMD_SPACE_BCK, TIM_F);
-			} else {
-				tpqputs(TPQD_IOCTLS, "MTBSR not supported");
-				stat = -ENXIO;
-			}
-			status_eom_detected = status_eof_detected = NO;
-			return stat;
+			stat = do_qic_cmd(QCMD_RD_FM_BCK, TIM_F);
+		} else {
+			stat = -ENXIO;
+		}
+		status_eom_detected = status_eof_detected = NO;
+		return stat;
 
-		case MTWEOF:
-			tpqputs(TPQD_IOCTLS, "MTWEOF write eof mark");
-			/* Plain GNU mt(1) 2.2 uses read-only mode for writing FM. :-( */
-			if (mode_access==READ)
+	case MTFSR:
+		if (TP_HAVE_FSR) {	/* This is an optional QIC-02 command */
+			tpqputs(TPQD_IOCTLS, "MTFSR forward space record");
+			if ((mode_access == WRITE) && status_bytes_wr)
 				return -EACCES;
+			stat = do_qic_cmd(QCMD_SPACE_FWD, TIM_F);
+		} else {
+				/**** fake it by doing a read data block command? ******/
+			tpqputs(TPQD_IOCTLS, "MTFSR not supported");
+			stat = -ENXIO;
+		}
+		return stat;
 
-			/* allow tape movement after writing FM */
-			status_bytes_rd = status_bytes_wr;	/* Kludge-O-Matic */
-			status_bytes_wr = NO;
-			return do_qic_cmd(QCMD_WRT_FM, TIM_M);
-			/* not sure what to do with status_bytes when WFM should fail */
-
-		case MTREW:
-			tpqputs(TPQD_IOCTLS, "MTREW rewinding tape");
-			if ((mode_access==WRITE) && status_bytes_wr)
+	case MTBSR:
+		if (TP_HAVE_BSR) {	/* This is an optional QIC-02 command */
+			/* we need this for appending files with GNU tar!! */
+			tpqputs(TPQD_IOCTLS, "MTFSR backward space record");
+			if ((mode_access == WRITE) && status_bytes_wr)
 				return -EACCES;
-			status_eom_detected = status_eof_detected = NO;
-			return do_qic_cmd(QCMD_REWIND, TIM_R);
+			stat = do_qic_cmd(QCMD_SPACE_BCK, TIM_F);
+		} else {
+			tpqputs(TPQD_IOCTLS, "MTBSR not supported");
+			stat = -ENXIO;
+		}
+		status_eom_detected = status_eof_detected = NO;
+		return stat;
 
-		case MTOFFL:
-			tpqputs(TPQD_IOCTLS, "MTOFFL rewinding & going offline");
-			/* Doing a drive select will clear (unlock) the current drive.
-			 * But that requires support for multiple drives and locking.
-			 */
-			if ((mode_access==WRITE) && status_bytes_wr)
-				return -EACCES;
-			status_eom_detected = status_eof_detected = NO;
+	case MTWEOF:
+		tpqputs(TPQD_IOCTLS, "MTWEOF write eof mark");
+		/* Plain GNU mt(1) 2.2 uses read-only mode for writing FM. :-( */
+		if (mode_access == READ)
+			return -EACCES;
+
+		/* allow tape movement after writing FM */
+		status_bytes_rd = status_bytes_wr;	/* Kludge-O-Matic */
+		status_bytes_wr = NO;
+		return do_qic_cmd(QCMD_WRT_FM, TIM_M);
+		/* not sure what to do with status_bytes when WFM should fail */
+
+	case MTREW:
+		tpqputs(TPQD_IOCTLS, "MTREW rewinding tape");
+		if ((mode_access == WRITE) && status_bytes_wr)
+			return -EACCES;
+		status_eom_detected = status_eof_detected = NO;
+		return do_qic_cmd(QCMD_REWIND, TIM_R);
+
+	case MTOFFL:
+		tpqputs(TPQD_IOCTLS, "MTOFFL rewinding & going offline");
+		/* Doing a drive select will clear (unlock) the current drive.
+		 * But that requires support for multiple drives and locking.
+		 */
+		if ((mode_access == WRITE) && status_bytes_wr)
+			return -EACCES;
+		status_eom_detected = status_eof_detected = NO;
 			/**** do rewind depending on minor bits??? ***/
-			stat = do_qic_cmd(QCMD_REWIND, TIM_R);
-			return stat;
+		stat = do_qic_cmd(QCMD_REWIND, TIM_R);
+		return stat;
 
-		case MTNOP:
-			tpqputs(TPQD_IOCTLS, "MTNOP setting status only");
+	case MTNOP:
+		tpqputs(TPQD_IOCTLS, "MTNOP setting status only");
 			/********** should do `read position' for drives that support it **********/
-			return (tp_sense(-1)==TE_OK)? 0 : -EIO;	/**** check return codes ****/
-
-		case MTRETEN:
-			tpqputs(TPQD_IOCTLS, "MTRETEN retension tape");
-			if ((mode_access==WRITE) && status_bytes_wr)
-				return -EACCES;
-			status_eom_detected = status_eof_detected = NO;
-			return do_qic_cmd(QCMD_RETEN, TIM_R);
+		return (tp_sense(-1) == TE_OK) ? 0 : -EIO;	/**** check return codes ****/
 
-		case MTBSFM:
-			/* Think think is like MTBSF, except that
-			 * we shouldn't skip the FM. Tricky.
-			 * Maybe use RD_FM_BCK, then do a SPACE_FWD?
-			 */
-			tpqputs(TPQD_IOCTLS, "MTBSFM not supported");
-			if ((mode_access==WRITE) && status_bytes_wr)
-				return -EACCES;
-			return -ENXIO;
+	case MTRETEN:
+		tpqputs(TPQD_IOCTLS, "MTRETEN retension tape");
+		if ((mode_access == WRITE) && status_bytes_wr)
+			return -EACCES;
+		status_eom_detected = status_eof_detected = NO;
+		return do_qic_cmd(QCMD_RETEN, TIM_R);
+
+	case MTBSFM:
+		/* Think think is like MTBSF, except that
+		 * we shouldn't skip the FM. Tricky.
+		 * Maybe use RD_FM_BCK, then do a SPACE_FWD?
+		 */
+		tpqputs(TPQD_IOCTLS, "MTBSFM not supported");
+		if ((mode_access == WRITE) && status_bytes_wr)
+			return -EACCES;
+		return -ENXIO;
 
-		case MTFSFM:
-			/* I think this is like MTFSF, except that
-			 * we shouldn't skip the FM. Tricky.
-			 * Maybe use QCMD_RD_DATA until we get a TP_FIL exception?
-			 * But then the FM will have been skipped...
-			 * Maybe use RD_FM, then RD_FM_BCK, but not all
-			 * drives will support that!
-			 */
-			tpqputs(TPQD_IOCTLS, "MTFSFM not supported");
-			if ((mode_access==WRITE) && status_bytes_wr)
-				return -EACCES;
-			return -ENXIO;
+	case MTFSFM:
+		/* I think this is like MTFSF, except that
+		 * we shouldn't skip the FM. Tricky.
+		 * Maybe use QCMD_RD_DATA until we get a TP_FIL exception?
+		 * But then the FM will have been skipped...
+		 * Maybe use RD_FM, then RD_FM_BCK, but not all
+		 * drives will support that!
+		 */
+		tpqputs(TPQD_IOCTLS, "MTFSFM not supported");
+		if ((mode_access == WRITE) && status_bytes_wr)
+			return -EACCES;
+		return -ENXIO;
 
-		case MTEOM:
-			/* This should leave the tape ready for appending
-			 * another file to the end, such that it would append
-			 * after the last FM on tape.
+	case MTEOM:
+		/* This should leave the tape ready for appending
+		 * another file to the end, such that it would append
+		 * after the last FM on tape.
+		 */
+		tpqputs(TPQD_IOCTLS, "MTEOM search for End Of recorded Media");
+		if ((mode_access == WRITE) && status_bytes_wr)
+			return -EACCES;
+		if (TP_HAVE_EOD) {
+			/* Use faster seeking when possible.
+			 * This requires the absence of data beyond the EOM.
+			 * It seems that my drive does not always perform the
+			 * SEEK_EOD correctly, unless it is preceded by a
+			 * rewind command.
 			 */
-			tpqputs(TPQD_IOCTLS, "MTEOM search for End Of recorded Media");
-			if ((mode_access==WRITE) && status_bytes_wr)
-				return -EACCES;
-			if (TP_HAVE_EOD) {
-				/* Use faster seeking when possible.
-				 * This requires the absence of data beyond the EOM.
-				 * It seems that my drive does not always perform the
-				 * SEEK_EOD correctly, unless it is preceded by a
-				 * rewind command.
-				 */
 # if 0
-				status_eom_detected = status_eof_detected = NO;
+			status_eom_detected = status_eof_detected = NO;
 # endif
-				stat = do_qic_cmd(QCMD_REWIND, TIM_R);
-				if (stat)
-					return stat;
-				stat = do_qic_cmd(QCMD_SEEK_EOD, TIM_F);
-				/* After a successful seek, TP_EOR should be returned */
-			} else {
-				/* else just seek until the drive returns exception "No Data" */
-				stat = 0;
-				while ((stat==0) && (!status_eom_detected)) {
-					stat = do_qic_cmd(QCMD_RD_FM, TIM_F); /***** should use MTFSFM here???? ******/
-				}
-				if (tperror.exs & TP_NDT)
-					return 0;
-			}
-			return stat;
-
-		case MTERASE:
-			tpqputs(TPQD_IOCTLS, "MTERASE -- ERASE TAPE !");
-			if  ((tperror.exs & TP_ST0) && (tperror.exs & TP_WRP)) {
-				tpqputs(TPQD_ALWAYS, "Cartridge is write-protected.");
-				return -EACCES;
-			} else {
-				time_t t = jiffies;
-
-				/* Plain GNU mt(1) 2.2 erases a tape in O_RDONLY. :-( */
-				if (mode_access==READ) 
-					return -EACCES;
-
-				/* give user a few seconds to pull out tape */
-				while (jiffies - t < 4*HZ)
-					schedule();
+			stat = do_qic_cmd(QCMD_REWIND, TIM_R);
+			if (stat)
+				return stat;
+			stat = do_qic_cmd(QCMD_SEEK_EOD, TIM_F);
+			/* After a successful seek, TP_EOR should be returned */
+		} else {
+			/* else just seek until the drive returns exception "No Data" */
+			stat = 0;
+			while ((stat == 0) && (!status_eom_detected)) {
+				stat = do_qic_cmd(QCMD_RD_FM, TIM_F);	      /***** should use MTFSFM here???? ******/
 			}
+			if (tperror.exs & TP_NDT)
+				return 0;
+		}
+		return stat;
 
-			/* don't bother writing filemark first */
-			status_eom_detected = status_eof_detected = NO;
-			return do_qic_cmd(QCMD_ERASE, TIM_R);
+	case MTERASE:
+		tpqputs(TPQD_IOCTLS, "MTERASE -- ERASE TAPE !");
+		if ((tperror.exs & TP_ST0) && (tperror.exs & TP_WRP)) {
+			tpqputs(TPQD_ALWAYS, "Cartridge is write-protected.");
+			return -EACCES;
+		} else {
+			time_t t = jiffies;
 
-		case MTRAS1:
-			if (TP_HAVE_RAS1) {
-				tpqputs(TPQD_IOCTLS, "MTRAS1: non-destructive self test");
-				stat = do_qic_cmd(QCMD_SELF_TST1, TIM_R);
-				if (stat != 0) {
-					tpqputs(TPQD_ALWAYS, "RAS1 failed");
-					return stat;
-				}
-				return (tp_sense(0)==TE_OK)? 0 : -EIO; /* get_ext_status3(); */
-			}
-			tpqputs(TPQD_IOCTLS, "RAS1 not supported");
-			return -ENXIO;
+			/* Plain GNU mt(1) 2.2 erases a tape in O_RDONLY. :-( */
+			if (mode_access == READ)
+				return -EACCES;
 
-		case MTRAS2:
-			if (TP_HAVE_RAS2) {
-				tpqputs(TPQD_IOCTLS, "MTRAS2: destructive self test");
-				stat = do_qic_cmd(QCMD_SELF_TST2, TIM_R);
-				if (stat != 0) {
-					tpqputs(TPQD_ALWAYS, "RAS2 failed");
-					return stat;
-				}
-				return (tp_sense(0)==TE_OK)? 0 : -EIO; /* get_ext_status3(); */
+			/* FIXME */
+			/* give user a few seconds to pull out tape */
+			while (jiffies - t < 4 * HZ)
+				schedule();
+		}
+
+		/* don't bother writing filemark first */
+		status_eom_detected = status_eof_detected = NO;
+		return do_qic_cmd(QCMD_ERASE, TIM_R);
+
+	case MTRAS1:
+		if (TP_HAVE_RAS1) {
+			tpqputs(TPQD_IOCTLS, "MTRAS1: non-destructive self test");
+			stat = do_qic_cmd(QCMD_SELF_TST1, TIM_R);
+			if (stat != 0) {
+				tpqputs(TPQD_ALWAYS, "RAS1 failed");
+				return stat;
 			}
-			tpqputs(TPQD_IOCTLS, "RAS2 not supported");
-			return -ENXIO;
+			return (tp_sense(0) == TE_OK) ? 0 : -EIO;	/* get_ext_status3(); */
+		}
+		tpqputs(TPQD_IOCTLS, "RAS1 not supported");
+		return -ENXIO;
 
-		case MTSEEK:
-			if (TP_HAVE_SEEK && (QIC02_TAPE_IFC==ARCHIVE)) {
-				tpqputs(TPQD_IOCTLS, "MTSEEK seeking block");
-				if ((mode_access==WRITE) && status_bytes_wr)
-					return -EACCES;
-				/* NOTE: address (24 bits) is in seek_addr_buf[] */
-				return do_qic_cmd(AR_QCMDV_SEEK_BLK, TIM_F);
+	case MTRAS2:
+		if (TP_HAVE_RAS2) {
+			tpqputs(TPQD_IOCTLS, "MTRAS2: destructive self test");
+			stat = do_qic_cmd(QCMD_SELF_TST2, TIM_R);
+			if (stat != 0) {
+				tpqputs(TPQD_ALWAYS, "RAS2 failed");
+				return stat;
 			}
-			else
-				return -ENOTTY;
+			return (tp_sense(0) == TE_OK) ? 0 : -EIO;	/* get_ext_status3(); */
+		}
+		tpqputs(TPQD_IOCTLS, "RAS2 not supported");
+		return -ENXIO;
 
-		default:
+	case MTSEEK:
+		if (TP_HAVE_SEEK && (QIC02_TAPE_IFC == ARCHIVE)) {
+			tpqputs(TPQD_IOCTLS, "MTSEEK seeking block");
+			if ((mode_access == WRITE) && status_bytes_wr)
+				return -EACCES;
+			/* NOTE: address (24 bits) is in seek_addr_buf[] */
+			return do_qic_cmd(AR_QCMDV_SEEK_BLK, TIM_F);
+		} else
 			return -ENOTTY;
+
+	default:
+		return -ENOTTY;
 	}
-} /* do_ioctl_cmd */
+}				/* do_ioctl_cmd */
 
 
 /* dma_transfer(): This routine is called for every 512 bytes to be read
@@ -1362,40 +1390,43 @@
  *	- adjust the timeout
  *	- tell the tape controller to start transferring
  * We assume the dma address and mode are, and remain, valid.
- */ 
+ */
 static inline void dma_transfer(void)
 {
 	unsigned long flags;
 
-	if (QIC02_TAPE_IFC == WANGTEK) /* or EVEREX */
+	if (QIC02_TAPE_IFC == WANGTEK)	/* or EVEREX */
 		outb_p(WT_CTL_ONLINE, QIC02_CTL_PORT);	/* back to normal */
 	else if (QIC02_TAPE_IFC == ARCHIVE)
 		outb_p(0, AR_RESET_DMA_PORT);
-	else /* QIC02_TAPE_IFC == MOUNTAIN */
+	else			/* QIC02_TAPE_IFC == MOUNTAIN */
 		outb_p(ctlbits, QIC02_CTL_PORT);
 
 
-	flags=claim_dma_lock();
+	flags = claim_dma_lock();
 	clear_dma_ff(QIC02_TAPE_DMA);
 	set_dma_mode(QIC02_TAPE_DMA, dma_mode);
-	set_dma_addr(QIC02_TAPE_DMA, virt_to_bus(buffaddr) + dma_bytes_done);
+	set_dma_addr(QIC02_TAPE_DMA,
+		     virt_to_bus(buffaddr) + dma_bytes_done);
 	set_dma_count(QIC02_TAPE_DMA, TAPE_BLKSIZE);
 
 	/* start tape DMA controller */
-	if (QIC02_TAPE_IFC == WANGTEK) /* or EVEREX */
-		outb_p(WT_CTL_DMA | WT_CTL_ONLINE, QIC02_CTL_PORT); /* trigger DMA transfer */
+	if (QIC02_TAPE_IFC == WANGTEK)	/* or EVEREX */
+		outb_p(WT_CTL_DMA | WT_CTL_ONLINE, QIC02_CTL_PORT);	/* trigger DMA transfer */
 
 	else if (QIC02_TAPE_IFC == ARCHIVE) {
-		outb_p(AR_CTL_IEN | AR_CTL_DNIEN, QIC02_CTL_PORT);  /* enable interrupts again */
-		outb_p(0, AR_START_DMA_PORT);			  /* start DMA transfer */
+		outb_p(AR_CTL_IEN | AR_CTL_DNIEN, QIC02_CTL_PORT);	/* enable interrupts again */
+		outb_p(0, AR_START_DMA_PORT);	/* start DMA transfer */
 		/* In dma_end() AR_RESET_DMA_PORT is written too. */
 
-	} else /* QIC02_TAPE_IFC == MOUNTAIN */ {
+	} else {		/* QIC02_TAPE_IFC == MOUNTAIN */
+
 		inb(MTN_R_DESELECT_DMA_PORT);
-		outb_p(ctlbits | (MTN_CTL_EXC_IEN | MTN_CTL_DNIEN), QIC02_CTL_PORT);
-		outb_p(0, MTN_W_SELECT_DMA_PORT);	 /* start DMA transfer */
+		outb_p(ctlbits | (MTN_CTL_EXC_IEN | MTN_CTL_DNIEN),
+		       QIC02_CTL_PORT);
+		outb_p(0, MTN_W_SELECT_DMA_PORT);	/* start DMA transfer */
 		if (dma_mode == DMA_MODE_WRITE)
-			outb_p(0, MTN_W_DMA_WRITE_PORT); /* start DMA transfer */
+			outb_p(0, MTN_W_DMA_WRITE_PORT);	/* start DMA transfer */
 	}
 
 	/* start computer DMA controller */
@@ -1406,7 +1437,7 @@
 	/* block transfer should start now, jumping to the 
 	 * interrupt routine when done or an exception was detected.
 	 */
-} /* dma_transfer */
+}				/* dma_transfer */
 
 
 /* start_dma() sets a DMA transfer up between the tape controller and
@@ -1421,15 +1452,16 @@
 {
 	int stat;
 	unsigned long flags;
-	
+
 	tpqputs(TPQD_DEBUG, "start_dma() enter");
-	TPQDEB({printk(TPQIC02_NAME ": doing_read==%d, doing_write==%d\n", doing_read, doing_write);})
+	TPQDEB( {printk(TPQIC02_NAME ": doing_read==%d, doing_write==%d\n",
+		      doing_read, doing_write);})
 
-	dma_bytes_done = 0;
+	    dma_bytes_done = 0;
 	dma_bytes_todo = bytes_todo;
 	status_error = NO;
 	/* dma_mode!=0 indicates that the dma controller is in use */
-	dma_mode = (mode == WRITE)? DMA_MODE_WRITE : DMA_MODE_READ;	
+	dma_mode = (mode == WRITE) ? DMA_MODE_WRITE : DMA_MODE_READ;
 
 	/* Only give READ/WRITE DATA command to tape drive if we haven't
 	 * done that already. Otherwise the drive will rewind to the beginning
@@ -1443,22 +1475,25 @@
 
 #if 0
 		/* Next dummy get status is to make sure CNI is valid,
-                   since we're only just starting a read/write it doesn't
-                   matter some exceptions are cleared by reading the status;
-                   we're only interested in CNI and WRP. -Eddy */
+		   since we're only just starting a read/write it doesn't
+		   matter some exceptions are cleared by reading the status;
+		   we're only interested in CNI and WRP. -Eddy */
 		get_status(&tperror);
 #else
 		/* TP_CNI should now be handled in open(). -Hennus */
 #endif
 
-		stat = tp_sense(((mode == WRITE)? 0 : TP_WRP) | TP_BOM | TP_FIL);
+		stat =
+		    tp_sense(((mode ==
+			       WRITE) ? 0 : TP_WRP) | TP_BOM | TP_FIL);
 		if (stat != TE_OK)
 			return stat;
 
 #if OBSOLETE
 		/************* not needed iff rd_status() would wait for ready!!!!!! **********/
 		if (wait_for_ready(TIM_S) != TE_OK) {	/*** not sure this is needed ***/
-			tpqputs(TPQD_ALWAYS, "wait_for_ready failed in start_dma");
+			tpqputs(TPQD_ALWAYS,
+				"wait_for_ready failed in start_dma");
 			return -EIO;
 		}
 #endif
@@ -1471,10 +1506,11 @@
 		/* Tell the controller the data direction */
 
 		/* r/w, timeout medium, check exceptions, sets status_cmd_pending. */
-		stat = send_qic02_cmd((mode == WRITE)? QCMD_WRT_DATA : QCMD_RD_DATA, TIM_M, 0);
-		if (stat!=TE_OK) {
+		stat = send_qic02_cmd((mode == WRITE) 
+					? QCMD_WRT_DATA : QCMD_RD_DATA, TIM_M, 0);
+		if (stat != TE_OK) {
 			printk(TPQIC02_NAME ": start_dma: init %s failed\n",
-				(mode == WRITE)? "write" : "read");
+			       (mode == WRITE) ? "write" : "read");
 			(void) tp_sense(0);
 			return stat;
 		}
@@ -1485,15 +1521,17 @@
 		if (wait_for_ready(TIM_M) != TE_OK)
 			return -EIO;
 		switch (mode) {
-			case READ:
-				doing_read = YES;
-				break;
-			case WRITE:
-				doing_write = YES;
-				break;
-			default:
-				printk(TPQIC02_NAME ": requested unknown mode %d\n", mode);
-				panic(TPQIC02_NAME ": invalid mode in start_dma()");
+		case READ:
+			doing_read = YES;
+			break;
+		case WRITE:
+			doing_write = YES;
+			break;
+		default:
+			printk(TPQIC02_NAME
+			       ": requested unknown mode %d\n", mode);
+			panic(TPQIC02_NAME
+			      ": invalid mode in start_dma()");
 		}
 
 	} else if (is_exception()) {
@@ -1502,7 +1540,8 @@
 		 *
 		 * ******** this also affects EOF/EOT handling! ************
 		 */
-		tpqputs(TPQD_ALWAYS, "detected exception in start_dma() while transfer in progress");
+		tpqputs(TPQD_ALWAYS,
+			"detected exception in start_dma() while transfer in progress");
 		status_error = YES;
 		return TE_END;
 	}
@@ -1513,7 +1552,7 @@
 	/* This assumes tape is already positioned, but these
 	 * semi-'intelligent' drives are unpredictable...
 	 */
-	TIMERON(TIM_M*2);
+	TIMERON(TIM_M * 2);
 
 	/* initiate first data block read from/write to the tape controller */
 
@@ -1524,7 +1563,7 @@
 
 	TPQPUTS("start_dma() end");
 	return TE_OK;
-} /* start_dma */
+}				/* start_dma */
 
 
 /* This cleans up after the dma transfer has completed
@@ -1533,7 +1572,7 @@
  * sense() will set `status_eof_detected' and
  * `status_eom_detected', as required.
  */
-static void end_dma(unsigned long * bytes_done)
+static void end_dma(unsigned long *bytes_done)
 {
 	int stat = TE_OK;
 	unsigned long flags;
@@ -1542,35 +1581,37 @@
 
 	TPQPUTS("end_dma() enter");
 
-	flags=claim_dma_lock();
-	
+	flags = claim_dma_lock();
+
 	disable_dma(QIC02_TAPE_DMA);
 	clear_dma_ff(QIC02_TAPE_DMA);
-	
+
 	release_dma_lock(flags);
 
-	if (QIC02_TAPE_IFC == WANGTEK) /* or EVEREX */
+	if (QIC02_TAPE_IFC == WANGTEK)	/* or EVEREX */
 		outb_p(WT_CTL_ONLINE, QIC02_CTL_PORT);	/* back to normal */
 	else if (QIC02_TAPE_IFC == ARCHIVE)
 		outb_p(0, AR_RESET_DMA_PORT);
-	else /* QIC02_TAPE_IFC == MOUNTAIN */ {
+	else {			/* QIC02_TAPE_IFC == MOUNTAIN */
+
 		/* Clear control bits, de-select ONLINE during tp_sense */
 		ctlbits &= ~MTN_QIC02_CTL_ONLINE;
 	}
 
 	stat = wait_for_ready(TIM_M);
-	if (status_error || (stat!=TE_OK)) {
+	if (status_error || (stat != TE_OK)) {
 		tpqputs(TPQD_DMAX, "DMA transfer exception");
-		stat = tp_sense((dma_mode==READ)? TP_WRP : 0);
+		stat = tp_sense((dma_mode == READ) ? TP_WRP : 0);
 		/* no return here -- got to clean up first! */
-	} else /* if (QIC02_TAPE_IFC == MOUNTAIN) */ {
+	} else {		/* if (QIC02_TAPE_IFC == MOUNTAIN) */
+
 		outb_p(ctlbits, QIC02_CTL_PORT);
 	}
 
 	if (QIC02_TAPE_IFC == MOUNTAIN)
 		inb(MTN_R_DESELECT_DMA_PORT);
 
- 	/* take the tape controller offline */
+	/* take the tape controller offline */
 
 	/* finish off DMA stuff */
 
@@ -1588,7 +1629,7 @@
 
 	TPQPUTS("end_dma() exit");
 	/*** could return stat here ***/
-} /* end_dma */
+}				/* end_dma */
 
 /*********** Below are the (public) OS-interface procedures ***********/
 
@@ -1602,7 +1643,7 @@
 static void qic02_tape_times_out(unsigned long dummy)
 {
 	printk("time-out in %s driver\n", TPQIC02_NAME);
-	if ((status_cmd_pending>0) || dma_mode) {
+	if ((status_cmd_pending > 0) || dma_mode) {
 		/* takes tooo long, shut it down */
 		status_dead = YES;
 		status_cmd_pending = 0;
@@ -1614,7 +1655,7 @@
 			wake_up(&qic02_tape_transfer);
 		}
 	}
-} /* qic02_tape_times_out */
+}				/* qic02_tape_times_out */
 
 /*
  * Interrupt handling:
@@ -1647,7 +1688,8 @@
  * When we are finished, set flags to indicate end, disable timer.
  * NOTE: This *must* be fast! 
  */
-static void qic02_tape_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static void qic02_tape_interrupt(int irq, void *dev_id,
+				 struct pt_regs *regs)
 {
 	int stat, r, i;
 	unsigned long flags;
@@ -1662,20 +1704,21 @@
 		stat = inb(QIC02_STAT_PORT);	/* Knock, knock */
 		if (QIC02_TAPE_IFC == ARCHIVE) {	/* "Who's there?" */
 			if (((stat & (AR_STAT_DMADONE)) == 0) &&
-        	              ((stat & (QIC02_STAT_EXCEPTION)) != 0)) {
+			    ((stat & (QIC02_STAT_EXCEPTION)) != 0)) {
 				TIMERCONT;
-				return;			/* "Linux with IRQ sharing" */
+				return;	/* "Linux with IRQ sharing" */
 			}
 		}
 
 		if ((stat & QIC02_STAT_EXCEPTION) == 0) {	/* exception occurred */
 			/* Possible causes for an exception during a transfer:
-			 * 	- during a write-cycle: end of tape (EW) hole detected.
-			 *	- during a read-cycle: filemark or EOD detected.
-			 *	- something went wrong
+			 *      - during a write-cycle: end of tape (EW) hole detected.
+			 *      - during a read-cycle: filemark or EOD detected.
+			 *      - something went wrong
 			 * So don't continue with the next block.
 			 */
-			tpqputs(TPQD_ALWAYS, "isr: exception on tape controller");
+			tpqputs(TPQD_ALWAYS,
+				"isr: exception on tape controller");
 			printk("      status %02x\n", stat);
 			status_error = TE_EX;
 
@@ -1691,25 +1734,27 @@
 		 */
 		r = 0;
 
-	    /* Skip next ready check for Archive controller because
-	     * it may be busy reading ahead. Weird. --hhb
-	     */
+		/* Skip next ready check for Archive controller because
+		 * it may be busy reading ahead. Weird. --hhb
+		 */
 		if (QIC02_TAPE_IFC == WANGTEK)	/* I think this is a drive-dependency, not IFC -- hhb */
-			if (stat & QIC02_STAT_READY) {		/* not ready */
-				tpqputs(TPQD_ALWAYS, "isr: ? Tape controller not ready");
+			if (stat & QIC02_STAT_READY) {	/* not ready */
+				tpqputs(TPQD_ALWAYS,
+					"isr: ? Tape controller not ready");
 				r = 1;
 			}
 
-		flags=claim_dma_lock();
-		
-		if ( (i = get_dma_residue(QIC02_TAPE_DMA)) != 0 ) {
-			printk(TPQIC02_NAME ": dma_residue == %x !!!\n", i);
+		flags = claim_dma_lock();
+
+		if ((i = get_dma_residue(QIC02_TAPE_DMA)) != 0) {
+			printk(TPQIC02_NAME ": dma_residue == %x !!!\n",
+			       i);
 			r = 1;	/* big trouble, but can't do much about it... */
 		}
-		
+
 		release_dma_lock(flags);
 
-		if (r) 
+		if (r)
 			return;
 
 		/* finish DMA cycle */
@@ -1724,14 +1769,14 @@
 			wake_up(&qic02_tape_transfer);
 		} else {
 			/* start next transfer, account for track-switching time */
-			mod_timer(&tp_timer, jiffies + 6*HZ);
+			mod_timer(&tp_timer, jiffies + 6 * HZ);
 			dma_transfer();
 		}
 	} else {
 		printk(TPQIC02_NAME ": Unexpected interrupt, stat == %x\n",
 		       inb(QIC02_STAT_PORT));
 	}
-} /* qic02_tape_interrupt */
+}				/* qic02_tape_interrupt */
 
 
 /* read/write routines:
@@ -1766,190 +1811,173 @@
  * request would return the EOF flag for the previous file.
  */
 
-static ssize_t qic02_tape_read(struct file * filp, char * buf, size_t count, loff_t *ppos)
+static ssize_t qic02_tape_read(struct file *filp, char *buf, size_t count,
+			       loff_t * ppos)
 {
-    int err;
-    kdev_t dev = filp->f_dentry->d_inode->i_rdev;
-    unsigned short flags = filp->f_flags;
-    unsigned long bytes_todo, bytes_done, total_bytes_done = 0;
-    int stat;
-
-    if (status_zombie==YES)
-    {
-	tpqputs(TPQD_ALWAYS, "configs not set");		
-	return -ENXIO;
-    }
-
-    if (TP_DIAGS(current_tape_dev))
-      /* can't print a ``long long'' (for filp->f_pos), so chop it */
-      printk(TPQIC02_NAME ": request READ, minor=%x, buf=%p, count=%lx"
-	                  ", pos=%lx, flags=%x\n",
-	     MINOR(dev), buf, (long) count,
-	     (unsigned long) filp->f_pos, flags);
-    
-    if (count % TAPE_BLKSIZE)	/* Only allow mod 512 bytes at a time. */
-    {
-	tpqputs(TPQD_BLKSZ, "Wrong block size");
-	return -EINVAL;
-    }
+	int err;
+	kdev_t dev = filp->f_dentry->d_inode->i_rdev;
+	unsigned short flags = filp->f_flags;
+	unsigned long bytes_todo, bytes_done, total_bytes_done = 0;
+	int stat;
+
+	if (status_zombie == YES) {
+		tpqputs(TPQD_ALWAYS, "configs not set");
+		return -ENXIO;
+	}
 
-    /* Just assume everything is ok. Controller will scream if not. */
+	if (TP_DIAGS(current_tape_dev))
+		/* can't print a ``long long'' (for filp->f_pos), so chop it */
+		printk(TPQIC02_NAME
+		       ": request READ, minor=%x, buf=%p, count=%lx"
+		       ", pos=%lx, flags=%x\n", MINOR(dev), buf,
+		       (long) count, (unsigned long) filp->f_pos, flags);
 
-    if (status_bytes_wr)	/* Once written, no more reads, 'till after WFM. */
-    {
-	return -EACCES;
-    }
-    
-    /* This is rather ugly because it has to implement a finite state
-     * machine in order to handle the EOF situations properly.
-     */
-    while ((signed)count>=0)
-    {
-	bytes_done = 0;
-	/* see how much fits in the kernel buffer */
-	bytes_todo = TPQBUF_SIZE;
-	if (bytes_todo>count)
-	{
-	    bytes_todo = count;
+	if (count % TAPE_BLKSIZE) {	/* Only allow mod 512 bytes at a time. */
+		tpqputs(TPQD_BLKSZ, "Wrong block size");
+		return -EINVAL;
 	}
-	
-	/* Must ensure that user program sees exactly one EOF token (==0) */
-	if (return_read_eof==YES)
-	{
-	    if (TPQDBG(DEBUG))
-	    {
-		printk("read: return_read_eof==%d, reported_read_eof==%d, total_bytes_done==%lu\n", return_read_eof, reported_read_eof, total_bytes_done);
-	    }
-	    
-	    if (reported_read_eof==NO)
-	    {
-		/* have not yet returned EOF to user program */
-		if (total_bytes_done>0)
-		{
-		    return total_bytes_done; /* next time return EOF */
-		}
-		else
-		{
-		    reported_read_eof = YES; /* move on next time */
-		    return 0;		 /* return EOF */
-		}				
-	    }
-	    else
-	    {
-		/* Application program has already received EOF
-		 * (above), now continue with next file on tape,
-		 * if possible.
-		 * When the FM is reached, EXCEPTION is set,
-		 * causing a sense(). Subsequent read/writes will
-		 * continue after the FM.
-		 */
+
+	/* Just assume everything is ok. Controller will scream if not. */
+
+	if (status_bytes_wr) {	/* Once written, no more reads, 'till after WFM. */
+		return -EACCES;
+	}
+
+	/* This is rather ugly because it has to implement a finite state
+	 * machine in order to handle the EOF situations properly.
+	 */
+	while ((signed) count >= 0) {
+		bytes_done = 0;
+		/* see how much fits in the kernel buffer */
+		bytes_todo = TPQBUF_SIZE;
+		if (bytes_todo > count) {
+			bytes_todo = count;
+		}
+
+		/* Must ensure that user program sees exactly one EOF token (==0) */
+		if (return_read_eof == YES) {
+			if (TPQDBG(DEBUG)) {
+				printk
+				    ("read: return_read_eof==%d, reported_read_eof==%d, total_bytes_done==%lu\n",
+				     return_read_eof, reported_read_eof,
+				     total_bytes_done);
+			}
+
+			if (reported_read_eof == NO) {
+				/* have not yet returned EOF to user program */
+				if (total_bytes_done > 0) {
+					return total_bytes_done;	/* next time return EOF */
+				} else {
+					reported_read_eof = YES;	/* move on next time */
+					return 0;	/* return EOF */
+				}
+			} else {
+				/* Application program has already received EOF
+				 * (above), now continue with next file on tape,
+				 * if possible.
+				 * When the FM is reached, EXCEPTION is set,
+				 * causing a sense(). Subsequent read/writes will
+				 * continue after the FM.
+				 */
 		/*********** ?????????? this should check for (EOD|NDT), not EOM, 'cause we can read past EW: ************/
-		if (status_eom_detected)
-		{
-		    /* If EOM, nothing left to read, so keep returning EOFs.
-		     *** should probably set some flag to avoid clearing
-		     *** status_eom_detected through ioctls or something
-		     */
-		    return 0;
-		}
-		else
-		{
-		    /* just eof, there may be more files ahead... */
-		    return_read_eof = NO;
-		    reported_read_eof = NO;
-		    status_eof_detected = NO; /* reset this too */
-		    /*fall through*/
+				if (status_eom_detected) {
+					/* If EOM, nothing left to read, so keep returning EOFs.
+					 *** should probably set some flag to avoid clearing
+					 *** status_eom_detected through ioctls or something
+					 */
+					return 0;
+				} else {
+					/* just eof, there may be more files ahead... */
+					return_read_eof = NO;
+					reported_read_eof = NO;
+					status_eof_detected = NO;	/* reset this too */
+					/*fall through */
+				}
+			}
 		}
-	    }
-	}
-	
+
 	/*****************************/
-	if (bytes_todo==0)
-	{
-	    return total_bytes_done;
-	}
-	
-	if (bytes_todo>0)
-	{
-	    /* start reading data */
-	    if (is_exception())	/****************************************/
-	    {
-		tpqputs(TPQD_DMAX, "is_exception() before start_dma()!");
-	    }
-	    
+		if (bytes_todo == 0) {
+			return total_bytes_done;
+		}
+
+		if (bytes_todo > 0) {
+			/* start reading data */
+			if (is_exception()) {
+/****************************************/
+				tpqputs(TPQD_DMAX,
+					"is_exception() before start_dma()!");
+			}
+
 /******************************************************************
  ***** if start_dma() fails because the head is positioned 0 bytes
  ***** before the FM, (causing EXCEPTION to be set) return_read_eof should
  ***** be set to YES, and we should return total_bytes_done, rather than -ENXIO.
  ***** The app should recognize this as an EOF condition.
  ***************************************************************************/
-	    stat = start_dma(READ, bytes_todo);
-	    if (stat == TE_OK)
-	    {
-		/* Wait for transfer to complete, interrupt should wake us */
-		while (dma_mode != 0)
-		{
-		    sleep_on(&qic02_tape_transfer);
-		}
-		if (status_error)
-		{
-		    return_read_eof = YES;
-		}
-		
-	    }
-	    else if (stat != TE_END)
-	    {
-		/* should do sense() on error here */
+			stat = start_dma(READ, bytes_todo);
+			if (stat == TE_OK) {
+				/* Wait for transfer to complete, interrupt should wake us */
+				while (dma_mode != 0) {
+					sleep_on(&qic02_tape_transfer);
+				}
+				if (status_error) {
+					return_read_eof = YES;
+				}
+
+			} else if (stat != TE_END) {
+				/* should do sense() on error here */
 #if 0
-		return -ENXIO;
+				return -ENXIO;
 #else
-		printk("Trouble: stat==%02x\n", stat);
-		return_read_eof = YES;
+				printk("Trouble: stat==%02x\n", stat);
+				return_read_eof = YES;
 		/*************** check EOF/EOT handling!!!!!! **/
 #endif
-	    }
-	    end_dma(&bytes_done);
-	    if (bytes_done>bytes_todo)
-	    {
-		tpqputs(TPQD_ALWAYS, "read: Oops, read more bytes than requested");
-		return -EIO;
-	    }
-	    /* copy buffer to user-space in one go */
-	    if (bytes_done>0)
-	    {
-		err = copy_to_user(buf, buffaddr, bytes_done);
-		if (err)
-		{
-		    return -EFAULT;
-		}
-	    }
+			}
+			end_dma(&bytes_done);
+			if (bytes_done > bytes_todo) {
+				tpqputs(TPQD_ALWAYS,
+					"read: Oops, read more bytes than requested");
+				return -EIO;
+			}
+			/* copy buffer to user-space in one go */
+			if (bytes_done > 0) {
+				err =
+				    copy_to_user(buf, buffaddr,
+						 bytes_done);
+				if (err) {
+					return -EFAULT;
+				}
+			}
 #if 1
-	    /* Checks Ton's patch below */
-	    if ((return_read_eof == NO) && (status_eof_detected == YES))
-	    {
-		printk(TPQIC02_NAME ": read(): return_read_eof=%d, status_eof_detected=YES. return_read_eof:=YES\n", return_read_eof);
-	    }
+			/* Checks Ton's patch below */
+			if ((return_read_eof == NO)
+			    && (status_eof_detected == YES)) {
+				printk(TPQIC02_NAME
+				       ": read(): return_read_eof=%d, status_eof_detected=YES. return_read_eof:=YES\n",
+				       return_read_eof);
+			}
 #endif
-	    if ((bytes_todo != bytes_done) || (status_eof_detected == YES))
-	    {
-		/* EOF or EOM detected. return EOF next time. */
-		return_read_eof = YES;
-	    }
-	    
-	} /* else: ignore read request for 0 bytes */
+			if ((bytes_todo != bytes_done)
+			    || (status_eof_detected == YES)) {
+				/* EOF or EOM detected. return EOF next time. */
+				return_read_eof = YES;
+			}
 
-	if (bytes_done>0)
-	{
-	    status_bytes_rd = YES;
-	    buf += bytes_done;
-	    *ppos += bytes_done;
-	    total_bytes_done += bytes_done;
-	    count -= bytes_done;
-	}
-    }
-    tpqputs(TPQD_ALWAYS, "read request for <0 bytes");
-    return -EINVAL;
-} /* qic02_tape_read */
+		}
+		/* else: ignore read request for 0 bytes */
+		if (bytes_done > 0) {
+			status_bytes_rd = YES;
+			buf += bytes_done;
+			*ppos += bytes_done;
+			total_bytes_done += bytes_done;
+			count -= bytes_done;
+		}
+	}
+	tpqputs(TPQD_ALWAYS, "read request for <0 bytes");
+	return -EINVAL;
+}				/* qic02_tape_read */
 
 
 
@@ -1981,100 +2009,85 @@
  * tape device again. The driver will detect an exception status in (No Cartridge)
  * and force a rewind. After that tar may continue writing.
  */
-static ssize_t qic02_tape_write( struct file * filp,  const char * buf, 
-		size_t count, loff_t *ppos)
+static ssize_t qic02_tape_write(struct file *filp, const char *buf,
+				size_t count, loff_t * ppos)
 {
-    int err;
-    kdev_t dev = filp->f_dentry->d_inode->i_rdev;
-    unsigned short flags = filp->f_flags;
-    unsigned long bytes_todo, bytes_done, total_bytes_done = 0;
-    
-    if (status_zombie==YES)
-    {
-	tpqputs(TPQD_ALWAYS, "configs not set");		
-	return -ENXIO;
-    }
-
-    if (TP_DIAGS(current_tape_dev))
-    {
-	/* can't print a ``long long'' (for filp->f_pos), so chop it */
-	printk(TPQIC02_NAME ": request WRITE, minor=%x, buf=%p"
-	                    ", count=%lx, pos=%lx, flags=%x\n",
-	       MINOR(dev), buf,
-	       (long) count, (unsigned long) filp->f_pos, flags);
-    }
-    
-    if (count % TAPE_BLKSIZE) 	/* only allow mod 512 bytes at a time */
-    {
-	tpqputs(TPQD_BLKSZ, "Wrong block size");
-	return -EINVAL;
-    }
+	int err;
+	kdev_t dev = filp->f_dentry->d_inode->i_rdev;
+	unsigned short flags = filp->f_flags;
+	unsigned long bytes_todo, bytes_done, total_bytes_done = 0;
 
-    if (mode_access==READ)
-    {
-	tpqputs(TPQD_ALWAYS, "Not in write mode");
-	return -EACCES;
-    }
-
-    /* open() does a sense() and we can assume the tape isn't changed
-     * between open() and release(), so the tperror.exs bits will still
-     * be valid.
-     */
-    if ((tperror.exs & TP_ST0) && (tperror.exs & TP_WRP))
-    {
-	tpqputs(TPQD_ALWAYS, "Cartridge is write-protected.");
-	return -EACCES;	/* don't even try when write protected */
-    }
-      
-    if (doing_read == YES)
-    {
-	terminate_read(0);
-    }
-    
-    while ((signed)count>=0)
-    {
-	/* see how much fits in the kernel buffer */
-	bytes_done = 0;
-	bytes_todo = TPQBUF_SIZE;
-	if (bytes_todo>count)
-	{
-	    bytes_todo = count;
+	if (status_zombie == YES) {
+		tpqputs(TPQD_ALWAYS, "configs not set");
+		return -ENXIO;
 	}
-	
-	if (return_write_eof == YES)
-	{
-	    /* return_write_eof should be reset on reverse tape movements. */
-	    
-	    if (reported_write_eof==NO)
-	    {
-		if (bytes_todo>0)
-		{
-		    tpqputs(TPQD_ALWAYS, "partial write");
-		    /* partial write signals EOF to user program */
-		}
-		reported_write_eof = YES;
-		return total_bytes_done;
-	    }
-	    else
-	    {
-		return -ENOSPC;		 /* return error */
-	    }	
-	}
-	
-	/* Quit when done. */
-	if (bytes_todo==0)
-	{
-	    return total_bytes_done;
+
+	if (TP_DIAGS(current_tape_dev)) {
+		/* can't print a ``long long'' (for filp->f_pos), so chop it */
+		printk(TPQIC02_NAME ": request WRITE, minor=%x, buf=%p"
+		       ", count=%lx, pos=%lx, flags=%x\n",
+		       MINOR(dev), buf,
+		       (long) count, (unsigned long) filp->f_pos, flags);
+	}
+
+	if (count % TAPE_BLKSIZE) {	/* only allow mod 512 bytes at a time */
+		tpqputs(TPQD_BLKSZ, "Wrong block size");
+		return -EINVAL;
+	}
+
+	if (mode_access == READ) {
+		tpqputs(TPQD_ALWAYS, "Not in write mode");
+		return -EACCES;
+	}
+
+	/* open() does a sense() and we can assume the tape isn't changed
+	 * between open() and release(), so the tperror.exs bits will still
+	 * be valid.
+	 */
+	if ((tperror.exs & TP_ST0) && (tperror.exs & TP_WRP)) {
+		tpqputs(TPQD_ALWAYS, "Cartridge is write-protected.");
+		return -EACCES;	/* don't even try when write protected */
+	}
+
+	if (doing_read == YES) {
+		terminate_read(0);
 	}
-	
-	/* copy from user to DMA buffer and initiate transfer. */
-	if (bytes_todo>0)
-	{
-	    err = copy_from_user(buffaddr, buf, bytes_todo);
-	    if (err)
-	    {
-		return -EFAULT;
-	    }
+
+	while ((signed) count >= 0) {
+		/* see how much fits in the kernel buffer */
+		bytes_done = 0;
+		bytes_todo = TPQBUF_SIZE;
+		if (bytes_todo > count) {
+			bytes_todo = count;
+		}
+
+		if (return_write_eof == YES) {
+			/* return_write_eof should be reset on reverse tape movements. */
+
+			if (reported_write_eof == NO) {
+				if (bytes_todo > 0) {
+					tpqputs(TPQD_ALWAYS,
+						"partial write");
+					/* partial write signals EOF to user program */
+				}
+				reported_write_eof = YES;
+				return total_bytes_done;
+			} else {
+				return -ENOSPC;	/* return error */
+			}
+		}
+
+		/* Quit when done. */
+		if (bytes_todo == 0) {
+			return total_bytes_done;
+		}
+
+		/* copy from user to DMA buffer and initiate transfer. */
+		if (bytes_todo > 0) {
+			err = copy_from_user(buffaddr, buf, bytes_todo);
+			if (err) {
+				return -EFAULT;
+			}
 
 /****************** similar problem with read() at FM could happen here at EOT.
  ******************/
@@ -2082,78 +2095,74 @@
 /***** if at EOT, 0 bytes can be written. start_dma() will
  ***** fail and write() will return ENXIO error
  *****/
-	    if (start_dma(WRITE, bytes_todo) != TE_OK)
-	    {
-		tpqputs(TPQD_ALWAYS, "write: start_dma() failed");
-		/* should do sense() on error here */
-		return -ENXIO;	/*********** FIXTHIS **************/
-	    }
-
-	    /* Wait for write to complete, interrupt should wake us. */
-	    while ((status_error == 0) && (dma_mode != 0))
-	    {
-		sleep_on(&qic02_tape_transfer);
-	    }
-
-	    end_dma(&bytes_done);
-	    if (bytes_done>bytes_todo)
-	    {
-		tpqputs(TPQD_ALWAYS, "write: Oops, wrote more bytes than requested");
-		return -EIO;
-	    }
-	    /* If the dma-transfer was aborted because of an exception,
-	     * status_error will have been set in the interrupt handler.
-	     * Then end_dma() will do a sense().
-	     * If the exception was EXC_EOM, the EW-hole was encountered
-	     * and two more blocks could be written. For the time being we'll
-	     * just consider this to be the EOT.
-	     * Otherwise, something Bad happened, such as the maximum number
-	     * of block-rewrites was exceeded. [e.g. A very bad spot on tape was
-	     * encountered. Normally short dropouts are compensated for by
-	     * rewriting the block in error, up to 16 times. I'm not sure
-	     * QIC-24 drives can do this.]
-	     */
-	    if (status_error)
-	    {
-		if (status_eom_detected == YES)
-		{
-		    tpqputs(TPQD_ALWAYS, "write: EW detected");
-		    return_write_eof = YES;
-		}
-		else
-		{
-		    /* probably EXC_RWA */
-		    tpqputs(TPQD_ALWAYS, "write: dma: error in writing");
-		    return -EIO;
-		}
-	    }
-	    if (bytes_todo != bytes_done)
-	    {
-		/* EOF or EOM detected. return EOT next time. */
-		return_write_eof = YES;
-	    }
-	}
-	/* else: ignore write request for 0 bytes. */
-	
-	if (bytes_done>0)
-	{
-	    status_bytes_wr = YES;
-	    buf += bytes_done;
-	    *ppos += bytes_done;
-	    total_bytes_done += bytes_done;
-	    count -= bytes_done;
-	}
-    }
-    
-    tpqputs(TPQD_ALWAYS, "write request for <0 bytes");
-    if (TPQDBG(DEBUG))
-    {
-	printk(TPQIC02_NAME ": status_bytes_wr %x, buf %p"
-	                    ", total_bytes_done %lx, count %lx\n",
-	       status_bytes_wr, buf, total_bytes_done, (long) count);
-    }
-    return -EINVAL;
-} /* qic02_tape_write */
+			if (start_dma(WRITE, bytes_todo) != TE_OK) {
+				tpqputs(TPQD_ALWAYS,
+					"write: start_dma() failed");
+				/* should do sense() on error here */
+				return -ENXIO;
+				/*********** FIXTHIS **************/
+			}
+
+			/* Wait for write to complete, interrupt should wake us. */
+			while ((status_error == 0) && (dma_mode != 0)) {
+				sleep_on(&qic02_tape_transfer);
+			}
+
+			end_dma(&bytes_done);
+			if (bytes_done > bytes_todo) {
+				tpqputs(TPQD_ALWAYS,
+					"write: Oops, wrote more bytes than requested");
+				return -EIO;
+			}
+			/* If the dma-transfer was aborted because of an exception,
+			 * status_error will have been set in the interrupt handler.
+			 * Then end_dma() will do a sense().
+			 * If the exception was EXC_EOM, the EW-hole was encountered
+			 * and two more blocks could be written. For the time being we'll
+			 * just consider this to be the EOT.
+			 * Otherwise, something Bad happened, such as the maximum number
+			 * of block-rewrites was exceeded. [e.g. A very bad spot on tape was
+			 * encountered. Normally short dropouts are compensated for by
+			 * rewriting the block in error, up to 16 times. I'm not sure
+			 * QIC-24 drives can do this.]
+			 */
+			if (status_error) {
+				if (status_eom_detected == YES) {
+					tpqputs(TPQD_ALWAYS,
+						"write: EW detected");
+					return_write_eof = YES;
+				} else {
+					/* probably EXC_RWA */
+					tpqputs(TPQD_ALWAYS,
+						"write: dma: error in writing");
+					return -EIO;
+				}
+			}
+			if (bytes_todo != bytes_done) {
+				/* EOF or EOM detected. return EOT next time. */
+				return_write_eof = YES;
+			}
+		}
+		/* else: ignore write request for 0 bytes. */
+
+		if (bytes_done > 0) {
+			status_bytes_wr = YES;
+			buf += bytes_done;
+			*ppos += bytes_done;
+			total_bytes_done += bytes_done;
+			count -= bytes_done;
+		}
+	}
+
+	tpqputs(TPQD_ALWAYS, "write request for <0 bytes");
+	if (TPQDBG(DEBUG)) {
+		printk(TPQIC02_NAME ": status_bytes_wr %x, buf %p"
+		       ", total_bytes_done %lx, count %lx\n",
+		       status_bytes_wr, buf, total_bytes_done,
+		       (long) count);
+	}
+	return -EINVAL;
+}				/* qic02_tape_write */
 
 
 
@@ -2169,846 +2178,810 @@
  * Don't rewind if the minor bits specify density 0.
  */
 
-static int qic02_tape_open(struct inode * inode, struct file * filp)
+static int qic02_tape_open(struct inode *inode, struct file *filp)
 {
-    static int qic02_tape_open_no_use_count(struct inode *, struct file *);
-    int open_error;
+	static int qic02_tape_open_no_use_count(struct inode *,
+						struct file *);
+	int open_error;
 
-    open_error = qic02_tape_open_no_use_count(inode, filp);
-    return open_error;
+	open_error = qic02_tape_open_no_use_count(inode, filp);
+	return open_error;
 }
 
-static int qic02_tape_open_no_use_count(struct inode * inode, struct file * filp)
+static int qic02_tape_open_no_use_count(struct inode *inode,
+					struct file *filp)
 {
-    kdev_t dev = inode->i_rdev;
-    unsigned short flags = filp->f_flags;
-    unsigned short dens = 0;
-    int s;
-
-
-    if (TP_DIAGS(dev))
-    {
-	printk("qic02_tape_open: dev=%s, flags=%x     ",
-	       kdevname(dev), flags);
-    }
-
-    if (MINOR(dev)==255)	/* special case for resetting */
-    {
-	if (capable(CAP_SYS_ADMIN))
-	{
-	    return (tape_reset(1)==TE_OK) ? -EAGAIN : -ENXIO;
+	kdev_t dev = inode->i_rdev;
+	unsigned short flags = filp->f_flags;
+	unsigned short dens = 0;
+	int s;
+
+
+	if (TP_DIAGS(dev)) {
+		printk("qic02_tape_open: dev=%s, flags=%x     ",
+		       kdevname(dev), flags);
 	}
-	else
-	{
-	    return -EPERM;
+
+	if (MINOR(dev) == 255) {	/* special case for resetting */
+		if (capable(CAP_SYS_ADMIN)) {
+			return (tape_reset(1) == TE_OK) ? -EAGAIN : -ENXIO;
+		} else {
+			return -EPERM;
+		}
 	}
-    }
-    
-    if (status_dead==YES)
-    {
-	/* Allow `mt reset' ioctl() even when already open()ed. */
-	return 0;
-    }
-    
+
+	if (status_dead == YES) {
+		/* Allow `mt reset' ioctl() even when already open()ed. */
+		return 0;
+	}
+
 	/* Only one at a time from here on... */
-    if (file_count(filp)>1) 	/* filp->f_count==1 for the first open() */
-    {
-	return -EBUSY;
-    }
-
-    if (status_zombie==YES)
-    {
-	/* no irq/dma/port stuff allocated yet, no reset done
-	 * yet, so return until MTSETCONFIG has been done.
+	if (file_count(filp) > 1) {	/* filp->f_count==1 for the first open() */
+		return -EBUSY;
+	}
+
+	if (status_zombie == YES) {
+		/* no irq/dma/port stuff allocated yet, no reset done
+		 * yet, so return until MTSETCONFIG has been done.
+		 */
+		return 0;
+	}
+
+	status_bytes_rd = NO;
+	status_bytes_wr = NO;
+
+	return_read_eof = NO;	/********????????????????*****/
+	return_write_eof = (status_eot_detected) ? YES : NO;
+
+	/* Clear this in case user app close()d before reading EOF token */
+	status_eof_detected = NO;
+
+	reported_read_eof = NO;
+	reported_write_eof = NO;
+
+
+	switch (flags & O_ACCMODE) {
+	case O_RDONLY:
+		mode_access = READ;
+		break;
+	case O_WRONLY:		/* Fallthru... Strictly speaking this is not correct... */
+	case O_RDWR:		/* Reads are allowed as long as nothing is written */
+		mode_access = WRITE;
+		break;
+	}
+
+	/* This is to avoid tape-changed problems (TP_CNI exception).
+	 *
+	 * Since removing the cartridge will not raise an exception,
+	 * we always do a tp_sense() to make sure we have the proper
+	 * CNI status, the 2150L may need an additional sense.... - Eddy
 	 */
-	return 0;
-    }
-    
-    status_bytes_rd = NO;
-    status_bytes_wr = NO;
-    
-    return_read_eof = NO;	/********????????????????*****/
-    return_write_eof = (status_eot_detected)? YES : NO;
-
-    /* Clear this in case user app close()d before reading EOF token */
-    status_eof_detected = NO;
-
-    reported_read_eof = NO;
-    reported_write_eof = NO;
-
-
-    switch (flags & O_ACCMODE)
-    {
-     case O_RDONLY:
-	mode_access = READ;
-	break;
-     case O_WRONLY:	/* Fallthru... Strictly speaking this is not correct... */
-     case O_RDWR:	/* Reads are allowed as long as nothing is written */
-	mode_access = WRITE;
-	break;
-    }
-    
-    /* This is to avoid tape-changed problems (TP_CNI exception).
-     *
-     * Since removing the cartridge will not raise an exception,
-     * we always do a tp_sense() to make sure we have the proper
-     * CNI status, the 2150L may need an additional sense.... - Eddy
-     */
-    s = tp_sense(TP_WRP|TP_EOM|TP_BOM|TP_CNI|TP_EOR);
-    
-    if (s == TE_OK)
-    {
-	/* Try to clear cartridge-changed status for Archive-2150L */
-	if ((tperror.exs & TP_ST0) && (tperror.exs & TP_CNI))
-	{
-	    s = tp_sense(TP_WRP|TP_EOM|TP_BOM|TP_CNI|TP_EOR);
+	s = tp_sense(TP_WRP | TP_EOM | TP_BOM | TP_CNI | TP_EOR);
+
+	if (s == TE_OK) {
+		/* Try to clear cartridge-changed status for Archive-2150L */
+		if ((tperror.exs & TP_ST0) && (tperror.exs & TP_CNI)) {
+			s = tp_sense(TP_WRP | TP_EOM | TP_BOM | TP_CNI |
+				     TP_EOR);
+		}
+	}
+
+	if (s != TE_OK) {
+		tpqputs(TPQD_ALWAYS, "open: sense() failed");
+		return -EIO;
 	}
-    }
-    
-    if (s != TE_OK)
-    {
-	tpqputs(TPQD_ALWAYS, "open: sense() failed");
-	return -EIO;
-    }
-
-    /* exception bits should be up-to-date now, so check for
-     * tape presence and exit if absent.
-     * Even `mt stat' will fail without a tape.
-     */
-    if ((tperror.exs & TP_ST0) && (tperror.exs & TP_CNI))
-    {
-	tpqputs(TPQD_ALWAYS, "No tape present.");
-	return -EIO;
-    }
-
-    /* At this point we can assume that a tape is present and
-     * that it will remain present until release() is called.
-     */
-
-    /* not allowed to do QCMD_DENS_* unless tape is rewound */
-    if ((TP_DENS(dev)!=0) && (TP_DENS(current_tape_dev) != TP_DENS(dev)))
-    {
-	/* force rewind if minor bits have changed,
-	 * i.e. user wants to use tape in different format.
-	 * [assuming single drive operation]
+
+	/* exception bits should be up-to-date now, so check for
+	 * tape presence and exit if absent.
+	 * Even `mt stat' will fail without a tape.
 	 */
-	if (TP_HAVE_DENS)
-	{
-	    tpqputs(TPQD_REWIND, "Density minor bits have changed. Forcing rewind.");
-	    need_rewind = YES;
+	if ((tperror.exs & TP_ST0) && (tperror.exs & TP_CNI)) {
+		tpqputs(TPQD_ALWAYS, "No tape present.");
+		return -EIO;
 	}
-    }
-    else
-    {
-	/* density bits still the same, but TP_DIAGS bit 
-	 * may have changed.
+
+	/* At this point we can assume that a tape is present and
+	 * that it will remain present until release() is called.
 	 */
-	current_tape_dev = dev;
-    }
-    
-    if (need_rewind == YES)  /***************** CHECK THIS!!!!!!!! **********/
-    {
-	s = do_qic_cmd(QCMD_REWIND, TIM_R);
-	if (s != 0)
-	{
-	    tpqputs(TPQD_ALWAYS, "open: rewind failed");
-	    return -EIO;
+
+	/* not allowed to do QCMD_DENS_* unless tape is rewound */
+	if ((TP_DENS(dev) != 0)
+	    && (TP_DENS(current_tape_dev) != TP_DENS(dev))) {
+		/* force rewind if minor bits have changed,
+		 * i.e. user wants to use tape in different format.
+		 * [assuming single drive operation]
+		 */
+		if (TP_HAVE_DENS) {
+			tpqputs(TPQD_REWIND,
+				"Density minor bits have changed. Forcing rewind.");
+			need_rewind = YES;
+		}
+	} else {
+		/* density bits still the same, but TP_DIAGS bit 
+		 * may have changed.
+		 */
+		current_tape_dev = dev;
+	}
+
+	if (need_rewind == YES) {
+/***************** CHECK THIS!!!!!!!! **********/
+		s = do_qic_cmd(QCMD_REWIND, TIM_R);
+		if (s != 0) {
+			tpqputs(TPQD_ALWAYS, "open: rewind failed");
+			return -EIO;
+		}
 	}
-    }
 
 
 /* Note: After a reset command, the controller will rewind the tape
  *	 just before performing any tape movement operation! ************ SO SET need_rewind flag!!!!!
- */ 
-    if (status_dead==YES)
-    {
-	tpqputs(TPQD_ALWAYS, "open: tape dead, attempting reset");
-	if (tape_reset(1)!=TE_OK)
-	{
-	    return -ENXIO;
+ */
+	if (status_dead == YES) {
+		tpqputs(TPQD_ALWAYS, "open: tape dead, attempting reset");
+		if (tape_reset(1) != TE_OK) {
+			return -ENXIO;
+		} else {
+			status_dead = NO;
+			if (tp_sense(~(TP_ST1 | TP_ILL)) != TE_OK) {
+				tpqputs(TPQD_ALWAYS,
+					"open: tp_sense() failed\n");
+				status_dead = YES;	/* try reset next time */
+				return -EIO;
+			}
+		}
 	}
-	else
-	{
-	    status_dead = NO;
-	    if (tp_sense(~(TP_ST1|TP_ILL)) != TE_OK)
-	    {
-		tpqputs(TPQD_ALWAYS, "open: tp_sense() failed\n");
-		status_dead = YES;	/* try reset next time */
+
+	/* things should be ok, once we get here */
+
+
+	/* set density: only allowed when TP_BOM status bit is set,
+	 * so we must have done a rewind by now. If not, just skip over.
+	 * Only give set density command when minor bits have changed.
+	 */
+	if (TP_DENS(current_tape_dev) == TP_DENS(dev)) {
+		return 0;
+	}
+
+	current_tape_dev = dev;
+	need_rewind = NO;
+	if (TP_HAVE_DENS) {
+		dens = TP_DENS(dev);
+	}
+
+	if (dens < sizeof(format_names) / sizeof(char *)) {
+		printk(TPQIC02_NAME ": format: %s%s\n",
+		       (dens != 0) ? "QIC-" : "", format_names[dens]);
+	} else {
+		tpqputs(TPQD_REWIND, "Wait for retensioning...");
+	}
+
+	switch (TP_DENS(dev)) {
+	case 0:		/* Minor 0 is for drives without set-density support */
+		s = 0;
+		break;
+	case 1:
+		s = do_qic_cmd(QCMD_DENS_11, TIM_S);
+		break;
+	case 2:
+		s = do_qic_cmd(QCMD_DENS_24, TIM_S);
+		break;
+	case 3:
+		s = do_qic_cmd(QCMD_DENS_120, TIM_S);
+		break;
+	case 4:
+		s = do_qic_cmd(QCMD_DENS_150, TIM_S);
+		break;
+	case 5:
+		s = do_qic_cmd(QCMD_DENS_300, TIM_S);
+		break;
+	case 6:
+		s = do_qic_cmd(QCMD_DENS_600, TIM_S);
+		break;
+	default:		/* otherwise do a retension before anything else */
+		s = do_qic_cmd(QCMD_RETEN, TIM_R);
+	}
+	if (s != 0) {
+		status_dead = YES;	/* force reset */
+		current_tape_dev = 0;	/* earlier 0xff80 */
 		return -EIO;
-	    }
 	}
-    }
-    
-    /* things should be ok, once we get here */
-    
-
-    /* set density: only allowed when TP_BOM status bit is set,
-     * so we must have done a rewind by now. If not, just skip over.
-     * Only give set density command when minor bits have changed.
-     */
-    if (TP_DENS(current_tape_dev) == TP_DENS(dev) )
-    {
+
 	return 0;
-    }
-    
-    current_tape_dev = dev;
-    need_rewind = NO;
-    if (TP_HAVE_DENS)
-    {
-	dens = TP_DENS(dev);
-    }
-    
-    if (dens < sizeof(format_names)/sizeof(char *))
-    {
-	printk(TPQIC02_NAME ": format: %s%s\n", (dens!=0)? "QIC-" : "", format_names[dens]);
-    }
-    else
-    {
-	tpqputs(TPQD_REWIND, "Wait for retensioning...");
-    }
-    
-    switch (TP_DENS(dev))
-    {
-     case 0: /* Minor 0 is for drives without set-density support */
-	s = 0;
-	break;
-     case 1:
-	s = do_qic_cmd(QCMD_DENS_11, TIM_S);
-	break;
-     case 2:
-	s = do_qic_cmd(QCMD_DENS_24, TIM_S);
-	break;
-     case 3:
-	s = do_qic_cmd(QCMD_DENS_120, TIM_S);
-	break;
-     case 4:
-	s = do_qic_cmd(QCMD_DENS_150, TIM_S);
-	break;
-     case 5:
-	s = do_qic_cmd(QCMD_DENS_300, TIM_S);
-	break;
-     case 6:
-	s = do_qic_cmd(QCMD_DENS_600, TIM_S);
-	break;
-     default:  /* otherwise do a retension before anything else */
-	s = do_qic_cmd(QCMD_RETEN, TIM_R);
-    }
-    if (s != 0)
-    {
-	status_dead = YES;	/* force reset */
-	current_tape_dev = 0; /* earlier 0xff80 */
-	return -EIO;
-    }
-    
-    return 0;
-} /* qic02_tape_open */
-
-
-static int qic02_tape_release(struct inode * inode, struct file * filp)
-{
-    kdev_t dev = inode->i_rdev;
-
-    lock_kernel();
-    if (TP_DIAGS(dev))
-    {
-	printk("qic02_tape_release: dev=%s\n",  kdevname(dev));
-    }
-    
-    if (status_zombie==NO)		/* don't rewind in zombie mode */
-    {
-	/* Terminate any pending write cycle. Terminating the read-cycle
-	 * is delayed until it is required to do so for a new command.
-	 */
-	terminate_write(-1);
-	
-	if (status_dead==YES)
-	{
-	    tpqputs(TPQD_ALWAYS, "release: device dead!?");
+}				/* qic02_tape_open */
+
+
+static int qic02_tape_release(struct inode *inode, struct file *filp)
+{
+	kdev_t dev = inode->i_rdev;
+
+	lock_kernel();
+	if (TP_DIAGS(dev)) {
+		printk("qic02_tape_release: dev=%s\n", kdevname(dev));
 	}
-	
-	/* Rewind only if minor number requires it AND 
-	 * read/writes have been done. ************* IS THIS CORRECT??????????
-	 */
-	if ((TP_REWCLOSE(dev)) && (status_bytes_rd | status_bytes_wr))
-	{
-	    tpqputs(TPQD_REWIND, "release: Doing rewind...");
-	    (void) do_qic_cmd(QCMD_REWIND, TIM_R);
+
+	if (status_zombie == NO) {	/* don't rewind in zombie mode */
+		/* Terminate any pending write cycle. Terminating the read-cycle
+		 * is delayed until it is required to do so for a new command.
+		 */
+		terminate_write(-1);
+
+		if (status_dead == YES) {
+			tpqputs(TPQD_ALWAYS, "release: device dead!?");
+		}
+
+		/* Rewind only if minor number requires it AND 
+		 * read/writes have been done. ************* IS THIS CORRECT??????????
+		 */
+		if ((TP_REWCLOSE(dev))
+		    && (status_bytes_rd | status_bytes_wr)) {
+			tpqputs(TPQD_REWIND, "release: Doing rewind...");
+			(void) do_qic_cmd(QCMD_REWIND, TIM_R);
+		}
 	}
-    }
-    unlock_kernel();
-    return 0;
-} /* qic02_tape_release */
+	unlock_kernel();
+	return 0;
+}				/* qic02_tape_release */
 
 
 #ifdef CONFIG_QIC02_DYNCONF
 /* Set masks etc. based on the interface card type. */
 static int update_ifc_masks(int ifc)
 {
-    QIC02_TAPE_IFC = ifc;
+	QIC02_TAPE_IFC = ifc;
 
-    if ((QIC02_TAPE_IFC == WANGTEK) || (QIC02_TAPE_IFC == EVEREX))
-    {
-	QIC02_STAT_PORT = QIC02_TAPE_PORT;
-	QIC02_CTL_PORT = QIC02_TAPE_PORT;
-	QIC02_CMD_PORT = QIC02_TAPE_PORT+1;
-	QIC02_DATA_PORT = QIC02_TAPE_PORT+1;
-	QIC02_STAT_READY = WT_QIC02_STAT_READY;
-	QIC02_STAT_EXCEPTION = WT_QIC02_STAT_EXCEPTION;
-	QIC02_STAT_MASK = WT_QIC02_STAT_MASK;
-	
-	QIC02_STAT_RESETMASK = WT_QIC02_STAT_RESETMASK;
-	QIC02_STAT_RESETVAL = WT_QIC02_STAT_RESETVAL;
-	
-	QIC02_CTL_RESET = WT_QIC02_CTL_RESET;
-	QIC02_CTL_REQUEST = WT_QIC02_CTL_REQUEST;
- 
-	if (QIC02_TAPE_DMA == 3)
-	{
-	    WT_CTL_DMA = WT_CTL_DMA3;
-	}
-	else if (QIC02_TAPE_DMA == 1)
-	{
-	    WT_CTL_DMA = WT_CTL_DMA1;
-	}
-	else
-	{
-	    tpqputs(TPQD_ALWAYS, "Unsupported or incorrect DMA channel");
-	    return -EIO;
-	} 
+	if ((QIC02_TAPE_IFC == WANGTEK) || (QIC02_TAPE_IFC == EVEREX)) {
+		QIC02_STAT_PORT = QIC02_TAPE_PORT;
+		QIC02_CTL_PORT = QIC02_TAPE_PORT;
+		QIC02_CMD_PORT = QIC02_TAPE_PORT + 1;
+		QIC02_DATA_PORT = QIC02_TAPE_PORT + 1;
+		QIC02_STAT_READY = WT_QIC02_STAT_READY;
+		QIC02_STAT_EXCEPTION = WT_QIC02_STAT_EXCEPTION;
+		QIC02_STAT_MASK = WT_QIC02_STAT_MASK;
+
+		QIC02_STAT_RESETMASK = WT_QIC02_STAT_RESETMASK;
+		QIC02_STAT_RESETVAL = WT_QIC02_STAT_RESETVAL;
+
+		QIC02_CTL_RESET = WT_QIC02_CTL_RESET;
+		QIC02_CTL_REQUEST = WT_QIC02_CTL_REQUEST;
+
+		if (QIC02_TAPE_DMA == 3) {
+			WT_CTL_DMA = WT_CTL_DMA3;
+		} else if (QIC02_TAPE_DMA == 1) {
+			WT_CTL_DMA = WT_CTL_DMA1;
+		} else {
+			tpqputs(TPQD_ALWAYS,
+				"Unsupported or incorrect DMA channel");
+			return -EIO;
+		}
 
-	if (QIC02_TAPE_IFC == EVEREX)
-	{
-	    /* Everex is a special case for Wangtek (actually
-	     * it's the other way 'round, but I saw Wangtek first)
-	     */
-	    if (QIC02_TAPE_DMA==3)
-	    {
-		WT_CTL_DMA = WT_CTL_DMA1;
-	    }
-	    
-	    /* Fixup the kernel copy of the IFC type to that
-	     * we don't have to distinguish between Wangtek and
-	     * and Everex at runtime.
-	     */
-	    QIC02_TAPE_IFC = WANGTEK;
-	}
-    }
-    else if (QIC02_TAPE_IFC == ARCHIVE)
-    {
-	QIC02_STAT_PORT = QIC02_TAPE_PORT+1;
-	QIC02_CTL_PORT = QIC02_TAPE_PORT+1;
-	QIC02_CMD_PORT = QIC02_TAPE_PORT;
-	QIC02_DATA_PORT = QIC02_TAPE_PORT;
-	QIC02_STAT_READY = AR_QIC02_STAT_READY;
-	QIC02_STAT_EXCEPTION  = AR_QIC02_STAT_EXCEPTION;
-	QIC02_STAT_MASK = AR_QIC02_STAT_MASK;
-	
-	QIC02_STAT_RESETMASK = AR_QIC02_STAT_RESETMASK;
-	QIC02_STAT_RESETVAL = AR_QIC02_STAT_RESETVAL;
-	
-	QIC02_CTL_RESET = AR_QIC02_CTL_RESET;
-	QIC02_CTL_REQUEST = AR_QIC02_CTL_REQUEST;
-	
-	if (QIC02_TAPE_DMA > 3)
-	{
-	    tpqputs(TPQD_ALWAYS, "Unsupported or incorrect DMA channel");
-	    return -EIO;
-	} 
-    }
-    else if (QIC02_TAPE_IFC == MOUNTAIN)
-    {
-	QIC02_STAT_PORT = QIC02_TAPE_PORT+1;
-	QIC02_CTL_PORT = QIC02_TAPE_PORT+1;
-	QIC02_CMD_PORT = QIC02_TAPE_PORT;
-	QIC02_DATA_PORT = QIC02_TAPE_PORT;
-	
-	QIC02_STAT_READY = MTN_QIC02_STAT_READY;
-	QIC02_STAT_EXCEPTION  = MTN_QIC02_STAT_EXCEPTION;
-	QIC02_STAT_MASK = MTN_QIC02_STAT_MASK;
-	
-	QIC02_STAT_RESETMASK = MTN_QIC02_STAT_RESETMASK;
-	QIC02_STAT_RESETVAL = MTN_QIC02_STAT_RESETVAL;
-	
-	QIC02_CTL_RESET = MTN_QIC02_CTL_RESET;
-	QIC02_CTL_REQUEST = MTN_QIC02_CTL_REQUEST;
-	
-	if (QIC02_TAPE_DMA > 3)
-	{
-	    tpqputs(TPQD_ALWAYS, "Unsupported or incorrect DMA channel");
-	    return -EIO;
-	} 
-    }
-    else
-    {
-	tpqputs(TPQD_ALWAYS, "Invalid interface type");
-	return -ENXIO;
-    }
-    return qic02_get_resources();
-} /* update_ifc_masks */
+		if (QIC02_TAPE_IFC == EVEREX) {
+			/* Everex is a special case for Wangtek (actually
+			 * it's the other way 'round, but I saw Wangtek first)
+			 */
+			if (QIC02_TAPE_DMA == 3) {
+				WT_CTL_DMA = WT_CTL_DMA1;
+			}
+
+			/* Fixup the kernel copy of the IFC type to that
+			 * we don't have to distinguish between Wangtek and
+			 * and Everex at runtime.
+			 */
+			QIC02_TAPE_IFC = WANGTEK;
+		}
+	} else if (QIC02_TAPE_IFC == ARCHIVE) {
+		QIC02_STAT_PORT = QIC02_TAPE_PORT + 1;
+		QIC02_CTL_PORT = QIC02_TAPE_PORT + 1;
+		QIC02_CMD_PORT = QIC02_TAPE_PORT;
+		QIC02_DATA_PORT = QIC02_TAPE_PORT;
+		QIC02_STAT_READY = AR_QIC02_STAT_READY;
+		QIC02_STAT_EXCEPTION = AR_QIC02_STAT_EXCEPTION;
+		QIC02_STAT_MASK = AR_QIC02_STAT_MASK;
+
+		QIC02_STAT_RESETMASK = AR_QIC02_STAT_RESETMASK;
+		QIC02_STAT_RESETVAL = AR_QIC02_STAT_RESETVAL;
+
+		QIC02_CTL_RESET = AR_QIC02_CTL_RESET;
+		QIC02_CTL_REQUEST = AR_QIC02_CTL_REQUEST;
+
+		if (QIC02_TAPE_DMA > 3) {
+			tpqputs(TPQD_ALWAYS,
+				"Unsupported or incorrect DMA channel");
+			return -EIO;
+		}
+	} else if (QIC02_TAPE_IFC == MOUNTAIN) {
+		QIC02_STAT_PORT = QIC02_TAPE_PORT + 1;
+		QIC02_CTL_PORT = QIC02_TAPE_PORT + 1;
+		QIC02_CMD_PORT = QIC02_TAPE_PORT;
+		QIC02_DATA_PORT = QIC02_TAPE_PORT;
+
+		QIC02_STAT_READY = MTN_QIC02_STAT_READY;
+		QIC02_STAT_EXCEPTION = MTN_QIC02_STAT_EXCEPTION;
+		QIC02_STAT_MASK = MTN_QIC02_STAT_MASK;
+
+		QIC02_STAT_RESETMASK = MTN_QIC02_STAT_RESETMASK;
+		QIC02_STAT_RESETVAL = MTN_QIC02_STAT_RESETVAL;
+
+		QIC02_CTL_RESET = MTN_QIC02_CTL_RESET;
+		QIC02_CTL_REQUEST = MTN_QIC02_CTL_REQUEST;
+
+		if (QIC02_TAPE_DMA > 3) {
+			tpqputs(TPQD_ALWAYS,
+				"Unsupported or incorrect DMA channel");
+			return -EIO;
+		}
+	} else {
+		tpqputs(TPQD_ALWAYS, "Invalid interface type");
+		return -ENXIO;
+	}
+	return qic02_get_resources();
+}				/* update_ifc_masks */
 #endif
 
 
 /* ioctl allows user programs to rewind the tape and stuff like that */
-static int qic02_tape_ioctl(struct inode * inode, struct file * filp, 
-		     unsigned int iocmd, unsigned long ioarg)
+static int qic02_tape_ioctl(struct inode *inode, struct file *filp,
+			    unsigned int iocmd, unsigned long ioarg)
 {
-    int error;
-    int dev_maj = MAJOR(inode->i_rdev);
-    int c;
-    struct mtop operation;
-    unsigned char blk_addr[6];
-    struct mtpos ioctl_tell;
-    
-
-    if (TP_DIAGS(current_tape_dev))
-    {
-	printk(TPQIC02_NAME ": ioctl(%4x, %4x, %4lx)\n", dev_maj, iocmd, ioarg);
-    }
-    
-    if (!inode || !ioarg)
-    {
-	return -EINVAL;
-    }
-    
-    /* check iocmd first */
-
-    if (dev_maj != QIC02_TAPE_MAJOR)
-    {
-	printk(TPQIC02_NAME ": Oops! Wrong device?\n");
-	/* A panic() would be appropriate here */
-	return -ENODEV;
-    }
-
-    c = _IOC_NR(iocmd);
+	int error;
+	int dev_maj = MAJOR(inode->i_rdev);
+	int c;
+	struct mtop operation;
+	unsigned char blk_addr[6];
+	struct mtpos ioctl_tell;
 
-#ifdef CONFIG_QIC02_DYNCONF
-    if (c == _IOC_NR(MTIOCGETCONFIG))
-    {
-	CHECK_IOC_SIZE(mtconfiginfo);
 
-	if (copy_to_user((char *) ioarg, (char *) &qic02_tape_dynconf, sizeof(qic02_tape_dynconf)))
-	{
-	    return -EFAULT;
+	if (TP_DIAGS(current_tape_dev)) {
+		printk(TPQIC02_NAME ": ioctl(%4x, %4x, %4lx)\n", dev_maj,
+		       iocmd, ioarg);
 	}
-	return 0;
 
-    }
-    else if (c == _IOC_NR(MTIOCSETCONFIG))
-    {
-	/* One should always do a MTIOCGETCONFIG first, then update
-	 * user-settings, then write back with MTIOCSETCONFIG.
-	 * The qic02conf program should re-open() the device before actual
-	 * use, to make sure everything is initialized.
-	 */
-	
-	CHECK_IOC_SIZE(mtconfiginfo);
-	
-	if (!capable(CAP_SYS_ADMIN))
-	{
-	    return -EPERM;
+	if (!inode || !ioarg) {
+		return -EINVAL;
 	}
-	
-	if ((doing_read!=NO) || (doing_write!=NO))
-	{
-	    return -EBUSY;
+
+	/* check iocmd first */
+
+	if (dev_maj != QIC02_TAPE_MAJOR) {
+		printk(TPQIC02_NAME ": Oops! Wrong device?\n");
+		/* A panic() would be appropriate here */
+		return -ENODEV;
 	}
-	
-	if (status_zombie==NO)
-	{
-	    qic02_release_resources();	/* and go zombie */
+
+	c = _IOC_NR(iocmd);
+
+#ifdef CONFIG_QIC02_DYNCONF
+	if (c == _IOC_NR(MTIOCGETCONFIG)) {
+		CHECK_IOC_SIZE(mtconfiginfo);
+
+		if (copy_to_user
+		    ((char *) ioarg, (char *) &qic02_tape_dynconf,
+		     sizeof(qic02_tape_dynconf))) {
+			return -EFAULT;
+		}
+		return 0;
+
+	} else if (c == _IOC_NR(MTIOCSETCONFIG)) {
+		/* One should always do a MTIOCGETCONFIG first, then update
+		 * user-settings, then write back with MTIOCSETCONFIG.
+		 * The qic02conf program should re-open() the device before actual
+		 * use, to make sure everything is initialized.
+		 */
+
+		CHECK_IOC_SIZE(mtconfiginfo);
+
+		if (!capable(CAP_SYS_ADMIN)) {
+			return -EPERM;
+		}
+
+		if ((doing_read != NO) || (doing_write != NO)) {
+			return -EBUSY;
+		}
+
+		if (status_zombie == NO) {
+			qic02_release_resources();	/* and go zombie */
+		}
+
+		/* copy struct from user space to kernel space */
+		if (copy_from_user
+		    ((char *) &qic02_tape_dynconf, (char *) ioarg,
+		     sizeof(qic02_tape_dynconf))) {
+			return -EFAULT;
+		}
+		return update_ifc_masks(qic02_tape_dynconf.ifc_type);
 	}
-	
-	/* copy struct from user space to kernel space */
-	if (copy_from_user((char *) &qic02_tape_dynconf, (char *) ioarg, sizeof(qic02_tape_dynconf)))
-	{
-	    return -EFAULT;
+	if (status_zombie == YES) {
+		tpqputs(TPQD_ALWAYS, "Configs not set");
+		return -ENXIO;
 	}
-	return update_ifc_masks(qic02_tape_dynconf.ifc_type);
-    }
-    if (status_zombie==YES)
-    {
-	tpqputs(TPQD_ALWAYS, "Configs not set");
-	return -ENXIO;
-    }
 #endif
-    if (c == _IOC_NR(MTIOCTOP))
-    {
-	CHECK_IOC_SIZE(mtop);
+	if (c == _IOC_NR(MTIOCTOP)) {
+		CHECK_IOC_SIZE(mtop);
 
-	/* copy mtop struct from user space to kernel space */
-	if (copy_from_user((char *) &operation, (char *) ioarg, sizeof(operation)))
-	{
-	    return -EFAULT;
-	}
+		/* copy mtop struct from user space to kernel space */
+		if (copy_from_user
+		    ((char *) &operation, (char *) ioarg,
+		     sizeof(operation))) {
+			return -EFAULT;
+		}
 
-	/* ---note: mt_count is signed, negative seeks must be
-	 * ---	    translated to seeks in opposite direction!
-	 * (only needed for Sun-programs, I think.)
-	 */
-	/* ---note: MTFSF with count 0 should position the
-	 * ---	    tape at the beginning of the current file.
-	 */
+		/* ---note: mt_count is signed, negative seeks must be
+		 * ---      translated to seeks in opposite direction!
+		 * (only needed for Sun-programs, I think.)
+		 */
+		/* ---note: MTFSF with count 0 should position the
+		 * ---      tape at the beginning of the current file.
+		 */
 
-	if (TP_DIAGS(current_tape_dev))
-	{
-	    printk("OP op=%4x, count=%4x\n", operation.mt_op, operation.mt_count);
-	}
-	
-	if (operation.mt_count < 0)
-	{
-	    tpqputs(TPQD_ALWAYS, "Warning: negative mt_count ignored");
-	}
-	
-	ioctl_status.mt_resid = operation.mt_count;
-	if (operation.mt_op == MTSEEK)
-	{
-	    if (!TP_HAVE_SEEK)
-	    {
-		return -ENOTTY;
-	    }
-	    
-	    seek_addr_buf[0] = (operation.mt_count>>16)&0xff;
-	    seek_addr_buf[1] = (operation.mt_count>>8)&0xff;
-	    seek_addr_buf[2] = (operation.mt_count)&0xff;
-	    if (operation.mt_count>>24)
-	    {
-		return -EINVAL;
-	    }
-	    if ((error = do_ioctl_cmd(operation.mt_op)) != 0)
-	    {
-		return error;
-	    }
-	    
-	    ioctl_status.mt_resid = 0;
-	}
-	else
-	{
-	    while (operation.mt_count > 0)
-	    {
-		operation.mt_count--;
-		if ((error = do_ioctl_cmd(operation.mt_op)) != 0)
-		{
-		    return error;
+		if (TP_DIAGS(current_tape_dev)) {
+			printk("OP op=%4x, count=%4x\n", operation.mt_op,
+			       operation.mt_count);
+		}
+
+		if (operation.mt_count < 0) {
+			tpqputs(TPQD_ALWAYS,
+				"Warning: negative mt_count ignored");
 		}
-		
+
 		ioctl_status.mt_resid = operation.mt_count;
-	    }
-	}
-	return 0;
-	
-    }
-    else if (c == _IOC_NR(MTIOCGET))
-    {
-	if (TP_DIAGS(current_tape_dev))
-	{
-	    printk("GET ");
-	}
-	
-	CHECK_IOC_SIZE(mtget);
+		if (operation.mt_op == MTSEEK) {
+			if (!TP_HAVE_SEEK) {
+				return -ENOTTY;
+			}
 
-	/* It appears (gmt(1)) that it is normal behaviour to
-	 * first set the status with MTNOP, and then to read
-	 * it out with MTIOCGET
-	 */
+			seek_addr_buf[0] =
+			    (operation.mt_count >> 16) & 0xff;
+			seek_addr_buf[1] =
+			    (operation.mt_count >> 8) & 0xff;
+			seek_addr_buf[2] = (operation.mt_count) & 0xff;
+			if (operation.mt_count >> 24) {
+				return -EINVAL;
+			}
+			if ((error = do_ioctl_cmd(operation.mt_op)) != 0) {
+				return error;
+			}
 
-	/* copy results to user space */
-	if (copy_to_user((char *) ioarg, (char *) &ioctl_status, sizeof(ioctl_status)))
-	{
-	    return -EFAULT;
-	}	
-	return 0;
-    }
-    else if (TP_HAVE_TELL && (c == _IOC_NR(MTIOCPOS)))
-    {
-	if (TP_DIAGS(current_tape_dev))
-	{
-	    printk("POS ");
-	}
-	
-	CHECK_IOC_SIZE(mtpos);
-	
-	tpqputs(TPQD_IOCTLS, "MTTELL reading block address");
-	if ((doing_read==YES) || (doing_write==YES))
-	{
-	    finish_rw(AR_QCMDV_TELL_BLK);
-	}
-	
-	c = rdstatus((char *) blk_addr, sizeof(blk_addr), AR_QCMDV_TELL_BLK);
-	if (c!=TE_OK)
-	{
-	    return -EIO;
-	}
-	
-	ioctl_tell.mt_blkno = (blk_addr[3] << 16) | (blk_addr[4] << 8) | blk_addr[5];
+			ioctl_status.mt_resid = 0;
+		} else {
+			while (operation.mt_count > 0) {
+				operation.mt_count--;
+				if ((error =
+				     do_ioctl_cmd(operation.mt_op)) != 0) {
+					return error;
+				}
 
-	/* copy results to user space */
-	if (copy_to_user((char *) ioarg, (char *) &ioctl_tell, sizeof(ioctl_tell)))
-	{
-	    return -EFAULT;
-	}
-	return 0;
+				ioctl_status.mt_resid = operation.mt_count;
+			}
+		}
+		return 0;
+
+	} else if (c == _IOC_NR(MTIOCGET)) {
+		if (TP_DIAGS(current_tape_dev)) {
+			printk("GET ");
+		}
+
+		CHECK_IOC_SIZE(mtget);
 
-    }
-    else
-    {
-	return -ENOTTY;	/* Other cmds not supported. */
-    }
-} /* qic02_tape_ioctl */
+		/* It appears (gmt(1)) that it is normal behaviour to
+		 * first set the status with MTNOP, and then to read
+		 * it out with MTIOCGET
+		 */
+
+		/* copy results to user space */
+		if (copy_to_user
+		    ((char *) ioarg, (char *) &ioctl_status,
+		     sizeof(ioctl_status))) {
+			return -EFAULT;
+		}
+		return 0;
+	} else if (TP_HAVE_TELL && (c == _IOC_NR(MTIOCPOS))) {
+		if (TP_DIAGS(current_tape_dev)) {
+			printk("POS ");
+		}
+
+		CHECK_IOC_SIZE(mtpos);
+
+		tpqputs(TPQD_IOCTLS, "MTTELL reading block address");
+		if ((doing_read == YES) || (doing_write == YES)) {
+			finish_rw(AR_QCMDV_TELL_BLK);
+		}
+
+		c = rdstatus((char *) blk_addr, sizeof(blk_addr),
+			     AR_QCMDV_TELL_BLK);
+		if (c != TE_OK) {
+			return -EIO;
+		}
+
+		ioctl_tell.mt_blkno =
+		    (blk_addr[3] << 16) | (blk_addr[4] << 8) | blk_addr[5];
+
+		/* copy results to user space */
+		if (copy_to_user
+		    ((char *) ioarg, (char *) &ioctl_tell,
+		     sizeof(ioctl_tell))) {
+			return -EFAULT;
+		}
+		return 0;
+
+	} else {
+		return -ENOTTY;	/* Other cmds not supported. */
+	}
+}				/* qic02_tape_ioctl */
 
 
 
 /* These are (most) of the interface functions: */
 static struct file_operations qic02_tape_fops = {
-	owner:		THIS_MODULE,
-	llseek:		no_llseek,
-	read:		qic02_tape_read,
-	write:		qic02_tape_write,
-	ioctl:		qic02_tape_ioctl,
-	open:		qic02_tape_open,
-	release:	qic02_tape_release,
+	owner:THIS_MODULE,
+	llseek:no_llseek,
+	read:qic02_tape_read,
+	write:qic02_tape_write,
+	ioctl:qic02_tape_ioctl,
+	open:qic02_tape_open,
+	release:qic02_tape_release,
 };
 
 
 static void qic02_release_resources(void)
 {
-    free_irq(QIC02_TAPE_IRQ, NULL);
-    free_dma(QIC02_TAPE_DMA);
-    release_region(QIC02_TAPE_PORT, QIC02_TAPE_PORT_RANGE);
-    if (buffaddr)
-    {
-	free_pages((unsigned long)buffaddr, get_order(TPQBUF_SIZE));
-    }
-    buffaddr = 0; /* Better to cause a panic than overwite someone else */
-    status_zombie = YES;
-} /* qic02_release_resources */
+	free_irq(QIC02_TAPE_IRQ, NULL);
+	free_dma(QIC02_TAPE_DMA);
+	release_region(QIC02_TAPE_PORT, QIC02_TAPE_PORT_RANGE);
+	if (buffaddr) {
+		free_pages((unsigned long) buffaddr,
+			   get_order(TPQBUF_SIZE));
+	}
+	buffaddr = 0;		/* Better to cause a panic than overwite someone else */
+	status_zombie = YES;
+}				/* qic02_release_resources */
 
 
 static int qic02_get_resources(void)
 {
-    /* First perform some checks. If one of them fails,
-     * the tape driver will not be registered to the system.
-     */
-    if (QIC02_TAPE_IRQ>16)
-    {
-	tpqputs(TPQD_ALWAYS, "Bogus interrupt number.");
-	return -ENXIO;
-    }
-
-    /* for DYNCONF, allocating IO, DMA and IRQ should not be done until 
-     * the config parameters have been set using MTSETCONFIG.
-     */
-
-    if (check_region(QIC02_TAPE_PORT, QIC02_TAPE_PORT_RANGE))
-    {
-	printk(TPQIC02_NAME ": IO space at 0x%x [%d ports] already reserved\n",
-	       QIC02_TAPE_PORT, QIC02_TAPE_PORT_RANGE);
-	return -ENXIO;
-    }
-
-    /* get IRQ */
-    if (request_irq(QIC02_TAPE_IRQ, qic02_tape_interrupt, SA_INTERRUPT, "QIC-02", NULL))
-    {
-	printk(TPQIC02_NAME ": can't allocate IRQ%d for QIC-02 tape\n",
-	       QIC02_TAPE_IRQ);
-	return -EBUSY;
-    }
-
-    /* After IRQ, allocate DMA channel */
-    if (request_dma(QIC02_TAPE_DMA,"QIC-02"))
-    {
-	printk(TPQIC02_NAME ": can't allocate DMA%d for QIC-02 tape\n",
-	       QIC02_TAPE_DMA);
-	free_irq(QIC02_TAPE_IRQ, NULL);
-	return -EBUSY;
-    }
+	/* First perform some checks. If one of them fails,
+	 * the tape driver will not be registered to the system.
+	 */
+	if (QIC02_TAPE_IRQ > 16) {
+		tpqputs(TPQD_ALWAYS, "Bogus interrupt number.");
+		return -ENXIO;
+	}
+
+	/* for DYNCONF, allocating IO, DMA and IRQ should not be done until 
+	 * the config parameters have been set using MTSETCONFIG.
+	 */
 
-    /* Grab the IO region. We already made sure it's available. */
-    request_region(QIC02_TAPE_PORT, QIC02_TAPE_PORT_RANGE, TPQIC02_NAME);
-    
-    /* Setup the page-address for the dma transfer. */
-    buffaddr = (void *)__get_dma_pages(GFP_KERNEL, get_order(TPQBUF_SIZE));
-    
-    if (!buffaddr)
-    {
-	qic02_release_resources();
-	return -EBUSY; /* Not ideal, EAGAIN perhaps? */
-    }
-    
-    memset(buffaddr, 0, TPQBUF_SIZE);
-    
-    printk(TPQIC02_NAME ": Settings: IRQ %d, DMA %d, IO 0x%x, IFC %s\n",
-	   QIC02_TAPE_IRQ, QIC02_TAPE_DMA,
-	   ((QIC02_TAPE_IFC==ARCHIVE) || (QIC02_TAPE_IFC==MOUNTAIN))?
-	   QIC02_CMD_PORT : QIC02_STAT_PORT,
-	   (QIC02_TAPE_IFC==MOUNTAIN)? "Mountain" :
-	   ((QIC02_TAPE_IFC==ARCHIVE)? "Archive" : "Wangtek"));
-    
-    if (tape_reset(0)!=TE_OK || tp_sense(TP_WRP|TP_POR|TP_CNI)!=TE_OK)
-    {
-	/* No drive detected, so vanish */
-	tpqputs(TPQD_ALWAYS, "No drive detected -- releasing IO/IRQ/DMA.");
-	status_dead = YES;
-	qic02_release_resources();
-	return -EIO;
-    }
-
-    /* All should be ok now */
-    status_zombie = NO;
-    return 0;
-} /* qic02_get_resources */
+	if (check_region(QIC02_TAPE_PORT, QIC02_TAPE_PORT_RANGE)) {
+		printk(TPQIC02_NAME
+		       ": IO space at 0x%x [%d ports] already reserved\n",
+		       QIC02_TAPE_PORT, QIC02_TAPE_PORT_RANGE);
+		return -ENXIO;
+	}
+
+	/* get IRQ */
+	if (request_irq
+	    (QIC02_TAPE_IRQ, qic02_tape_interrupt, SA_INTERRUPT, "QIC-02",
+	     NULL)) {
+		printk(TPQIC02_NAME
+		       ": can't allocate IRQ%d for QIC-02 tape\n",
+		       QIC02_TAPE_IRQ);
+		return -EBUSY;
+	}
+
+	/* After IRQ, allocate DMA channel */
+	if (request_dma(QIC02_TAPE_DMA, "QIC-02")) {
+		printk(TPQIC02_NAME
+		       ": can't allocate DMA%d for QIC-02 tape\n",
+		       QIC02_TAPE_DMA);
+		free_irq(QIC02_TAPE_IRQ, NULL);
+		return -EBUSY;
+	}
+
+	/* Grab the IO region. We already made sure it's available. */
+	request_region(QIC02_TAPE_PORT, QIC02_TAPE_PORT_RANGE,
+		       TPQIC02_NAME);
+
+	/* Setup the page-address for the dma transfer. */
+	buffaddr =
+	    (void *) __get_dma_pages(GFP_KERNEL, get_order(TPQBUF_SIZE));
+
+	if (!buffaddr) {
+		qic02_release_resources();
+		return -EBUSY;	/* Not ideal, EAGAIN perhaps? */
+	}
+
+	memset(buffaddr, 0, TPQBUF_SIZE);
+
+	printk(TPQIC02_NAME
+	       ": Settings: IRQ %d, DMA %d, IO 0x%x, IFC %s\n",
+	       QIC02_TAPE_IRQ, QIC02_TAPE_DMA, ((QIC02_TAPE_IFC == ARCHIVE)
+						|| (QIC02_TAPE_IFC ==
+						    MOUNTAIN)) ?
+	       QIC02_CMD_PORT : QIC02_STAT_PORT,
+	       (QIC02_TAPE_IFC ==
+		MOUNTAIN) ? "Mountain" : ((QIC02_TAPE_IFC ==
+					   ARCHIVE) ? "Archive" :
+					  "Wangtek"));
+
+	if (tape_reset(0) != TE_OK
+	    || tp_sense(TP_WRP | TP_POR | TP_CNI) != TE_OK) {
+		/* No drive detected, so vanish */
+		tpqputs(TPQD_ALWAYS,
+			"No drive detected -- releasing IO/IRQ/DMA.");
+		status_dead = YES;
+		qic02_release_resources();
+		return -EIO;
+	}
+
+	/* All should be ok now */
+	status_zombie = NO;
+	return 0;
+}				/* qic02_get_resources */
 
 int __init qic02_tape_init(void)
 {
-    if (TPSTATSIZE != 6)
-    {
-	printk(TPQIC02_NAME ": internal error: tpstatus struct incorrect!\n");
-	return -ENODEV;
-    }
-    if ((TPQBUF_SIZE<512) || (TPQBUF_SIZE>=0x10000))
-    {
-	printk(TPQIC02_NAME ": internal error: DMA buffer size out of range\n");
-	return -ENODEV;
-    }
+	if (TPSTATSIZE != 6) {
+		printk(TPQIC02_NAME
+		       ": internal error: tpstatus struct incorrect!\n");
+		return -ENODEV;
+	}
+	if ((TPQBUF_SIZE < 512) || (TPQBUF_SIZE >= 0x10000)) {
+		printk(TPQIC02_NAME
+		       ": internal error: DMA buffer size out of range\n");
+		return -ENODEV;
+	}
 
-    current_tape_dev = MKDEV(QIC02_TAPE_MAJOR, 0);
+	current_tape_dev = MKDEV(QIC02_TAPE_MAJOR, 0);
 
 #ifndef CONFIG_QIC02_DYNCONF
-    printk(TPQIC02_NAME ": IRQ %d, DMA %d, IO 0x%x, IFC %s, %s, %s\n",
-	   QIC02_TAPE_IRQ, QIC02_TAPE_DMA,
+	printk(TPQIC02_NAME ": IRQ %d, DMA %d, IO 0x%x, IFC %s, %s, %s\n",
+	       QIC02_TAPE_IRQ, QIC02_TAPE_DMA,
 # if QIC02_TAPE_IFC == WANGTEK
-	   QIC02_STAT_PORT, "Wangtek",
+	       QIC02_STAT_PORT, "Wangtek",
 # elif QIC02_TAPE_IFC == ARCHIVE
-	   QIC02_CMD_PORT, "Archive",
+	       QIC02_CMD_PORT, "Archive",
 # elif QIC02_TAPE_IFC == MOUNTAIN
-	   QIC02_CMD_PORT, "Mountain",
+	       QIC02_CMD_PORT, "Mountain",
 # else
 #  error
 # endif
-	   rcs_revision, rcs_date);
-    if (qic02_get_resources())
-    {
-	return -ENODEV;
-    }
+	       rcs_revision, rcs_date);
+	if (qic02_get_resources()) {
+		return -ENODEV;
+	}
 #else
-    printk(TPQIC02_NAME ": Runtime config, %s, %s\n", 
-	   rcs_revision, rcs_date);
+	printk(TPQIC02_NAME ": Runtime config, %s, %s\n",
+	       rcs_revision, rcs_date);
 #endif
-    printk(TPQIC02_NAME ": DMA buffers: %u blocks\n", NR_BLK_BUF);
-    /* If we got this far, install driver functions */
-    if (devfs_register_chrdev(QIC02_TAPE_MAJOR, TPQIC02_NAME, &qic02_tape_fops))
-    {
-	printk(TPQIC02_NAME ": Unable to get chrdev major %d\n", QIC02_TAPE_MAJOR);
+	printk(TPQIC02_NAME ": DMA buffers: %u blocks\n", NR_BLK_BUF);
+	/* If we got this far, install driver functions */
+	if (devfs_register_chrdev
+	    (QIC02_TAPE_MAJOR, TPQIC02_NAME, &qic02_tape_fops)) {
+		printk(TPQIC02_NAME ": Unable to get chrdev major %d\n",
+		       QIC02_TAPE_MAJOR);
 #ifndef CONFIG_QIC02_DYNCONF
-	qic02_release_resources();
+		qic02_release_resources();
 #endif
-	return -ENODEV;
-    }
-    devfs_register (NULL, "ntpqic11", DEVFS_FL_DEFAULT,
-		    QIC02_TAPE_MAJOR, 2,
-		    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
-		    &qic02_tape_fops, NULL);
-    devfs_register (NULL, "tpqic11", DEVFS_FL_DEFAULT,
-		    QIC02_TAPE_MAJOR, 3,
-		    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
-		    &qic02_tape_fops, NULL);
-    devfs_register (NULL, "ntpqic24", DEVFS_FL_DEFAULT,
-		    QIC02_TAPE_MAJOR, 4,
-		    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
-		    &qic02_tape_fops, NULL);
-    devfs_register (NULL, "tpqic24", DEVFS_FL_DEFAULT,
-		    QIC02_TAPE_MAJOR, 5,
-		    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
-		    &qic02_tape_fops, NULL);
-    devfs_register (NULL, "ntpqic120", DEVFS_FL_DEFAULT,
-		    QIC02_TAPE_MAJOR, 6,
-		    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
-		    &qic02_tape_fops, NULL);
-    devfs_register (NULL, "tpqic120", DEVFS_FL_DEFAULT,
-		    QIC02_TAPE_MAJOR, 7,
-		    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
-		    &qic02_tape_fops, NULL);
-    devfs_register (NULL, "ntpqic150", DEVFS_FL_DEFAULT,
-		    QIC02_TAPE_MAJOR, 8,
-		    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
-		    &qic02_tape_fops, NULL);
-    devfs_register (NULL, "tpqic150", DEVFS_FL_DEFAULT,
-		    QIC02_TAPE_MAJOR, 9,
-		    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
-		    &qic02_tape_fops, NULL);
-    init_waitqueue_head(&qic02_tape_transfer);
-    /* prepare timer */
-    TIMEROFF;
-    init_timer(&tp_timer);
-    tp_timer.function = qic02_tape_times_out;
-    
+		return -ENODEV;
+	}
+	devfs_register(NULL, "ntpqic11", DEVFS_FL_DEFAULT,
+		       QIC02_TAPE_MAJOR, 2,
+		       S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
+		       &qic02_tape_fops, NULL);
+	devfs_register(NULL, "tpqic11", DEVFS_FL_DEFAULT,
+		       QIC02_TAPE_MAJOR, 3,
+		       S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
+		       &qic02_tape_fops, NULL);
+	devfs_register(NULL, "ntpqic24", DEVFS_FL_DEFAULT,
+		       QIC02_TAPE_MAJOR, 4,
+		       S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
+		       &qic02_tape_fops, NULL);
+	devfs_register(NULL, "tpqic24", DEVFS_FL_DEFAULT,
+		       QIC02_TAPE_MAJOR, 5,
+		       S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
+		       &qic02_tape_fops, NULL);
+	devfs_register(NULL, "ntpqic120", DEVFS_FL_DEFAULT,
+		       QIC02_TAPE_MAJOR, 6,
+		       S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
+		       &qic02_tape_fops, NULL);
+	devfs_register(NULL, "tpqic120", DEVFS_FL_DEFAULT,
+		       QIC02_TAPE_MAJOR, 7,
+		       S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
+		       &qic02_tape_fops, NULL);
+	devfs_register(NULL, "ntpqic150", DEVFS_FL_DEFAULT,
+		       QIC02_TAPE_MAJOR, 8,
+		       S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
+		       &qic02_tape_fops, NULL);
+	devfs_register(NULL, "tpqic150", DEVFS_FL_DEFAULT,
+		       QIC02_TAPE_MAJOR, 9,
+		       S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
+		       &qic02_tape_fops, NULL);
+	init_waitqueue_head(&qic02_tape_transfer);
+	/* prepare timer */
+	TIMEROFF;
+	init_timer(&tp_timer);
+	tp_timer.function = qic02_tape_times_out;
+
 #ifndef CONFIG_QIC02_DYNCONF
-    if (tape_reset(0)!=TE_OK || tp_sense(TP_WRP|TP_POR|TP_CNI)!=TE_OK)
-    {
-	/* No drive detected, so vanish */
-	tpqputs(TPQD_ALWAYS, "No drive detected -- driver going on vacation...");
-	qic02_release_resources();
-	status_dead = YES;
-	return -ENODEV;
-    }
-    else
-    {
-	if (is_exception())
-	{
-	    tpqputs(TPQD_ALWAYS, "exception detected\n");
-	    (void) tp_sense(TP_WRP|TP_POR|TP_CNI);
+	if (tape_reset(0) != TE_OK
+	    || tp_sense(TP_WRP | TP_POR | TP_CNI) != TE_OK) {
+		/* No drive detected, so vanish */
+		tpqputs(TPQD_ALWAYS,
+			"No drive detected -- driver going on vacation...");
+		qic02_release_resources();
+		status_dead = YES;
+		return -ENODEV;
+	} else {
+		if (is_exception()) {
+			tpqputs(TPQD_ALWAYS, "exception detected\n");
+			(void) tp_sense(TP_WRP | TP_POR | TP_CNI);
+		}
 	}
-    }
 #endif
 
-    /* initialize generic status for ioctl requests */
-    
-    ioctl_status.mt_type	= QIC02_TAPE_DRIVE;	/* MT_IS* id nr */
-    
-    ioctl_status.mt_resid	= 0;	/* ---residual count */
-    ioctl_status.mt_gstat	= 0;	/* ---generic status */
-    ioctl_status.mt_erreg	= 0;	/* not used */
-    ioctl_status.mt_fileno	= 0;	/* number of current file on tape */
-    ioctl_status.mt_blkno	= 0;	/* number of current (logical) block */
+	/* initialize generic status for ioctl requests */
+
+	ioctl_status.mt_type = QIC02_TAPE_DRIVE;	/* MT_IS* id nr */
 
-    return 0;
-} /* qic02_tape_init */
+	ioctl_status.mt_resid = 0;	/* ---residual count */
+	ioctl_status.mt_gstat = 0;	/* ---generic status */
+	ioctl_status.mt_erreg = 0;	/* not used */
+	ioctl_status.mt_fileno = 0;	/* number of current file on tape */
+	ioctl_status.mt_blkno = 0;	/* number of current (logical) block */
+
+	return 0;
+}				/* qic02_tape_init */
 
 #ifdef MODULE
 
 void cleanup_module(void)
 {
-    if (status_zombie == NO)
-    {
-	qic02_release_resources();
-    }
-    devfs_unregister_chrdev(QIC02_TAPE_MAJOR, TPQIC02_NAME);
-    devfs_unregister(devfs_find_handle(NULL, "ntpqic11", QIC02_TAPE_MAJOR, 2, DEVFS_SPECIAL_CHR, 0));
-    devfs_unregister(devfs_find_handle(NULL, "tpqic11", QIC02_TAPE_MAJOR, 3, DEVFS_SPECIAL_CHR, 0));
-    devfs_unregister(devfs_find_handle(NULL, "ntpqic24", QIC02_TAPE_MAJOR, 4, DEVFS_SPECIAL_CHR, 0));
-    devfs_unregister(devfs_find_handle(NULL, "tpqic24", QIC02_TAPE_MAJOR, 5, DEVFS_SPECIAL_CHR, 0));
-    devfs_unregister(devfs_find_handle(NULL, "ntpqic120", QIC02_TAPE_MAJOR, 6, DEVFS_SPECIAL_CHR, 0));
-    devfs_unregister(devfs_find_handle(NULL, "tpqic120", QIC02_TAPE_MAJOR, 7, DEVFS_SPECIAL_CHR, 0));
-    devfs_unregister(devfs_find_handle(NULL, "ntpqic150", QIC02_TAPE_MAJOR, 8, DEVFS_SPECIAL_CHR, 0));
-    devfs_unregister(devfs_find_handle(NULL, "tpqic150", QIC02_TAPE_MAJOR, 9, DEVFS_SPECIAL_CHR, 0));
+	if (status_zombie == NO) {
+		qic02_release_resources();
+	}
+	devfs_unregister_chrdev(QIC02_TAPE_MAJOR, TPQIC02_NAME);
+	devfs_unregister(devfs_find_handle
+			 (NULL, "ntpqic11", QIC02_TAPE_MAJOR, 2,
+			  DEVFS_SPECIAL_CHR, 0));
+	devfs_unregister(devfs_find_handle
+			 (NULL, "tpqic11", QIC02_TAPE_MAJOR, 3,
+			  DEVFS_SPECIAL_CHR, 0));
+	devfs_unregister(devfs_find_handle
+			 (NULL, "ntpqic24", QIC02_TAPE_MAJOR, 4,
+			  DEVFS_SPECIAL_CHR, 0));
+	devfs_unregister(devfs_find_handle
+			 (NULL, "tpqic24", QIC02_TAPE_MAJOR, 5,
+			  DEVFS_SPECIAL_CHR, 0));
+	devfs_unregister(devfs_find_handle
+			 (NULL, "ntpqic120", QIC02_TAPE_MAJOR, 6,
+			  DEVFS_SPECIAL_CHR, 0));
+	devfs_unregister(devfs_find_handle
+			 (NULL, "tpqic120", QIC02_TAPE_MAJOR, 7,
+			  DEVFS_SPECIAL_CHR, 0));
+	devfs_unregister(devfs_find_handle
+			 (NULL, "ntpqic150", QIC02_TAPE_MAJOR, 8,
+			  DEVFS_SPECIAL_CHR, 0));
+	devfs_unregister(devfs_find_handle
+			 (NULL, "tpqic150", QIC02_TAPE_MAJOR, 9,
+			  DEVFS_SPECIAL_CHR, 0));
 }
 
 int init_module(void)
 {
-    int retval;
-    retval=qic02_tape_init();
+	int retval;
+	retval = qic02_tape_init();
 # ifdef CONFIG_QIC02_DYNCONF
-    /* This allows the dynamic config program to setup the card
-     * by presetting qic02_tape_dynconf via insmod
-     */
-    if (!retval && qic02_tape_dynconf.ifc_type)
-    {
-	retval=update_ifc_masks(qic02_tape_dynconf.ifc_type);
-	if (retval)
-	{
-	  cleanup_module();
+	/* This allows the dynamic config program to setup the card
+	 * by presetting qic02_tape_dynconf via insmod
+	 */
+	if (!retval && qic02_tape_dynconf.ifc_type) {
+		retval = update_ifc_masks(qic02_tape_dynconf.ifc_type);
+		if (retval) {
+			cleanup_module();
+		}
 	}
-    }
 # endif
-    return retval;
+	return retval;
 }
 #endif
+
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/tty_io.c linux/drivers/char/tty_io.c
--- v2.4.9/linux/drivers/char/tty_io.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/char/tty_io.c	Fri Sep  7 10:53:59 2001
@@ -442,8 +442,6 @@
 	file_list_lock();
 	for (l = tty->tty_files.next; l != &tty->tty_files; l = l->next) {
 		struct file * filp = list_entry(l, struct file, f_list);
-		if (!filp->f_dentry)
-			continue;
 		if (filp->f_dentry->d_inode->i_rdev == CONSOLE_DEV ||
 		    filp->f_dentry->d_inode->i_rdev == SYSCONS_DEV) {
 			cons_filp = filp;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/vino.h linux/drivers/char/vino.h
--- v2.4.9/linux/drivers/char/vino.h	Fri Jun 25 17:39:14 1999
+++ linux/drivers/char/vino.h	Wed Dec 31 16:00:00 1969
@@ -1,118 +0,0 @@
-/* $Id: vino.h,v 1.2 1999/02/09 23:03:53 ulfc Exp $
- * drivers/sgi/vino.h
- *
- * Copyright (C) 1999 Ulf Carlsson (ulfc@bun.falkenberg.se)
- */
-
-#define VINO_BASE		0x0008000
-
-#define VINO_REVID		0x0000
-#define VINO_CTRL		0x0008
-#define VINO_INTSTAT		0x0010	/* Interrupt status */
-#define VINO_I2C_CTRL		0x0018
-#define VINO_I2C_DATA		0x0020
-#define VINO_A_ALPHA		0x0028	/* Channel A ... */
-#define VINO_A_CLIPS		0x0030	/* Clipping start */
-#define VINO_A_CLIPE		0x0038	/* Clipping end */
-#define VINO_A_FRAMERT		0x0040	/* Framerate */
-#define VINO_A_FLDCNT		0x0048	/* Field counter */
-#define VINO_A_LNSZ		0x0050
-#define VINO_A_LNCNT		0x0058
-#define VINO_A_PGIX		0x0060	/* Page index */
-#define VINO_A_DESC_PTR		0x0068	/* Ptr to next four descriptors */
-#define VINO_A_DESC_TLB_PTR	0x0070	/* Ptr to start of descriptor table */
-#define VINO_A_DESC_DATA0	0x0078	/* Descriptor data 0 */
-#define VINO_A_DESC_DATA1	0x0080	/* ... */
-#define VINO_A_DESC_DATA2	0x0088
-#define VINO_A_DESC_DATA3	0x0090
-#define VINO_A_FIFO_THRESHOLD	0x0098	/* FIFO threshold */
-#define VINO_A_FIFO_RP		0x00a0
-#define VINO_A_FIFO_WP		0x00a8
-#define VINO_B_ALPHA		0x00b0	/* Channel B ... */
-#define VINO_B_CLIPS		0x00b8
-#define VINO_B_CLIPE		0x00c0
-#define VINO_B_FRAMERT		0x00c8
-#define VINO_B_FLDCNT		0x00d0
-#define VINO_B_LNSZ		0x00d8
-#define VINO_B_LNCNT		0x00e0
-#define VINO_B_PGIX		0x00e8
-#define VINO_B_DESC_PTR		0x00f0
-#define VINO_B_DESC_TLB_PTR	0x00f8
-#define VINO_B_DESC_DATA0	0x0100
-#define VINO_B_DESC_DATA1	0x0108
-#define VINO_B_DESC_DATA2	0x0110
-#define VINO_B_DESC_DATA3	0x0118
-#define VINO_B_FIFO_THRESHOLD	0x0120
-#define VINO_B_FIFO_RP		0x0128
-#define VINO_B_FIFO_WP		0x0130
-
-/* Bits in the VINO_REVID register */
-
-#define VINO_REVID_REV_MASK		0x000f	/* bits 0:3 */
-#define VINO_REVID_ID_MASK		0x00f0	/* bits 4:7 */
-
-/* Bits in the VINO_CTRL register */
-
-#define VINO_CTRL_LITTLE_ENDIAN		(1<<0)
-#define VINO_CTRL_A_FIELD_TRANS_INT	(1<<1)	/* Field transferred int */
-#define VINO_CTRL_A_FIFO_OF_INT		(1<<2)	/* FIFO overflow int */
-#define VINO_CTRL_A_END_DESC_TBL_INT	(1<<3)	/* End of desc table int */
-#define VINO_CTRL_B_FIELD_TRANS_INT	(1<<4)	/* Field transferred int */
-#define VINO_CTRL_B_FIFO_OF_INT		(1<<5)	/* FIFO overflow int */
-#define VINO_CTRL_B_END_DESC_TLB_INT	(1<<6)	/* End of desc table int */
-#define VINO_CTRL_A_DMA_ENBL		(1<<7)
-#define VINO_CTRL_A_INTERLEAVE_ENBL	(1<<8)
-#define VINO_CTRL_A_SYNC_ENBL		(1<<9)
-#define VINO_CTRL_A_SELECT		(1<<10)	/* 1=D1 0=Philips */
-#define VINO_CTRL_A_RGB			(1<<11)	/* 1=RGB 0=YUV */
-#define VINO_CTRL_A_LUMA_ONLY		(1<<12)
-#define VINO_CTRL_A_DEC_ENBL		(1<<13)	/* Decimation */
-#define VINO_CTRL_A_DEC_SCALE_MASK	0x1c000	/* bits 14:17 */
-#define VINO_CTRL_A_DEC_HOR_ONLY	(1<<17)	/* Horizontal only */
-#define VINO_CTRL_A_DITHER		(1<<18)	/* 24 -> 8 bit dither */
-#define VINO_CTRL_B_DMA_ENBL		(1<<19)
-#define VINO_CTRL_B_INTERLEAVE_ENBL	(1<<20)
-#define VINO_CTRL_B_SYNC_ENBL		(1<<21)
-#define VINO_CTRL_B_SELECT		(1<<22)	/* 1=D1 0=Philips */
-#define VINO_CTRL_B_RGB			(1<<22)	/* 1=RGB 0=YUV */
-#define VINO_CTRL_B_LUMA_ONLY		(1<<23)
-#define VINO_CTRL_B_DEC_ENBL		(1<<24)	/* Decimation */
-#define VINO_CTRL_B_DEC_SCALE_MASK	0x1c000000	/* bits 25:28 */
-#define VINO_CTRL_B_DEC_HOR_ONLY	(1<<29)	/* Decimation horizontal only */
-#define VINO_CTRL_B_DITHER		(1<<30)	/* ChanB 24 -> 8 bit dither */
-
-/* Bits in the Interrupt and Status register */
-
-#define VINO_INTSTAT_A_FIELD_TRANS	(1<<0)	/* Field transferred int */
-#define VINO_INTSTAT_A_FIFO_OF		(1<<1)	/* FIFO overflow int */
-#define VINO_INTSTAT_A_END_DESC_TBL	(1<<2)	/* End of desc table int */
-#define VINO_INTSTAT_B_FIELD_TRANS	(1<<3)	/* Field transferred int */
-#define VINO_INTSTAT_B_FIFO_OF		(1<<4)	/* FIFO overflow int */
-#define VINO_INTSTAT_B_END_DESC_TBL	(1<<5)	/* End of desc table int */
-
-/* Bits in the Clipping Start register */
-
-#define VINO_CLIPS_START		0x3ff		/* bits 0:9 */
-#define VINO_CLIPS_ODD_MASK		0x7fc00		/* bits 10:18 */
-#define VINO_CLIPS_EVEN_MASK		0xff80000	/* bits 19:27 */
-
-/* Bits in the Clipping End register */
-
-#define VINO_CLIPE_END			0x3ff		/* bits 0:9 */
-#define VINO_CLIPE_ODD_MASK		0x7fc00		/* bits 10:18 */
-#define VINO_CLIPE_EVEN_MASK		0xff80000	/* bits 19:27 */
-
-/* Bits in the Frame Rate register */
-
-#define VINO_FRAMERT_PAL		(1<<0)	/* 0=NTSC 1=PAL */
-#define VINO_FRAMERT_RT_MASK		0x1ffe		/* bits 1:12 */
-
-/* Bits in the VINO_I2C_CTRL */
-
-#define VINO_CTRL_I2C_IDLE		(1<<0)	/* write: 0=force idle
-						 * read: 0=idle 1=not idle */
-#define VINO_CTRL_I2C_DIR		(1<<1)	/* 0=read 1=write */
-#define VINO_CTRL_I2C_MORE_BYTES	(1<<2)	/* 0=last byte 1=more bytes */
-#define VINO_CTRL_I2C_TRANS_BUSY	(1<<4)	/* 0=trans done 1=trans busy */
-#define VINO_CTRL_I2C_ACK		(1<<5)	/* 0=ack received 1=ack not */
-#define VINO_CTRL_I2C_BUS_ERROR		(1<<7)	/* 0=no bus err 1=bus err */
diff -u --recursive --new-file v2.4.9/linux/drivers/char/vt.c linux/drivers/char/vt.c
--- v2.4.9/linux/drivers/char/vt.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/char/vt.c	Tue Aug 28 07:09:44 2001
@@ -28,7 +28,6 @@
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
-#include <asm/keyboard.h>
 
 #include <linux/kbd_kern.h>
 #include <linux/vt_kern.h>
@@ -145,8 +144,13 @@
 
 #endif
 
-void (*kd_mksound)(unsigned int hz, unsigned int ticks) = _kd_mksound;
+int _kbd_rate(struct kbd_repeat *rep)
+{
+	return -EINVAL;
+}
 
+void (*kd_mksound)(unsigned int hz, unsigned int ticks) = _kd_mksound;
+int (*kbd_rate)(struct kbd_repeat *rep) = _kbd_rate;
 
 #define i (tmp.kb_index)
 #define s (tmp.kb_table)
@@ -504,7 +508,6 @@
 	{
 		struct kbd_repeat kbrep;
 		
-		if (!kbd_rate) return( -EINVAL );
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
 
diff -u --recursive --new-file v2.4.9/linux/drivers/char/w83877f_wdt.c linux/drivers/char/w83877f_wdt.c
--- v2.4.9/linux/drivers/char/w83877f_wdt.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/char/w83877f_wdt.c	Thu Sep 13 15:21:32 2001
@@ -340,3 +340,5 @@
 
 module_init(w83877f_wdt_init);
 module_exit(w83877f_wdt_unload);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/wdt.c linux/drivers/char/wdt.c
--- v2.4.9/linux/drivers/char/wdt.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/char/wdt.c	Fri Sep  7 09:28:38 2001
@@ -538,3 +538,7 @@
 module_init(wdt_init);
 module_exit(wdt_exit);
 
+MODULE_AUTHOR("Alan Cox");
+MODULE_DESCRIPTION("Driver for ISA ICS watchdog cards (WDT500/501)");
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/char/wdt285.c linux/drivers/char/wdt285.c
--- v2.4.9/linux/drivers/char/wdt285.c	Sat May 19 17:43:05 2001
+++ linux/drivers/char/wdt285.c	Fri Sep  7 09:28:38 2001
@@ -190,6 +190,7 @@
 
 MODULE_AUTHOR("Phil Blundell <pb@nexus.co.uk>");
 MODULE_DESCRIPTION("21285 watchdog driver");
+MODULE_LICENSE("GPL");
 
 MODULE_PARM(soft_margin,"i");
 MODULE_PARM_DESC(soft_margin,"Watchdog timeout in seconds");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/wdt977.c linux/drivers/char/wdt977.c
--- v2.4.9/linux/drivers/char/wdt977.c	Mon Oct 16 12:58:51 2000
+++ linux/drivers/char/wdt977.c	Fri Sep  7 09:28:38 2001
@@ -199,3 +199,5 @@
 
 module_init(nwwatchdog_init);
 module_exit(nwwatchdog_exit);
+
+MODULE_LICENSE("GPL");
diff -u --recursive --new-file v2.4.9/linux/drivers/char/wdt_pci.c linux/drivers/char/wdt_pci.c
--- v2.4.9/linux/drivers/char/wdt_pci.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/char/wdt_pci.c	Fri Sep  7 09:28:38 2001
@@ -626,3 +626,9 @@
 
 module_init(wdtpci_init);
 module_exit(wdtpci_cleanup);
+
+MODULE_AUTHOR("JP Nollmann, Alan Cox");
+MODULE_DESCRIPTION("Driver for the ICS PCI watchdog cards");
+MODULE_LICENSE("GPL");
+
+EXPORT_NO_SYMBOLS;
diff -u --recursive --new-file v2.4.9/linux/drivers/i2c/i2c-adap-ite.c linux/drivers/i2c/i2c-adap-ite.c
--- v2.4.9/linux/drivers/i2c/i2c-adap-ite.c	Wed Dec 31 16:00:00 1969
+++ linux/drivers/i2c/i2c-adap-ite.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,319 @@
+/*
+   -------------------------------------------------------------------------
+   i2c-adap-ite.c i2c-hw access for the IIC peripheral on the ITE MIPS system
+   -------------------------------------------------------------------------
+   Hai-Pao Fan, MontaVista Software, Inc.
+   hpfan@mvista.com or source@mvista.com
+
+   Copyright 2001 MontaVista Software Inc.
+
+   ----------------------------------------------------------------------------
+   This file was highly leveraged from i2c-elektor.c, which was created
+   by Simon G. Vogl and Hans Berglund:
+
+ 
+     Copyright (C) 1995-97 Simon G. Vogl
+                   1998-99 Hans Berglund
+
+    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.		     */
+/* ------------------------------------------------------------------------- */
+
+/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
+   Frodo Looijaard <frodol@dds.nl> */
+
+#include <linux/kernel.h>
+#include <linux/ioport.h>
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/malloc.h>
+#include <linux/version.h>
+#include <linux/init.h>
+#include <asm/irq.h>
+#include <asm/io.h>
+
+#include <linux/i2c.h>
+#include <linux/i2c-algo-ite.h>
+#include <linux/i2c-adap-ite.h>
+#include "i2c-ite.h"
+
+#define DEFAULT_BASE  0x14014030
+#define ITE_IIC_IO_SIZE	0x40
+#define DEFAULT_IRQ   0
+#define DEFAULT_CLOCK 0x1b0e	/* default 16MHz/(27+14) = 400KHz */
+#define DEFAULT_OWN   0x55
+
+static int base  = 0;
+static int irq   = 0;
+static int clock = 0;
+static int own   = 0;
+
+static int i2c_debug=0;
+static struct iic_ite gpi;
+#if (LINUX_VERSION_CODE < 0x020301)
+static struct wait_queue *iic_wait = NULL;
+#else
+static wait_queue_head_t iic_wait;
+#endif
+static int iic_pending;
+
+/* ----- global defines -----------------------------------------------	*/
+#define DEB(x)	if (i2c_debug>=1) x
+#define DEB2(x) if (i2c_debug>=2) x
+#define DEB3(x) if (i2c_debug>=3) x
+#define DEBE(x)	x	/* error messages 				*/
+
+
+/* ----- local functions ----------------------------------------------	*/
+
+static void iic_ite_setiic(void *data, int ctl, short val)
+{
+        unsigned long j = jiffies + 10;
+
+	DEB3(printk(" Write 0x%02x to 0x%x\n",(unsigned short)val, ctl&0xff));
+	DEB3({while (jiffies < j) schedule();}) 
+	outw(val,ctl);
+}
+
+static short iic_ite_getiic(void *data, int ctl)
+{
+	short val;
+
+	val = inw(ctl);
+	DEB3(printk("Read 0x%02x from 0x%x\n",(unsigned short)val, ctl&0xff));  
+	return (val);
+}
+
+/* Return our slave address.  This is the address
+ * put on the I2C bus when another master on the bus wants to address us
+ * as a slave
+ */
+static int iic_ite_getown(void *data)
+{
+	return (gpi.iic_own);
+}
+
+
+static int iic_ite_getclock(void *data)
+{
+	return (gpi.iic_clock);
+}
+
+
+#if 0
+static void iic_ite_sleep(unsigned long timeout)
+{
+	schedule_timeout( timeout * HZ);
+}
+#endif
+
+
+/* Put this process to sleep.  We will wake up when the
+ * IIC controller interrupts.
+ */
+static void iic_ite_waitforpin(void) {
+
+   int timeout = 2;
+
+   /* If interrupts are enabled (which they are), then put the process to
+    * sleep.  This process will be awakened by two events -- either the
+    * the IIC peripheral interrupts or the timeout expires. 
+    * If interrupts are not enabled then delay for a reasonable amount 
+    * of time and return.
+    */
+   if (gpi.iic_irq > 0) {
+	cli();
+	if (iic_pending == 0) {
+		interruptible_sleep_on_timeout(&iic_wait, timeout*HZ );
+	} else
+		iic_pending = 0;
+	sti();
+   } else {
+      udelay(100);
+   }
+}
+
+
+static void iic_ite_handler(int this_irq, void *dev_id, struct pt_regs *regs) 
+{
+	
+   iic_pending = 1;
+
+   DEB2(printk("iic_ite_handler: in interrupt handler\n"));
+   wake_up_interruptible(&iic_wait);
+}
+
+
+/* Lock the region of memory where I/O registers exist.  Request our
+ * interrupt line and register its associated handler.
+ */
+static int iic_hw_resrc_init(void)
+{
+  	if (check_region(gpi.iic_base, ITE_IIC_IO_SIZE) < 0 ) {
+   	   return -ENODEV;
+  	} else {
+  	   request_region(gpi.iic_base, ITE_IIC_IO_SIZE, 
+		"i2c (i2c bus adapter)");
+  	}
+	if (gpi.iic_irq > 0) {
+	   if (request_irq(gpi.iic_irq, iic_ite_handler, 0, "ITE IIC", 0) < 0) {
+	      gpi.iic_irq = 0;
+	   } else
+	      DEB3(printk("Enabled IIC IRQ %d\n", gpi.iic_irq));
+	      enable_irq(gpi.iic_irq);
+	}
+	return 0;
+}
+
+
+static void iic_ite_release(void)
+{
+	if (gpi.iic_irq > 0) {
+		disable_irq(gpi.iic_irq);
+		free_irq(gpi.iic_irq, 0);
+	}
+	release_region(gpi.iic_base , 2);
+}
+
+
+static int iic_ite_reg(struct i2c_client *client)
+{
+	return 0;
+}
+
+
+static int iic_ite_unreg(struct i2c_client *client)
+{
+	return 0;
+}
+
+
+static void iic_ite_inc_use(struct i2c_adapter *adap)
+{
+#ifdef MODULE
+	MOD_INC_USE_COUNT;
+#endif
+}
+
+
+static void iic_ite_dec_use(struct i2c_adapter *adap)
+{
+#ifdef MODULE
+	MOD_DEC_USE_COUNT;
+#endif
+}
+
+
+/* ------------------------------------------------------------------------
+ * Encapsulate the above functions in the correct operations structure.
+ * This is only done when more than one hardware adapter is supported.
+ */
+static struct i2c_algo_iic_data iic_ite_data = {
+	NULL,
+	iic_ite_setiic,
+	iic_ite_getiic,
+	iic_ite_getown,
+	iic_ite_getclock,
+	iic_ite_waitforpin,
+	80, 80, 100,		/*	waits, timeout */
+};
+
+static struct i2c_adapter iic_ite_ops = {
+	"ITE IIC adapter",
+	I2C_HW_I_IIC,
+	NULL,
+	&iic_ite_data,
+	iic_ite_inc_use,
+	iic_ite_dec_use,
+	iic_ite_reg,
+	iic_ite_unreg,
+};
+
+/* Called when the module is loaded.  This function starts the
+ * cascade of calls up through the heirarchy of i2c modules (i.e. up to the
+ *  algorithm layer and into to the core layer)
+ */
+static int __init iic_ite_init(void) 
+{
+
+	struct iic_ite *piic = &gpi;
+
+	printk(KERN_INFO "Initialize ITE IIC adapter module\n");
+	if (base == 0)
+		piic->iic_base = DEFAULT_BASE;
+	else
+		piic->iic_base = base;
+
+	if (irq == 0)
+		piic->iic_irq = DEFAULT_IRQ;
+	else
+		piic->iic_irq = irq;
+
+	if (clock == 0)
+		piic->iic_clock = DEFAULT_CLOCK;
+	else
+		piic->iic_clock = clock;
+
+	if (own == 0)
+		piic->iic_own = DEFAULT_OWN;
+	else
+		piic->iic_own = own;
+
+	iic_ite_data.data = (void *)piic;
+#if (LINUX_VERSION_CODE >= 0x020301)
+	init_waitqueue_head(&iic_wait);
+#endif
+	if (iic_hw_resrc_init() == 0) {
+		if (i2c_iic_add_bus(&iic_ite_ops) < 0)
+			return -ENODEV;
+	} else {
+		return -ENODEV;
+	}
+	printk(KERN_INFO " found device at %#x irq %d.\n", 
+		piic->iic_base, piic->iic_irq);
+	return 0;
+}
+
+
+static void iic_ite_exit(void)
+{
+	i2c_iic_del_bus(&iic_ite_ops);
+        iic_ite_release();
+}
+
+EXPORT_NO_SYMBOLS;
+
+/* If modules is NOT defined when this file is compiled, then the MODULE_*
+ * macros will resolve to nothing
+ */
+MODULE_AUTHOR("MontaVista Software <www.mvista.com>");
+MODULE_DESCRIPTION("I2C-Bus adapter routines for ITE IIC bus adapter");
+
+MODULE_PARM(base, "i");
+MODULE_PARM(irq, "i");
+MODULE_PARM(clock, "i");
+MODULE_PARM(own, "i");
+MODULE_PARM(i2c_debug,"i");
+
+
+/* Called when module is loaded or when kernel is intialized.
+ * If MODULES is defined when this file is compiled, then this function will
+ * resolve to init_module (the function called when insmod is invoked for a
+ * module).  Otherwise, this function is called early in the boot, when the
+ * kernel is intialized.  Check out /include/init.h to see how this works.
+ */
+module_init(iic_ite_init);
+
+/* Resolves to module_cleanup when MODULES is defined. */
+module_exit(iic_ite_exit); 
diff -u --recursive --new-file v2.4.9/linux/drivers/i2c/i2c-algo-ite.c linux/drivers/i2c/i2c-algo-ite.c
--- v2.4.9/linux/drivers/i2c/i2c-algo-ite.c	Wed Dec 31 16:00:00 1969
+++ linux/drivers/i2c/i2c-algo-ite.c	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,872 @@
+/*
+   -------------------------------------------------------------------------
+   i2c-algo-ite.c i2c driver algorithms for ITE adapters	    
+   
+   Hai-Pao Fan, MontaVista Software, Inc.
+   hpfan@mvista.com or source@mvista.com
+
+   Copyright 2000 MontaVista Software Inc.
+
+   ---------------------------------------------------------------------------
+   This file was highly leveraged from i2c-algo-pcf.c, which was created
+   by Simon G. Vogl and Hans Berglund:
+
+
+     Copyright (C) 1995-1997 Simon G. Vogl
+                   1998-2000 Hans Berglund
+
+    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.		     */
+/* ------------------------------------------------------------------------- */
+
+/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and 
+   Frodo Looijaard <frodol@dds.nl> ,and also from Martin Bailey
+   <mbailey@littlefeet-inc.com> */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/malloc.h>
+#include <linux/version.h>
+#include <linux/init.h>
+#include <asm/uaccess.h>
+#include <linux/ioport.h>
+#include <linux/errno.h>
+#include <linux/sched.h>
+
+#include <linux/i2c.h>
+#include <linux/i2c-algo-ite.h>
+#include "i2c-ite.h"
+
+#define	PM_DSR		IT8172_PCI_IO_BASE + IT_PM_DSR
+#define	PM_IBSR		IT8172_PCI_IO_BASE + IT_PM_DSR + 0x04 
+#define GPIO_CCR	IT8172_PCI_IO_BASE + IT_GPCCR
+
+/* ----- global defines ----------------------------------------------- */
+#define DEB(x) if (i2c_debug>=1) x
+#define DEB2(x) if (i2c_debug>=2) x
+#define DEB3(x) if (i2c_debug>=3) x /* print several statistical values*/
+#define DEBPROTO(x) if (i2c_debug>=9) x;
+ 	/* debug the protocol by showing transferred bits */
+#define DEF_TIMEOUT 16
+
+/* debugging - slow down transfer to have a look at the data .. 	*/
+/* I use this with two leds&resistors, each one connected to sda,scl 	*/
+/* respectively. This makes sure that the algorithm works. Some chips   */
+/* might not like this, as they have an internal timeout of some mils	*/
+/*
+#define SLO_IO      jif=jiffies;while(jiffies<=jif+i2c_table[minor].veryslow)\
+                        if (need_resched) schedule();
+*/
+
+
+/* ----- global variables ---------------------------------------------	*/
+
+#ifdef SLO_IO
+	int jif;
+#endif
+
+/* module parameters:
+ */
+static int i2c_debug=1;
+static int iic_test=0;	/* see if the line-setting functions work	*/
+static int iic_scan=0;	/* have a look at what's hanging 'round		*/
+
+/* --- setting states on the bus with the right timing: ---------------	*/
+
+#define get_clock(adap) adap->getclock(adap->data)
+#define iic_outw(adap, reg, val) adap->setiic(adap->data, reg, val)
+#define iic_inw(adap, reg) adap->getiic(adap->data, reg)
+
+
+/* --- other auxiliary functions --------------------------------------	*/
+
+static void iic_start(struct i2c_algo_iic_data *adap)
+{
+	iic_outw(adap,ITE_I2CHCR,ITE_CMD);
+}
+
+static void iic_stop(struct i2c_algo_iic_data *adap)
+{
+	iic_outw(adap,ITE_I2CHCR,0);
+	iic_outw(adap,ITE_I2CHSR,ITE_I2CHSR_TDI);
+}
+
+static void iic_reset(struct i2c_algo_iic_data *adap)
+{
+	iic_outw(adap, PM_IBSR, iic_inw(adap, PM_IBSR) | 0x80);
+}
+
+
+static int wait_for_bb(struct i2c_algo_iic_data *adap)
+{
+	int timeout = DEF_TIMEOUT;
+	short status;
+
+	status = iic_inw(adap, ITE_I2CHSR);
+#ifndef STUB_I2C
+	while (timeout-- && (status & ITE_I2CHSR_HB)) {
+		udelay(1000); /* How much is this? */
+		status = iic_inw(adap, ITE_I2CHSR);
+	}
+#endif
+	if (timeout<=0) {
+		printk(KERN_ERR "Timeout, host is busy\n");
+		iic_reset(adap);
+	}
+	return(timeout<=0);
+}
+
+/*
+ * Puts this process to sleep for a period equal to timeout 
+ */
+static inline void iic_sleep(unsigned long timeout)
+{
+	schedule_timeout( timeout * HZ);
+}
+
+/* After we issue a transaction on the IIC bus, this function
+ * is called.  It puts this process to sleep until we get an interrupt from
+ * from the controller telling us that the transaction we requested in complete.
+ */
+static int wait_for_pin(struct i2c_algo_iic_data *adap, short *status) {
+
+	int timeout = DEF_TIMEOUT;
+	
+	timeout = wait_for_bb(adap);
+	if (timeout) {
+  		DEB2(printk("Timeout waiting for host not busy\n");)
+  		return -EIO;
+	}                           
+	timeout = DEF_TIMEOUT;
+
+	*status = iic_inw(adap, ITE_I2CHSR);
+#ifndef STUB_I2C
+	while (timeout-- && !(*status & ITE_I2CHSR_TDI)) {
+	   adap->waitforpin();
+	   *status = iic_inw(adap, ITE_I2CHSR);
+	}
+#endif
+	if (timeout <= 0)
+		return(-1);
+	else
+		return(0);
+}
+
+static int wait_for_fe(struct i2c_algo_iic_data *adap, short *status)
+{
+	int timeout = DEF_TIMEOUT;
+
+	*status = iic_inw(adap, ITE_I2CFSR);
+#ifndef STUB_I2C 
+	while (timeout-- && (*status & ITE_I2CFSR_FE)) {
+		udelay(1000);
+		iic_inw(adap, ITE_I2CFSR);
+	}
+#endif
+	if (timeout <= 0) 
+		return(-1);
+	else
+		return(0);
+}
+
+static int iic_init (struct i2c_algo_iic_data *adap)
+{
+	short i;
+
+	/* Clear bit 7 to set I2C to normal operation mode */
+	i=iic_inw(adap, PM_DSR)& 0xff7f;
+	iic_outw(adap, PM_DSR, i);
+
+	/* set IT_GPCCR port C bit 2&3 as function 2 */
+	i = iic_inw(adap, GPIO_CCR) & 0xfc0f;
+	iic_outw(adap,GPIO_CCR,i);
+
+	/* Clear slave address/sub-address */
+	iic_outw(adap,ITE_I2CSAR, 0);
+	iic_outw(adap,ITE_I2CSSAR, 0);
+
+	/* Set clock counter register */
+	iic_outw(adap,ITE_I2CCKCNT, get_clock(adap));
+
+	/* Set START/reSTART/STOP time registers */
+	iic_outw(adap,ITE_I2CSHDR, 0x0a);
+	iic_outw(adap,ITE_I2CRSUR, 0x0a);
+	iic_outw(adap,ITE_I2CPSUR, 0x0a);
+
+	/* Enable interrupts on completing the current transaction */
+	iic_outw(adap,ITE_I2CHCR, ITE_I2CHCR_IE | ITE_I2CHCR_HCE);
+
+	/* Clear transfer count */
+	iic_outw(adap,ITE_I2CFBCR, 0x0);
+
+	DEB2(printk("iic_init: Initialized IIC on ITE 0x%x\n",
+		iic_inw(adap, ITE_I2CHSR)));
+	return 0;
+}
+
+
+/*
+ * Sanity check for the adapter hardware - check the reaction of
+ * the bus lines only if it seems to be idle.
+ */
+static int test_bus(struct i2c_algo_iic_data *adap, char *name) {
+#if 0
+	int scl,sda;
+	sda=getsda(adap);
+	if (adap->getscl==NULL) {
+		printk("test_bus: Warning: Adapter can't read from clock line - skipping test.\n");
+		return 0;		
+	}
+	scl=getscl(adap);
+	printk("test_bus: Adapter: %s scl: %d  sda: %d -- testing...\n",
+	name,getscl(adap),getsda(adap));
+	if (!scl || !sda ) {
+		printk("test_bus: %s seems to be busy.\n",adap->name);
+		goto bailout;
+	}
+	sdalo(adap);
+	printk("test_bus:1 scl: %d  sda: %d \n",getscl(adap),
+	       getsda(adap));
+	if ( 0 != getsda(adap) ) {
+		printk("test_bus: %s SDA stuck high!\n",name);
+		sdahi(adap);
+		goto bailout;
+	}
+	if ( 0 == getscl(adap) ) {
+		printk("test_bus: %s SCL unexpected low while pulling SDA low!\n",
+			name);
+		goto bailout;
+	}		
+	sdahi(adap);
+	printk("test_bus:2 scl: %d  sda: %d \n",getscl(adap),
+	       getsda(adap));
+	if ( 0 == getsda(adap) ) {
+		printk("test_bus: %s SDA stuck low!\n",name);
+		sdahi(adap);
+		goto bailout;
+	}
+	if ( 0 == getscl(adap) ) {
+		printk("test_bus: %s SCL unexpected low while SDA high!\n",
+		       adap->name);
+	goto bailout;
+	}
+	scllo(adap);
+	printk("test_bus:3 scl: %d  sda: %d \n",getscl(adap),
+	       getsda(adap));
+	if ( 0 != getscl(adap) ) {
+
+		sclhi(adap);
+		goto bailout;
+	}
+	if ( 0 == getsda(adap) ) {
+		printk("test_bus: %s SDA unexpected low while pulling SCL low!\n",
+			name);
+		goto bailout;
+	}
+	sclhi(adap);
+	printk("test_bus:4 scl: %d  sda: %d \n",getscl(adap),
+	       getsda(adap));
+	if ( 0 == getscl(adap) ) {
+		printk("test_bus: %s SCL stuck low!\n",name);
+		sclhi(adap);
+		goto bailout;
+	}
+	if ( 0 == getsda(adap) ) {
+		printk("test_bus: %s SDA unexpected low while SCL high!\n",
+			name);
+		goto bailout;
+	}
+	printk("test_bus: %s passed test.\n",name);
+	return 0;
+bailout:
+	sdahi(adap);
+	sclhi(adap);
+	return -ENODEV;
+#endif
+	return (0);
+}
+
+/* ----- Utility functions
+ */
+
+
+/* Verify the device we want to talk to on the IIC bus really exists. */
+static inline int try_address(struct i2c_algo_iic_data *adap,
+		       unsigned int addr, int retries)
+{
+	int i, ret = -1;
+	short status;
+
+	for (i=0;i<retries;i++) {
+		iic_outw(adap, ITE_I2CSAR, addr);
+		iic_start(adap);
+		if (wait_for_pin(adap, &status) == 0) {
+			if ((status & ITE_I2CHSR_DNE) == 0) { 
+				iic_stop(adap);
+				iic_outw(adap, ITE_I2CFCR, ITE_I2CFCR_FLUSH);
+				ret=1;
+				break;	/* success! */
+			}
+		}
+		iic_stop(adap);
+		udelay(adap->udelay);
+	}
+	DEB2(if (i) printk("try_address: needed %d retries for 0x%x\n",i,
+	                   addr));
+	return ret;
+}
+
+
+static int iic_sendbytes(struct i2c_adapter *i2c_adap,const char *buf,
+                         int count)
+{
+	struct i2c_algo_iic_data *adap = i2c_adap->algo_data;
+	int wrcount=0, timeout;
+	short status;
+	int loops, remainder, i, j;
+	union {
+		char byte[2];
+		unsigned short word;
+	} tmp;
+   
+	iic_outw(adap, ITE_I2CSSAR, (unsigned short)buf[wrcount++]);
+	count--;
+	if (count == 0)
+		return -EIO;
+
+	loops =  count / 32;		/* 32-byte FIFO */
+	remainder = count % 32;
+
+	if(loops) {
+		for(i=0; i<loops; i++) {
+
+			iic_outw(adap, ITE_I2CFBCR, 32);
+			for(j=0; j<32/2; j++) {
+				tmp.byte[1] = buf[wrcount++];
+				tmp.byte[0] = buf[wrcount++];
+				iic_outw(adap, ITE_I2CFDR, tmp.word); 
+			}
+
+			/* status FIFO overrun */
+			iic_inw(adap, ITE_I2CFSR);
+			iic_inw(adap, ITE_I2CFBCR);
+
+			iic_outw(adap, ITE_I2CHCR, ITE_WRITE);	/* Issue WRITE command */
+
+			/* Wait for transmission to complete */
+			timeout = wait_for_pin(adap, &status);
+			if(timeout) {
+				iic_stop(adap);
+				printk("iic_sendbytes: %s write timeout.\n", i2c_adap->name);
+				return -EREMOTEIO; /* got a better one ?? */
+     	}
+			if (status & ITE_I2CHSR_DB) {
+				iic_stop(adap);
+				printk("iic_sendbytes: %s write error - no ack.\n", i2c_adap->name);
+				return -EREMOTEIO; /* got a better one ?? */
+			}
+		}
+	}
+	if(remainder) {
+		iic_outw(adap, ITE_I2CFBCR, remainder);
+		for(i=0; i<remainder/2; i++) {
+			tmp.byte[1] = buf[wrcount++];
+			tmp.byte[0] = buf[wrcount++];
+			iic_outw(adap, ITE_I2CFDR, tmp.word);
+		}
+
+		/* status FIFO overrun */
+		iic_inw(adap, ITE_I2CFSR);
+		iic_inw(adap, ITE_I2CFBCR);
+
+		iic_outw(adap, ITE_I2CHCR, ITE_WRITE);  /* Issue WRITE command */
+
+		timeout = wait_for_pin(adap, &status);
+		if(timeout) {
+			iic_stop(adap);
+			printk("iic_sendbytes: %s write timeout.\n", i2c_adap->name);
+			return -EREMOTEIO; /* got a better one ?? */
+		}
+#ifndef STUB_I2C
+		if (status & ITE_I2CHSR_DB) { 
+			iic_stop(adap);
+			printk("iic_sendbytes: %s write error - no ack.\n", i2c_adap->name);
+			return -EREMOTEIO; /* got a better one ?? */
+		}
+#endif
+	}
+	iic_stop(adap);
+	return wrcount;
+}
+
+
+static int iic_readbytes(struct i2c_adapter *i2c_adap, char *buf, int count,
+	int sread)
+{
+	int rdcount=0, i, timeout;
+	short status;
+	struct i2c_algo_iic_data *adap = i2c_adap->algo_data;
+	int loops, remainder, j;
+	union {
+		char byte[2];
+		unsigned short word;
+	} tmp;
+		
+	loops = count / 32;				/* 32-byte FIFO */
+	remainder = count % 32;
+
+	if(loops) {
+		for(i=0; i<loops; i++) {
+			iic_outw(adap, ITE_I2CFBCR, 32);
+			if (sread)
+				iic_outw(adap, ITE_I2CHCR, ITE_SREAD);
+			else
+				iic_outw(adap, ITE_I2CHCR, ITE_READ);		/* Issue READ command */
+
+			timeout = wait_for_pin(adap, &status);
+			if(timeout) {
+				iic_stop(adap);
+				printk("iic_readbytes:  %s read timeout.\n", i2c_adap->name);
+				return (-1);
+			}
+#ifndef STUB_I2C
+			if (status & ITE_I2CHSR_DB) {
+				iic_stop(adap);
+				printk("iic_readbytes: %s read error - no ack.\n", i2c_adap->name);
+				return (-1);
+			}
+#endif
+
+			timeout = wait_for_fe(adap, &status);
+			if(timeout) {
+				iic_stop(adap);
+				printk("iic_readbytes:  %s FIFO is empty\n", i2c_adap->name);
+				return (-1); 
+			}
+
+			for(j=0; j<32/2; j++) {
+				tmp.word = iic_inw(adap, ITE_I2CFDR);
+				buf[rdcount++] = tmp.byte[1];
+				buf[rdcount++] = tmp.byte[0];
+			}
+
+			/* status FIFO underrun */
+			iic_inw(adap, ITE_I2CFSR);
+
+		}
+	}
+
+
+	if(remainder) {
+		remainder=(remainder+1)/2 * 2;
+		iic_outw(adap, ITE_I2CFBCR, remainder);
+		if (sread)
+			iic_outw(adap, ITE_I2CHCR, ITE_SREAD);
+		else
+		iic_outw(adap, ITE_I2CHCR, ITE_READ);		/* Issue READ command */
+
+		timeout = wait_for_pin(adap, &status);
+		if(timeout) {
+			iic_stop(adap);
+			printk("iic_readbytes:  %s read timeout.\n", i2c_adap->name);
+			return (-1);
+		}
+#ifndef STUB_I2C
+		if (status & ITE_I2CHSR_DB) {
+			iic_stop(adap);
+			printk("iic_readbytes: %s read error - no ack.\n", i2c_adap->name);
+			return (-1);
+		}
+#endif
+		timeout = wait_for_fe(adap, &status);
+		if(timeout) {
+			iic_stop(adap);
+			printk("iic_readbytes:  %s FIFO is empty\n", i2c_adap->name);
+			return (-1);
+		}         
+
+		for(i=0; i<(remainder+1)/2; i++) {
+			tmp.word = iic_inw(adap, ITE_I2CFDR);
+			buf[rdcount++] = tmp.byte[1];
+			buf[rdcount++] = tmp.byte[0];
+		}
+
+		/* status FIFO underrun */
+		iic_inw(adap, ITE_I2CFSR);
+
+	}
+
+	iic_stop(adap);
+	return rdcount;
+}
+
+
+/* This function implements combined transactions.  Combined
+ * transactions consist of combinations of reading and writing blocks of data.
+ * Each transfer (i.e. a read or a write) is separated by a repeated start
+ * condition.
+ */
+#if 0
+static int iic_combined_transaction(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num) 
+{
+   int i;
+   struct i2c_msg *pmsg;
+   int ret;
+
+   DEB2(printk("Beginning combined transaction\n"));
+
+   for(i=0; i<(num-1); i++) {
+      pmsg = &msgs[i];
+      if(pmsg->flags & I2C_M_RD) {
+         DEB2(printk("  This one is a read\n"));
+         ret = iic_readbytes(i2c_adap, pmsg->buf, pmsg->len, IIC_COMBINED_XFER);
+      }
+      else if(!(pmsg->flags & I2C_M_RD)) {
+         DEB2(printk("This one is a write\n"));
+         ret = iic_sendbytes(i2c_adap, pmsg->buf, pmsg->len, IIC_COMBINED_XFER);
+      }
+   }
+   /* Last read or write segment needs to be terminated with a stop */
+   pmsg = &msgs[i];
+
+   if(pmsg->flags & I2C_M_RD) {
+      DEB2(printk("Doing the last read\n"));
+      ret = iic_readbytes(i2c_adap, pmsg->buf, pmsg->len, IIC_SINGLE_XFER);
+   }
+   else if(!(pmsg->flags & I2C_M_RD)) {
+      DEB2(printk("Doing the last write\n"));
+      ret = iic_sendbytes(i2c_adap, pmsg->buf, pmsg->len, IIC_SINGLE_XFER);
+   }
+
+   return ret;
+}
+#endif
+
+
+/* Whenever we initiate a transaction, the first byte clocked
+ * onto the bus after the start condition is the address (7 bit) of the
+ * device we want to talk to.  This function manipulates the address specified
+ * so that it makes sense to the hardware when written to the IIC peripheral.
+ *
+ * Note: 10 bit addresses are not supported in this driver, although they are
+ * supported by the hardware.  This functionality needs to be implemented.
+ */
+static inline int iic_doAddress(struct i2c_algo_iic_data *adap,
+                                struct i2c_msg *msg, int retries) 
+{
+	unsigned short flags = msg->flags;
+	unsigned int addr;
+	int ret;
+
+/* Ten bit addresses not supported right now */
+	if ( (flags & I2C_M_TEN)  ) { 
+#if 0
+		addr = 0xf0 | (( msg->addr >> 7) & 0x03);
+		DEB2(printk("addr0: %d\n",addr));
+		ret = try_address(adap, addr, retries);
+		if (ret!=1) {
+			printk("iic_doAddress: died at extended address code.\n");
+			return -EREMOTEIO;
+		}
+		iic_outw(adap,msg->addr & 0x7f);
+		if (ret != 1) {
+			printk("iic_doAddress: died at 2nd address code.\n");
+			return -EREMOTEIO;
+		}
+		if ( flags & I2C_M_RD ) {
+			i2c_repstart(adap);
+			addr |= 0x01;
+			ret = try_address(adap, addr, retries);
+			if (ret!=1) {
+				printk("iic_doAddress: died at extended address code.\n");
+				return -EREMOTEIO;
+			}
+		}
+#endif
+	} else {
+
+		addr = ( msg->addr << 1 );
+
+#if 0
+		if (flags & I2C_M_RD )
+			addr |= 1;
+		if (flags & I2C_M_REV_DIR_ADDR )
+			addr ^= 1;
+#endif
+
+		if (iic_inw(adap, ITE_I2CSAR) != addr) {
+			iic_outw(adap, ITE_I2CSAR, addr);
+			ret = try_address(adap, addr, retries);
+			if (ret!=1) {
+				printk("iic_doAddress: died at address code.\n");
+				return -EREMOTEIO;
+			}
+		}
+
+  }
+
+	return 0;
+}
+
+
+/* Description: Prepares the controller for a transaction (clearing status
+ * registers, data buffers, etc), and then calls either iic_readbytes or
+ * iic_sendbytes to do the actual transaction.
+ *
+ * still to be done: Before we issue a transaction, we should
+ * verify that the bus is not busy or in some unknown state.
+ */
+static int iic_xfer(struct i2c_adapter *i2c_adap,
+		    struct i2c_msg msgs[], 
+		    int num)
+{
+	struct i2c_algo_iic_data *adap = i2c_adap->algo_data;
+	struct i2c_msg *pmsg;
+	int i = 0;
+	int ret, timeout;
+    
+	pmsg = &msgs[i];
+
+	if(!pmsg->len) {
+		DEB2(printk("iic_xfer: read/write length is 0\n");)
+		return -EIO;
+	}
+	if(!(pmsg->flags & I2C_M_RD) && (!(pmsg->len)%2) ) {
+		DEB2(printk("iic_xfer: write buffer length is not odd\n");)
+		return -EIO; 
+	}
+
+	/* Wait for any pending transfers to complete */
+	timeout = wait_for_bb(adap);
+	if (timeout) {
+		DEB2(printk("iic_xfer: Timeout waiting for host not busy\n");)
+		return -EIO;
+	}
+
+	/* Flush FIFO */
+	iic_outw(adap, ITE_I2CFCR, ITE_I2CFCR_FLUSH);
+
+	/* Load address */
+	ret = iic_doAddress(adap, pmsg, i2c_adap->retries);
+	if (ret)
+		return -EIO;
+
+#if 0
+	/* Combined transaction (read and write) */
+	if(num > 1) {
+           DEB2(printk("iic_xfer: Call combined transaction\n"));
+           ret = iic_combined_transaction(i2c_adap, msgs, num);
+  }
+#endif
+
+	DEB3(printk("iic_xfer: Msg %d, addr=0x%x, flags=0x%x, len=%d\n",
+		i, msgs[i].addr, msgs[i].flags, msgs[i].len);)
+
+	if(pmsg->flags & I2C_M_RD) 		/* Read */
+		ret = iic_readbytes(i2c_adap, pmsg->buf, pmsg->len, 0);
+	else {													/* Write */ 
+		udelay(1000);
+		ret = iic_sendbytes(i2c_adap, pmsg->buf, pmsg->len);
+	}
+
+	if (ret != pmsg->len)
+		DEB3(printk("iic_xfer: error or fail on read/write %d bytes.\n",ret)); 
+	else
+		DEB3(printk("iic_xfer: read/write %d bytes.\n",ret));
+
+	return ret;
+}
+
+
+/* Implements device specific ioctls.  Higher level ioctls can
+ * be found in i2c-core.c and are typical of any i2c controller (specifying
+ * slave address, timeouts, etc).  These ioctls take advantage of any hardware
+ * features built into the controller for which this algorithm-adapter set
+ * was written.  These ioctls allow you to take control of the data and clock
+ * lines and set the either high or low,
+ * similar to a GPIO pin.
+ */
+static int algo_control(struct i2c_adapter *adapter, 
+	unsigned int cmd, unsigned long arg)
+{
+
+  struct i2c_algo_iic_data *adap = adapter->algo_data;
+  struct i2c_iic_msg s_msg;
+  char *buf;
+	int ret;
+
+  if (cmd == I2C_SREAD) {
+		if(copy_from_user(&s_msg, (struct i2c_iic_msg *)arg, 
+				sizeof(struct i2c_iic_msg))) 
+			return -EFAULT;
+		buf = kmalloc(s_msg.len, GFP_KERNEL);
+		if (buf== NULL)
+			return -ENOMEM;
+
+		/* Flush FIFO */
+		iic_outw(adap, ITE_I2CFCR, ITE_I2CFCR_FLUSH);
+
+		/* Load address */
+		iic_outw(adap, ITE_I2CSAR,s_msg.addr<<1);
+		iic_outw(adap, ITE_I2CSSAR,s_msg.waddr & 0xff);
+
+		ret = iic_readbytes(adapter, buf, s_msg.len, 1);
+		if (ret>=0) {
+			if(copy_to_user( s_msg.buf, buf, s_msg.len) ) 
+				ret = -EFAULT;
+		}
+		kfree(buf);
+	}
+	return 0;
+}
+
+
+static u32 iic_func(struct i2c_adapter *adap)
+{
+	return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR | 
+	       I2C_FUNC_PROTOCOL_MANGLING; 
+}
+
+/* -----exported algorithm data: -------------------------------------	*/
+
+static struct i2c_algorithm iic_algo = {
+	"ITE IIC algorithm",
+	I2C_ALGO_IIC,
+	iic_xfer,		/* master_xfer	*/
+	NULL,				/* smbus_xfer	*/
+	NULL,				/* slave_xmit		*/
+	NULL,				/* slave_recv		*/
+	algo_control,			/* ioctl		*/
+	iic_func,			/* functionality	*/
+};
+
+
+/* 
+ * registering functions to load algorithms at runtime 
+ */
+int i2c_iic_add_bus(struct i2c_adapter *adap)
+{
+	int i;
+	short status;
+	struct i2c_algo_iic_data *iic_adap = adap->algo_data;
+
+	if (iic_test) {
+		int ret = test_bus(iic_adap, adap->name);
+		if (ret<0)
+			return -ENODEV;
+	}
+
+	DEB2(printk("i2c-algo-ite: hw routines for %s registered.\n",
+	            adap->name));
+
+	/* register new adapter to i2c module... */
+
+	adap->id |= iic_algo.id;
+	adap->algo = &iic_algo;
+
+	adap->timeout = 100;	/* default values, should	*/
+	adap->retries = 3;		/* be replaced by defines	*/
+	adap->flags = 0;
+
+#ifdef MODULE
+	MOD_INC_USE_COUNT;
+#endif
+
+	i2c_add_adapter(adap);
+	iic_init(iic_adap);
+
+	/* scan bus */
+	/* By default scanning the bus is turned off. */
+	if (iic_scan) {
+		printk(KERN_INFO " i2c-algo-ite: scanning bus %s.\n",
+		       adap->name);
+		for (i = 0x00; i < 0xff; i+=2) {
+			iic_outw(iic_adap, ITE_I2CSAR, i);
+			iic_start(iic_adap);
+			if ( (wait_for_pin(iic_adap, &status) == 0) && 
+			    ((status & ITE_I2CHSR_DNE) == 0) ) { 
+				printk(KERN_INFO "\n(%02x)\n",i>>1); 
+			} else {
+				printk(KERN_INFO "."); 
+				iic_reset(iic_adap);
+			}
+			udelay(iic_adap->udelay);
+		}
+	}
+	return 0;
+}
+
+
+int i2c_iic_del_bus(struct i2c_adapter *adap)
+{
+	int res;
+	if ((res = i2c_del_adapter(adap)) < 0)
+		return res;
+	DEB2(printk("i2c-algo-ite: adapter unregistered: %s\n",adap->name));
+
+#ifdef MODULE
+	MOD_DEC_USE_COUNT;
+#endif
+	return 0;
+}
+
+
+int __init i2c_algo_iic_init (void)
+{
+	printk(KERN_INFO "ITE iic (i2c) algorithm module\n");
+	return 0;
+}
+
+
+void i2c_algo_iic_exit(void)
+{
+	return;
+}
+
+
+EXPORT_SYMBOL(i2c_iic_add_bus);
+EXPORT_SYMBOL(i2c_iic_del_bus);
+
+/* The MODULE_* macros resolve to nothing if MODULES is not defined
+ * when this file is compiled.
+ */
+MODULE_AUTHOR("MontaVista Software <www.mvista.com>");
+MODULE_DESCRIPTION("ITE iic algorithm");
+
+MODULE_PARM(iic_test, "i");
+MODULE_PARM(iic_scan, "i");
+MODULE_PARM(i2c_debug,"i");
+
+MODULE_PARM_DESC(iic_test, "Test if the I2C bus is available");
+MODULE_PARM_DESC(iic_scan, "Scan for active chips on the bus");
+MODULE_PARM_DESC(i2c_debug,
+        "debug level - 0 off; 1 normal; 2,3 more verbose; 9 iic-protocol");
+
+
+/* This function resolves to init_module (the function invoked when a module
+ * is loaded via insmod) when this file is compiled with MODULES defined.
+ * Otherwise (i.e. if you want this driver statically linked to the kernel),
+ * a pointer to this function is stored in a table and called
+ * during the intialization of the kernel (in do_basic_setup in /init/main.c) 
+ *
+ * All this functionality is complements of the macros defined in linux/init.h
+ */
+module_init(i2c_algo_iic_init);
+
+
+/* If MODULES is defined when this file is compiled, then this function will
+ * resolved to cleanup_module.
+ */
+module_exit(i2c_algo_iic_exit);
diff -u --recursive --new-file v2.4.9/linux/drivers/i2c/i2c-ite.h linux/drivers/i2c/i2c-ite.h
--- v2.4.9/linux/drivers/i2c/i2c-ite.h	Wed Dec 31 16:00:00 1969
+++ linux/drivers/i2c/i2c-ite.h	Sun Sep  9 10:43:02 2001
@@ -0,0 +1,117 @@
+/*
+   --------------------------------------------------------------------
+   i2c-ite.h: Global defines for the I2C controller on board the    
+                 ITE MIPS processor.                                
+   --------------------------------------------------------------------
+   Hai-Pao Fan, MontaVista Software, Inc.
+   hpfan@mvista.com or source@mvista.com
+
+   Copyright 2001 MontaVista Software Inc.
+
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+
+ */
+
+#ifndef I2C_ITE_H
+#define I2C_ITE_H 1
+
+#include <asm/it8172/it8172.h>
+
+/* I2C Registers */
+#define ITE_I2CHCR	IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x30
+#define ITE_I2CHSR	IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x34
+#define ITE_I2CSAR	IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x38
+#define ITE_I2CSSAR	IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x3c
+#define ITE_I2CCKCNT	IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x48
+#define ITE_I2CSHDR	IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x4c
+#define ITE_I2CRSUR	IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x50
+#define ITE_I2CPSUR	IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x54
+
+#define ITE_I2CFDR	IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x70
+#define ITE_I2CFBCR	IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x74
+#define ITE_I2CFCR	IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x78
+#define ITE_I2CFSR	IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x7c
+
+
+/* Host Control Register ITE_I2CHCR */
+#define	ITE_I2CHCR_HCE	0x01	/* Enable I2C Host Controller */
+#define	ITE_I2CHCR_IE	0x02	/* Enable the interrupt after completing
+				   the current transaction */
+#define ITE_I2CHCR_CP_W	0x00	/* bit2-4 000 - Write */
+#define	ITE_I2CHCR_CP_R	0x08	/*	  010 - Current address read */
+#define	ITE_I2CHCR_CP_S	0x10	/*	  100 - Sequential read */
+#define ITE_I2CHCR_ST	0x20	/* Initiates the I2C host controller to execute
+				   the command and send the data programmed in
+				   all required registers to I2C bus */
+#define ITE_CMD		ITE_I2CHCR_HCE | ITE_I2CHCR_IE | ITE_I2CHCR_ST
+#define ITE_WRITE	ITE_CMD | ITE_I2CHCR_CP_W
+#define ITE_READ	ITE_CMD | ITE_I2CHCR_CP_R
+#define ITE_SREAD	ITE_CMD | ITE_I2CHCR_CP_S
+
+/* Host Status Register ITE_I2CHSR */
+#define	ITE_I2CHSR_DB	0x01	/* Device is busy, receives NACK response except
+				   in the first and last bytes */
+#define	ITE_I2CHSR_DNE	0x02	/* Target address on I2C bus does not exist */
+#define	ITE_I2CHSR_TDI	0x04	/* R/W Transaction on I2C bus was completed */
+#define	ITE_I2CHSR_HB	0x08	/* Host controller is processing transactions */
+#define	ITE_I2CHSR_FER	0x10	/* Error occurs in the FIFO */
+
+/* Slave Address Register ITE_I2CSAR */
+#define	ITE_I2CSAR_SA_MASK	0xfe	/* Target I2C device address */
+#define	ITE_I2CSAR_ASO		0x0100	/* Output 1/0 to I2CAS port when the
+					   next slave address is addressed */
+
+/* Slave Sub-address Register ITE_I2CSSAR */
+#define	ITE_I2CSSAR_SUBA_MASK	0xff	/* Target I2C device sub-address */
+
+/* Clock Counter Register ITE_I2CCKCNT */
+#define	ITE_I2CCKCNT_STOP	0x00	/* stop I2C clock */
+#define	ITE_I2CCKCNT_HPCC_MASK	0x7f	/* SCL high period counter */
+#define	ITE_I2CCKCNT_LPCC_MASK	0x7f00	/* SCL low period counter */
+
+/* START Hold Time Register ITE_I2CSHDR */
+/* value is counted based on 16 MHz internal clock */
+#define ITE_I2CSHDR_FM	0x0a	/* START condition at fast mode */
+#define	ITE_I2CSHDR_SM	0x47	/* START contition at standard mode */
+
+/* (Repeated) START Setup Time Register ITE_I2CRSUR */
+/* value is counted based on 16 MHz internal clock */
+#define	ITE_I2CRSUR_FM	0x0a	/* repeated START condition at fast mode */
+#define	ITE_I2CRSUR_SM	0x50	/* repeated START condition at standard mode */
+
+/* STOP setup Time Register ITE_I2CPSUR */
+
+/* FIFO Data Register ITE_I2CFDR */
+#define	ITE_I2CFDR_MASK		0xff
+
+/* FIFO Byte Count Register ITE_I2CFBCR */
+#define ITE_I2CFBCR_MASK	0x3f
+
+/* FIFO Control Register ITE_I2CFCR */
+#define	ITE_I2CFCR_FLUSH	0x01	/* Flush FIFO and reset the FIFO point
+					   and I2CFSR */
+/* FIFO Status Register ITE_I2CFSR */
+#define	ITE_I2CFSR_FO	0x01	/* FIFO is overrun when write */
+#define	ITE_I2CFSR_FU	0x02	/* FIFO is underrun when read */
+#define	ITE_I2CFSR_FF	0x04	/* FIFO is full when write */
+#define	ITE_I2CFSR_FE	0x08	/* FIFO is empty when read */
+
+#endif  /* I2C_ITE_H */
diff -u --recursive --new-file v2.4.9/linux/drivers/i2o/i2o_block.c linux/drivers/i2o/i2o_block.c
--- v2.4.9/linux/drivers/i2o/i2o_block.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/i2o/i2o_block.c	Mon Sep 10 12:42:31 2001
@@ -1141,6 +1141,8 @@
 	switch (cmd) {
 		case BLKGETSIZE:
 			return put_user(i2ob[minor].nr_sects, (long *) arg);
+		case BLKGETSIZE64:
+			return put_user((u64)i2ob[minor].nr_sects << 9, (u64 *)arg);
 
 		case HDIO_GETGEO:
 		{
@@ -1195,9 +1197,6 @@
 	if(!dev->i2odev)
 		return 0;
 
-	/* Sync the device so we don't get errors */
-	fsync_dev(inode->i_rdev);
-
 	if (dev->refcnt <= 0)
 		printk(KERN_ALERT "i2ob_release: refcount(%d) <= 0\n", dev->refcnt);
 	dev->refcnt--;
@@ -1857,16 +1856,14 @@
 
 static struct gendisk i2ob_gendisk = 
 {
-	MAJOR_NR,
-	"i2o/hd",
-	4,
-	1<<4,
-	i2ob,
-	i2ob_sizes,
-	MAX_I2OB,
-	NULL,
-	NULL,
-	&i2ob_fops,
+	major:		MAJOR_NR,
+	major_name:	"i2o/hd",
+	minor_shift:	4,
+	max_p:		1<<4,
+	part:		i2ob,
+	sizes:		i2ob_sizes,
+	nr_real:	MAX_I2OB,
+	fops:		&i2ob_fops,
 };
 
 
@@ -1978,9 +1975,8 @@
 
 	/*
 	 *	Adding i2ob_gendisk into the gendisk list.
-	 */	
-	i2ob_gendisk.next = gendisk_head;
-	gendisk_head = &i2ob_gendisk;
+	 */
+	add_gendisk(&i2ob_gendisk);
 
 	return 0;
 }
@@ -2050,20 +2046,6 @@
 	 */
 	blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
 
-	/*
-	 *	Why isnt register/unregister gendisk in the kernel ???
-	 */
-
-	if (gendisk_head == &i2ob_gendisk) {
-		gendisk_head = i2ob_gendisk.next;
-		}
-	else {
-		for (gdp = gendisk_head; gdp; gdp = gdp->next)
-			if (gdp->next == &i2ob_gendisk)
-			{
-				gdp->next = i2ob_gendisk.next;
-				break;
-			}
-	}
+	del_gendisk(&i2ob_gendisk);
 }
 #endif
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/Config.in linux/drivers/ide/Config.in
--- v2.4.9/linux/drivers/ide/Config.in	Mon Aug 27 12:41:41 2001
+++ linux/drivers/ide/Config.in	Fri Sep  7 09:28:38 2001
@@ -135,7 +135,7 @@
 	 if [ "$CONFIG_BLK_DEV_IDEDISK" = "y" -a "$CONFIG_EXPERIMENTAL" = "y" ]; then
 	    bool '    PROMISE DC4030 support (EXPERIMENTAL)' CONFIG_BLK_DEV_PDC4030
 	 fi
-	 bool '    QDI QD6580 support' CONFIG_BLK_DEV_QD6580
+	 bool '    QDI QD65xx support' CONFIG_BLK_DEV_QD65XX
 	 bool '    UMC-8672 support' CONFIG_BLK_DEV_UMC8672
       fi
    fi
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/Makefile linux/drivers/ide/Makefile
--- v2.4.9/linux/drivers/ide/Makefile	Mon Aug 27 12:41:41 2001
+++ linux/drivers/ide/Makefile	Fri Sep  7 09:28:38 2001
@@ -56,7 +56,7 @@
 ide-obj-$(CONFIG_BLK_DEV_PDC4030)	+= pdc4030.o
 ide-obj-$(CONFIG_BLK_DEV_PDC_ADMA)	+= pdcadma.o
 ide-obj-$(CONFIG_BLK_DEV_PIIX)		+= piix.o
-ide-obj-$(CONFIG_BLK_DEV_QD6580)	+= qd6580.o
+ide-obj-$(CONFIG_BLK_DEV_QD65XX)	+= qd65xx.o
 ide-obj-$(CONFIG_BLK_DEV_IDE_RAPIDE)	+= rapide.o
 ide-obj-$(CONFIG_BLK_DEV_RZ1000)	+= rz1000.o
 ide-obj-$(CONFIG_BLK_DEV_SIS5513)	+= sis5513.o
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/amd7409.c linux/drivers/ide/amd7409.c
--- v2.4.9/linux/drivers/ide/amd7409.c	Sat May 19 17:43:06 2001
+++ linux/drivers/ide/amd7409.c	Wed Dec 31 16:00:00 1969
@@ -1,471 +0,0 @@
-/*
- * linux/drivers/ide/amd7409.c		Version 0.05	June 9, 2000
- *
- * Copyright (C) 1999-2000		Andre Hedrick <andre@linux-ide.org>
- * May be copied or modified under the terms of the GNU General Public License
- *
- */
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/delay.h>
-#include <linux/timer.h>
-#include <linux/mm.h>
-#include <linux/ioport.h>
-#include <linux/blkdev.h>
-#include <linux/hdreg.h>
-
-#include <linux/interrupt.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-
-#include "ide_modes.h"
-
-#define DISPLAY_VIPER_TIMINGS
-
-#if defined(DISPLAY_VIPER_TIMINGS) && defined(CONFIG_PROC_FS)
-#include <linux/stat.h>
-#include <linux/proc_fs.h>
-
-static int amd7409_get_info(char *, char **, off_t, int);
-extern int (*amd7409_display_info)(char *, char **, off_t, int); /* ide-proc.c */
-extern char *ide_media_verbose(ide_drive_t *);
-static struct pci_dev *bmide_dev;
-
-static int amd7409_get_info (char *buffer, char **addr, off_t offset, int count)
-{
-	char *p = buffer;
-	u32 bibma = pci_resource_start(bmide_dev, 4);
-	u8 c0 = 0, c1 = 0;
-
-	/*
-	 * at that point bibma+0x2 et bibma+0xa are byte registers
-	 * to investigate:
-	 */
-	c0 = inb_p((unsigned short)bibma + 0x02);
-	c1 = inb_p((unsigned short)bibma + 0x0a);
-
-	p += sprintf(p, "\n                                AMD 7409 VIPER Chipset.\n");
-	p += sprintf(p, "--------------- Primary Channel ---------------- Secondary Channel -------------\n");
-	p += sprintf(p, "                %sabled                         %sabled\n",
-			(c0&0x80) ? "dis" : " en",
-			(c1&0x80) ? "dis" : " en");
-	p += sprintf(p, "--------------- drive0 --------- drive1 -------- drive0 ---------- drive1 ------\n");
-	p += sprintf(p, "DMA enabled:    %s              %s             %s               %s\n",
-			(c0&0x20) ? "yes" : "no ", (c0&0x40) ? "yes" : "no ",
-			(c1&0x20) ? "yes" : "no ", (c1&0x40) ? "yes" : "no " );
-	p += sprintf(p, "UDMA\n");
-	p += sprintf(p, "DMA\n");
-	p += sprintf(p, "PIO\n");
-
-	return p-buffer;	/* => must be less than 4k! */
-}
-#endif  /* defined(DISPLAY_VIPER_TIMINGS) && defined(CONFIG_PROC_FS) */
-
-byte amd7409_proc = 0;
-
-extern char *ide_xfer_verbose (byte xfer_rate);
-
-static unsigned int amd7409_swdma_check (struct pci_dev *dev)
-{
-	unsigned int class_rev;
-	pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
-	class_rev &= 0xff;
-	return ((int) (class_rev >= 7) ? 1 : 0);
-}
-
-static int amd7409_swdma_error(ide_drive_t *drive)
-{
-	printk("%s: single-word DMA not support (revision < C4)\n", drive->name);
-	return 0;
-}
-
-/*
- * Here is where all the hard work goes to program the chipset.
- *
- */
-static int amd7409_tune_chipset (ide_drive_t *drive, byte speed)
-{
-	ide_hwif_t *hwif	= HWIF(drive);
-	struct pci_dev *dev	= hwif->pci_dev;
-	int err			= 0;
-	byte unit		= (drive->select.b.unit & 0x01);
-#ifdef CONFIG_BLK_DEV_IDEDMA
-	unsigned long dma_base	= hwif->dma_base;
-#endif /* CONFIG_BLK_DEV_IDEDMA */
-	byte drive_pci		= 0x00;
-	byte drive_pci2		= 0x00;
-	byte ultra_timing	= 0x00;
-	byte dma_pio_timing	= 0x00;
-	byte pio_timing		= 0x00;
-
-        switch (drive->dn) {
-		case 0: drive_pci = 0x53; drive_pci2 = 0x4b; break;
-		case 1: drive_pci = 0x52; drive_pci2 = 0x4a; break;
-		case 2: drive_pci = 0x51; drive_pci2 = 0x49; break;
-		case 3: drive_pci = 0x50; drive_pci2 = 0x48; break;
-		default:
-                        return -1;
-        }
-
-	pci_read_config_byte(dev, drive_pci, &ultra_timing);
-	pci_read_config_byte(dev, drive_pci2, &dma_pio_timing);
-	pci_read_config_byte(dev, 0x4c, &pio_timing);
-
-#ifdef DEBUG
-	printk("%s: UDMA 0x%02x DMAPIO 0x%02x PIO 0x%02x ",
-		drive->name, ultra_timing, dma_pio_timing, pio_timing);
-#endif
-
-	ultra_timing &= ~0xC7;
-	dma_pio_timing &= ~0xFF;
-	pio_timing &= ~(0x03 << drive->dn);
-
-#ifdef DEBUG
-	printk(":: UDMA 0x%02x DMAPIO 0x%02x PIO 0x%02x ",
-		ultra_timing, dma_pio_timing, pio_timing);
-#endif
-
-	switch(speed) {
-#ifdef CONFIG_BLK_DEV_IDEDMA
-		case XFER_UDMA_4:
-			ultra_timing |= 0x45;
-			dma_pio_timing |= 0x20;
-			break;
-		case XFER_UDMA_3:
-			ultra_timing |= 0x44;
-			dma_pio_timing |= 0x20;
-			break;
-		case XFER_UDMA_2:
-			ultra_timing |= 0x40;
-			dma_pio_timing |= 0x20;
-			break;
-		case XFER_UDMA_1:
-			ultra_timing |= 0x41;
-			dma_pio_timing |= 0x20;
-			break;
-		case XFER_UDMA_0:
-			ultra_timing |= 0x42;
-			dma_pio_timing |= 0x20;
-			break;
-		case XFER_MW_DMA_2:
-			dma_pio_timing |= 0x20;
-			break;
-		case XFER_MW_DMA_1:
-			dma_pio_timing |= 0x21;
-			break;
-		case XFER_MW_DMA_0:
-			dma_pio_timing |= 0x77;
-			break;
-		case XFER_SW_DMA_2:
-			if (!amd7409_swdma_check(dev))
-				return amd7409_swdma_error(drive);
-			dma_pio_timing |= 0x42;
-			break;
-		case XFER_SW_DMA_1:
-			if (!amd7409_swdma_check(dev))
-				return amd7409_swdma_error(drive);
-			dma_pio_timing |= 0x65;
-			break;
-		case XFER_SW_DMA_0:
-			if (!amd7409_swdma_check(dev))
-				return amd7409_swdma_error(drive);
-			dma_pio_timing |= 0xA8;
-			break;
-#endif /* CONFIG_BLK_DEV_IDEDMA */
-		case XFER_PIO_4:
-			dma_pio_timing |= 0x20;
-			break;
-		case XFER_PIO_3:
-			dma_pio_timing |= 0x22;
-			break;
-		case XFER_PIO_2:
-			dma_pio_timing |= 0x42;
-			break;
-		case XFER_PIO_1:
-			dma_pio_timing |= 0x65;
-			break;
-		case XFER_PIO_0:
-		default:
-			dma_pio_timing |= 0xA8;
-			break;
-        }
-
-	pio_timing |= (0x03 << drive->dn);
-
-	if (!drive->init_speed)
-		drive->init_speed = speed;
-
-#ifdef CONFIG_BLK_DEV_IDEDMA
-	pci_write_config_byte(dev, drive_pci, ultra_timing);
-#endif /* CONFIG_BLK_DEV_IDEDMA */
-	pci_write_config_byte(dev, drive_pci2, dma_pio_timing);
-	pci_write_config_byte(dev, 0x4c, pio_timing);
-
-#ifdef DEBUG
-	printk(":: UDMA 0x%02x DMAPIO 0x%02x PIO 0x%02x\n",
-		ultra_timing, dma_pio_timing, pio_timing);
-#endif
-
-#ifdef CONFIG_BLK_DEV_IDEDMA
-	if (speed > XFER_PIO_4) {
-		outb(inb(dma_base+2)|(1<<(5+unit)), dma_base+2);
-	} else {
-		outb(inb(dma_base+2) & ~(1<<(5+unit)), dma_base+2);
-	}
-#endif /* CONFIG_BLK_DEV_IDEDMA */
-
-	err = ide_config_drive_speed(drive, speed);
-	drive->current_speed = speed;
-	return (err);
-}
-
-static void config_chipset_for_pio (ide_drive_t *drive)
-{
-	unsigned short eide_pio_timing[6] = {960, 480, 240, 180, 120, 90};
-	unsigned short xfer_pio	= drive->id->eide_pio_modes;
-	byte			timing, speed, pio;
-
-	pio = ide_get_best_pio_mode(drive, 255, 5, NULL);
-
-	if (xfer_pio> 4)
-		xfer_pio = 0;
-
-	if (drive->id->eide_pio_iordy > 0) {
-		for (xfer_pio = 5;
-			xfer_pio>0 &&
-			drive->id->eide_pio_iordy>eide_pio_timing[xfer_pio];
-			xfer_pio--);
-	} else {
-		xfer_pio = (drive->id->eide_pio_modes & 4) ? 0x05 :
-			   (drive->id->eide_pio_modes & 2) ? 0x04 :
-			   (drive->id->eide_pio_modes & 1) ? 0x03 :
-			   (drive->id->tPIO & 2) ? 0x02 :
-			   (drive->id->tPIO & 1) ? 0x01 : xfer_pio;
-	}
-
-	timing = (xfer_pio >= pio) ? xfer_pio : pio;
-
-	switch(timing) {
-		case 4: speed = XFER_PIO_4;break;
-		case 3: speed = XFER_PIO_3;break;
-		case 2: speed = XFER_PIO_2;break;
-		case 1: speed = XFER_PIO_1;break;
-		default:
-			speed = (!drive->id->tPIO) ? XFER_PIO_0 : XFER_PIO_SLOW;
-			break;
-	}
-	(void) amd7409_tune_chipset(drive, speed);
-	drive->current_speed = speed;
-}
-
-static void amd7409_tune_drive (ide_drive_t *drive, byte pio)
-{
-	byte speed;
-	switch(pio) {
-		case 4:		speed = XFER_PIO_4;break;
-		case 3:		speed = XFER_PIO_3;break;
-		case 2:		speed = XFER_PIO_2;break;
-		case 1:		speed = XFER_PIO_1;break;
-		default:	speed = XFER_PIO_0;break;
-	}
-	(void) amd7409_tune_chipset(drive, speed);
-}
-
-#ifdef CONFIG_BLK_DEV_IDEDMA
-/*
- * This allows the configuration of ide_pci chipset registers
- * for cards that learn about the drive's UDMA, DMA, PIO capabilities
- * after the drive is reported by the OS.
- */
-static int config_chipset_for_dma (ide_drive_t *drive)
-{
-	struct hd_driveid *id	= drive->id;
-	byte udma_66		= eighty_ninty_three(drive);
-	byte udma_100		= 0;
-	byte speed		= 0x00;
-	int  rval;
-
-	if ((id->dma_ultra & 0x0020) && (udma_66)&& (udma_100)) {
-		speed = XFER_UDMA_5;
-	} else if ((id->dma_ultra & 0x0010) && (udma_66)) {
-		speed = XFER_UDMA_4;
-	} else if ((id->dma_ultra & 0x0008) && (udma_66)) {
-		speed = XFER_UDMA_3;
-	} else if (id->dma_ultra & 0x0004) {
-		speed = XFER_UDMA_2;
-	} else if (id->dma_ultra & 0x0002) {
-		speed = XFER_UDMA_1;
-	} else if (id->dma_ultra & 0x0001) {
-		speed = XFER_UDMA_0;
-	} else if (id->dma_mword & 0x0004) {
-		speed = XFER_MW_DMA_2;
-	} else if (id->dma_mword & 0x0002) {
-		speed = XFER_MW_DMA_1;
-	} else if (id->dma_mword & 0x0001) {
-		speed = XFER_MW_DMA_0;
-	} else {
-		return ((int) ide_dma_off_quietly);
-	}
-
-	(void) amd7409_tune_chipset(drive, speed);
-
-	rval = (int)(	((id->dma_ultra >> 11) & 3) ? ide_dma_on :
-			((id->dma_ultra >> 8) & 7) ? ide_dma_on :
-			((id->dma_mword >> 8) & 7) ? ide_dma_on :
-						     ide_dma_off_quietly);
-
-	return rval;
-}
-
-
-
-static int config_drive_xfer_rate (ide_drive_t *drive)
-{
-	struct hd_driveid *id = drive->id;
-	ide_dma_action_t dma_func = ide_dma_on;
-
-	if (id && (id->capability & 1) && HWIF(drive)->autodma) {
-		/* Consult the list of known "bad" drives */
-		if (ide_dmaproc(ide_dma_bad_drive, drive)) {
-			dma_func = ide_dma_off;
-			goto fast_ata_pio;
-		}
-		dma_func = ide_dma_off_quietly;
-		if (id->field_valid & 4) {
-			if (id->dma_ultra & 0x002F) {
-				/* Force if Capable UltraDMA */
-				dma_func = config_chipset_for_dma(drive);
-				if ((id->field_valid & 2) &&
-				    (dma_func != ide_dma_on))
-					goto try_dma_modes;
-			}
-		} else if (id->field_valid & 2) {
-try_dma_modes:
-			if ((id->dma_mword & 0x0007) ||
-			    ((id->dma_1word & 0x007) &&
-			     (amd7409_swdma_check(HWIF(drive)->pci_dev)))) {
-				/* Force if Capable regular DMA modes */
-				dma_func = config_chipset_for_dma(drive);
-				if (dma_func != ide_dma_on)
-					goto no_dma_set;
-			}
-			
-		} else if (ide_dmaproc(ide_dma_good_drive, drive)) {
-			if (id->eide_dma_time > 150) {
-				goto no_dma_set;
-			}
-			/* Consult the list of known "good" drives */
-			dma_func = config_chipset_for_dma(drive);
-			if (dma_func != ide_dma_on)
-				goto no_dma_set;
-		} else {
-			goto fast_ata_pio;
-		}
-	} else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
-		dma_func = ide_dma_off_quietly;
-no_dma_set:
-
-		config_chipset_for_pio(drive);
-	}
-	return HWIF(drive)->dmaproc(dma_func, drive);
-}
-
-/*
- * amd7409_dmaproc() initiates/aborts (U)DMA read/write operations on a drive.
- */
-
-int amd7409_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
-{
-	switch (func) {
-		case ide_dma_check:
-			return config_drive_xfer_rate(drive);
-		default:
-			break;
-	}
-	return ide_dmaproc(func, drive);	/* use standard DMA stuff */
-}
-#endif /* CONFIG_BLK_DEV_IDEDMA */
-
-unsigned int __init pci_init_amd7409 (struct pci_dev *dev, const char *name)
-{
-	unsigned long fixdma_base = pci_resource_start(dev, 4);
-
-#ifdef CONFIG_BLK_DEV_IDEDMA
-	if (!amd7409_swdma_check(dev))
-		printk("%s: disabling single-word DMA support (revision < C4)\n", name);
-#endif /* CONFIG_BLK_DEV_IDEDMA */
-
-	if (!fixdma_base) {
-		/*
-		 *
-		 */
-	} else {
-		/*
-		 * enable DMA capable bit, and "not" simplex only
-		 */
-		outb(inb(fixdma_base+2) & 0x60, fixdma_base+2);
-
-		if (inb(fixdma_base+2) & 0x80)
-			printk("%s: simplex device: DMA will fail!!\n", name);
-	}
-#if defined(DISPLAY_VIPER_TIMINGS) && defined(CONFIG_PROC_FS)
-	if (!amd7409_proc) {
-		amd7409_proc = 1;
-		bmide_dev = dev;
-		amd7409_display_info = &amd7409_get_info;
-	}
-#endif /* DISPLAY_VIPER_TIMINGS && CONFIG_PROC_FS */
-
-	return 0;
-}
-
-unsigned int __init ata66_amd7409 (ide_hwif_t *hwif)
-{
-#ifdef CONFIG_AMD7409_OVERRIDE
-	byte ata66 = 1;
-#else
-	byte ata66 = 0;
-#endif /* CONFIG_AMD7409_OVERRIDE */
-
-#if 0
-	pci_read_config_byte(hwif->pci_dev, 0x48, &ata66);
-	return ((ata66 & 0x02) ? 0 : 1);
-#endif
-	return ata66;
-}
-
-void __init ide_init_amd7409 (ide_hwif_t *hwif)
-{
-	hwif->tuneproc = &amd7409_tune_drive;
-	hwif->speedproc = &amd7409_tune_chipset;
-
-#ifndef CONFIG_BLK_DEV_IDEDMA
-	hwif->drives[0].autotune = 1;
-	hwif->drives[1].autotune = 1;
-	hwif->autodma = 0;
-	return;
-#else
-
-	if (hwif->dma_base) {
-		hwif->dmaproc = &amd7409_dmaproc;
-		if (!noautodma)
-			hwif->autodma = 1;
-	} else {
-		hwif->autodma = 0;
-		hwif->drives[0].autotune = 1;
-		hwif->drives[1].autotune = 1;
-	}
-#endif /* CONFIG_BLK_DEV_IDEDMA */
-}
-
-void __init ide_dmacapable_amd7409 (ide_hwif_t *hwif, unsigned long dmabase)
-{
-	ide_setup_dma(hwif, dmabase, 8);
-}
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/buddha.c linux/drivers/ide/buddha.c
--- v2.4.9/linux/drivers/ide/buddha.c	Wed Jul 25 17:10:20 2001
+++ linux/drivers/ide/buddha.c	Thu Sep 13 15:21:32 2001
@@ -43,7 +43,7 @@
 #define BUDDHA_BASE2	0xa00
 #define BUDDHA_BASE3	0xc00
 
-static const u_int buddha_bases[CATWEASEL_NUM_HWIFS] __initdata = {
+static u_int buddha_bases[CATWEASEL_NUM_HWIFS] __initdata = {
     BUDDHA_BASE1, BUDDHA_BASE2, BUDDHA_BASE3
 };
 
@@ -76,7 +76,7 @@
 #define BUDDHA_IRQ2	0xf40		/* interrupt */
 #define BUDDHA_IRQ3	0xf80
 
-static const int buddha_irqports[CATWEASEL_NUM_HWIFS] __initdata = {
+static int buddha_irqports[CATWEASEL_NUM_HWIFS] __initdata = {
     BUDDHA_IRQ1, BUDDHA_IRQ2, BUDDHA_IRQ3
 };
 
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/hd.c linux/drivers/ide/hd.c
--- v2.4.9/linux/drivers/ide/hd.c	Sat Apr 28 11:27:53 2001
+++ linux/drivers/ide/hd.c	Mon Sep 10 12:42:31 2001
@@ -639,9 +639,11 @@
 		}
 
          	case BLKGETSIZE:   /* Return device size */
-			if (!arg)  return -EINVAL;
 			return put_user(hd[MINOR(inode->i_rdev)].nr_sects, 
 					(long *) arg);
+         	case BLKGETSIZE64:
+			return put_user((u64)hd[MINOR(inode->i_rdev)].nr_sects << 9, 
+					(u64 *) arg);
 
 		case BLKRRPART: /* Re-read partition tables */
 			if (!capable(CAP_SYS_ADMIN))
@@ -688,16 +690,13 @@
 extern struct block_device_operations hd_fops;
 
 static struct gendisk hd_gendisk = {
-	MAJOR_NR,	/* Major number */	
-	"hd",		/* Major name */
-	6,		/* Bits to shift to get real from partition */
-	1 << 6,		/* Number of partitions per real */
-	hd,		/* hd struct */
-	hd_sizes,	/* block sizes */
-	0,		/* number */
-	NULL,		/* internal use, not presently used */
-	NULL,		/* next */
-	&hd_fops,       /* file operations */
+	major:		MAJOR_NR,
+	major_name:	"hd",
+	minor_shift:	6,
+	max_p:		1 << 6,
+	part:		hd,
+	sizes:		hd_sizes,
+	fops:		&hd_fops,
 };
 	
 static void hd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
@@ -842,8 +841,7 @@
 	}
 	blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST);
 	read_ahead[MAJOR_NR] = 8;		/* 8 sector (4kB) read-ahead */
-	hd_gendisk.next = gendisk_head;
-	gendisk_head = &hd_gendisk;
+	add_gendisk(&hd_gendisk);
 	init_timer(&device_timer);
 	device_timer.function = hd_times_out;
 	hd_geninit();
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/ide-dma.c linux/drivers/ide/ide-dma.c
--- v2.4.9/linux/drivers/ide/ide-dma.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/ide/ide-dma.c	Sun Sep  9 10:43:02 2001
@@ -130,10 +130,30 @@
 	{ "WDC AC23200L"	,	"21.10N21"	},
 	{ "Compaq CRD-8241B"	,	"ALL"		},
 	{ "CRD-8400B"		,	"ALL"		},
+	{ "CRD-8480B",			"ALL"		},
+	{ "CRD-8480C",			"ALL"		},
+	{ "CRD-8482B",			"ALL"		},
+ 	{ "CRD-84"		,	"ALL"		},
+	{ "SanDisk SDP3B"	,	"ALL"		},
+	{ "SanDisk SDP3B-64"	,	"ALL"		},
+	{ "SANYO CD-ROM CRD"	,	"ALL"		},
+	{ "HITACHI CDR-8"	,	"ALL"		},
+	{ "HITACHI CDR-8335"	,	"ALL"		},
+	{ "HITACHI CDR-8435"	,	"ALL"		},
+	{ "Toshiba CD-ROM XM-6202B"	,	"ALL"		},
+	{ "CD-532E-A"		,	"ALL"		},
+	{ "E-IDE CD-ROM CR-840",	"ALL"		},
+	{ "CD-ROM Drive/F5A",	"ALL"		},
+	{ "RICOH CD-R/RW MP7083A",	"ALL"		},
+	{ "WPI CDD-820",		"ALL"		},
+	{ "SAMSUNG CD-ROM SC-148C",	"ALL"		},
+	{ "SAMSUNG CD-ROM SC-148F",	"ALL"		},
+	{ "SAMSUNG CD-ROM SC",	"ALL"		},
 	{ "SanDisk SDP3B-64"	,	"ALL"		},
 	{ "SAMSUNG CD-ROM SN-124",	"ALL"		},
 	{ "PLEXTOR CD-R PX-W8432T",	"ALL"		},
 	{ "ATAPI CD-ROM DRIVE 40X MAXIMUM",	"ALL"		},
+	{ "_NEC DV5800A",               "ALL"           },  
 	{ 0			,	0		}
 
 };
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/ide-floppy.c linux/drivers/ide/ide-floppy.c
--- v2.4.9/linux/drivers/ide/ide-floppy.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/ide/ide-floppy.c	Fri Sep  7 09:28:38 2001
@@ -1,7 +1,8 @@
 /*
- * linux/drivers/ide/ide-floppy.c	Version 0.9.sv	Jan 6 2001
+ * linux/drivers/ide/ide-floppy.c	Version 0.97.sv	Jan 14 2001
  *
  * Copyright (C) 1996 - 1999 Gadi Oxman <gadio@netvision.net.il>
+ * Copyright (C) 2000 - 2001 Paul Bristow <paul@paulbristow.net>
  */
 
 /*
@@ -10,6 +11,12 @@
  * The driver currently doesn't have any fancy features, just the bare
  * minimum read/write support.
  *
+ * This driver supports the following IDE floppy drives:
+ *
+ * LS-120 SuperDisk
+ * Iomega Zip 100/250
+ * Iomega PC Card Clik!/PocketZip
+ *
  * Many thanks to Lode Leroy <Lode.Leroy@www.ibase.be>, who tested so many
  * ALPHA patches to this driver on an EASYSTOR LS-120 ATAPI floppy drive.
  *
@@ -38,6 +45,20 @@
  *                       mode page.  Implemented four IOCTLs in order to
  *                       implement formatting.  IOCTls begin with 0x4600,
  *                       0x46 is 'F' as in Format.
+ *            Jan 9 01   Userland option to select format verify.
+ *                       Added PC_SUPPRESS_ERROR flag - some idefloppy drives
+ *                       do not implement IDEFLOPPY_CAPABILITIES_PAGE, and
+ *                       return a sense error.  Suppress error reporting in
+ *                       this particular case in order to avoid spurious
+ *                       errors in syslog.  The culprit is
+ *                       idefloppy_get_capability_page(), so move it to
+ *                       idefloppy_begin_format() so that it's not used
+ *                       unless absolutely necessary.
+ *                       If drive does not support format progress indication
+ *                       monitor the dsc bit in the status register.
+ *                       Also, O_NDELAY on open will allow the device to be
+ *                       opened without a disk available.  This can be used to
+ *                       open an unformatted disk, or get the device capacity.
  * Ver 0.91  Dec 11 99   Added IOMEGA Clik! drive support by 
  *     		   <paul@paulbristow.net>
  * Ver 0.92  Oct 22 00   Paul Bristow became official maintainer for this 
@@ -49,9 +70,10 @@
  * Ver 0.96  Jan  7 01   Actually in line with release version of 2.4.0
  *                       including set_bit patch from Rusty Russel
  * Ver 0.97  Jul 22 01   Merge 0.91-0.96 onto 0.9.sv for ac series
+ * Ver 0.97.sv Aug 3 01  Backported from 2.4.7-ac3
  */
 
-#define IDEFLOPPY_VERSION "0.97"
+#define IDEFLOPPY_VERSION "0.97.sv"
 
 #include <linux/config.h>
 #include <linux/module.h>
@@ -140,6 +162,8 @@
 #define	PC_DMA_ERROR			4	/* 1 when encountered problem during DMA */
 #define	PC_WRITING			5	/* Data direction */
 
+#define	PC_SUPPRESS_ERROR		6	/* Suppress error reporting */
+
 /*
  *	Removable Block Access Capabilities Page
  */
@@ -1022,8 +1046,11 @@
 		 *	a legitimate error code was received.
 		 */
 		if (!test_bit (PC_ABORT, &pc->flags)) {
-			printk (KERN_ERR "ide-floppy: %s: I/O error, pc = %2x, key = %2x, asc = %2x, ascq = %2x\n",
+			if (!test_bit (PC_SUPPRESS_ERROR, &pc->flags)) {
+				;
+      printk( KERN_ERR "ide-floppy: %s: I/O error, pc = %2x, key = %2x, asc = %2x, ascq = %2x\n",
 				drive->name, pc->c[0], floppy->sense_key, floppy->asc, floppy->ascq);
+			}
 			pc->error = IDEFLOPPY_ERROR_GENERAL;		/* Giving up */
 		}
 		floppy->failed_pc=NULL;
@@ -1101,14 +1128,19 @@
 	pc->request_transfer = 255;
 }
 
-static void idefloppy_create_format_unit_cmd (idefloppy_pc_t *pc, int b, int l)
+static void idefloppy_create_format_unit_cmd (idefloppy_pc_t *pc, int b, int l,
+					      int flags)
 {
 	idefloppy_init_pc (pc);
 	pc->c[0] = IDEFLOPPY_FORMAT_UNIT_CMD;
 	pc->c[1] = 0x17;
 
 	memset(pc->buffer, 0, 12);
-	pc->buffer[1] = 0xA2;	/* Format list header, byte 1: FOV/DCRT/IMM */
+	pc->buffer[1] = 0xA2;
+	/* Default format list header, byte 1: FOV/DCRT/IMM bits set */
+
+	if (flags & 1)				/* Verify bit on... */
+		pc->buffer[1] ^= 0x20;		/* ... turn off DCRT bit */
 	pc->buffer[3] = 8;
 
 	put_unaligned(htonl(b), (unsigned int *)(&pc->buffer[4]));
@@ -1300,9 +1332,12 @@
 	floppy->srfp=0;
 	idefloppy_create_mode_sense_cmd (&pc, IDEFLOPPY_CAPABILITIES_PAGE,
 						 MODE_SENSE_CURRENT);
+
+	set_bit(PC_SUPPRESS_ERROR, &pc.flags);
 	if (idefloppy_queue_pc_tail (drive,&pc)) {
 		return 1;
 	}
+
 	header = (idefloppy_mode_parameter_header_t *) pc.buffer;
 	page= (idefloppy_capabilities_page_t *)(header+1);
 	floppy->srfp=page->srfp;
@@ -1378,7 +1413,6 @@
         if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags))
 	{
 		(void) idefloppy_get_flexible_disk_page (drive);
-		(void) idefloppy_get_capability_page (drive);
 	}
 
 	drive->part[0].nr_sects = floppy->blocks * floppy->bs_factor;
@@ -1478,7 +1512,12 @@
 ** struct idefloppy_format_command {
 **        int nblocks;
 **        int blocksize;
+**        int flags;
 **        } ;
+**
+** flags is a bitmask, currently, the only defined flag is:
+**
+**        0x01 - verify media after format.
 */
 
 static int idefloppy_begin_format(ide_drive_t *drive,
@@ -1488,15 +1527,18 @@
 {
 	int blocks;
 	int length;
+	int flags;
 	idefloppy_pc_t pc;
 
 	if (get_user(blocks, arg)
-	    || get_user(length, arg+1))
+	    || get_user(length, arg+1)
+	    || get_user(flags, arg+2))
 	{
 		return (-EFAULT);
 	}
 
-	idefloppy_create_format_unit_cmd(&pc, blocks, length);
+	(void) idefloppy_get_capability_page (drive);	/* Get the SFRP bit */
+	idefloppy_create_format_unit_cmd(&pc, blocks, length, flags);
 	if (idefloppy_queue_pc_tail (drive, &pc))
 	{
                 return (-EIO);
@@ -1510,8 +1552,8 @@
 ** Userland gives a pointer to an int.  The int is set to a progresss
 ** indicator 0-65536, with 65536=100%.
 **
-** If the drive does not support format progress indication, we just return
-** a 65536, screw it.
+** If the drive does not support format progress indication, we just check
+** the dsc bit, and return either 0 or 65536.
 */
 
 static int idefloppy_get_format_progress(ide_drive_t *drive,
@@ -1536,8 +1578,21 @@
 		{
 			progress_indication=floppy->progress_indication;
 		}
+		/* Else assume format_unit has finished, and we're
+		** at 0x10000 */
 	}
+	else
+	{
+		idefloppy_status_reg_t status;
+		unsigned long flags;
 
+		__save_flags(flags);
+		__cli();
+		status.all=GET_STAT();
+		__restore_flags(flags);
+
+		progress_indication= !status.b.dsc ? 0:0x10000;
+	}
 	if (put_user(progress_indication, arg))
 		return (-EFAULT);
 
@@ -1587,8 +1642,6 @@
 		{
 			idefloppy_floppy_t *floppy = drive->driver_data;
 
-			set_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags);
-
 			if (drive->usage > 1)
 			{
 				/* Don't format if someone is using the disk */
@@ -1599,7 +1652,12 @@
 			}
 			else
 			{
-				int rc=idefloppy_begin_format(drive, inode,
+				int rc;
+
+				set_bit(IDEFLOPPY_FORMAT_IN_PROGRESS,
+					&floppy->flags);
+
+				rc=idefloppy_begin_format(drive, inode,
 							      file,
 							      (int *)arg);
 
@@ -1637,7 +1695,6 @@
 
 	MOD_INC_USE_COUNT;
 	if (drive->usage == 1) {
-
 		clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags);
 		/* Just in case */
 
@@ -1647,7 +1704,14 @@
 			(void) idefloppy_queue_pc_tail (drive, &pc);
 		}
 
-		if (idefloppy_get_capacity (drive)) {
+		if (idefloppy_get_capacity (drive)
+		   && (filp->f_flags & O_NDELAY) == 0
+		    /*
+		    ** Allow O_NDELAY to open a drive without a disk, or with
+		    ** an unreadable disk, so that we can get the format
+		    ** capacity of the drive or begin the format - Sam
+		    */
+		    ) {
 			drive->usage--;
 			MOD_DEC_USE_COUNT;
 			return -EIO;
@@ -1893,6 +1957,17 @@
 		for (i = 0; i < 1 << PARTN_BITS; i++)
 			max_sectors[major][minor + i] = 64;
 	}
+  /*
+   *      Guess what?  The IOMEGA Clik! drive also needs the
+   *      above fix.  It makes nasty clicking noises without
+   *      it, so please don't remove this.
+   */
+  if (strcmp(drive->id->model, "IOMEGA Clik! 40 CZ ATAPI") == 0)
+  {
+    for (i = 0; i < 1 << PARTN_BITS; i++)
+      max_sectors[major][minor + i] = 64;
+    set_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags);
+  }
 
 	/*
 	*      Guess what?  The IOMEGA Clik! drive also needs the
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/ide-pci.c linux/drivers/ide/ide-pci.c
--- v2.4.9/linux/drivers/ide/ide-pci.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/ide/ide-pci.c	Sun Sep  9 10:43:02 2001
@@ -38,6 +38,7 @@
 #define DEVID_PIIX4U3	((ide_pci_devid_t){PCI_VENDOR_ID_INTEL,   PCI_DEVICE_ID_INTEL_82801BA_9})
 #define DEVID_PIIX4U4	((ide_pci_devid_t){PCI_VENDOR_ID_INTEL,   PCI_DEVICE_ID_INTEL_82801BA_8})
 #define DEVID_VIA_IDE	((ide_pci_devid_t){PCI_VENDOR_ID_VIA,     PCI_DEVICE_ID_VIA_82C561})
+#define DEVID_MR_IDE	((ide_pci_devid_t){PCI_VENDOR_ID_VIA,     PCI_DEVICE_ID_VIA_82C576_1})
 #define DEVID_VP_IDE	((ide_pci_devid_t){PCI_VENDOR_ID_VIA,     PCI_DEVICE_ID_VIA_82C586_1})
 #define DEVID_PDC20246	((ide_pci_devid_t){PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20246})
 #define DEVID_PDC20262	((ide_pci_devid_t){PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20262})
@@ -385,6 +386,7 @@
 	{DEVID_PIIX4U3,	"PIIX4",	PCI_PIIX,	ATA66_PIIX,	INIT_PIIX,	NULL,		{{0x41,0x80,0x80}, {0x43,0x80,0x80}},	ON_BOARD,	0 },
 	{DEVID_PIIX4U4, "PIIX4",	PCI_PIIX,	ATA66_PIIX,	INIT_PIIX,	NULL,		{{0x41,0x80,0x80}, {0x43,0x80,0x80}},	ON_BOARD,	0 },
 	{DEVID_VIA_IDE,	"VIA_IDE",	NULL,		NULL,		NULL,		NULL,		{{0x00,0x00,0x00}, {0x00,0x00,0x00}},	ON_BOARD,	0 },
+	{DEVID_MR_IDE,	"VP_IDE",	PCI_VIA82CXXX,	ATA66_VIA82CXXX,INIT_VIA82CXXX,	DMA_VIA82CXXX,	{{0x40,0x02,0x02}, {0x40,0x01,0x01}}, 	ON_BOARD,	0 },
 	{DEVID_VP_IDE,	"VP_IDE",	PCI_VIA82CXXX,	ATA66_VIA82CXXX,INIT_VIA82CXXX,	DMA_VIA82CXXX,	{{0x40,0x02,0x02}, {0x40,0x01,0x01}}, 	ON_BOARD,	0 },
 #ifdef CONFIG_PDC202XX_FORCE
         {DEVID_PDC20246,"PDC20246",	PCI_PDC202XX,	NULL,		INIT_PDC202XX,	NULL,		{{0x00,0x00,0x00}, {0x00,0x00,0x00}},	OFF_BOARD,	16 },
@@ -758,6 +760,7 @@
 		    IDE_PCI_DEVID_EQ(d->devid, DEVID_PIIX4NX) ||
 		    IDE_PCI_DEVID_EQ(d->devid, DEVID_HPT34X)  ||
 		    IDE_PCI_DEVID_EQ(d->devid, DEVID_VIA_IDE) ||
+		    IDE_PCI_DEVID_EQ(d->devid, DEVID_MR_IDE)  ||
 		    IDE_PCI_DEVID_EQ(d->devid, DEVID_VP_IDE))
 			autodma = 0;
 		if (autodma)
@@ -767,6 +770,7 @@
 		    IDE_PCI_DEVID_EQ(d->devid, DEVID_PDC20265) ||
 		    IDE_PCI_DEVID_EQ(d->devid, DEVID_PDC20267) ||
 		    IDE_PCI_DEVID_EQ(d->devid, DEVID_PDC20268) ||
+		    IDE_PCI_DEVID_EQ(d->devid, DEVID_PDC20268R) ||
 		    IDE_PCI_DEVID_EQ(d->devid, DEVID_AEC6210) ||
 		    IDE_PCI_DEVID_EQ(d->devid, DEVID_AEC6260) ||
 		    IDE_PCI_DEVID_EQ(d->devid, DEVID_AEC6260R) ||
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/ide-probe.c linux/drivers/ide/ide-probe.c
--- v2.4.9/linux/drivers/ide/ide-probe.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/ide/ide-probe.c	Sat Sep  8 12:02:32 2001
@@ -747,7 +747,7 @@
  */
 static void init_gendisk (ide_hwif_t *hwif)
 {
-	struct gendisk *gd, **gdp;
+	struct gendisk *gd;
 	unsigned int unit, units, minors;
 	int *bs, *max_sect, *max_ra;
 	extern devfs_handle_t ide_devfs_handle;
@@ -800,8 +800,8 @@
 	if (gd->flags)
 		memset (gd->flags, 0, sizeof *gd->flags * units);
 
-	for (gdp = &gendisk_head; *gdp; gdp = &((*gdp)->next)) ;
-	hwif->gd = *gdp = gd;			/* link onto tail of list */
+	hwif->gd = gd;
+	add_gendisk(gd);
 
 	for (unit = 0; unit < units; ++unit) {
 		if (hwif->drives[unit].present) {
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/ide-proc.c linux/drivers/ide/ide-proc.c
--- v2.4.9/linux/drivers/ide/ide-proc.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/ide/ide-proc.c	Fri Sep  7 09:28:38 2001
@@ -404,7 +404,7 @@
 		case ide_cmd640:	name = "cmd640";	break;
 		case ide_dtc2278:	name = "dtc2278";	break;
 		case ide_ali14xx:	name = "ali14xx";	break;
-		case ide_qd6580:	name = "qd6580";	break;
+		case ide_qd65xx:	name = "qd65xx";	break;
 		case ide_umc8672:	name = "umc8672";	break;
 		case ide_ht6560b:	name = "ht6560b";	break;
 		case ide_pdc4030:	name = "pdc4030";	break;
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/ide.c linux/drivers/ide/ide.c
--- v2.4.9/linux/drivers/ide/ide.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/ide/ide.c	Mon Sep 10 12:42:32 2001
@@ -2059,7 +2059,7 @@
 
 void ide_unregister (unsigned int index)
 {
-	struct gendisk *gd, **gdp;
+	struct gendisk *gd;
 	ide_drive_t *drive, *d;
 	ide_hwif_t *hwif, *g;
 	ide_hwgroup_t *hwgroup;
@@ -2179,13 +2179,9 @@
 	blk_dev[hwif->major].data = NULL;
 	blk_dev[hwif->major].queue = NULL;
 	blksize_size[hwif->major] = NULL;
-	for (gdp = &gendisk_head; *gdp; gdp = &((*gdp)->next))
-		if (*gdp == hwif->gd)
-			break;
-	if (*gdp == NULL)
-		printk("gd not in disk chain!\n");
-	else {
-		gd = *gdp; *gdp = gd->next;
+	gd = hwif->gd;
+	if (gd) {
+		del_gendisk(gd);
 		kfree(gd->sizes);
 		kfree(gd->part);
 		if (gd->de_arr)
@@ -2193,6 +2189,7 @@
 		if (gd->flags)
 			kfree (gd->flags);
 		kfree(gd);
+		hwif->gd = NULL;
 	}
 	old_hwif		= *hwif;
 	init_hwif_data (index);	/* restore hwif data to pristine status */
@@ -2663,6 +2660,8 @@
 
 	 	case BLKGETSIZE:   /* Return device size */
 			return put_user(drive->part[MINOR(inode->i_rdev)&PARTN_MASK].nr_sects, (long *) arg);
+	 	case BLKGETSIZE64:
+			return put_user((u64)drive->part[MINOR(inode->i_rdev)&PARTN_MASK].nr_sects << 9, (u64 *) arg);
 
 		case BLKRRPART: /* Re-read partition tables */
 			if (!capable(CAP_SYS_ADMIN)) return -EACCES;
@@ -2788,6 +2787,8 @@
 		case BLKPG:
 		case BLKELVGET:
 		case BLKELVSET:
+		case BLKBSZGET:
+		case BLKBSZSET:
 			return blk_ioctl(inode->i_rdev, cmd, arg);
 
 		case HDIO_GET_BUSSTATE:
@@ -2987,7 +2988,7 @@
  * "ide0=ht6560b"	: probe/support HT6560B interface
  * "ide0=cmd640_vlb"	: *REQUIRED* for VLB cards with the CMD640 chip
  *			  (not for PCI -- automatically detected)
- * "ide0=qd6580"	: probe/support qd6580 interface
+ * "ide0=qd65xx"	: probe/support qd65xx interface
  * "ide0=ali14xx"	: probe/support ali14xx chipsets (ALI M1439, M1443, M1445)
  * "ide0=umc8672"	: probe/support umc8672 chipsets
  * "idex=dc4030"	: probe/support Promise DC4030VL interface
@@ -3155,7 +3156,7 @@
 		const char *ide_words[] = {
 			"noprobe", "serialize", "autotune", "noautotune", "reset", "dma", "ata66",
 			"minus8", "minus9", "minus10",
-			"four", "qd6580", "ht6560b", "cmd640_vlb", "dtc2278", "umc8672", "ali14xx", "dc4030", NULL };
+			"four", "qd65xx", "ht6560b", "cmd640_vlb", "dtc2278", "umc8672", "ali14xx", "dc4030", NULL };
 		hw = s[3] - '0';
 		hwif = &ide_hwifs[hw];
 		i = match_parm(&s[4], ide_words, vals, 3);
@@ -3222,14 +3223,14 @@
 				goto done;
 			}
 #endif /* CONFIG_BLK_DEV_HT6560B */
-#if CONFIG_BLK_DEV_QD6580
-			case -12: /* "qd6580" */
+#if CONFIG_BLK_DEV_QD65XX
+			case -12: /* "qd65xx" */
 			{
-				extern void init_qd6580 (void);
-				init_qd6580();
+				extern void init_qd65xx (void);
+				init_qd65xx();
 				goto done;
 			}
-#endif /* CONFIG_BLK_DEV_QD6580 */
+#endif /* CONFIG_BLK_DEV_QD65XX */
 #ifdef CONFIG_BLK_DEV_4DRIVES
 			case -11: /* "four" drives on one set of ports */
 			{
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/it8172.c linux/drivers/ide/it8172.c
--- v2.4.9/linux/drivers/ide/it8172.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/ide/it8172.c	Fri Sep  7 09:28:38 2001
@@ -5,7 +5,7 @@
  *
  * Copyright 2000 MontaVista Software Inc.
  * Author: MontaVista Software, Inc.
- *              stevel@mvista.com or support@mvista.com
+ *              stevel@mvista.com or source@mvista.com
  *
  *  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
@@ -57,50 +57,41 @@
 void __init ide_init_it8172 (ide_hwif_t *hwif);
 
 
-/*
- *  Based on settings done by AMI BIOS
- *  (might be usefull if drive is not registered in CMOS for any reason).
- */
 static void it8172_tune_drive (ide_drive_t *drive, byte pio)
 {
     unsigned long flags;
     u16 master_data;
-    byte slave_data;
+    u32 slave_data;
     int is_slave	= (&HWIF(drive)->drives[1] == drive);
-    int master_port	= HWIF(drive)->index ? 0x42 : 0x40;
-    int slave_port	= 0x44;
-    /* ISP  RTC */
-    byte timings[][2]	= { { 0, 0 },
-			    { 0, 0 },
-			    { 1, 0 },
-			    { 2, 1 },
-			    { 2, 3 }, };
-
+    int master_port	= 0x40;
+    int slave_port      = 0x44;
+    
     pio = ide_get_best_pio_mode(drive, pio, 5, NULL);
     pci_read_config_word(HWIF(drive)->pci_dev, master_port, &master_data);
+    pci_read_config_dword(HWIF(drive)->pci_dev, slave_port, &slave_data);
+
+    /*
+     * FIX! The DIOR/DIOW pulse width and recovery times in port 0x44
+     * are being left at the default values of 8 PCI clocks (242 nsec
+     * for a 33 MHz clock). These can be safely shortened at higher
+     * PIO modes.
+     */
+    
     if (is_slave) {
-	master_data = master_data | 0x4000;
+	master_data |= 0x4000;
 	if (pio > 1)
-	    /* enable PPE, IE and TIME */
-	    master_data = master_data | 0x0070;
-	pci_read_config_byte(HWIF(drive)->pci_dev, slave_port, &slave_data);
-	slave_data = slave_data & (HWIF(drive)->index ? 0x0f : 0xf0);
-	slave_data = slave_data |
-	    ((timings[pio][0] << 2) | (timings[pio][1]
-				       << (HWIF(drive)->index ? 4 : 0)));
+	    /* enable PPE and IE */
+	    master_data |= 0x0060;
     } else {
-	master_data = master_data & 0xccf8;
+	master_data &= 0xc060;
 	if (pio > 1)
-	    /* enable PPE, IE and TIME */
-	    master_data = master_data | 0x0007;
-	master_data = master_data | (timings[pio][0] << 12) |
-	    (timings[pio][1] << 8);
+	    /* enable PPE and IE */
+	    master_data |= 0x0006;
     }
+
     save_flags(flags);
     cli();
     pci_write_config_word(HWIF(drive)->pci_dev, master_port, master_data);
-    if (is_slave)
-	pci_write_config_byte(HWIF(drive)->pci_dev, slave_port, slave_data);
     restore_flags(flags);
 }
 
@@ -150,12 +141,22 @@
     pci_read_config_byte(dev, 0x48, &reg48);
     pci_read_config_byte(dev, 0x4a, &reg4a);
 
+    /*
+     * Setting the DMA cycle time to 2 or 3 PCI clocks (60 and 91 nsec
+     * at 33 MHz PCI clock) seems to cause BadCRC errors during DMA
+     * transfers on some drives, even though both numbers meet the minimum
+     * ATAPI-4 spec of 73 and 54 nsec for UDMA 1 and 2 respectively.
+     * So the faster times are just commented out here. The good news is
+     * that the slower cycle time has very little affect on transfer
+     * performance.
+     */
+    
     switch(speed) {
     case XFER_UDMA_4:
-    case XFER_UDMA_2:	u_speed = 2 << (drive->dn * 4); break;
+    case XFER_UDMA_2:	//u_speed = 2 << (drive->dn * 4); break;
     case XFER_UDMA_5:
     case XFER_UDMA_3:
-    case XFER_UDMA_1:	u_speed = 1 << (drive->dn * 4); break;
+    case XFER_UDMA_1:	//u_speed = 1 << (drive->dn * 4); break;
     case XFER_UDMA_0:	u_speed = 0 << (drive->dn * 4); break;
     case XFER_MW_DMA_2:
     case XFER_MW_DMA_1:
@@ -164,25 +165,16 @@
     }
 
     if (speed >= XFER_UDMA_0) {
-	if (!(reg48 & u_flag))
-	    pci_write_config_byte(dev, 0x48, reg48|u_flag);
-	if (!(reg4a & u_speed)) {
-	    pci_write_config_byte(dev, 0x4a, reg4a & ~a_speed);
-	    pci_write_config_byte(dev, 0x4a, reg4a|u_speed);
-	}
-    }
-    if (speed < XFER_UDMA_0) {
-	if (reg48 & u_flag)
-	    pci_write_config_byte(dev, 0x48, reg48 & ~u_flag);
-	if (reg4a & a_speed)
-	    pci_write_config_byte(dev, 0x4a, reg4a & ~a_speed);
+	pci_write_config_byte(dev, 0x48, reg48 | u_flag);
+	reg4a &= ~a_speed;
+	pci_write_config_byte(dev, 0x4a, reg4a | u_speed);
+    } else {
+	pci_write_config_byte(dev, 0x48, reg48 & ~u_flag);
+	pci_write_config_byte(dev, 0x4a, reg4a & ~a_speed);
     }
 
     it8172_tune_drive(drive, it8172_dma_2_pio(speed));
 
-#if IT8172_DEBUG
-    printk("%s: %s drive%d\n", drive->name, ide_xfer_verbose(speed), drive->dn);
-#endif
     if (!drive->init_speed)
 	drive->init_speed = speed;
     err = ide_config_drive_speed(drive, speed);
@@ -236,7 +228,9 @@
     /* Other cases are done by generic IDE-DMA code. */
     return ide_dmaproc(func, drive);
 }
+
 #endif /* defined(CONFIG_BLK_DEV_IDEDMA) && (CONFIG_IT8172_TUNING) */
+
 
 unsigned int __init pci_init_it8172 (struct pci_dev *dev, const char *name)
 {
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/pdc202xx.c linux/drivers/ide/pdc202xx.c
--- v2.4.9/linux/drivers/ide/pdc202xx.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/ide/pdc202xx.c	Fri Sep  7 09:28:38 2001
@@ -133,6 +133,7 @@
 
 	switch(dev->device) {
 		case PCI_DEVICE_ID_PROMISE_20268:
+		case PCI_DEVICE_ID_PROMISE_20268R:
 			p += sprintf(p, "\n                                PDC20268 TX2 Chipset.\n");
 			invalid_data_set = 1;
 			break;
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/qd6580.c linux/drivers/ide/qd6580.c
--- v2.4.9/linux/drivers/ide/qd6580.c	Tue Jun 20 07:52:36 2000
+++ linux/drivers/ide/qd6580.c	Wed Dec 31 16:00:00 1969
@@ -1,410 +0,0 @@
-/*
- *  linux/drivers/ide/qd6580.c		Version 0.04	June 4, 2000
- *
- *  Copyright (C) 1996-2000  Linus Torvalds & author (see below)
- */
-
-/*
- *  Version 0.03	Cleaned auto-tune, added probe
- *  Version 0.04	Added second channel tuning
- *
- * QDI QD6580 EIDE controller fast support
- *
- * To activate controller support use kernel parameter "ide0=qd6580"
- * To enable tuning use kernel parameter "ide0=autotune"
- * To enable tuning second channel (not really tested),
- *    use parameter "ide1=autotune"
- */
-
-/* 
- * Rewritten from the work of Colten Edwards <pje120@cs.usask.ca> by
- * Samuel Thibault <samuel.thibault@fnac.net>
- */
-
-#undef REALLY_SLOW_IO           /* most systems can safely undef this */
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/delay.h>
-#include <linux/timer.h>
-#include <linux/mm.h>
-#include <linux/ioport.h>
-#include <linux/blkdev.h>
-#include <linux/hdreg.h>
-#include <linux/ide.h>
-#include <linux/init.h>
-
-#include <asm/io.h>
-
-#include "ide_modes.h"
-
-/*
- * I/O ports are 0xb0-0xb3
- *            or 0x30-0x33
- *	-- this is a dual IDE interface with I/O chips
- *
- * More research on qd6580 being done by willmore@cig.mot.com (David)
- * More Information given by Petr Sourcek (petr@ryston.cz)
- * http://www.ryston.cz/petr/vlb
- */
-
-/*
- * 0xb0: Timer1
- *
- *
- * 0xb1: Config
- *
- * bit 0: ide baseport: 1 = 0x1f0 ; 0 = 0x170
- *   (? Strange: the Dos driver uses it, and then forces baseport to 0x1f0 ?)
- * bit 1: qd baseport: 1 = 0xb0 ; 0 = 0x30
- * bit 2: ID3: bus speed: 1 = <=33MHz ; 0 = >33MHz
- * bit 3: 1 for qd6580
- * upper nibble is either 1010 or 0101, or else it isn't a qd6580
- *
- *
- * 0xb2: Timer2
- *
- *
- * 0xb3: Control
- *
- * bits 0-3 must always be set 1
- * bit 4 must be set 1, but is set 0 by dos driver while measuring vlb clock
- * bit 0 : 1 = Only primary port enabled : channel 0 for hda, channel 1 for hdb
- *         0 = Primary and Secondary ports enabled : channel 0 for hda & hdb
- *                                                   channel 1 for hdc & hdd
- * bit 1 : 1 = only disks on primary port
- *         0 = disks & ATAPI devices on primary port
- * bit 2-4 : always 0
- * bit 5 : status, but of what ?
- * bit 6 : always set 1 by dos driver
- * bit 7 : set 1 for non-ATAPI devices (read-ahead and post-write buffer ?)
- */
-
-/* truncates a in [b,c] */
-#define IDE_IN(a,b,c)   ( ((a)<(b)) ? (b) : ( (a)>(c) ? (c) : (a)) )
-
-typedef struct ide_hd_timings_s {
-	int active_time;		/* Active pulse (ns) minimum */
-	int recovery_time;		/* Recovery pulse (ns) minimum */
-} ide_hd_timings_t;
-
-static int basePort;		/* base port address (0x30 or 0xb0) */
-static byte config;			/* config register of qd6580 */
-static byte control;		/* control register of qd6580 */
-
-static int bus_clock;		/* Vesa local bus clock (ns) */
-static int tuned=0;			/* to remember whether we've already been tuned */
-static int snd_tuned=0;		/* to remember whether we've already been tuned */
-static int nb_disks_prim=0;	/* number of disk drives on primary port */
-
-/*
- * write_reg
- *
- * writes the specified byte on the specified register
- */
-
-static void write_reg ( byte content, byte reg )
-{
-	unsigned long flags;
-
-	save_flags(flags);		/* all CPUs */
-	cli();					/* all CPUs */
-	outb_p(content,reg);
-	inb(0x3f6);
-	restore_flags(flags);	/* all CPUs */
-}
-
-/*
- * tune_drive
- *
- * Finds timings for the specified drive, returns it in struct t
- */
-
-static void tune_drive ( ide_drive_t *drive, byte pio, ide_hd_timings_t *t )
-{
-	ide_pio_data_t d;
-
-	t->active_time   = 175;
-	t->recovery_time = 415; /* worst cases values from the dos driver */
-
-	if (!drive->present) {	/* not present : free to give any timing */
-		t->active_time = 0;
-		t->recovery_time = 0;
-		return;
-	}
-
-	pio = ide_get_best_pio_mode(drive, pio, 255, &d);
-	pio = IDE_MIN(pio,4);
-
-	switch (pio) {
-		case 0: break;
-		case 3:
-			if (d.cycle_time >= 110) {
-				t->active_time = 86;
-				t->recovery_time = d.cycle_time-102;
-			} else {
-				printk("%s: Strange recovery time !\n",drive->name);
-				return;
-			}
-			break;
-		case 4:
-			if (d.cycle_time >= 69) {
-				t->active_time = 70;
-				t->recovery_time = d.cycle_time-61;
-			} else {
-				printk("%s: Strange recovery time !\n",drive->name);
-				return;
-			}
-			break;
-		default:
-			if (d.cycle_time >= 180) {
-				t->active_time = 110;
-				t->recovery_time = d.cycle_time - 120;
-			} else {
-				t->active_time = ide_pio_timings[pio].active_time;
-				t->recovery_time = d.cycle_time
-						-t->active_time;
-			}
-	}
-	printk("%s: PIO mode%d, tim1=%dns tim2=%dns\n", drive->name, pio, t->active_time, t->recovery_time);
-
-	if (drive->media == ide_disk)
-		nb_disks_prim++;
-	else {
-/* need to disable read-ahead FIFO and post-write buffer for ATAPI drives*/
-		write_reg(0x5f,basePort+0x03);
-		printk("%s: Warning: please try to connect this drive to secondary IDE port\nto improve data transfer rate on primary IDE port.\n",drive->name);
-	}
-}
-
-/*
- * tune_snd_drive
- *
- * Finds timings for the specified drive, using second channel rules
- */
-
-static void tune_snd_drive ( ide_drive_t *drive, byte pio, ide_hd_timings_t *t )
-{
-	ide_pio_data_t d;
-
-	t->active_time   = 175;
-	t->recovery_time = 415;
-
-	if (!drive->present) {	/* not present : free to give any timing */
-		t->active_time = 0;
-		t->recovery_time = 0;
-		return;
-	}
-
-	pio = ide_get_best_pio_mode(drive, pio, 255, &d);
-
-	if ((pio) && (d.cycle_time >= 180)) {
-		t->active_time = 115;
-		t->recovery_time = d.cycle_time - 115;
-	}
-	printk("%s: PIO mode%d, tim1=%dns tim2=%dns\n", drive->name, pio, t->active_time, t->recovery_time);
-
-	if ((drive->media == ide_disk) && (nb_disks_prim<2)) {
-/* a disk drive on secondary port while there's room on primary, which is the
- * only one that has read-ahead fifo and post-write buffer ? What a waste !*/
-		printk("%s: Warning: please try to connect this drive to primary IDE port\nto improve data transfer rate.\n",drive->name);
-	}
-}
-
-/*
- * compute_timing
- *
- * computes the timing value where
- *    lower nibble is active time,   in count of VLB clocks, 17-(from 2 to 17)
- *    upper nibble is recovery time, in count of VLB clocks, 15-(from 2 to 15)
- */
-
-static byte compute_timing ( char name[6], ide_hd_timings_t *t )
-{
-	byte active_cycle;
-	byte recovery_cycle;
-	byte parameter;
-
-	active_cycle   = 17-IDE_IN(t->active_time   / bus_clock + 1, 2, 17);
-	recovery_cycle = 15-IDE_IN(t->recovery_time / bus_clock + 1, 2, 15);
-
-	parameter = active_cycle | (recovery_cycle<<4);
-
-	printk("%s: tim1=%dns tim2=%dns => %#x\n", name, t[0].active_time, t[0].recovery_time, parameter);
-	return(parameter);
-}
-
-/*
- * tune_ide
- *
- * Tunes the whole hwif, ie tunes each drives, and in case we have to share,
- * takes the worse timings to tune qd6580
- */
-
-static void tune_ide ( ide_hwif_t *hwif, byte pio )
-{
-	unsigned long flags;
-	ide_hd_timings_t t[2]={{0,0},{0,0}};
-	int bus_speed = ide_system_bus_speed ();
-
-	bus_clock = 1000 / bus_speed;
-
-	save_flags(flags);		/* all CPUs */
-	cli();					/* all CPUs */
-	outb( (bus_clock<30) ? 0x0 : 0x0a, basePort + 0x02);
-	outb( 0x40 | ((control & 0x02) ? 0x9f:0x1f), basePort+0x03);
-	restore_flags(flags);
-
-	tune_drive (&hwif->drives[0], pio, &t[0]);
-	tune_drive (&hwif->drives[1], pio, &t[1]);
-
-	if (control & 0x01) { /* only primary port enabled, can tune separately */
-		write_reg(compute_timing (hwif->drives[0].name, &t[0]),basePort);
-		write_reg(compute_timing (hwif->drives[1].name, &t[1]),basePort+0x02);
-	} else {			  /* both ports enabled, we have to share */
-
-		t[0].active_time   = IDE_MAX(t[0].active_time,  t[1].active_time);
-		t[0].recovery_time = IDE_MAX(t[0].recovery_time,t[1].recovery_time);
-		write_reg(compute_timing (hwif->name, &t[0]),basePort);
-	}
-}
-
-/*
- * tune_snd_ide
- *
- * Tunes the whole secondary hwif, ie tunes each drives, and takes the worse
- * timings to tune qd6580
- */
-
-static void tune_snd_ide ( ide_hwif_t *hwif, byte pio )
-{
-	ide_hd_timings_t t[2]={{0,0},{0,0}};
-
-	tune_snd_drive (&hwif->drives[0], pio, &t[0]);
-	tune_snd_drive (&hwif->drives[1], pio, &t[1]);
-
-	t[0].active_time   = IDE_MAX(t[0].active_time,  t[1].active_time);
-	t[0].recovery_time = IDE_MAX(t[0].recovery_time,t[1].recovery_time);
-
-	write_reg(compute_timing (hwif->name, &t[0]),basePort+0x02);
-}
-
-/*
- * tune_qd6580
- *
- * tunes the hwif if not tuned
- */
-
-static void tune_qd6580 (ide_drive_t *drive, byte pio)
-{
-	if (! tuned) {
-		tune_ide(HWIF(drive), pio);
-		tuned = 1;
-	}
-}
-
-/*
- * tune_snd_qd6580
- *
- * tunes the second hwif if not tuned
- */
-
-static void tune_snd_qd6580 (ide_drive_t *drive, byte pio)
-{
-	if (! snd_tuned) {
-		tune_snd_ide(HWIF(drive), pio);
-		snd_tuned = 1;
-	}
-}
-
-/*
- * testreg
- *
- * tests if the given port is a register
- */
-
-static int __init testreg(int port)
-{
-	byte savereg;
-	byte readreg;
-	unsigned long flags;
-
-	save_flags(flags);		/* all CPUs */
-	cli();					/* all CPUs */
-	savereg = inb(port);
-	outb_p(0x15,port);		/* safe value */
-	readreg = inb_p(port);
-	outb(savereg,port);
-	restore_flags(flags);	/* all CPUs */
-
-	if (savereg == 0x15) {
-		printk("Outch ! the probe for qd6580 isn't reliable !\n");
-		printk("Please contact maintainers to tell about your hardware\n");
-		printk("Assuming qd6580 is not present.\n");
-		return 0;
-	}
-
-	return (readreg == 0x15);
-}
-
-/*
- * trybase:
- *
- * tries to find a qd6580 at the given base and save it if found
- */
-
-static int __init trybase (int base)
-{
-	unsigned long flags;
-
-	save_flags(flags);		/* all CPUs */
-	cli();					/* all CPUs */
-	config = inb(base+0x01);
-	control = inb(base+0x03);
-	restore_flags(flags);	/* all CPUs */
-
-	if (((config & 0xf0) != 0x50) && ((config & 0xf0) != 0xa0)) return(0);
-	if (! ( ((config & 0x02) == 0x0) == (base == 0x30) ) ) return (0);
-
-	/* Seems to be OK, let's use it */
-
-	basePort = base;
-	return(testreg(base));
-}
-
-/*
- * probe:
- *
- * probes qd6580 at 0xb0 (the default) or 0x30
- */
-
-static int __init probe (void)
-{
-	return (trybase(0xb0) ? 1 : trybase(0x30));
-}
-
-/*
- * init_qd6580:
- *
- * called at the very beginning of initialization ; should just probe and link
- */
-
-void __init init_qd6580 (void)
-{
-	if (! probe()) {
-		printk("qd6580: not found\n");
-		return;
-	}
-
-	printk("qd6580: base=%#x, config=%#x, control=%#x\n", basePort, config, control);
-
-	ide_hwifs[0].chipset = ide_qd6580;
-	ide_hwifs[0].tuneproc = &tune_qd6580;
-	if (!(control & 0x01)) {
-		ide_hwifs[1].chipset = ide_qd6580;
-		ide_hwifs[1].tuneproc = &tune_snd_qd6580;
-		ide_hwifs[0].mate = &ide_hwifs[1];
-		ide_hwifs[1].mate = &ide_hwifs[0];
-		ide_hwifs[1].channel = 1;
-	}
-}
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/qd65xx.c linux/drivers/ide/qd65xx.c
--- v2.4.9/linux/drivers/ide/qd65xx.c	Wed Dec 31 16:00:00 1969
+++ linux/drivers/ide/qd65xx.c	Fri Sep  7 09:28:38 2001
@@ -0,0 +1,453 @@
+/*
+ *  linux/drivers/ide/qd65xx.c		Version 0.06	Aug 3, 2000
+ *
+ *  Copyright (C) 1996-2000  Linus Torvalds & author (see below)
+ */
+
+/*
+ *  Version 0.03	Cleaned auto-tune, added probe
+ *  Version 0.04	Added second channel tuning
+ *  Version 0.05	Enhanced tuning ; added qd6500 support
+ *  Version 0.06	added dos driver's list
+ *
+ * QDI QD6500/QD6580 EIDE controller fast support
+ *
+ * Please set local bus speed using kernel parameter idebus
+ * 	for example, "idebus=33" stands for 33Mhz VLbus
+ * To activate controller support, use "ide0=qd65xx"
+ * To enable tuning, use "ide0=autotune"
+ * To enable second channel tuning (qd6580 only), use "ide1=autotune"
+ */
+
+/*
+ * Rewritten from the work of Colten Edwards <pje120@cs.usask.ca> by
+ * Samuel Thibault <samuel.thibault@fnac.net>
+ */
+
+#undef REALLY_SLOW_IO		/* most systems can safely undef this */
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/timer.h>
+#include <linux/mm.h>
+#include <linux/ioport.h>
+#include <linux/blkdev.h>
+#include <linux/hdreg.h>
+#include <linux/ide.h>
+#include <linux/init.h>
+#include <asm/io.h>
+
+#include "ide_modes.h"
+#include "qd65xx.h"
+
+/*
+ * I/O ports are 0x30-0x31 (and 0x32-0x33 for qd6580)
+ *            or 0xb0-0xb1 (and 0xb2-0xb3 for qd6580)
+ *	-- qd6500 is a single IDE interface
+ *	-- qd6580 is a dual IDE interface
+ *
+ * More research on qd6580 being done by willmore@cig.mot.com (David)
+ * More Information given by Petr Soucek (petr@ryston.cz)
+ * http://www.ryston.cz/petr/vlb
+ */
+
+/*
+ * base: Timer1
+ *
+ *
+ * base+0x01: Config (R/O)
+ *
+ * bit 0: ide baseport: 1 = 0x1f0 ; 0 = 0x170 (only useful for qd6500)
+ * bit 1: qd65xx baseport: 1 = 0xb0 ; 0 = 0x30
+ * bit 2: ID3: bus speed: 1 = <=33MHz ; 0 = >33MHz
+ * bit 3: qd6500: 1 = disabled, 0 = enabled
+ *        qd6580: 1
+ * upper nibble:
+ *        qd6500: 1100
+ *        qd6580: either 1010 or 0101
+ *
+ * base+0x02: Timer2 (qd6580 only)
+ *
+ *
+ * base+0x03: Control (qd6580 only)
+ *
+ * bits 0-3 must always be set 1
+ * bit 4 must be set 1, but is set 0 by dos driver while measuring vlb clock
+ * bit 0 : 1 = Only primary port enabled : channel 0 for hda, channel 1 for hdb
+ *         0 = Primary and Secondary ports enabled : channel 0 for hda & hdb
+ *                                                   channel 1 for hdc & hdd
+ * bit 1 : 1 = only disks on primary port
+ *         0 = disks & ATAPI devices on primary port
+ * bit 2-4 : always 0
+ * bit 5 : status, but of what ?
+ * bit 6 : always set 1 by dos driver
+ * bit 7 : set 1 for non-ATAPI devices on primary port
+ * 	(maybe read-ahead and post-write buffer ?)
+ */
+
+static int timings[4]={-1,-1,-1,-1}; /* stores current timing for each timer */
+
+static void qd_write_reg (byte content, byte reg)
+{
+	unsigned long flags;
+
+	save_flags(flags);	/* all CPUs */
+	cli();			/* all CPUs */
+	outb(content,reg);
+	restore_flags(flags);	/* all CPUs */
+}
+
+byte __init qd_read_reg (byte reg)
+{
+	unsigned long flags;
+	byte read;
+
+	save_flags(flags);	/* all CPUs */
+	cli();			/* all CPUs */
+	read = inb(reg);
+	restore_flags(flags);	/* all CPUs */
+	return read;
+}
+
+/*
+ * qd_select:
+ *
+ * This routine is invoked from ide.c to prepare for access to a given drive.
+ */
+
+static void qd_select (ide_drive_t *drive)
+{
+	byte index = (( (QD_TIMREG(drive)) & 0x80 ) >> 7) |
+			(QD_TIMREG(drive) & 0x02);
+
+	if (timings[index] != QD_TIMING(drive))
+		qd_write_reg(timings[index] = QD_TIMING(drive), QD_TIMREG(drive));
+}
+
+/*
+ * qd6500_compute_timing
+ *
+ * computes the timing value where
+ * 	lower nibble represents active time,   in count of VLB clocks
+ * 	upper nibble represents recovery time, in count of VLB clocks
+ */
+
+static byte qd6500_compute_timing (ide_hwif_t *hwif, int active_time, int recovery_time)
+{
+	byte active_cycle,recovery_cycle;
+
+	if (system_bus_clock()<=33) {
+		active_cycle =   9  - IDE_IN(active_time   * system_bus_clock() / 1000 + 1, 2, 9);
+		recovery_cycle = 15 - IDE_IN(recovery_time * system_bus_clock() / 1000 + 1, 0, 15);
+	} else {
+		active_cycle =   8  - IDE_IN(active_time   * system_bus_clock() / 1000 + 1, 1, 8);
+		recovery_cycle = 18 - IDE_IN(recovery_time * system_bus_clock() / 1000 + 1, 3, 18);
+	}
+
+	return((recovery_cycle<<4) | 0x08 | active_cycle);
+}
+
+/*
+ * qd6580_compute_timing
+ *
+ * idem for qd6580
+ */
+
+static byte qd6580_compute_timing (int active_time, int recovery_time)
+{
+	byte active_cycle   = 17-IDE_IN(active_time   * system_bus_clock() / 1000 + 1, 2, 17);
+	byte recovery_cycle = 15-IDE_IN(recovery_time * system_bus_clock() / 1000 + 1, 2, 15);
+
+	return((recovery_cycle<<4) | active_cycle);
+}
+
+/*
+ * qd_find_disk_type
+ *
+ * tries to find timing from dos driver's table
+ */
+
+static int qd_find_disk_type (ide_drive_t *drive,
+		int *active_time, int *recovery_time)
+{
+	struct qd65xx_timing_s *p;
+	char model[40];
+
+	if (!*drive->id->model) return 0;
+
+	strncpy(model,drive->id->model,40);
+	ide_fixstring(model,40,1); /* byte-swap */
+
+	for (p = qd65xx_timing ; p->offset != -1 ; p++) {
+		if (!strncmp(p->model, model+p->offset,4)) {
+			printk(KERN_DEBUG "%s: listed !\n",drive->name);
+			*active_time = p->active;
+			*recovery_time = p->recovery;
+			return 1;
+		}
+	}
+	return 0;
+}
+
+/*
+ * qd_timing_ok:
+ *
+ * check whether timings don't conflict
+ */
+
+static int qd_timing_ok (ide_drive_t drives[])
+{
+	return (IDE_IMPLY(drives[0].present && drives[1].present,
+			IDE_IMPLY(QD_TIMREG(drives) == QD_TIMREG(drives+1),
+			          QD_TIMING(drives) == QD_TIMING(drives+1))));
+	/* if same timing register, must be same timing */
+}
+
+/*
+ * qd_set_timing:
+ *
+ * records the timing, and enables selectproc as needed
+ */
+
+static void qd_set_timing (ide_drive_t *drive, byte timing)
+{
+	ide_hwif_t *hwif = HWIF(drive);
+
+	drive->drive_data &= 0xff00;
+	drive->drive_data |= timing;
+	if (qd_timing_ok(hwif->drives)) {
+		qd_select(drive); /* selects once */
+		hwif->selectproc = NULL;
+	} else
+		hwif->selectproc = &qd_select;
+
+	printk(KERN_DEBUG "%s: %#x\n",drive->name,timing);
+}
+
+/*
+ * qd6500_tune_drive
+ */
+
+static void qd6500_tune_drive (ide_drive_t *drive, byte pio)
+{
+	int active_time   = 175;
+	int recovery_time = 415; /* worst case values from the dos driver */
+
+	if (drive->id && !qd_find_disk_type(drive,&active_time,&recovery_time)
+		&& drive->id->tPIO && (drive->id->field_valid & 0x02)
+		&& drive->id->eide_pio >= 240) {
+
+		printk(KERN_INFO "%s: PIO mode%d\n", drive->name,
+				drive->id->tPIO);
+		active_time = 110;
+		recovery_time = drive->id->eide_pio - 120;
+	}
+
+	qd_set_timing(drive,qd6500_compute_timing(HWIF(drive),active_time,recovery_time));
+}
+
+/*
+ * qd6580_tune_drive
+ */
+
+static void qd6580_tune_drive (ide_drive_t *drive, byte pio)
+{
+	ide_pio_data_t d;
+	int base = HWIF(drive)->select_data;
+	int active_time   = 175;
+	int recovery_time = 415; /* worst case values from the dos driver */
+
+	if (drive->id && !qd_find_disk_type(drive,&active_time,&recovery_time)) {
+		pio = ide_get_best_pio_mode(drive, pio, 255, &d);
+		pio = IDE_MIN(pio,4);
+
+		switch (pio) {
+			case 0: break;
+			case 3:
+				if (d.cycle_time >= 110) {
+					active_time = 86;
+					recovery_time = d.cycle_time-102;
+				} else
+					printk(KERN_WARNING "%s: Strange recovery time !\n",drive->name);
+				break;
+			case 4:
+				if (d.cycle_time >= 69) {
+					active_time = 70;
+					recovery_time = d.cycle_time-61;
+				} else
+					printk(KERN_WARNING "%s: Strange recovery time !\n",drive->name);
+				break;
+			default:
+				if (d.cycle_time >= 180) {
+					active_time = 110;
+					recovery_time = d.cycle_time - 120;
+				} else {
+					active_time = ide_pio_timings[pio].active_time;
+					recovery_time = d.cycle_time
+							-active_time;
+				}
+		}
+		printk(KERN_INFO "%s: PIO mode%d\n",drive->name,pio);
+	}
+
+	if (!HWIF(drive)->channel && drive->media != ide_disk) {
+		qd_write_reg(0x5f,QD_CONTROL_PORT);
+		printk(KERN_WARNING "%s: ATAPI: disabled read-ahead FIFO and post-write buffer on %s.\n",drive->name,HWIF(drive)->name);
+	}
+
+	qd_set_timing(drive,qd6580_compute_timing(active_time,recovery_time));
+}
+
+/*
+ * qd_testreg
+ *
+ * tests if the given port is a register
+ */
+
+static int __init qd_testreg(int port)
+{
+	byte savereg;
+	byte readreg;
+	unsigned long flags;
+
+	save_flags(flags);	/* all CPUs */
+	cli();			/* all CPUs */
+	savereg = inb_p(port);
+	outb_p(QD_TESTVAL,port);	/* safe value */
+	readreg = inb_p(port);
+	outb(savereg,port);
+	restore_flags(flags);	/* all CPUs */
+
+	if (savereg == QD_TESTVAL) {
+		printk(KERN_ERR "Outch ! the probe for qd65xx isn't reliable !\n");
+		printk(KERN_ERR "Please contact maintainers to tell about your hardware\n");
+		printk(KERN_ERR "Assuming qd65xx is not present.\n");
+		return 1;
+	}
+
+	return (readreg != QD_TESTVAL);
+}
+
+/*
+ * probe:
+ *
+ * looks at the specified baseport, and if qd found, registers & initialises it
+ * return 1 if another qd may be probed
+ */
+
+int __init probe (int base)
+{
+	byte config;
+	byte index;
+
+	config = qd_read_reg(QD_CONFIG_PORT);
+
+	if (! ((config & QD_CONFIG_BASEPORT) >> 1 == (base == 0xb0)) ) return 1;
+
+	index = ! (config & QD_CONFIG_IDE_BASEPORT);
+
+	if ((config & 0xf0) == QD_CONFIG_QD6500) {
+		ide_hwif_t *hwif = &ide_hwifs[index];
+
+		if (qd_testreg(base)) return 1;		/* bad register */
+
+			/* qd6500 found */
+
+		printk(KERN_NOTICE "%s: qd6500 at %#x\n",
+			ide_hwifs[index].name, base);
+		
+		printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n",
+			config, QD_ID3);
+		
+		if (config & QD_CONFIG_DISABLED) {
+			printk(KERN_WARNING "qd6500 is disabled !\n");
+			return 1;
+		}
+
+		hwif->chipset = ide_qd65xx;
+		hwif->select_data = base;
+		hwif->config_data = config;
+		hwif->drives[0].drive_data =
+		hwif->drives[1].drive_data = QD6500_DEF_DATA;
+		hwif->drives[0].io_32bit =
+		hwif->drives[1].io_32bit = 1;
+		hwif->tuneproc = &qd6500_tune_drive;
+		return 1;
+	}
+
+	if (((config & 0xf0) == QD_CONFIG_QD6580_A) || ((config & 0xf0) == QD_CONFIG_QD6580_B)) {
+
+		byte control;
+
+		if (qd_testreg(base) || qd_testreg(base+0x02)) return 1;
+			/* bad registers */
+
+			/* qd6580 found */
+
+		control = qd_read_reg(QD_CONTROL_PORT);
+
+		printk(KERN_NOTICE "qd6580 at %#x\n", base);
+		printk(KERN_DEBUG "qd6580: config=%#x, control=%#x, ID3=%u\n",
+			config, control, QD_ID3);
+
+		if (control & QD_CONTR_SEC_DISABLED) {
+			ide_hwif_t *hwif = &ide_hwifs[index];
+
+			/* secondary disabled */
+			printk(KERN_INFO "%s: qd6580: single IDE board\n",
+					ide_hwifs[index].name);
+
+			hwif->chipset = ide_qd65xx;
+			hwif->select_data = base;
+			hwif->config_data = config | (control <<8);
+			hwif->drives[0].drive_data =
+			hwif->drives[1].drive_data = QD6580_DEF_DATA;
+			hwif->drives[0].io_32bit =
+			hwif->drives[1].io_32bit = 1;
+			hwif->tuneproc = &qd6580_tune_drive;
+
+			qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT);
+
+			return 1;
+		} else {
+			int i,j;
+			/* secondary enabled */
+			printk(KERN_INFO "%s&%s: qd6580: dual IDE board\n",
+					ide_hwifs[0].name,ide_hwifs[1].name);
+
+			for (i=0;i<2;i++) {
+
+				ide_hwifs[i].chipset = ide_qd65xx;
+				ide_hwifs[i].mate = &ide_hwifs[i^1];
+				ide_hwifs[i].channel = i;
+
+				ide_hwifs[i].select_data = base;
+				ide_hwifs[i].config_data = config | (control <<8);
+				ide_hwifs[i].tuneproc = &qd6580_tune_drive;
+
+				for (j=0;j<2;j++) {
+					ide_hwifs[i].drives[j].drive_data = QD6580_DEF_DATA;
+					ide_hwifs[i].drives[j].io_32bit = 1;
+				}
+			}
+
+			qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT);
+
+			return 0; /* no other qd65xx possible */
+		}
+	}
+	/* no qd65xx found */
+	return 1;
+}
+
+/*
+ * init_qd65xx:
+ *
+ * called at the very beginning of initialization ; should just probe and link
+ */
+
+void __init init_qd65xx (void)
+{
+	if (probe(0x30)) probe(0xb0);
+}
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/qd65xx.h linux/drivers/ide/qd65xx.h
--- v2.4.9/linux/drivers/ide/qd65xx.h	Wed Dec 31 16:00:00 1969
+++ linux/drivers/ide/qd65xx.h	Fri Sep  7 09:28:38 2001
@@ -0,0 +1,139 @@
+/*
+ * linux/drivers/ide/qd65xx.h
+ *
+ * Copyright (c) 2000	Linus Torvalds & authors
+ */
+
+/*
+ * Authors:	Petr Soucek <petr@ryston.cz>
+ * 		Samuel Thibault <samuel.thibault@fnac.net>
+ */
+
+/* truncates a in [b,c] */
+#define IDE_IN(a,b,c)   ( ((a)<(b)) ? (b) : ( (a)>(c) ? (c) : (a)) )
+
+#define IDE_IMPLY(a,b)	((!(a)) || (b))
+
+#define QD_TIM1_PORT		(base)
+#define QD_CONFIG_PORT		(base+0x01)
+#define QD_TIM2_PORT		(base+0x02)
+#define QD_CONTROL_PORT		(base+0x03)
+
+#define QD_CONFIG_IDE_BASEPORT	0x01
+#define QD_CONFIG_BASEPORT	0x02
+#define QD_CONFIG_ID3		0x04
+#define QD_CONFIG_DISABLED	0x08
+#define QD_CONFIG_QD6500	0xc0
+#define QD_CONFIG_QD6580_A	0xa0
+#define QD_CONFIG_QD6580_B	0x50
+
+#define QD_CONTR_SEC_DISABLED	0x01
+
+#define QD_ID3			(config & QD_CONFIG_ID3)
+
+#define QD_CONFIG(hwif)		((hwif)->config_data & 0x00ff)
+#define QD_CONTROL(hwif)	(((hwif)->config_data & 0xff00) >> 8)
+
+#define QD_TIMING(drive)	(byte)(((drive)->drive_data) & 0x00ff)
+#define QD_TIMREG(drive)	(byte)((((drive)->drive_data) & 0xff00) >> 8)
+
+#define QD6500_DEF_DATA		((QD_TIM1_PORT<<8) | (QD_ID3 ? 0x0c : 0x08))
+#define QD6580_DEF_DATA		((QD_TIM1_PORT<<8) | (QD_ID3 ? 0x0a : 0x00))
+#define QD_DEF_CONTR		(0x40 | ((control & 0x02) ? 0x9f : 0x1f))
+
+#define QD_TESTVAL		0x19	/* safe value */
+
+/* Drive specific timing taken from DOS driver v3.7 */
+
+struct qd65xx_timing_s {
+	char	offset;   /* ofset from the beginning of Model Number" */
+	char	model[4];    /* 4 chars from Model number, no conversion */
+	short	active;   /* active time */
+	short	recovery; /* recovery time */
+} qd65xx_timing [] = {
+	{ 30, "2040", 110, 225 },  /* Conner CP30204			*/
+	{ 30, "2045", 135, 225 },  /* Conner CP30254			*/
+	{ 30, "1040", 155, 325 },  /* Conner CP30104			*/
+	{ 30, "1047", 135, 265 },  /* Conner CP30174			*/
+	{ 30, "5344", 135, 225 },  /* Conner CP3544			*/
+	{ 30, "01 4", 175, 405 },  /* Conner CP-3104			*/
+	{ 27, "C030", 175, 375 },  /* Conner CP3000			*/
+	{  8, "PL42", 110, 295 },  /* Quantum LP240			*/
+	{  8, "PL21", 110, 315 },  /* Quantum LP120			*/
+	{  8, "PL25", 175, 385 },  /* Quantum LP52			*/
+	{  4, "PA24", 110, 285 },  /* WD Piranha SP4200			*/
+	{  6, "2200", 110, 260 },  /* WD Caviar AC2200			*/
+	{  6, "3204", 110, 235 },  /* WD Caviar AC2340			*/
+	{  6, "1202", 110, 265 },  /* WD Caviar AC2120			*/
+	{  0, "DS3-", 135, 315 },  /* Teac SD340			*/
+	{  8, "KM32", 175, 355 },  /* Toshiba MK234			*/
+	{  2, "53A1", 175, 355 },  /* Seagate ST351A			*/
+	{  2, "4108", 175, 295 },  /* Seagate ST1480A			*/
+	{  2, "1344", 175, 335 },  /* Seagate ST3144A			*/
+	{  6, "7 12", 110, 225 },  /* Maxtor 7213A			*/
+	{ 30, "02F4", 145, 295 },  /* Conner 3204F			*/
+	{  2, "1302", 175, 335 },  /* Seagate ST3120A			*/
+	{  2, "2334", 145, 265 },  /* Seagate ST3243A			*/
+	{  2, "2338", 145, 275 },  /* Seagate ST3283A			*/
+	{  2, "3309", 145, 275 },  /* Seagate ST3390A			*/
+	{  2, "5305", 145, 275 },  /* Seagate ST3550A			*/
+	{  2, "4100", 175, 295 },  /* Seagate ST1400A			*/
+	{  2, "4110", 175, 295 },  /* Seagate ST1401A			*/
+	{  2, "6300", 135, 265 },  /* Seagate ST3600A			*/
+	{  2, "5300", 135, 265 },  /* Seagate ST3500A			*/
+	{  6, "7 31", 135, 225 },  /* Maxtor 7131 AT			*/
+	{  6, "7 43", 115, 265 },  /* Maxtor 7345 AT			*/
+	{  6, "7 42", 110, 255 },  /* Maxtor 7245 AT			*/
+	{  6, "3 04", 135, 265 },  /* Maxtor 340 AT			*/
+	{  6, "61 0", 135, 285 },  /* WD AC160				*/
+	{  6, "1107", 135, 235 },  /* WD AC1170				*/
+	{  6, "2101", 110, 220 },  /* WD AC1210				*/
+	{  6, "4202", 135, 245 },  /* WD AC2420				*/
+	{  6, "41 0", 175, 355 },  /* WD Caviar 140			*/
+	{  6, "82 0", 175, 355 },  /* WD Caviar 280			*/
+	{  8, "PL01", 175, 375 },  /* Quantum LP105			*/
+	{  8, "PL25", 110, 295 },  /* Quantum LP525			*/
+	{ 10, "4S 2", 175, 385 },  /* Quantum ELS42			*/
+	{ 10, "8S 5", 175, 385 },  /* Quantum ELS85			*/
+	{ 10, "1S72", 175, 385 },  /* Quantum ELS127			*/
+	{ 10, "1S07", 175, 385 },  /* Quantum ELS170			*/
+	{  8, "ZE42", 135, 295 },  /* Quantum EZ240			*/
+	{  8, "ZE21", 175, 385 },  /* Quantum EZ127			*/
+	{  8, "ZE58", 175, 385 },  /* Quantum EZ85			*/
+	{  8, "ZE24", 175, 385 },  /* Quantum EZ42			*/
+	{ 27, "C036", 155, 325 },  /* Conner CP30064			*/
+	{ 27, "C038", 155, 325 },  /* Conner CP30084			*/
+	{  6, "2205", 110, 255 },  /* WDC AC2250			*/
+	{  2, " CHA", 140, 415 },  /* WDC AH series; WDC AH260, WDC	*/
+	{  2, " CLA", 140, 415 },  /* WDC AL series: WDC AL2120, 2170,	*/
+	{  4, "UC41", 140, 415 },  /* WDC CU140				*/
+	{  6, "1207", 130, 275 },  /* WDC AC2170			*/
+	{  6, "2107", 130, 275 },  /* WDC AC1270			*/
+	{  6, "5204", 130, 275 },  /* WDC AC2540			*/
+	{ 30, "3004", 110, 235 },  /* Conner CP30340			*/
+	{ 30, "0345", 135, 255 },  /* Conner CP30544			*/
+	{ 12, "12A3", 175, 320 },  /* MAXTOR LXT-213A			*/
+	{ 12, "43A0", 145, 240 },  /* MAXTOR LXT-340A			*/
+	{  6, "7 21", 180, 290 },  /* Maxtor 7120 AT			*/
+	{  6, "7 71", 135, 240 },  /* Maxtor 7170 AT			*/
+	{ 12, "45\0000", 110, 205 },   /* MAXTOR MXT-540		*/
+	{  8, "PL11", 180, 290 },  /* QUANTUM LP110A			*/
+	{  8, "OG21", 150, 275 },  /* QUANTUM GO120			*/
+	{ 12, "42A5", 175, 320 },  /* MAXTOR LXT-245A			*/
+	{  2, "2309", 175, 295 },  /* ST3290A				*/
+	{  2, "3358", 180, 310 },  /* ST3385A				*/
+	{  2, "6355", 180, 310 },  /* ST3655A				*/
+	{  2, "1900", 175, 270 },  /* ST9100A				*/
+	{  2, "1954", 175, 270 },  /* ST9145A				*/
+	{  2, "1909", 175, 270 },  /* ST9190AG				*/
+	{  2, "2953", 175, 270 },  /* ST9235A				*/
+	{  2, "1359", 175, 270 },  /* ST3195A				*/
+	{ 24, "3R11", 175, 290 },  /* ALPS ELECTRIC Co.,LTD, DR311C	*/
+	{  0, "2M26", 175, 215 },  /* M262XT-0Ah			*/
+	{  4, "2253", 175, 300 },  /* HP C2235A				*/
+	{  4, "-32A", 145, 245 },  /* H3133-A2				*/
+	{ 30, "0326", 150, 270 },  /* Samsung Electronics 120MB		*/
+	{ 30, "3044", 110, 195 },  /* Conner CFA340A			*/
+	{ 30, "43A0", 110, 195 },  /* Conner CFA340A			*/
+	{ -1, "    ", 175, 415 }   /* unknown disk name			*/
+};
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/serverworks.c linux/drivers/ide/serverworks.c
--- v2.4.9/linux/drivers/ide/serverworks.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/ide/serverworks.c	Sun Sep  9 10:43:02 2001
@@ -544,8 +544,33 @@
 	return 0;
 }
 
+/* On Dell PowerEdge servers with a CSB5, the top two bits of the subsystem
+ * device ID indicate presence of an 80-pin cable.
+ * Bit 15 clear = secondary IDE channel does not have 80-pin cable.
+ * Bit 15 set   = secondary IDE channel has 80-pin cable.
+ * Bit 14 clear = primary IDE channel does not have 80-pin cable.
+ * Bit 14 set   = primary IDE channel has 80-pin cable.
+ */
+
+static unsigned int __init ata66_svwks_dell (ide_hwif_t *hwif)
+{
+	struct pci_dev *dev	= hwif->pci_dev;
+	if (dev->subsystem_vendor == PCI_VENDOR_ID_DELL        &&
+	    dev->vendor           == PCI_VENDOR_ID_SERVERWORKS &&
+	    dev->device           == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE)
+		return ((1 << (hwif->channel + 14)) &
+			dev->subsystem_device) ? 1 : 0;
+
+	return 0;
+
+}
+
 unsigned int __init ata66_svwks (ide_hwif_t *hwif)
 {
+	struct pci_dev *dev	= hwif->pci_dev;
+	if (dev->subsystem_vendor == PCI_VENDOR_ID_DELL)
+		return ata66_svwks_dell (hwif);
+	
 	return 0;
 }
 
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/sis5513.c linux/drivers/ide/sis5513.c
--- v2.4.9/linux/drivers/ide/sis5513.c	Sun Aug 12 13:27:59 2001
+++ linux/drivers/ide/sis5513.c	Fri Sep  7 09:28:38 2001
@@ -96,7 +96,7 @@
 	{ 4, "Mode 2" }, 
 	{ 3, "Mode 3" },
 	{ 2, "Mode 4" },
-	{ 0, "Undefined" }
+	{ 0, "Mode 5" }
 };
 
 static __inline__ char * find_udma_mode (byte cycle_time)
@@ -135,7 +135,7 @@
 };
 
 static char * cycle_time [] = {
-	"Undefined", "2 CLCK",
+	"2 CLK", "2 CLK",
 	"3 CLK", "4 CLK",
 	"5 CLK", "6 CLK",
 	"7 CLK", "8 CLK"
@@ -495,7 +495,7 @@
 	printk("%s: %s drive%d\n", drive->name, ide_xfer_verbose(speed), drive->dn);
 #endif /* SIS5513_DEBUG_DRIVE_INFO */
 
-	return ((int)	((id->dma_ultra >> 11) & 3) ? ide_dma_on :
+	return ((int)	((id->dma_ultra >> 11) & 7) ? ide_dma_on :
 			((id->dma_ultra >> 8) & 7) ? ide_dma_on :
 			((id->dma_mword >> 8) & 7) ? ide_dma_on :
 			((id->dma_1word >> 8) & 7) ? ide_dma_on :
@@ -515,7 +515,7 @@
 		}
 		dma_func = ide_dma_off_quietly;
 		if (id->field_valid & 4) {
-			if (id->dma_ultra & 0x001F) {
+			if (id->dma_ultra & 0x003F) {
 				/* Force if Capable UltraDMA */
 				dma_func = config_chipset_for_dma(drive, 1);
 				if ((id->field_valid & 2) &&
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/sl82c105.c linux/drivers/ide/sl82c105.c
--- v2.4.9/linux/drivers/ide/sl82c105.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/ide/sl82c105.c	Fri Sep  7 10:45:30 2001
@@ -28,7 +28,6 @@
 
 extern char *ide_xfer_verbose (byte xfer_rate);
 
-#ifdef CONFIG_ARCH_NETWINDER
 /*
  * Convert a PIO mode and cycle time to the required on/off
  * times for the interface.  This has protection against run-away
@@ -272,37 +271,4 @@
 {
 	hwif->tuneproc = tune_sl82c105;
 }
-
-#else
-
-unsigned int pci_init_sl82c105(struct pci_dev *dev, const char *msg)
-{
-	return ide_special_settings(dev, msg);
-}
-
-void dma_init_sl82c105(ide_hwif_t *hwif, unsigned long dma_base)
-{
-	ide_setup_dma(hwif, dma_base, 8);
-}
-
-void __init ide_init_sl82c105(ide_hwif_t *hwif)
-{
-	struct pci_dev *dev = hwif->pci_dev;
-	unsigned short t16;
-	unsigned int t32;
-	pci_read_config_word(dev, PCI_COMMAND, &t16);
-	printk("SL82C105 command word: %x\n",t16);
-        t16 |= PCI_COMMAND_IO;
-        pci_write_config_word(dev, PCI_COMMAND, t16);
-	/* IDE timing */
-	pci_read_config_dword(dev, 0x44, &t32);
-	printk("IDE timing: %08x, resetting to PIO0 timing\n",t32);
-	pci_write_config_dword(dev, 0x44, 0x03e4);
-#ifndef CONFIG_MBX
-	pci_read_config_dword(dev, 0x40, &t32);
-	printk("IDE control/status register: %08x\n",t32);
-	pci_write_config_dword(dev, 0x40, 0x10ff08a1);
-#endif /* CONFIG_MBX */
-}
-#endif
 
diff -u --recursive --new-file v2.4.9/linux/drivers/ide/via82cxxx.c linux/drivers/ide/via82cxxx.c
--- v2.4.9/linux/drivers/ide/via82cxxx.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/ide/via82cxxx.c	Tue Sep 11 08:40:36 2001
@@ -1,5 +1,5 @@
 /*
- * $Id: via82cxxx.c,v 3.23 2001/03/09 09:30:00 vojtech Exp $
+ * $Id: via82cxxx.c,v 3.29 2001/09/10 10:06:00 vojtech Exp $
  *
  *  Copyright (c) 2000-2001 Vojtech Pavlik
  *
@@ -14,17 +14,20 @@
 /*
  * VIA IDE driver for Linux. Supports
  *
- *   vt82c586, vt82c586a, vt82c586b, vt82c596a, vt82c596b,
+ *   vt82c576, vt82c586, vt82c586a, vt82c586b, vt82c596a, vt82c596b,
  *   vt82c686, vt82c686a, vt82c686b, vt8231, vt8233
  *
  * southbridges, which can be found in
  *
- *  VIA Apollo VP, VPX, VPX/97, VP2, VP2/97, VP3, MVP3, MVP4, P6, Pro,
- *  Pro Plus, Pro 133, Pro 133A, ProMedia PM601, ProSavage PM133, PLE133,
- *  Pro 266, KX133, KT133, ProSavage KM133, KT133A, KT266
- *  PC-Chips VXPro, VXPro+, TXPro-III, TXPro-AGP, ViaGra, BXToo, BXTel
- *  AMD 640, 640 AGP, 750 IronGate
- *  ETEQ 6618, 6628, 6638
+ *  VIA Apollo Master, VP, VP2, VP2/97, VP3, VPX, VPX/97, MVP3, MVP4, P6, Pro,
+ *    ProII, ProPlus, Pro133, Pro133+, Pro133A, Pro133A Dual, Pro133T, Pro133Z,
+ *    PLE133, PLE133T, Pro266, Pro266T, ProP4X266, PM601, PM133, PN133, PL133T,
+ *    PX266, PM266, KX133, KT133, KT133A, KLE133, KT266, KX266, KM133, KM133A,
+ *    KL133, KN133, KM266
+ *  PC-Chips VXPro, VXPro+, VXTwo, TXPro-III, TXPro-AGP, AGPPro, ViaGra, BXToo,
+ *    BXTel, BXpert
+ *  AMD 640, 640 AGP, 750 IronGate, 760, 760MP
+ *  ETEQ 6618, 6628, 6629, 6638
  *  Micron Samurai
  *
  * chipsets. Supports
@@ -87,8 +90,7 @@
 #define VIA_BAD_PREQ		0x010	/* Crashes if PREQ# till DDACK# set */
 #define VIA_BAD_CLK66		0x020	/* 66 MHz clock doesn't work correctly */
 #define VIA_SET_FIFO		0x040	/* Needs to have FIFO split set */
-#define VIA_SET_THRESH		0x080	/* Needs to have FIFO thresholds set */
-#define VIA_BAD_PIO		0x100	/* Always uses 26 PCICLK/xfer regardles of PIO mode */
+#define VIA_NO_UNMASK		0x080	/* Doesn't work with IRQ unmasking on */
 
 /*
  * VIA SouthBridge chips.
@@ -101,19 +103,24 @@
 	unsigned char rev_max;
 	unsigned short flags;
 } via_isa_bridges[] = {
-#ifdef VIA_NEW_BRIDGES_TESTED
-	{ "vt8233",	PCI_DEVICE_ID_VIA_8233_0,   0x00, 0x2f, VIA_UDMA_100 },
-	{ "vt8231",	PCI_DEVICE_ID_VIA_8231,     0x00, 0x2f, VIA_UDMA_66 },
+#ifdef FUTURE_BRIDGES
+	{ "vt8237",	PCI_DEVICE_ID_VIA_8237,     0x00, 0x2f, VIA_UDMA_100 },
+	{ "vt8235",	PCI_DEVICE_ID_VIA_8235,     0x00, 0x2f, VIA_UDMA_100 },
+	{ "vt8233c",	PCI_DEVICE_ID_VIA_8233C,    0x00, 0x2f, VIA_UDMA_100 },
 #endif
-	{ "vt82c686b",	PCI_DEVICE_ID_VIA_82C686,   0x40, 0x4f, VIA_UDMA_100 | VIA_BAD_PIO },
+	{ "vt8233",	PCI_DEVICE_ID_VIA_8233_0,   0x00, 0x2f, VIA_UDMA_100 },
+	{ "vt8231",	PCI_DEVICE_ID_VIA_8231,     0x00, 0x2f, VIA_UDMA_100 },
+	{ "vt82c686b",	PCI_DEVICE_ID_VIA_82C686,   0x40, 0x4f, VIA_UDMA_100 },
 	{ "vt82c686a",	PCI_DEVICE_ID_VIA_82C686,   0x10, 0x2f, VIA_UDMA_66 },
 	{ "vt82c686",	PCI_DEVICE_ID_VIA_82C686,   0x00, 0x0f, VIA_UDMA_33 | VIA_BAD_CLK66 },
 	{ "vt82c596b",	PCI_DEVICE_ID_VIA_82C596,   0x10, 0x2f, VIA_UDMA_66 },
 	{ "vt82c596a",	PCI_DEVICE_ID_VIA_82C596,   0x00, 0x0f, VIA_UDMA_33 | VIA_BAD_CLK66 },
-	{ "vt82c586b",	PCI_DEVICE_ID_VIA_82C586_0, 0x40, 0x4f, VIA_UDMA_33 | VIA_SET_FIFO | VIA_BAD_PREQ },
+	{ "vt82c586b",	PCI_DEVICE_ID_VIA_82C586_0, 0x47, 0x4f, VIA_UDMA_33 | VIA_SET_FIFO },
+	{ "vt82c586b",	PCI_DEVICE_ID_VIA_82C586_0, 0x40, 0x46, VIA_UDMA_33 | VIA_SET_FIFO | VIA_BAD_PREQ },
 	{ "vt82c586b",	PCI_DEVICE_ID_VIA_82C586_0, 0x30, 0x3f, VIA_UDMA_33 | VIA_SET_FIFO },
 	{ "vt82c586a",	PCI_DEVICE_ID_VIA_82C586_0, 0x20, 0x2f, VIA_UDMA_33 | VIA_SET_FIFO },
 	{ "vt82c586",	PCI_DEVICE_ID_VIA_82C586_0, 0x00, 0x0f, VIA_UDMA_NONE | VIA_SET_FIFO },
+	{ "vt82c576",	PCI_DEVICE_ID_VIA_82C576,   0x00, 0x2f, VIA_UDMA_NONE | VIA_SET_FIFO | VIA_NO_UNMASK },
 	{ NULL }
 };
 
@@ -154,7 +161,7 @@
 
 	via_print("----------VIA BusMastering IDE Configuration----------------");
 
-	via_print("Driver Version:                     3.23");
+	via_print("Driver Version:                     3.29");
 	via_print("South Bridge:                       VIA %s", via_config->name);
 
 	pci_read_config_byte(isa_dev, PCI_REVISION_ID, &t);
@@ -220,8 +227,8 @@
 		switch (via_config->flags & VIA_UDMA) {
 			
 			case VIA_UDMA_100:
-				speed[i] = 2000 / udma[i];
-				cycle[i] = 10 * udma[i];
+				speed[i] = 60 * via_clock / udma[i];
+				cycle[i] = 333 / via_clock * udma[i];
 				break;
 
 			case VIA_UDMA_66:
@@ -301,7 +308,7 @@
 	switch (via_config->flags & VIA_UDMA) {
 		case VIA_UDMA_33:   UT = T;   break;
 		case VIA_UDMA_66:   UT = T/2; break;
-		case VIA_UDMA_100:  UT = 10;  break;
+		case VIA_UDMA_100:  UT = T/3; break;
 		default:	    UT = T;   break;
 	}
 
@@ -424,7 +431,7 @@
 	}
 
 	if (via_config->flags & VIA_BAD_CLK66) {			/* Disable Clk66 */
-		pci_read_config_dword(dev, VIA_UDMA_TIMING, &u);	/* Would cause trouble on 596a */
+		pci_read_config_dword(dev, VIA_UDMA_TIMING, &u);	/* Would cause trouble on 596a and 686 */
 		pci_write_config_dword(dev, VIA_UDMA_TIMING, u & ~0x80008);
 	}
 
@@ -453,9 +460,6 @@
 		}
 	}
 
-	if (via_config->flags & VIA_SET_THRESH)				/* 1/2 FIFO full to trigger xmit */
-		t = (t & 0xf0) | 0x0a;
-
 	pci_write_config_byte(dev, VIA_FIFO_CONFIG, t);
 
 /*
@@ -509,7 +513,7 @@
 
 	for (i = 0; i < 2; i++) {
 		hwif->drives[i].io_32bit = 1;
-		hwif->drives[i].unmask = 1;
+		hwif->drives[i].unmask = (via_config->flags & VIA_NO_UNMASK) ? 0 : 1;
 		hwif->drives[i].autotune = 1;
 		hwif->drives[i].dn = hwif->channel * 2 + i;
 	}
diff -u --recursive --new-file v2.4.9/linux/drivers/ieee1394/highlevel.c linux/drivers/ieee1394/highlevel.c
--- v2.4.9/linux/drivers/ieee1394/highlevel.c	Wed Jul 25 17:10:20 2001
+++ linux/drivers/ieee1394/highlevel.c	Fri Sep  7 09:28:38 2001
@@ -157,15 +157,16 @@
 #define DEFINE_MULTIPLEXER(Function) \
 void highlevel_##Function(struct hpsb_host *host) \
 { \
-        struct list_head *entry; \
+        struct list_head *entry,*next; \
         void (*funcptr)(struct hpsb_host*); \
         read_lock(&hl_drivers_lock); \
         entry = hl_drivers.next; \
         while (entry != &hl_drivers) { \
+        	next = entry->next; \
                 funcptr = list_entry(entry, struct hpsb_highlevel, hl_list) \
                           ->op->Function; \
                 if (funcptr) funcptr(host); \
-                entry = entry->next; \
+                entry = next; \
         } \
         read_unlock(&hl_drivers_lock); \
 }
diff -u --recursive --new-file v2.4.9/linux/drivers/ieee1394/ieee1394_core.c linux/drivers/ieee1394/ieee1394_core.c
--- v2.4.9/linux/drivers/ieee1394/ieee1394_core.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/ieee1394/ieee1394_core.c	Fri Sep  7 09:28:38 2001
@@ -352,7 +352,7 @@
         }
 
         if (ackcode != ACK_PENDING || !packet->expect_response) {
-                packet->state = complete;
+                packet->state = completed;
                 up(&packet->state_change);
                 up(&packet->state_change);
                 run_task_queue(&packet->complete_tq);
@@ -503,7 +503,7 @@
                 break;
         }
 
-        packet->state = complete;
+        packet->state = completed;
         up(&packet->state_change);
         run_task_queue(&packet->complete_tq);
 }
@@ -720,7 +720,7 @@
 
         list_for_each(lh, &llist) {
                 packet = list_entry(lh, struct hpsb_packet, list);
-                packet->state = complete;
+                packet->state = completed;
                 packet->ack_code = ACKX_ABORTED;
                 up(&packet->state_change);
                 run_task_queue(&packet->complete_tq);
@@ -761,7 +761,7 @@
 
         list_for_each(lh, &expiredlist) {
                 packet = list_entry(lh, struct hpsb_packet, list);
-                packet->state = complete;
+                packet->state = completed;
                 packet->ack_code = ACKX_TIMEOUT;
                 up(&packet->state_change);
                 run_task_queue(&packet->complete_tq);
diff -u --recursive --new-file v2.4.9/linux/drivers/ieee1394/ieee1394_core.h linux/drivers/ieee1394/ieee1394_core.h
--- v2.4.9/linux/drivers/ieee1394/ieee1394_core.h	Mon Aug 27 12:41:41 2001
+++ linux/drivers/ieee1394/ieee1394_core.h	Fri Sep  7 09:28:38 2001
@@ -25,11 +25,11 @@
         /* Okay, this is core internal and a no care for hosts.
          * queued   = queued for sending
          * pending  = sent, waiting for response
-         * complete = processing completed, successful or not
+         * completed = processing completed, successful or not
          * incoming = incoming packet
          */
         enum { 
-                unused, queued, pending, complete, incoming 
+                unused, queued, pending, completed, incoming 
         } __attribute__((packed)) state;
 
         /* These are core internal. */
diff -u --recursive --new-file v2.4.9/linux/drivers/ieee1394/video1394.c linux/drivers/ieee1394/video1394.c
--- v2.4.9/linux/drivers/ieee1394/video1394.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/ieee1394/video1394.c	Thu Sep 13 15:21:32 2001
@@ -103,7 +103,7 @@
 	int ctxMatch;
 	wait_queue_head_t waitq;
         spinlock_t lock;
-    unsigned int syt_offset;
+	unsigned int syt_offset;
 	int flags;
 };
 
diff -u --recursive --new-file v2.4.9/linux/drivers/input/Config.in linux/drivers/input/Config.in
--- v2.4.9/linux/drivers/input/Config.in	Tue Aug 22 11:41:14 2000
+++ linux/drivers/input/Config.in	Wed Sep 12 15:34:06 2001
@@ -6,15 +6,13 @@
 comment 'Input core support'
 
 tristate 'Input core support' CONFIG_INPUT
-if [ "$CONFIG_INPUT" != "n" ]; then
-   dep_tristate '  Keyboard support' CONFIG_INPUT_KEYBDEV $CONFIG_INPUT
-   dep_tristate '  Mouse support' CONFIG_INPUT_MOUSEDEV $CONFIG_INPUT
-   if [ "$CONFIG_INPUT_MOUSEDEV" != "n" ]; then
-      int '   Horizontal screen resolution' CONFIG_INPUT_MOUSEDEV_SCREEN_X 1024
-      int '   Vertical screen resolution' CONFIG_INPUT_MOUSEDEV_SCREEN_Y 768
-   fi
-   dep_tristate '  Joystick support' CONFIG_INPUT_JOYDEV $CONFIG_INPUT
-   dep_tristate '  Event interface support' CONFIG_INPUT_EVDEV $CONFIG_INPUT
+dep_tristate '  Keyboard support' CONFIG_INPUT_KEYBDEV $CONFIG_INPUT
+dep_tristate '  Mouse support' CONFIG_INPUT_MOUSEDEV $CONFIG_INPUT
+if [ "$CONFIG_INPUT_MOUSEDEV" != "n" ]; then
+   int '   Horizontal screen resolution' CONFIG_INPUT_MOUSEDEV_SCREEN_X 1024
+   int '   Vertical screen resolution' CONFIG_INPUT_MOUSEDEV_SCREEN_Y 768
 fi
+dep_tristate '  Joystick support' CONFIG_INPUT_JOYDEV $CONFIG_INPUT
+dep_tristate '  Event interface support' CONFIG_INPUT_EVDEV $CONFIG_INPUT
 
 endmenu
diff -u --recursive --new-file v2.4.9/linux/drivers/input/evdev.c linux/drivers/input/evdev.c
--- v2.4.9/linux/drivers/input/evdev.c	Fri Feb  9 11:30:23 2001
+++ linux/drivers/input/evdev.c	Wed Sep 12 15:34:06 2001
@@ -1,7 +1,7 @@
 /*
- * $Id: evdev.c,v 1.10 2000/06/23 09:23:00 vojtech Exp $
+ * $Id: evdev.c,v 1.27 2001/05/28 09:06:44 vojtech Exp $
  *
- *  Copyright (c) 1999-2000 Vojtech Pavlik
+ *  Copyright (c) 1999-2001 Vojtech Pavlik
  *
  *  Event char devices, giving access to raw input device events.
  *
@@ -11,18 +11,18 @@
 /*
  * 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 
+ * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * 
+ *
  * Should you need to contact me, the author, you can do so either by
  * e-mail - mail your message to <vojtech@suse.cz>, or by paper mail:
  * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
@@ -72,7 +72,7 @@
 		list->buffer[list->head].code = code;
 		list->buffer[list->head].value = value;
 		list->head = (list->head + 1) & (EVDEV_BUFFER_SIZE - 1);
-		
+
 		kill_fasync(&list->fasync, SIGIO, POLL_IN);
 
 		list = list->next;
@@ -104,7 +104,7 @@
 
 	if (!--list->evdev->open) {
 		if (list->evdev->exist) {
-			input_close_device(&list->evdev->handle);	
+			input_close_device(&list->evdev->handle);
 		} else {
 			input_unregister_minor(list->evdev->devfs);
 			evdev_table[list->evdev->minor] = NULL;
@@ -138,14 +138,26 @@
 
 	if (!list->evdev->open++)
 		if (list->evdev->exist)
-			input_open_device(&list->evdev->handle);	
+			input_open_device(&list->evdev->handle);
 
 	return 0;
 }
 
 static ssize_t evdev_write(struct file * file, const char * buffer, size_t count, loff_t *ppos)
 {
-	return -EINVAL;
+	struct evdev_list *list = file->private_data;
+	struct input_event event;
+	int retval = 0;
+
+	while (retval < count) {
+
+		if (copy_from_user(&event, buffer + retval, sizeof(struct input_event)))
+			return -EFAULT;
+		input_event(list->evdev->handle.dev, event.type, event.code, event.value);
+		retval += sizeof(struct input_event);
+	}
+
+	return retval;
 }
 
 static ssize_t evdev_read(struct file * file, char * buffer, size_t count, loff_t *ppos)
@@ -161,6 +173,10 @@
 
 		while (list->head == list->tail) {
 
+			if (!list->evdev->exist) {
+				retval = -ENODEV;
+				break;
+			}
 			if (file->f_flags & O_NONBLOCK) {
 				retval = -EAGAIN;
 				break;
@@ -187,7 +203,7 @@
 		retval += sizeof(struct input_event);
 	}
 
-	return retval;	
+	return retval;
 }
 
 /* No kernel lock - fine */
@@ -219,6 +235,32 @@
 			if ((retval = put_user(dev->idversion, ((short *) arg) + 3))) return retval;
 			return 0;
 
+		case EVIOCSFF:
+			if (dev->upload_effect) {
+				struct ff_effect effect;
+				int err;
+
+				if (copy_from_user((void*)(&effect), (void*)arg, sizeof(effect))) {
+					return -EINVAL;
+				}
+				err = dev->upload_effect(dev, &effect);
+				if (put_user(effect.id, &(((struct ff_effect*)arg)->id))) {
+					return -EINVAL;
+				}
+				return err;
+			}
+			else return -ENOSYS;
+
+		case EVIOCRMFF:
+			if (dev->erase_effect) {
+				return dev->erase_effect(dev, (int)arg);
+			}
+			else return -ENOSYS;
+
+		case EVIOCGEFFECTS:
+			put_user(dev->ff_effects_max, (int*) arg);
+			return 0;
+
 		default:
 
 			if (_IOC_TYPE(cmd) != 'E' || _IOC_DIR(cmd) != _IOC_READ)
@@ -236,6 +278,7 @@
 					case EV_ABS: bits = dev->absbit; len = ABS_MAX; break;
 					case EV_LED: bits = dev->ledbit; len = LED_MAX; break;
 					case EV_SND: bits = dev->sndbit; len = SND_MAX; break;
+					case EV_FF:  bits = dev->ffbit;  len = FF_MAX;  break;
 					default: return -EINVAL;
 				}
 				len = NBITS(len) * sizeof(long);
@@ -310,7 +353,7 @@
 
 	evdev->devfs = input_register_minor("event%d", minor, EVDEV_MINOR_BASE);
 
-	printk(KERN_INFO "event%d: Event device for input%d\n", minor, dev->number);
+//	printk(KERN_INFO "event%d: Event device for input%d\n", minor, dev->number);
 
 	return &evdev->handle;
 }
@@ -323,13 +366,14 @@
 
 	if (evdev->open) {
 		input_close_device(handle);
+		wake_up_interruptible(&evdev->wait);
 	} else {
 		input_unregister_minor(evdev->devfs);
 		evdev_table[evdev->minor] = NULL;
 		kfree(evdev);
 	}
 }
-	
+
 static struct input_handler evdev_handler = {
 	event:		evdev_event,
 	connect:	evdev_connect,
diff -u --recursive --new-file v2.4.9/linux/drivers/input/input.c linux/drivers/input/input.c
--- v2.4.9/linux/drivers/input/input.c	Fri Nov 17 16:52:23 2000
+++ linux/drivers/input/input.c	Wed Sep 12 15:34:06 2001
@@ -1,7 +1,7 @@
 /*
- * $Id: input.c,v 1.7 2000/05/28 17:31:36 vojtech Exp $
+ * $Id: input.c,v 1.20 2001/05/17 15:50:27 vojtech Exp $
  *
- *  Copyright (c) 1999-2000 Vojtech Pavlik
+ *  Copyright (c) 1999-2001 Vojtech Pavlik
  *
  *  The input layer module itself
  *
@@ -124,6 +124,13 @@
 
 			break;
 
+		case EV_MSC:
+
+			if (code > MSC_MAX || !test_bit(code, dev->mscbit))
+				return;
+	
+			break;
+
 		case EV_LED:
 	
 			if (code > LED_MAX || !test_bit(code, dev->ledbit) || !!test_bit(code, dev->led) == value)
@@ -152,14 +159,11 @@
 			if (dev->event) dev->event(dev, type, code, value);
 
 			break;
-	}
-/*
- * Add randomness.
- */
 
-#if 0 /* BUG */
-	add_input_randomness(((unsigned long) dev) ^ (type << 24) ^ (code << 16) ^ value);
-#endif
+		case EV_FF:
+			if (dev->event) dev->event(dev, type, code, value);
+			break;
+	}
 
 /*
  * Distribute the event to handler modules.
diff -u --recursive --new-file v2.4.9/linux/drivers/input/keybdev.c linux/drivers/input/keybdev.c
--- v2.4.9/linux/drivers/input/keybdev.c	Wed Apr 25 14:35:25 2001
+++ linux/drivers/input/keybdev.c	Wed Sep 12 15:34:06 2001
@@ -39,7 +39,8 @@
 
 #if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(__alpha__) || \
     defined(__mips__) || defined(CONFIG_SPARC64) || defined(CONFIG_SUPERH) || \
-    defined(CONFIG_PPC) || defined(__mc68000__)
+    defined(CONFIG_PPC) || defined(__mc68000__) || defined(__hppa__) || \
+    defined(__arm__)
 
 static int x86_sysrq_alt = 0;
 #ifdef CONFIG_SPARC64
@@ -197,14 +198,14 @@
 
 	input_open_device(handle);
 
-	printk(KERN_INFO "keybdev.c: Adding keyboard: input%d\n", dev->number);
+//	printk(KERN_INFO "keybdev.c: Adding keyboard: input%d\n", dev->number);
 
 	return handle;
 }
 
 static void keybdev_disconnect(struct input_handle *handle)
 {
-	printk(KERN_INFO "keybdev.c: Removing keyboard: input%d\n", handle->dev->number);
+//	printk(KERN_INFO "keybdev.c: Removing keyboard: input%d\n", handle->dev->number);
 	input_close_device(handle);
 	kfree(handle);
 }
diff -u --recursive --new-file v2.4.9/linux/drivers/input/mousedev.c linux/drivers/input/mousedev.c
--- v2.4.9/linux/drivers/input/mousedev.c	Sun Mar 25 18:14:20 2001
+++ linux/drivers/input/mousedev.c	Wed Sep 12 15:34:06 2001
@@ -1,9 +1,9 @@
 /*
- * $Id: mousedev.c,v 1.15 2000/08/14 21:05:26 vojtech Exp $
+ * $Id: mousedev.c,v 1.24 2000/11/15 10:57:45 vojtech Exp $
  *
  *  Copyright (c) 1999-2000 Vojtech Pavlik
  *
- *  Input driver to PS/2 or ImPS/2 device driver module.
+ *  Input driver to ImExPS/2 device driver module.
  *
  *  Sponsored by SuSE
  */
@@ -66,20 +66,22 @@
 	signed char ps2[6];
 	unsigned long buttons;
 	unsigned char ready, buffer, bufsiz;
-	unsigned char mode, genseq, impseq;
+	unsigned char mode, imexseq, impsseq;
 };
 
-#define MOUSEDEV_GENIUS_LEN	5
-#define MOUSEDEV_IMPS_LEN	6
+#define MOUSEDEV_SEQ_LEN	6
 
-static unsigned char mousedev_genius_seq[] = { 0xe8, 3, 0xe6, 0xe6, 0xe6 };
 static unsigned char mousedev_imps_seq[] = { 0xf3, 200, 0xf3, 100, 0xf3, 80 };
+static unsigned char mousedev_imex_seq[] = { 0xf3, 200, 0xf3, 200, 0xf3, 80 };
 
 static struct input_handler mousedev_handler;
 
 static struct mousedev *mousedev_table[MOUSEDEV_MINORS];
 static struct mousedev mousedev_mix;
 
+static int xres = CONFIG_INPUT_MOUSEDEV_SCREEN_X;
+static int yres = CONFIG_INPUT_MOUSEDEV_SCREEN_Y;
+
 static void mousedev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
 {
 	struct mousedev *mousedevs[3] = { handle->private, &mousedev_mix, NULL };
@@ -99,12 +101,12 @@
 					switch (code) {
 						case ABS_X:	
 							size = handle->dev->absmax[ABS_X] - handle->dev->absmin[ABS_X];
-							list->dx += (value * CONFIG_INPUT_MOUSEDEV_SCREEN_X - list->oldx) / size;
+							list->dx += (value * xres - list->oldx) / size;
 							list->oldx += list->dx * size;
 							break;
 						case ABS_Y:
 							size = handle->dev->absmax[ABS_Y] - handle->dev->absmin[ABS_Y];
-							list->dy -= (value * CONFIG_INPUT_MOUSEDEV_SCREEN_Y - list->oldy) / size;
+							list->dy -= (value * yres - list->oldy) / size;
 							list->oldy -= list->dy * size;
 							break;
 					}
@@ -124,12 +126,12 @@
 						case BTN_TOUCH:
 						case BTN_LEFT:   index = 0; break;
 						case BTN_4:
-						case BTN_EXTRA:  if (list->mode > 1) { index = 4; break; }
+						case BTN_EXTRA:  if (list->mode == 2) { index = 4; break; }
 						case BTN_STYLUS:
 						case BTN_1:
 						case BTN_RIGHT:  index = 1; break;
 						case BTN_3:
-						case BTN_SIDE:   if (list->mode > 1) { index = 3; break; }
+						case BTN_SIDE:   if (list->mode == 2) { index = 3; break; }
 						case BTN_2:
 						case BTN_STYLUS2:
 						case BTN_MIDDLE: index = 2; break;	
@@ -257,14 +259,19 @@
 	list->dy -= list->ps2[off + 2];
 	list->bufsiz = off + 3;
 
-	if (list->mode > 1)
-		list->ps2[off] |= ((list->buttons & 0x18) << 3);
+	if (list->mode == 2) {
+		list->ps2[off + 3] = (list->dz > 7 ? 7 : (list->dz < -7 ? -7 : list->dz));
+		list->dz -= list->ps2[off + 3];
+		list->ps2[off + 3] = (list->ps2[off + 3] & 0x0f) | ((list->buttons & 0x18) << 1);
+		list->bufsiz++;
+	}
 	
-	if (list->mode) {
+	if (list->mode == 1) {
 		list->ps2[off + 3] = (list->dz > 127 ? 127 : (list->dz < -127 ? -127 : list->dz));
-		list->bufsiz++;
 		list->dz -= list->ps2[off + 3];
+		list->bufsiz++;
 	}
+
 	if (!list->dx && !list->dy && (!list->mode || !list->dz)) list->ready = 0;
 	list->buffer = list->bufsiz;
 }
@@ -278,27 +285,26 @@
 
 	for (i = 0; i < count; i++) {
 
-		if (get_user(c, &buffer[i]))
+		if (get_user(c, buffer + i))
 			return -EFAULT;
 
-		if (c == mousedev_genius_seq[list->genseq]) {
-			if (++list->genseq == MOUSEDEV_GENIUS_LEN) {
-				list->genseq = 0;
-				list->ready = 1;
+		if (c == mousedev_imex_seq[list->imexseq]) {
+			if (++list->imexseq == MOUSEDEV_SEQ_LEN) {
+				list->imexseq = 0;
 				list->mode = 2;
 			}
-		} else list->genseq = 0;
+		} else list->imexseq = 0;
 
-		if (c == mousedev_imps_seq[list->impseq]) {
-			if (++list->impseq == MOUSEDEV_IMPS_LEN) {
-				list->impseq = 0;
-				list->ready = 1;
+		if (c == mousedev_imps_seq[list->impsseq]) {
+			if (++list->impsseq == MOUSEDEV_SEQ_LEN) {
+				list->impsseq = 0;
 				list->mode = 1;
 			}
-		} else list->impseq = 0;
+		} else list->impsseq = 0;
 
 		list->ps2[0] = 0xfa;
 		list->bufsiz = 1;
+		list->ready = 1;
 
 		switch (c) {
 
@@ -307,16 +313,16 @@
 				break;
 
 			case 0xf2: /* Get ID */
-				list->ps2[1] = (list->mode == 1) ? 3 : 0;
+				switch (list->mode) {
+					case 0: list->ps2[1] = 0;
+					case 1: list->ps2[1] = 3;
+					case 2: list->ps2[1] = 4;
+				}
 				list->bufsiz = 2;
 				break;
 
 			case 0xe9: /* Get info */
-				if (list->mode == 2) {
-					list->ps2[1] = 0x00; list->ps2[2] = 0x33; list->ps2[3] = 0x55;
-				} else {
-					list->ps2[1] = 0x60; list->ps2[2] = 3; list->ps2[3] = 200;
-				}
+				list->ps2[1] = 0x60; list->ps2[2] = 3; list->ps2[3] = 200;
 				list->bufsiz = 4;
 				break;
 		}
@@ -434,7 +440,7 @@
 	if (mousedev_mix.open)
 		input_open_device(&mousedev->handle);
 
-	printk(KERN_INFO "mouse%d: PS/2 mouse device for input%d\n", minor, dev->number);
+//	printk(KERN_INFO "mouse%d: PS/2 mouse device for input%d\n", minor, dev->number);
 
 	return &mousedev->handle;
 }
@@ -491,3 +497,7 @@
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
 MODULE_DESCRIPTION("Input driver to PS/2 or ImPS/2 device driver");
+MODULE_PARM(xres, "i");
+MODULE_PARM_DESC(xres, "Horizontal screen resolution");
+MODULE_PARM(yres, "i");
+MODULE_PARM_DESC(yres, "Vertical screen resolution");
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/Config.in linux/drivers/isdn/Config.in
--- v2.4.9/linux/drivers/isdn/Config.in	Mon Aug 27 12:41:41 2001
+++ linux/drivers/isdn/Config.in	Sun Sep  9 10:45:43 2001
@@ -76,8 +76,11 @@
 	 bool '  Am7930' CONFIG_HISAX_AMD7930
       fi
    fi
+   bool '  HiSax debugging' CONFIG_HISAX_DEBUG
+
    dep_tristate 'Sedlbauer PCMCIA cards' CONFIG_HISAX_SEDLBAUER_CS $CONFIG_PCMCIA
    dep_tristate 'ELSA PCMCIA MicroLink cards' CONFIG_HISAX_ELSA_CS $CONFIG_PCMCIA
+   dep_tristate 'ST5481 USB ISDN modem (EXPERIMENTAL)' CONFIG_HISAX_ST5481 $CONFIG_HISAX $CONFIG_USB $CONFIG_EXPERIMENTAL
 fi
 endmenu
 
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/act2000/act2000_isa.c linux/drivers/isdn/act2000/act2000_isa.c
--- v2.4.9/linux/drivers/isdn/act2000/act2000_isa.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/isdn/act2000/act2000_isa.c	Sun Sep  9 10:43:02 2001
@@ -418,7 +418,7 @@
 int
 act2000_isa_download(act2000_card * card, act2000_ddef * cb)
 {
-        int length;
+        unsigned int length;
         int ret;
         int l;
         int c;
@@ -431,9 +431,8 @@
         if (!act2000_isa_reset(card->port))
                 return -ENXIO;
         act2000_isa_delay(HZ / 2);
-        if ((ret = verify_area(VERIFY_READ, (void *) cb, sizeof(cblock))))
-                return ret;
-        copy_from_user(&cblock, (char *) cb, sizeof(cblock));
+        if(copy_from_user(&cblock, (char *) cb, sizeof(cblock)))
+        	return -EFAULT;
         length = cblock.length;
         p = cblock.buffer;
         if ((ret = verify_area(VERIFY_READ, (void *) p, length)))
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/eicon/Divas_mod.c linux/drivers/isdn/eicon/Divas_mod.c
--- v2.4.9/linux/drivers/isdn/eicon/Divas_mod.c	Fri Mar  2 11:12:08 2001
+++ linux/drivers/isdn/eicon/Divas_mod.c	Thu Sep 13 12:55:23 2001
@@ -29,7 +29,7 @@
 #include <linux/pci.h>
 #include <linux/ioport.h>
 #include <linux/slab.h>
-#include <errno.h>
+#include <linux/errno.h>
 
 #include "adapter.h"
 #include "uxio.h"
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/eicon/idi.c linux/drivers/isdn/eicon/idi.c
--- v2.4.9/linux/drivers/isdn/eicon/idi.c	Fri Mar  2 11:12:08 2001
+++ linux/drivers/isdn/eicon/idi.c	Sun Sep  9 10:45:43 2001
@@ -431,7 +431,9 @@
     i = this->XCurrent;
     X = PTR_X(a,this);
     while(i<this->XNum && length<270) {
-      clength = MIN((word)(270-length),X[i].PLength-this->XOffset);
+      clength = (word)(270-length);
+      if (clength > X[i].PLength-this->XOffset)
+	      clength = X[i].PLength-this->XOffset;
       a->ram_out_buffer(a,
                         &ReqOut->XBuffer.P[length],
                         PTR_P(a,this,&X[i].P[this->XOffset]),
@@ -837,8 +839,9 @@
         this->ROffset = 0;
         this->RCurrent++;
       }
-      clength = MIN(a->ram_inw(a, &RBuffer->length)-offset,
-                    R[this->RCurrent].PLength-this->ROffset);
+      clength = a->ram_inw(a, &RBuffer->length)-offset;
+      if (clength > R[this->RCurrent].PLength-this->ROffset)
+	      clength = R[this->RCurrent].PLength-this->ROffset;
       if(R[this->RCurrent].P) {
         a->ram_in_buffer(a,
                          &RBuffer->P[offset],
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/eicon/kprintf.c linux/drivers/isdn/eicon/kprintf.c
--- v2.4.9/linux/drivers/isdn/eicon/kprintf.c	Mon Aug 27 12:41:41 2001
+++ linux/drivers/isdn/eicon/kprintf.c	Sun Sep  9 10:45:43 2001
@@ -30,8 +30,6 @@
 #include "eicon.h"
 #include "sys.h"
 #include <stdarg.h>
-#undef MAX
-#undef MIN
 
 #include "divas.h"
 #include "divalog.h"
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/eicon/pc.h linux/drivers/isdn/eicon/pc.h
--- v2.4.9/linux/drivers/isdn/eicon/pc.h	Fri Mar  2 11:12:08 2001
+++ linux/drivers/isdn/eicon/pc.h	Sun Sep  9 10:45:43 2001
@@ -29,12 +29,6 @@
 #define byte unsigned char
 #define word unsigned short
 #define dword unsigned long
-#if !defined(MIN)
-#define MIN(a,b) ((a)>(b) ? (b) : (a))
-#endif
-#if !defined(MAX)
-#define MAX(a,b) ((a)>(b) ? (a) : (b))
-#endif
 
 /*------------------------------------------------------------------*/
 /* buffer definition                                                */
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/eicon/sys.h linux/drivers/isdn/eicon/sys.h
--- v2.4.9/linux/drivers/isdn/eicon/sys.h	Fri Mar  2 11:12:08 2001
+++ linux/drivers/isdn/eicon/sys.h	Sun Sep  9 10:45:43 2001
@@ -54,15 +54,6 @@
 #define NULL    ((void *) 0)
 #endif
 
-/* MIN and MAX */
-
-#if !defined(MIN)
-#define MIN(a,b) ((a)>(b) ? (b) : (a))
-#endif
-#if !defined(MAX)
-#define MAX(a,b) ((a)>(b) ? (a) : (b))
-#endif
-
 /* Return the dimension of an array */
 
 #if !defined(DIM)
@@ -85,6 +76,8 @@
 /* void HwAssert(char *file, int line, char *condition); */
 
 #include <linux/kernel.h>
+#include <linux/string.h>
+
 #define _PRINTK printk
 
 #define _PRINTF	DivasPrintf
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/hisax/Makefile linux/drivers/isdn/hisax/Makefile
--- v2.4.9/linux/drivers/isdn/hisax/Makefile	Sun Aug 12 13:27:59 2001
+++ linux/drivers/isdn/hisax/Makefile	Sun Sep  9 10:45:43 2001
@@ -2,20 +2,21 @@
 
 # The target object and module list name.
 
-O_TARGET	:= vmlinux-obj.o
+O_TARGET	  := vmlinux-obj.o
 
 # Objects that export symbols.
 
-export-objs	:= config.o
+export-objs	  := config.o fsm.o
 
 # Multipart objects.
 
-list-multi	:= hisax.o
-hisax-objs	:= config.o isdnl1.o tei.o isdnl2.o isdnl3.o \
-		   lmgr.o q931.o callc.o fsm.o cert.o
+list-multi	  := hisax.o hisax_st5481.o
+hisax-objs	  := config.o isdnl1.o tei.o isdnl2.o isdnl3.o \
+		     lmgr.o q931.o callc.o fsm.o cert.o
+hisax_st5481-objs := st5481_init.o st5481_usb.o st5481_d.o st5481_b.o \
+		     st5481_hdlc.o
 
 # Optional parts of multipart objects.
-
 hisax-objs-$(CONFIG_HISAX_EURO) += l3dss1.o
 hisax-objs-$(CONFIG_HISAX_NI1) += l3ni1.o
 hisax-objs-$(CONFIG_HISAX_1TR6) += l3_1tr6.o
@@ -27,7 +28,6 @@
 hisax-objs-$(CONFIG_HISAX_AVM_A1) += avm_a1.o isac.o arcofi.o hscx.o
 hisax-objs-$(CONFIG_HISAX_AVM_A1_PCMCIA) += avm_a1p.o isac.o arcofi.o hscx.o
 hisax-objs-$(CONFIG_HISAX_FRITZPCI) += avm_pci.o isac.o arcofi.o
-hisax-objs-$(CONFIG_HISAX_AVM_A1) += avm_a1.o isac.o arcofi.o hscx.o
 hisax-objs-$(CONFIG_HISAX_ELSA) += elsa.o isac.o arcofi.o hscx.o
 hisax-objs-$(CONFIG_HISAX_IX1MICROR2) += ix1_micro.o isac.o arcofi.o hscx.o
 hisax-objs-$(CONFIG_HISAX_DIEHLDIVA) += diva.o isac.o arcofi.o hscx.o
@@ -54,9 +54,10 @@
 
 # Each configuration option enables a list of files.
 
-obj-$(CONFIG_ISDN_DRV_HISAX)	+= hisax.o
+obj-$(CONFIG_ISDN_DRV_HISAX)		+= hisax.o
 obj-$(CONFIG_HISAX_SEDLBAUER_CS)	+= sedlbauer_cs.o
-obj-$(CONFIG_HISAX_ELSA_CS)	+= elsa_cs.o
+obj-$(CONFIG_HISAX_ELSA_CS)		+= elsa_cs.o
+obj-$(CONFIG_HISAX_ST5481)		+= hisax_st5481.o
 
 CERT := $(shell md5sum -c md5sums.asc >> /dev/null;echo $$?)
 CFLAGS_cert.o := -DCERTIFICATION=$(CERT)
@@ -67,3 +68,6 @@
 
 hisax.o: $(hisax-objs)
 	$(LD) -r -o $@ $(hisax-objs)
+
+hisax_st5481.o: $(hisax_st5481-objs)
+	$(LD) -r -o $@ $(hisax_st5481-objs)
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/hisax/callc.c linux/drivers/isdn/hisax/callc.c
--- v2.4.9/linux/drivers/isdn/hisax/callc.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/isdn/hisax/callc.c	Sun Sep  9 10:45:43 2001
@@ -1,4 +1,4 @@
-/* $Id: callc.c,v 2.51.6.4 2001/06/09 15:14:17 kai Exp $
+/* $Id: callc.c,v 2.51.6.5 2001/08/23 19:44:23 kai Exp $
  *
  * Author       Karsten Keil (keil@isdn4linux.de)
  *              based on the teles driver from Jan den Ouden
@@ -20,12 +20,12 @@
 #define MOD_USE_COUNT ( GET_USE_COUNT (&__this_module))
 #endif	/* MODULE */
 
-const char *lli_revision = "$Revision: 2.51.6.4 $";
+const char *lli_revision = "$Revision: 2.51.6.5 $";
 
 extern struct IsdnCard cards[];
 extern int nrcards;
-extern void HiSax_mod_dec_use_count(void);
-extern void HiSax_mod_inc_use_count(void);
+extern void HiSax_mod_dec_use_count(struct IsdnCardState *cs);
+extern void HiSax_mod_inc_use_count(struct IsdnCardState *cs);
 
 static int init_b_st(struct Channel *chanp, int incoming);
 static void release_b_st(struct Channel *chanp);
@@ -1584,7 +1584,7 @@
 			}
 			break;
 		case (ISDN_CMD_LOCK):
-			HiSax_mod_inc_use_count();
+			HiSax_mod_inc_use_count(csta);
 #ifdef MODULE
 			if (csta->channel[0].debug & 0x400)
 				HiSax_putstatus(csta, "   LOCK ", "modcnt %lx",
@@ -1592,7 +1592,7 @@
 #endif				/* MODULE */
 			break;
 		case (ISDN_CMD_UNLOCK):
-			HiSax_mod_dec_use_count();
+			HiSax_mod_dec_use_count(csta);
 #ifdef MODULE
 			if (csta->channel[0].debug & 0x400)
 				HiSax_putstatus(csta, " UNLOCK ", "modcnt %lx",
@@ -1624,11 +1624,11 @@
 					break;
 				case (3):
 					for (i = 0; i < *(unsigned int *) ic->parm.num; i++)
-						HiSax_mod_dec_use_count();
+						HiSax_mod_dec_use_count(NULL);
 					break;
 				case (4):
 					for (i = 0; i < *(unsigned int *) ic->parm.num; i++)
-						HiSax_mod_inc_use_count();
+						HiSax_mod_inc_use_count(NULL);
 					break;
 				case (5):	/* set card in leased mode */
 					num = *(unsigned int *) ic->parm.num;
@@ -1698,7 +1698,7 @@
 #ifdef MODULE
 				case (55):
 					MOD_USE_COUNT = 0;
-					HiSax_mod_inc_use_count();
+					HiSax_mod_inc_use_count(NULL);
 					break;
 #endif				/* MODULE */
 				case (11):
@@ -1810,6 +1810,7 @@
 		cli();
 		nskb = skb_clone(skb, GFP_ATOMIC);
 		if (nskb) {
+			nskb->truesize = nskb->len;
 			if (!ack)
 				nskb->pkt_type = PACKET_NOACK;
 			if (chanp->l2_active_protocol == ISDN_PROTO_L2_X75I)
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/hisax/config.c linux/drivers/isdn/hisax/config.c
--- v2.4.9/linux/drivers/isdn/hisax/config.c	Wed Jul 25 17:10:20 2001
+++ linux/drivers/isdn/hisax/config.c	Sun Sep  9 10:45:43 2001
@@ -1,4 +1,4 @@
-/* $Id: config.c,v 2.57.6.16 2001/07/13 09:01:00 kai Exp $
+/* $Id: config.c,v 2.57.6.18 2001/08/27 22:19:05 kai Exp $
  *
  * Author       Karsten Keil (keil@isdn4linux.de)
  *              based on the teles driver from Jan den Ouden
@@ -313,7 +313,8 @@
 #define DEFAULT_PROTO_NAME "UNKNOWN"
 #endif
 #ifndef DEFAULT_CARD
-#error "HiSax: No cards configured"
+#define DEFAULT_CARD 0
+#define DEFAULT_CFG {0,0,0,0}
 #endif
 
 int hisax_init_pcmcia(void *, int *, struct IsdnCard *);
@@ -423,16 +424,6 @@
 	certification_check(1);
 }
 
-void HiSax_mod_dec_use_count(void)
-{
-	MOD_DEC_USE_COUNT;
-}
-
-void HiSax_mod_inc_use_count(void)
-{
-	MOD_INC_USE_COUNT;
-}
-
 #ifndef MODULE
 #define MAX_ARG	(HISAX_MAX_CARDS*5)
 static int __init HiSax_setup(char *line)
@@ -840,8 +831,9 @@
 	if (csta->DC_Close != NULL) {
 		csta->DC_Close(csta);
 	}
-	csta->cardmsg(csta, CARD_RELEASE, NULL);
-	if (csta->dbusytimer.function != NULL)
+	if (csta->cardmsg)
+		csta->cardmsg(csta, CARD_RELEASE, NULL);
+	if (csta->dbusytimer.function != NULL) // FIXME?
 		del_timer(&csta->dbusytimer);
 	ll_unload(csta);
 }
@@ -1137,6 +1129,9 @@
 		ret = setup_netjet_u(card);
 		break;
 #endif
+	case ISDN_CTYPE_DYNAMIC:
+		ret = 2;
+		break;
 	default:
 		printk(KERN_WARNING
 		       "HiSax: Support for %s Card not selected\n",
@@ -1165,7 +1160,17 @@
 
 	init_bcstate(cs, 0);
 	init_bcstate(cs, 1);
-	ret = init_card(cs);
+
+	/* init_card only handles interrupts which are not */
+	/* used here for the loadable driver */
+	switch (card->typ) {
+	case ISDN_CTYPE_DYNAMIC:
+		ret = 0;
+		break;
+	default:
+		ret = init_card(cs);
+		break;
+	}
 	if (ret) {
 		closecard(cardnr);
 		ret = 0;
@@ -1343,6 +1348,8 @@
 #ifdef MODULE
 	if (!type[0]) {
 		/* We 'll register drivers later, but init basic functions */
+		for (i = 0; i < HISAX_MAX_CARDS; i++)
+			cards[i].typ = 0;
 		return 0;
 	}
 #ifdef CONFIG_HISAX_ELSA
@@ -1572,7 +1579,6 @@
 {
 #ifdef MODULE
 	int i;
-	int nzproto = 0;
 
 	nrcards = 0;
 	/* Initialize all structs, even though we only accept
@@ -1584,14 +1590,12 @@
 		cards[i].typ = type[i];
 		if (protocol[i]) {
 			cards[i].protocol = protocol[i];
-			nzproto++;
 		}
 	}
 	cards[0].para[0] = pcm_irq;
 	cards[0].para[1] = (int) pcm_iob;
 	cards[0].protocol = prot;
 	cards[0].typ = ISDN_CTYPE_HFC_SP_PCMCIA;
-	nzproto = 1;
 
 	if (!HiSax_id)
 		HiSax_id = HiSaxID;
@@ -1615,7 +1619,6 @@
 {
 #ifdef MODULE
 	int i;
-	int nzproto = 0;
 
 	nrcards = 0;
 	/* Initialize all structs, even though we only accept
@@ -1627,14 +1630,12 @@
 		cards[i].typ = type[i];
 		if (protocol[i]) {
 			cards[i].protocol = protocol[i];
-			nzproto++;
 		}
 	}
 	cards[0].para[0] = pcm_irq;
 	cards[0].para[1] = (int) pcm_iob;
 	cards[0].protocol = prot;
 	cards[0].typ = ISDN_CTYPE_SEDLBAUER_PCMCIA;
-	nzproto = 1;
 
 	if (!HiSax_id)
 		HiSax_id = HiSaxID;
@@ -1658,7 +1659,6 @@
 {
 #ifdef MODULE
 	int i;
-	int nzproto = 0;
 
 	nrcards = 0;
 	/* Initialize all structs, even though we only accept
@@ -1670,14 +1670,12 @@
 		cards[i].typ = type[i];
 		if (protocol[i]) {
 			cards[i].protocol = protocol[i];
-			nzproto++;
 		}
 	}
 	cards[0].para[0] = pcm_irq;
 	cards[0].para[1] = (int) pcm_iob;
 	cards[0].protocol = prot;
 	cards[0].typ = ISDN_CTYPE_A1_PCMCIA;
-	nzproto = 1;
 
 	if (!HiSax_id)
 		HiSax_id = HiSaxID;
@@ -1715,11 +1713,362 @@
 	return ret;
 }
 
+#include "hisax_if.h"
+
+EXPORT_SYMBOL(hisax_register);
+EXPORT_SYMBOL(hisax_unregister);
+
+static void hisax_d_l1l2(struct hisax_if *ifc, int pr, void *arg);
+static void hisax_b_l1l2(struct hisax_if *ifc, int pr, void *arg);
+static void hisax_d_l2l1(struct PStack *st, int pr, void *arg);
+static void hisax_b_l2l1(struct PStack *st, int pr, void *arg);
+static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg);
+static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs);
+static void hisax_bc_close(struct BCState *bcs);
+static void hisax_bh(struct IsdnCardState *cs);
+static void EChannel_proc_rcv(struct hisax_d_if *d_if);
+
+int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
+		   char *name, int protocol)
+{
+	int i, retval;
+	char id[20];
+	struct IsdnCardState *cs;
+
+	for (i = 0; i < HISAX_MAX_CARDS; i++) {
+		if (!cards[i].typ)
+			break;
+	}
+
+	if (i >= HISAX_MAX_CARDS)
+		return -EBUSY;
+
+	cards[i].typ = ISDN_CTYPE_DYNAMIC;
+	cards[i].protocol = protocol;
+	sprintf(id, "%s%d", name, i);
+	nrcards++;
+	retval = checkcard(i, id, 0);
+	if (retval == 0) { // yuck
+		cards[i].typ = 0;
+		nrcards--;
+		return retval;
+	}
+	cs = cards[i].cs;
+	hisax_d_if->cs = cs;
+	cs->hw.hisax_d_if = hisax_d_if;
+	cs->cardmsg = hisax_cardmsg;
+	cs->tqueue.routine = (void *) (void *) hisax_bh;
+	cs->channel[0].d_st->l2.l2l1 = hisax_d_l2l1;
+	for (i = 0; i < 2; i++) {
+		cs->bcs[i].BC_SetStack = hisax_bc_setstack;
+		cs->bcs[i].BC_Close = hisax_bc_close;
+
+		b_if[i]->ifc.l1l2 = hisax_b_l1l2;
+
+		hisax_d_if->b_if[i] = b_if[i];
+	}
+	hisax_d_if->ifc.l1l2 = hisax_d_l1l2;
+	skb_queue_head_init(&hisax_d_if->erq);
+	clear_bit(0, &hisax_d_if->ph_state);
+	
+	return 0;
+}
+
+void hisax_unregister(struct hisax_d_if *hisax_d_if)
+{
+	cards[hisax_d_if->cs->cardnr].typ = 0;
+	HiSax_closecard(hisax_d_if->cs->cardnr);
+	skb_queue_purge(&hisax_d_if->erq);
+}
+
+#include "isdnl1.h"
+
+static void hisax_sched_event(struct IsdnCardState *cs, int event)
+{
+	cs->event |= 1 << event;
+	queue_task(&cs->tqueue, &tq_immediate);
+	mark_bh(IMMEDIATE_BH);
+}
+
+static void hisax_bh(struct IsdnCardState *cs)
+{
+	struct PStack *st;
+	int pr;
+
+	if (test_and_clear_bit(D_RCVBUFREADY, &cs->event))
+		DChannel_proc_rcv(cs);
+	if (test_and_clear_bit(E_RCVBUFREADY, &cs->event))
+		EChannel_proc_rcv(cs->hw.hisax_d_if);
+	if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) {
+		if (test_bit(0, &cs->hw.hisax_d_if->ph_state))
+			pr = PH_ACTIVATE | INDICATION;
+		else
+			pr = PH_DEACTIVATE | INDICATION;
+		for (st = cs->stlist; st; st = st->next)
+			st->l1.l1l2(st, pr, NULL);
+		
+	}
+}
+
+static void hisax_b_sched_event(struct BCState *bcs, int event)
+{
+	bcs->event |= 1 << event;
+	queue_task(&bcs->tqueue, &tq_immediate);
+	mark_bh(IMMEDIATE_BH);
+}
+
+static inline void D_L2L1(struct hisax_d_if *d_if, int pr, void *arg)
+{
+	struct hisax_if *ifc = (struct hisax_if *) d_if;
+	ifc->l2l1(ifc, pr, arg);
+}
+
+static inline void B_L2L1(struct hisax_b_if *b_if, int pr, void *arg)
+{
+	struct hisax_if *ifc = (struct hisax_if *) b_if;
+	ifc->l2l1(ifc, pr, arg);
+}
+
+static void hisax_d_l1l2(struct hisax_if *ifc, int pr, void *arg)
+{
+	struct hisax_d_if *d_if = (struct hisax_d_if *) ifc;
+	struct IsdnCardState *cs = d_if->cs;
+	struct PStack *st;
+	struct sk_buff *skb;
+
+	switch (pr) {
+	case PH_ACTIVATE | INDICATION:
+		set_bit(0, &d_if->ph_state);
+		hisax_sched_event(cs, D_L1STATECHANGE);
+		break;
+	case PH_DEACTIVATE | INDICATION:
+		clear_bit(0, &d_if->ph_state);
+		hisax_sched_event(cs, D_L1STATECHANGE);
+		break;
+	case PH_DATA | INDICATION:
+		skb_queue_tail(&cs->rq, arg);
+		hisax_sched_event(cs, D_RCVBUFREADY);
+		break;
+	case PH_DATA | CONFIRM:
+		skb = skb_dequeue(&cs->sq);
+		if (skb) {
+			D_L2L1(d_if, PH_DATA | REQUEST, skb);
+			break;
+		}
+		clear_bit(FLG_L1_DBUSY, &cs->HW_Flags);
+		for (st = cs->stlist; st; st = st->next) {
+			if (test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags)) {
+				st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
+				break;
+			}
+		}
+		break;
+	case PH_DATA_E | INDICATION:
+		skb_queue_tail(&d_if->erq, arg);
+		hisax_sched_event(cs, E_RCVBUFREADY);
+		break;
+	default:
+		printk("pr %#x\n", pr);
+		break;
+	}
+}
+
+static void hisax_b_l1l2(struct hisax_if *ifc, int pr, void *arg)
+{
+	struct hisax_b_if *b_if = (struct hisax_b_if *) ifc;
+	struct BCState *bcs = b_if->bcs;
+	struct PStack *st = bcs->st;
+	struct sk_buff *skb;
+
+	// FIXME use isdnl1?
+	switch (pr) {
+	case PH_ACTIVATE | INDICATION:
+		st->l1.l1l2(st, pr, NULL);
+		break;
+	case PH_DEACTIVATE | INDICATION:
+		st->l1.l1l2(st, pr, NULL);
+		bcs->hw.b_if = NULL;
+		break;
+	case PH_DATA | INDICATION:
+		skb_queue_tail(&bcs->rqueue, arg);
+		hisax_b_sched_event(bcs, B_RCVBUFREADY);
+		break;
+	case PH_DATA | CONFIRM:
+		bcs->tx_cnt -= (int) arg;
+		if (bcs->st->lli.l1writewakeup)
+			bcs->st->lli.l1writewakeup(bcs->st, (int) arg);
+		skb = skb_dequeue(&bcs->squeue);
+		if (skb) {
+			B_L2L1(b_if, PH_DATA | REQUEST, skb);
+			break;
+		}
+		clear_bit(BC_FLG_BUSY, &bcs->Flag);
+		if (test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags)) {
+			st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
+		}
+		break;
+	default:
+		printk("hisax_b_l1l2 pr %#x\n", pr);
+		break;
+	}
+}
+
+static void hisax_d_l2l1(struct PStack *st, int pr, void *arg)
+{
+	struct IsdnCardState *cs = st->l1.hardware;
+	struct hisax_d_if *hisax_d_if = cs->hw.hisax_d_if;
+	struct sk_buff *skb = arg;
+
+	switch (pr) {
+	case PH_DATA | REQUEST:
+	case PH_PULL | INDICATION:
+		if (cs->debug & DEB_DLOG_HEX)
+			LogFrame(cs, skb->data, skb->len);
+		if (cs->debug & DEB_DLOG_VERBOSE)
+			dlogframe(cs, skb, 0);
+		Logl2Frame(cs, skb, "PH_DATA_REQ", 0);
+		// FIXME lock?
+		if (!test_and_set_bit(FLG_L1_DBUSY, &cs->HW_Flags))
+			D_L2L1(hisax_d_if, PH_DATA | REQUEST, skb);
+		else
+			skb_queue_tail(&cs->sq, skb);
+		break;
+	case PH_PULL | REQUEST:
+		if (!test_bit(FLG_L1_DBUSY, &cs->HW_Flags))
+			st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
+		else
+			set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
+		break;
+	default:
+		D_L2L1(hisax_d_if, pr, arg);
+		break;
+	}
+}
+
+static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg)
+{
+	return 0;
+}
+
+static void hisax_b_l2l1(struct PStack *st, int pr, void *arg)
+{
+	struct BCState *bcs = st->l1.bcs;
+	struct hisax_b_if *b_if = bcs->hw.b_if;
+
+	switch (pr) {
+	case PH_ACTIVATE | REQUEST:
+		B_L2L1(b_if, pr, (void *) st->l1.mode);
+		break;
+	case PH_DATA | REQUEST:
+	case PH_PULL | INDICATION:
+		// FIXME lock?
+		if (!test_and_set_bit(BC_FLG_BUSY, &bcs->Flag)) {
+			B_L2L1(b_if, PH_DATA | REQUEST, arg);
+		} else {
+			skb_queue_tail(&bcs->squeue, arg);
+		}
+		break;
+	case PH_PULL | REQUEST:
+		if (!test_bit(BC_FLG_BUSY, &bcs->Flag))
+			st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
+		else
+			set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
+		break;
+	default:
+		B_L2L1(b_if, pr, arg);
+		break;
+	}
+}
+
+static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs)
+{
+	struct IsdnCardState *cs = st->l1.hardware;
+	struct hisax_d_if *hisax_d_if = cs->hw.hisax_d_if;
+
+	bcs->channel = st->l1.bc;
+
+	bcs->hw.b_if = hisax_d_if->b_if[st->l1.bc];
+	hisax_d_if->b_if[st->l1.bc]->bcs = bcs;
+
+	st->l1.bcs = bcs;
+	st->l2.l2l1 = hisax_b_l2l1;
+	setstack_manager(st);
+	bcs->st = st;
+	setstack_l1_B(st);
+	skb_queue_head_init(&bcs->rqueue);
+	skb_queue_head_init(&bcs->squeue);
+	return 0;
+}
+
+static void hisax_bc_close(struct BCState *bcs)
+{
+	struct hisax_b_if *b_if = bcs->hw.b_if;
+
+	if (b_if)
+		B_L2L1(b_if, PH_DEACTIVATE | REQUEST, NULL);
+}
+
+static void EChannel_proc_rcv(struct hisax_d_if *d_if)
+{
+	struct IsdnCardState *cs = d_if->cs;
+	u_char *ptr;
+	struct sk_buff *skb;
+
+	while ((skb = skb_dequeue(&d_if->erq)) != NULL) {
+		if (cs->debug & DEB_DLOG_HEX) {
+			ptr = cs->dlog;
+			if ((skb->len) < MAX_DLOG_SPACE / 3 - 10) {
+				*ptr++ = 'E';
+				*ptr++ = 'C';
+				*ptr++ = 'H';
+				*ptr++ = 'O';
+				*ptr++ = ':';
+				ptr += QuickHex(ptr, skb->data, skb->len);
+				ptr--;
+				*ptr++ = '\n';
+				*ptr = 0;
+				HiSax_putstatus(cs, NULL, cs->dlog);
+			} else
+				HiSax_putstatus(cs, "LogEcho: ",
+						"warning Frame too big (%d)",
+						skb->len);
+		}
+		dev_kfree_skb_any(skb);
+	}
+}
+
+void HiSax_mod_dec_use_count(struct IsdnCardState *cs)
+{
+	struct module *mod;
+
+	if (cs && cs->cardmsg == hisax_cardmsg) {
+		mod = cs->hw.hisax_d_if->owner;
+		if (mod)
+			__MOD_DEC_USE_COUNT(mod);
+	} else {
+		MOD_DEC_USE_COUNT;
+	}
+}
+
+void HiSax_mod_inc_use_count(struct IsdnCardState *cs)
+{
+	struct module *mod;
+
+	if (cs && cs->cardmsg == hisax_cardmsg) {
+		mod = cs->hw.hisax_d_if->owner;
+		if (mod)
+		// hope we do win the race...
+			try_inc_mod_count(mod);
+	} else {
+		MOD_INC_USE_COUNT;
+	}
+}
+
 #include <linux/pci.h>
 
 static struct pci_device_id hisax_pci_tbl[] __initdata = {
 #ifdef CONFIG_HISAX_FRITZPCI
-	{PCI_VENDOR_ID_AVM,      PCI_DEVICE_ID_AVM_A1,          PCI_ANY_ID, PCI_ANY_ID},
+	{PCI_VENDOR_ID_AVM,      PCI_DEVICE_ID_AVM_A1,           PCI_ANY_ID, PCI_ANY_ID},
 #endif
 #ifdef CONFIG_HISAX_DIEHLDIVA
 	{PCI_VENDOR_ID_EICON,    PCI_DEVICE_ID_EICON_DIVA20,     PCI_ANY_ID, PCI_ANY_ID},
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/hisax/elsa_ser.c linux/drivers/isdn/hisax/elsa_ser.c
--- v2.4.9/linux/drivers/isdn/hisax/elsa_ser.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/isdn/hisax/elsa_ser.c	Sun Sep  9 10:45:43 2001
@@ -1,4 +1,4 @@
-/* $Id: elsa_ser.c,v 2.10.6.2 2001/06/09 15:14:17 kai Exp $
+/* $Id: elsa_ser.c,v 2.10.6.3 2001/08/17 12:34:26 kai Exp $
  *
  * stuff for the serial modem on ELSA cards
  *
@@ -14,10 +14,6 @@
 #define RS_ISR_PASS_LIMIT 256
 #define BASE_BAUD ( 1843200 / 16 )
 
-#ifndef MIN
-#define MIN(a,b)	((a) < (b) ? (a) : (b))
-#endif
-
 //#define SERIAL_DEBUG_OPEN 1
 //#define SERIAL_DEBUG_INTR 1
 //#define SERIAL_DEBUG_FLOW 1
@@ -257,7 +253,7 @@
 write_modem(struct BCState *bcs) {
 	int ret=0;
 	struct IsdnCardState *cs = bcs->cs;
-	int count, len, fp, buflen;
+	int count, len, fp;
 	long flags;
 	
 	if (!bcs->tx_skb)
@@ -266,12 +262,14 @@
 		return 0;
 	save_flags(flags);
 	cli();
-	buflen = MAX_MODEM_BUF - cs->hw.elsa.transcnt;
-	len = MIN(buflen, bcs->tx_skb->len);		
+	len = bcs->tx_skb->len;
+	if (len > MAX_MODEM_BUF - cs->hw.elsa.transcnt)
+		len = MAX_MODEM_BUF - cs->hw.elsa.transcnt;
 	fp = cs->hw.elsa.transcnt + cs->hw.elsa.transp;
 	fp &= (MAX_MODEM_BUF -1);
-	count = MIN(len, MAX_MODEM_BUF - fp);
-	if (count < len) {
+	count = len;
+	if (count > MAX_MODEM_BUF - fp) {
+		count = MAX_MODEM_BUF - fp;
 		memcpy(cs->hw.elsa.transbuf + fp, bcs->tx_skb->data, count);
 		skb_pull(bcs->tx_skb, count);
 		cs->hw.elsa.transcnt += count;
@@ -472,8 +470,9 @@
 	}
 	fp = cs->hw.elsa.transcnt + cs->hw.elsa.transp;
 	fp &= (MAX_MODEM_BUF -1);
-	count = MIN(len, MAX_MODEM_BUF - fp);
-	if (count < len) {
+	count = len;
+	if (count > MAX_MODEM_BUF - fp) {
+		count = MAX_MODEM_BUF - fp;
 		memcpy(cs->hw.elsa.transbuf + fp, msg, count);
 		cs->hw.elsa.transcnt += count;
 		msg += count;
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/hisax/fsm.c linux/drivers/isdn/hisax/fsm.c
--- v2.4.9/linux/drivers/isdn/hisax/fsm.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/isdn/hisax/fsm.c	Sun Sep  9 10:45:43 2001
@@ -1,4 +1,4 @@
-/* $Id: fsm.c,v 1.14.6.2 2001/05/26 15:19:57 kai Exp $
+/* $Id: fsm.c,v 1.14.6.3 2001/08/23 19:44:23 kai Exp $
  *
  * Author       Karsten Keil (keil@isdn4linux.de)
  *              based on the teles driver from Jan den Ouden
@@ -14,6 +14,14 @@
 #include "hisax.h"
 
 #define FSM_TIMER_DEBUG 0
+
+EXPORT_SYMBOL(FsmNew);
+EXPORT_SYMBOL(FsmFree);
+EXPORT_SYMBOL(FsmEvent);
+EXPORT_SYMBOL(FsmChangeState);
+EXPORT_SYMBOL(FsmInitTimer);
+EXPORT_SYMBOL(FsmDelTimer);
+EXPORT_SYMBOL(FsmRestartTimer);
 
 int __init
 FsmNew(struct Fsm *fsm, struct FsmNode *fnlist, int fncount)
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/hisax/fsm.h linux/drivers/isdn/hisax/fsm.h
--- v2.4.9/linux/drivers/isdn/hisax/fsm.h	Wed Dec 31 16:00:00 1969
+++ linux/drivers/isdn/hisax/fsm.h	Sun Sep  9 10:45:43 2001
@@ -0,0 +1,48 @@
+#ifndef __FSM_H__
+#define __FSM_H__
+
+#include <linux/timer.h>
+
+struct FsmInst;
+
+typedef void (* FSMFNPTR)(struct FsmInst *, int, void *);
+
+struct Fsm {
+	FSMFNPTR *jumpmatrix;
+	int state_count, event_count;
+	char **strEvent, **strState;
+};
+
+struct FsmInst {
+	struct Fsm *fsm;
+	int state;
+	int debug;
+	void *userdata;
+	int userint;
+	void (*printdebug) (struct FsmInst *, char *, ...);
+};
+
+struct FsmNode {
+	int state, event;
+	void (*routine) (struct FsmInst *, int, void *);
+};
+
+struct FsmTimer {
+	struct FsmInst *fi;
+	struct timer_list tl;
+	int event;
+	void *arg;
+};
+
+int FsmNew(struct Fsm *fsm, struct FsmNode *fnlist, int fncount);
+void FsmFree(struct Fsm *fsm);
+int FsmEvent(struct FsmInst *fi, int event, void *arg);
+void FsmChangeState(struct FsmInst *fi, int newstate);
+void FsmInitTimer(struct FsmInst *fi, struct FsmTimer *ft);
+int FsmAddTimer(struct FsmTimer *ft, int millisec, int event,
+		void *arg, int where);
+void FsmRestartTimer(struct FsmTimer *ft, int millisec, int event,
+		     void *arg, int where);
+void FsmDelTimer(struct FsmTimer *ft, int where);
+
+#endif
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/hisax/hisax.h linux/drivers/isdn/hisax/hisax.h
--- v2.4.9/linux/drivers/isdn/hisax/hisax.h	Wed Jul 25 17:10:20 2001
+++ linux/drivers/isdn/hisax/hisax.h	Sun Sep  9 10:45:43 2001
@@ -1,4 +1,4 @@
-/* $Id: hisax.h,v 2.52.6.7 2001/07/18 16:02:15 kai Exp $
+/* $Id: hisax.h,v 2.52.6.8 2001/08/23 19:44:23 kai Exp $
  *
  *   Basic declarations, defines and prototypes
  *
@@ -455,7 +455,6 @@
 	struct tq_struct tq_xmt;
 };
 
-
 #define BC_FLG_INIT	1
 #define BC_FLG_ACTIV	2
 #define BC_FLG_BUSY	3
@@ -512,6 +511,7 @@
 		struct tiger_hw tiger;
 		struct amd7930_hw  amd7930;
 		struct w6692B_hw w6692;
+		struct hisax_b_if *b_if;
 	} hw;
 };
 
@@ -897,6 +897,7 @@
 		struct bkm_hw ax;
 		struct gazel_hw gazel;
 		struct w6692_hw w6692;
+		struct hisax_d_if *hisax_d_if;
 	} hw;
 	int myid;
 	isdn_if iif;
@@ -991,7 +992,8 @@
 #define  ISDN_CTYPE_HFC_SX      37
 #define  ISDN_CTYPE_NETJET_U	38
 #define  ISDN_CTYPE_HFC_SP_PCMCIA      39
-#define  ISDN_CTYPE_COUNT	39
+#define  ISDN_CTYPE_DYNAMIC     40
+#define  ISDN_CTYPE_COUNT	40
 
 
 #ifdef ISDN_CHIP_ISAC
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/hisax/hisax_debug.h linux/drivers/isdn/hisax/hisax_debug.h
--- v2.4.9/linux/drivers/isdn/hisax/hisax_debug.h	Wed Dec 31 16:00:00 1969
+++ linux/drivers/isdn/hisax/hisax_debug.h	Sun Sep  9 10:45:43 2001
@@ -0,0 +1,80 @@
+/*
+ * Common debugging macros for use with the hisax driver
+ *
+ * Author       Frode Isaksen
+ * Copyright    2001 by Frode Isaksen      <fisaksen@bewan.com>
+ * 
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
+ *
+ */
+
+/* 
+ * How to use:
+ * 
+ * Before including this file, you need to
+ *   #define __debug_variable my_debug
+ * where my_debug is a variable in your code which
+ * determines the debug bitmask.
+ *
+ * If CONFIG_HISAX_DEBUG is not set, all macros evaluate to nothing
+ */
+
+#ifndef __HISAX_DEBUG_H__
+#define __HISAX_DEBUG_H__
+
+#ifdef CONFIG_HISAX_DEBUG
+
+#define DBG(level, format, arg...) do { \
+if (level & __debug_variable) \
+printk(KERN_DEBUG __FUNCTION__ ": " format "\n" , ## arg); \
+} while (0)
+
+#define DBG_PACKET(level,data,count) \
+  if (level & __debug_variable) dump_packet(__FUNCTION__,data,count)
+
+#define DBG_SKB(level,skb) \
+  if ((level & __debug_variable) && skb) dump_packet(__FUNCTION__,skb->data,skb->len)
+
+
+static void __attribute__((unused))
+dump_packet(const char *name,const u_char *data,int pkt_len)
+{
+#define DUMP_HDR_SIZE 20
+#define DUMP_TLR_SIZE 8
+	if (pkt_len) {
+		int i,len1,len2;
+
+		printk(KERN_DEBUG "%s: length=%d,data=",name,pkt_len);
+
+		if (pkt_len >  DUMP_HDR_SIZE+ DUMP_TLR_SIZE) {
+			len1 = DUMP_HDR_SIZE;
+			len2 = DUMP_TLR_SIZE;
+		} else {
+			len1 = pkt_len > DUMP_HDR_SIZE ? DUMP_HDR_SIZE : pkt_len;
+			len2 = 0;			
+		}
+		for (i = 0; i < len1; ++i) {
+		 	printk ("%.2x", data[i]);
+		}
+		if (len2) {
+		 	printk ("..");
+			for (i = pkt_len-DUMP_TLR_SIZE; i < pkt_len; ++i) {
+				printk ("%.2x", data[i]);
+			}
+		}
+		printk ("\n");
+	}
+#undef DUMP_HDR_SIZE
+#undef DUMP_TLR_SIZE
+}
+
+#else
+
+#define DBG(level, format, arg...) do {} while (0)
+#define DBG_PACKET(level,data,count) do {} while (0)
+#define DBG_SKB(level,skb) do {} while (0)
+
+#endif
+
+#endif
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/hisax/hisax_if.h linux/drivers/isdn/hisax/hisax_if.h
--- v2.4.9/linux/drivers/isdn/hisax/hisax_if.h	Wed Dec 31 16:00:00 1969
+++ linux/drivers/isdn/hisax/hisax_if.h	Sun Sep  9 10:45:43 2001
@@ -0,0 +1,54 @@
+#ifndef __HISAX_IF_H__
+#define __HISAX_IF_H__
+
+#include <linux/skbuff.h>
+
+#define REQUEST		0
+#define CONFIRM		1
+#define INDICATION	2
+#define RESPONSE	3
+
+#define PH_ACTIVATE	0x0100
+#define PH_DEACTIVATE	0x0110
+#define PH_DATA		0x0120
+#define PH_PULL		0x0130
+#define PH_DATA_E	0x0140
+
+#define L1_MODE_NULL	0
+#define L1_MODE_TRANS	1
+#define L1_MODE_HDLC	2
+#define L1_MODE_EXTRN	3
+#define L1_MODE_HDLC_56K 4
+#define L1_MODE_MODEM	7
+#define L1_MODE_V32	8
+#define L1_MODE_FAX	9
+
+struct hisax_if {
+	void *priv; // private to driver
+	void (*l1l2)(struct hisax_if *, int pr, void *arg);
+	void (*l2l1)(struct hisax_if *, int pr, void *arg);
+};
+
+struct hisax_b_if {
+	struct hisax_if ifc;
+
+	// private to hisax
+	struct BCState *bcs;
+};
+
+struct hisax_d_if {
+	struct hisax_if ifc;
+
+	// private to hisax
+	struct module *owner;
+	struct IsdnCardState *cs;
+	struct hisax_b_if *b_if[2];
+	struct sk_buff_head erq;
+	long ph_state;
+};
+
+int hisax_register(struct hisax_d_if *hisax_if, struct hisax_b_if *b_if[],
+		   char *name, int protocol);
+void hisax_unregister(struct hisax_d_if *hisax_if);
+
+#endif
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/hisax/isar.c linux/drivers/isdn/hisax/isar.c
--- v2.4.9/linux/drivers/isdn/hisax/isar.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/isdn/hisax/isar.c	Fri Sep  7 09:28:38 2001
@@ -1,4 +1,4 @@
-/* $Id: isar.c,v 1.17.6.3 2001/06/09 15:14:17 kai Exp $
+/* $Id: isar.c,v 1.17.6.4 2001/08/17 12:34:26 kai Exp $
  *
  * isar.c   ISAR (Siemens PSB 7110) specific routines
  *
@@ -18,8 +18,6 @@
 #define DBG_LOADFIRM	0
 #define DUMP_MBOXFRAME	2
 
-#define MIN(a,b) ((a<b)?a:b)
-
 #define DLE	0x10
 #define ETX	0x03
 
@@ -272,7 +270,9 @@
 			ret = 1;goto reterror;
 		}
 		while (left>0) {
-			noc = MIN(126, left);
+			noc = left;
+			if (noc > 126)
+				noc = 126;
 			nom = 2*noc;
 			mp  = msg;
 			*mp++ = sadr / 256;
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/hisax/isdnl1.c linux/drivers/isdn/hisax/isdnl1.c
--- v2.4.9/linux/drivers/isdn/hisax/isdnl1.c	Tue Jul  3 17:08:19 2001
+++ linux/drivers/isdn/hisax/isdnl1.c	Sun Sep  9 10:45:43 2001
@@ -1,4 +1,4 @@
-/* $Id: isdnl1.c,v 2.41.6.3 2001/05/26 15:19:57 kai Exp $
+/* $Id: isdnl1.c,v 2.41.6.4 2001/08/23 19:44:23 kai Exp $
  *
  * isdnl1.c     common low level stuff for Siemens Chipsetbased isdn cards
  *              based on the teles driver from Jan den Ouden
@@ -15,7 +15,7 @@
  *
  */
 
-const char *l1_revision = "$Revision: 2.41.6.3 $";
+const char *l1_revision = "$Revision: 2.41.6.4 $";
 
 #define __NO_VERSION__
 #include <linux/init.h>
@@ -895,7 +895,8 @@
 	setstack_manager(st);
 	st->l1.stlistp = &(cs->stlist);
 	st->l2.l2l1  = dch_l2l1;
-	cs->setstack_d(st, cs);
+	if (cs->setstack_d)
+		cs->setstack_d(st, cs);
 }
 
 void
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/hisax/isdnl1.h linux/drivers/isdn/hisax/isdnl1.h
--- v2.4.9/linux/drivers/isdn/hisax/isdnl1.h	Fri Mar  2 11:12:09 2001
+++ linux/drivers/isdn/hisax/isdnl1.h	Sun Sep  9 10:45:43 2001
@@ -1,4 +1,4 @@
-/* $Id: isdnl1.h,v 2.9.6.1 2001/02/16 16:43:27 kai Exp $
+/* $Id: isdnl1.h,v 2.9.6.2 2001/08/23 19:44:23 kai Exp $
  *
  * Layer 1 defines
  *
@@ -14,6 +14,7 @@
 #define D_RX_MON1	5
 #define D_TX_MON0	6
 #define D_TX_MON1	7
+#define E_RCVBUFREADY	8
 
 #define B_RCVBUFREADY 0
 #define B_XMTBUFREADY 1
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/hisax/st5481.h linux/drivers/isdn/hisax/st5481.h
--- v2.4.9/linux/drivers/isdn/hisax/st5481.h	Wed Dec 31 16:00:00 1969
+++ linux/drivers/isdn/hisax/st5481.h	Sun Sep  9 10:45:43 2001
@@ -0,0 +1,533 @@
+/*
+ * Driver for ST5481 USB ISDN modem
+ *
+ * Author       Frode Isaksen
+ * Copyright    2001 by Frode Isaksen      <fisaksen@bewan.com>
+ *              2001 by Kai Germaschewski  <kai.germaschewski@gmx.de>
+ * 
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
+ *
+ */
+
+#ifndef _ST5481_H_
+#define _ST5481_H_
+
+// USB IDs, the Product Id is in the range 0x4810-0x481F
+
+#define ST_VENDOR_ID 0x0483
+#define ST5481_PRODUCT_ID 0x4810
+#define ST5481_PRODUCT_ID_MASK 0xFFF0
+
+// ST5481 endpoints when using alternative setting 3 (2B+D).
+// To get the endpoint address, OR with 0x80 for IN endpoints.
+
+#define EP_CTRL   0x00U /* Control endpoint */
+#define EP_INT    0x01U /* Interrupt endpoint */
+#define EP_B1_OUT 0x02U /* B1 channel out */
+#define EP_B1_IN  0x03U /* B1 channel in */
+#define EP_B2_OUT 0x04U /* B2 channel out */
+#define EP_B2_IN  0x05U /* B2 channel in */
+#define EP_D_OUT  0x06U /* D channel out */
+#define EP_D_IN   0x07U /* D channel in */
+  
+// Number of isochronous packets. With 20 packets we get
+// 50 interrupts/sec for each endpoint.
+
+#define NUM_ISO_PACKETS_D      20
+#define NUM_ISO_PACKETS_B      20
+
+// Size of each isochronous packet.
+// In outgoing direction we need to match ISDN data rates:
+// D:  2 bytes / msec -> 16 kbit / s
+// B: 16 bytes / msec -> 64 kbit / s
+#define SIZE_ISO_PACKETS_D_IN  16
+#define SIZE_ISO_PACKETS_D_OUT 2
+#define SIZE_ISO_PACKETS_B_IN  32
+#define SIZE_ISO_PACKETS_B_OUT 8
+
+// If we overrun/underrun, we send one packet with +/- 2 bytes
+#define B_FLOW_ADJUST 2
+
+// Registers that are written using vendor specific device request
+// on endpoint 0. 
+
+#define LBA			0x02 /* S loopback */
+#define SET_DEFAULT		0x06 /* Soft reset */
+#define LBB			0x1D /* S maintenance loopback */
+#define STT			0x1e /* S force transmission signals */
+#define SDA_MIN			0x20 /* SDA-sin minimal value */
+#define SDA_MAX			0x21 /* SDA-sin maximal value */
+#define SDELAY_VALUE		0x22 /* Delay between Tx and Rx clock */
+#define IN_D_COUNTER		0x36 /* D receive channel fifo counter */
+#define OUT_D_COUNTER		0x37 /* D transmit channel fifo counter */
+#define IN_B1_COUNTER		0x38 /* B1 receive channel fifo counter */
+#define OUT_B1_COUNTER		0x39 /* B1 transmit channel fifo counter */
+#define IN_B2_COUNTER		0x3a /* B2 receive channel fifo counter */
+#define OUT_B2_COUNTER		0x3b /* B2 transmit channel fifo counter */
+#define FFCTRL_IN_D		0x3C /* D receive channel fifo threshold low */
+#define FFCTRH_IN_D		0x3D /* D receive channel fifo threshold high */
+#define FFCTRL_OUT_D		0x3E /* D transmit channel fifo threshold low */
+#define FFCTRH_OUT_D		0x3F /* D transmit channel fifo threshold high */
+#define FFCTRL_IN_B1		0x40 /* B1 receive channel fifo threshold low */
+#define FFCTRH_IN_B1		0x41 /* B1 receive channel fifo threshold high */
+#define FFCTRL_OUT_B1		0x42 /* B1 transmit channel fifo threshold low */
+#define FFCTRH_OUT_B1		0x43 /* B1 transmit channel fifo threshold high */
+#define FFCTRL_IN_B2		0x44 /* B2 receive channel fifo threshold low */
+#define FFCTRH_IN_B2		0x45 /* B2 receive channel fifo threshold high */
+#define FFCTRL_OUT_B2		0x46 /* B2 transmit channel fifo threshold low */
+#define FFCTRH_OUT_B2		0x47 /* B2 transmit channel fifo threshold high */
+#define MPMSK			0x4A /* Multi purpose interrupt MASK register */
+#define	FFMSK_D			0x4c /* D fifo interrupt MASK register */
+#define	FFMSK_B1		0x4e /* B1 fifo interrupt MASK register */
+#define	FFMSK_B2		0x50 /* B2 fifo interrupt MASK register */
+#define GPIO_DIR		0x52 /* GPIO pins direction registers */
+#define GPIO_OUT		0x53 /* GPIO pins output register */
+#define GPIO_IN			0x54 /* GPIO pins input register */ 
+#define TXCI			0x56 /* CI command to be transmitted */
+
+
+// Format of the interrupt packet received on endpoint 1:
+//
+// +--------+--------+--------+--------+--------+--------+
+// !MPINT   !FFINT_D !FFINT_B1!FFINT_B2!CCIST   !GPIO_INT!
+// +--------+--------+--------+--------+--------+--------+
+
+// Offsets in the interrupt packet
+
+#define MPINT			0
+#define FFINT_D			1
+#define FFINT_B1		2
+#define FFINT_B2		3
+#define CCIST			4
+#define GPIO_INT		5
+#define INT_PKT_SIZE            6
+
+// MPINT
+#define LSD_INT                 0x80 /* S line activity detected */
+#define RXCI_INT		0x40 /* Indicate primitive arrived */
+#define	DEN_INT			0x20 /* Signal enabling data out of D Tx fifo */
+#define DCOLL_INT		0x10 /* D channel collision */
+#define AMIVN_INT		0x04 /* AMI violation number reached 2 */
+#define INFOI_INT		0x04 /* INFOi changed */
+#define DRXON_INT               0x02 /* Reception channel active */
+#define GPCHG_INT               0x01 /* GPIO pin value changed */
+
+// FFINT_x
+#define IN_OVERRUN		0x80 /* In fifo overrun */
+#define OUT_UNDERRUN		0x40 /* Out fifo underrun */
+#define IN_UP			0x20 /* In fifo thresholdh up-crossed */
+#define IN_DOWN			0x10 /* In fifo thresholdl down-crossed */
+#define OUT_UP			0x08 /* Out fifo thresholdh up-crossed */
+#define OUT_DOWN		0x04 /* Out fifo thresholdl down-crossed */
+#define IN_COUNTER_ZEROED	0x02 /* In down-counter reached 0 */
+#define OUT_COUNTER_ZEROED	0x01 /* Out down-counter reached 0 */
+
+#define ANY_REC_INT	(IN_OVERRUN+IN_UP+IN_DOWN+IN_COUNTER_ZEROED)
+#define ANY_XMIT_INT	(OUT_UNDERRUN+OUT_UP+OUT_DOWN+OUT_COUNTER_ZEROED)
+
+
+// Level 1 commands that are sent using the TXCI device request
+#define ST5481_CMD_DR		 0x0 /* Deactivation Request */
+#define ST5481_CMD_RES		 0x1 /* state machine RESet */
+#define ST5481_CMD_TM1		 0x2 /* Test Mode 1 */
+#define ST5481_CMD_TM2		 0x3 /* Test Mode 2 */
+#define ST5481_CMD_PUP		 0x7 /* Power UP */
+#define ST5481_CMD_AR8		 0x8 /* Activation Request class 1 */
+#define ST5481_CMD_AR10		 0x9 /* Activation Request class 2 */
+#define ST5481_CMD_ARL		 0xA /* Activation Request Loopback */
+#define ST5481_CMD_PDN		 0xF /* Power DoWn */
+
+// Turn on/off the LEDs using the GPIO device request.
+// To use the B LEDs, number_of_leds must be set to 4
+#define B1_LED		0x10U
+#define B2_LED		0x20U
+#define GREEN_LED	0x40U
+#define RED_LED	        0x80U
+
+// D channel out states
+enum {
+	ST_DOUT_NONE,
+
+	ST_DOUT_SHORT_INIT,
+	ST_DOUT_SHORT_WAIT_DEN,
+
+	ST_DOUT_LONG_INIT,
+	ST_DOUT_LONG_WAIT_DEN,
+	ST_DOUT_NORMAL,
+
+	ST_DOUT_WAIT_FOR_UNDERRUN,
+        ST_DOUT_WAIT_FOR_NOT_BUSY,
+	ST_DOUT_WAIT_FOR_STOP,
+	ST_DOUT_WAIT_FOR_RESET,
+};
+
+#define DOUT_STATE_COUNT (ST_DOUT_WAIT_FOR_RESET + 1)
+
+// D channel out events
+enum {
+	EV_DOUT_START_XMIT,
+	EV_DOUT_COMPLETE,
+	EV_DOUT_DEN,
+	EV_DOUT_RESETED,
+	EV_DOUT_STOPPED,
+	EV_DOUT_COLL,
+	EV_DOUT_UNDERRUN,
+};
+
+#define DOUT_EVENT_COUNT (EV_DOUT_UNDERRUN + 1)
+
+// ----------------------------------------------------------------------
+
+enum {
+	ST_L1_F3,
+	ST_L1_F4,
+	ST_L1_F6,
+	ST_L1_F7,
+	ST_L1_F8,
+};
+
+#define L1_STATE_COUNT (ST_L1_F8+1)
+
+// The first 16 entries match the Level 1 indications that 
+// are found at offset 4 (CCIST) in the interrupt packet
+
+enum {
+	EV_IND_DP,  // 0000 Deactivation Pending
+	EV_IND_1,   // 0001
+	EV_IND_2,   // 0010
+	EV_IND_3,   // 0011
+	EV_IND_RSY, // 0100 ReSYnchronizing
+	EV_IND_5,   // 0101
+	EV_IND_6,   // 0110
+	EV_IND_7,   // 0111
+	EV_IND_AP,  // 1000 Activation Pending
+	EV_IND_9,   // 1001
+	EV_IND_10,  // 1010
+	EV_IND_11,  // 1011
+	EV_IND_AI8, // 1100 Activation Indication class 8
+	EV_IND_AI10,// 1101 Activation Indication class 10
+	EV_IND_AIL, // 1110 Activation Indication Loopback
+	EV_IND_DI,  // 1111 Deactivation Indication
+	EV_PH_ACTIVATE_REQ,
+	EV_PH_DEACTIVATE_REQ,
+	EV_TIMER3,
+};
+
+#define L1_EVENT_COUNT (EV_TIMER3 + 1)
+
+#define ERR(format, arg...) \
+printk(KERN_ERR __FILE__ ": " __FUNCTION__ ": " format "\n" , ## arg)
+
+#define WARN(format, arg...) \
+printk(KERN_WARNING __FILE__ ": " __FUNCTION__ ": " format "\n" , ## arg)
+
+#define INFO(format, arg...) \
+printk(KERN_INFO __FILE__ ": " __FUNCTION__ ": " format "\n" , ## arg)
+
+#include "st5481_hdlc.h"
+#include "fsm.h"
+#include "hisax_if.h"
+#include <linux/skbuff.h>
+
+/* ======================================================================
+ * FIFO handling
+ */
+
+/* Generic FIFO structure */ 
+struct fifo {
+	u_char r,w,count,size;
+	spinlock_t lock;
+};
+
+/*
+ * Init an FIFO
+ */
+static inline void fifo_init(struct fifo *fifo, int size)
+{
+	fifo->r = fifo->w = fifo->count = 0;
+	fifo->size = size;
+	spin_lock_init(&fifo->lock);
+}
+
+/*
+ * Add an entry to the FIFO
+ */
+static inline int fifo_add(struct fifo *fifo)
+{
+	unsigned long flags;
+	int index;
+
+	if (!fifo) {
+		return -1;
+	}
+
+	spin_lock_irqsave(&fifo->lock, flags);
+	if (fifo->count == fifo->size) {
+		// FIFO full
+		index = -1;
+	} else {
+		// Return index where to get the next data to add to the FIFO
+		index = fifo->w++ & (fifo->size-1); 
+		fifo->count++;
+	}
+	spin_unlock_irqrestore(&fifo->lock, flags);
+	return index;
+}
+
+/*
+ * Remove an entry from the FIFO with the index returned.
+ */
+static inline int fifo_remove(struct fifo *fifo)
+{
+	unsigned long flags;
+	int index;
+
+	if (!fifo) {
+		return -1;
+	}
+
+	spin_lock_irqsave(&fifo->lock, flags);		
+	if (!fifo->count) {
+		// FIFO empty
+		index = -1;
+	} else {
+		// Return index where to get the next data from the FIFO
+		index = fifo->r++ & (fifo->size-1); 
+		fifo->count--;
+	}
+	spin_unlock_irqrestore(&fifo->lock, flags);
+
+	return index;
+}
+
+/* ======================================================================
+ * control pipe
+ */
+typedef void (*ctrl_complete_t)(void *);
+
+typedef struct ctrl_msg {
+	devrequest dr;
+	ctrl_complete_t complete;
+	void *context;
+} ctrl_msg; 
+
+/* FIFO of ctrl messages waiting to be sent */
+#define MAX_EP0_MSG 16
+struct ctrl_msg_fifo {
+	struct fifo f;
+	struct ctrl_msg data[MAX_EP0_MSG];
+};	
+
+#define MAX_DFRAME_LEN_L1	300
+#define HSCX_BUFMAX	4096
+
+struct st5481_ctrl {
+	struct ctrl_msg_fifo msg_fifo;
+	unsigned long busy;
+	struct urb *urb;
+};
+
+struct st5481_intr {
+  //	struct evt_fifo evt_fifo;
+	struct urb *urb;
+};
+
+struct st5481_d_out {
+	struct hdlc_vars hdlc_state;
+	struct urb *urb[2]; /* double buffering */
+	unsigned long busy;
+	struct sk_buff *tx_skb;
+	struct FsmInst fsm;
+};
+
+struct st5481_b_out {
+	struct hdlc_vars hdlc_state;
+	struct urb *urb[2]; /* double buffering */
+	u_char flow_event;
+	u_long busy;
+	struct sk_buff *tx_skb;
+};
+
+struct st5481_in {
+	struct hdlc_vars hdlc_state;
+	struct urb *urb[2]; /* double buffering */
+	int mode;
+	int bufsize;
+	unsigned int num_packets;
+	unsigned int packet_size;
+	unsigned char ep, counter;
+	unsigned char *rcvbuf;
+	struct st5481_adapter *adapter;
+	struct hisax_if *hisax_if;
+};
+
+int st5481_setup_in(struct st5481_in *in);
+void st5481_release_in(struct st5481_in *in);
+void st5481_in_mode(struct st5481_in *in, int mode);
+
+struct st5481_bcs {
+	struct hisax_b_if b_if;
+	struct st5481_adapter *adapter;
+	struct st5481_in b_in;
+	struct st5481_b_out b_out;
+	int channel;
+	int mode;
+};
+
+struct st5481_adapter {
+	struct list_head list;
+	int number_of_leds;
+	struct usb_device *usb_dev;
+	struct hisax_d_if hisax_d_if;
+
+	struct st5481_ctrl ctrl;
+	struct st5481_intr intr;
+	struct st5481_in d_in;
+	struct st5481_d_out d_out;
+
+	unsigned char leds;
+	unsigned int led_counter;
+
+	unsigned long event;
+
+	struct FsmInst l1m;
+	struct FsmTimer timer;
+
+	struct st5481_bcs bcs[2];
+};
+
+#define TIMER3_VALUE 7000
+
+/* ======================================================================
+ *
+ */
+
+/*
+ * Submit an URB with error reporting. This is a macro so
+ * the __FUNCTION__ returns the caller function name.
+ */
+#define SUBMIT_URB(urb) \
+({ \
+	int status; \
+	if ((status = usb_submit_urb(urb)) < 0) { \
+		WARN("usb_submit_urb failed,status=%d", status); \
+	} \
+        status; \
+})
+
+/*
+ * USB double buffering, return the URB index (0 or 1).
+ */
+static inline int get_buf_nr(struct urb *urbs[], struct urb *urb)
+{
+        return (urbs[0]==urb ? 0 : 1); 
+}
+
+/* ---------------------------------------------------------------------- */
+
+/* B Channel */
+
+int  st5481_setup_b(struct st5481_bcs *bcs);
+void st5481_release_b(struct st5481_bcs *bcs);
+void st5481_d_l2l1(struct hisax_if *hisax_d_if, int pr, void *arg);
+
+/* D Channel */
+
+int  st5481_setup_d(struct st5481_adapter *adapter);
+void st5481_release_d(struct st5481_adapter *adapter);
+void st5481_b_l2l1(struct hisax_if *b_if, int pr, void *arg);
+int  st5481_d_init(void);
+void st5481_d_exit(void);
+
+/* USB */
+void st5481_ph_command(struct st5481_adapter *adapter, unsigned int command);
+int st5481_setup_isocpipes(struct urb* urb[2], struct usb_device *dev, 
+			   unsigned int pipe, int num_packets,
+			   int packet_size, int buf_size,
+			   usb_complete_t complete, void *context);
+void st5481_release_isocpipes(struct urb* urb[2]);
+
+int  st5481_isoc_flatten(struct urb *urb);
+void st5481_usb_pipe_reset(struct st5481_adapter *adapter,
+		    u_char pipe, ctrl_complete_t complete, void *context);
+void st5481_usb_ctrl_msg(struct st5481_adapter *adapter,
+		  u8 request, u8 requesttype, u16 value, u16 index,
+		  ctrl_complete_t complete, void *context);
+void st5481_usb_device_ctrl_msg(struct st5481_adapter *adapter,
+			 u8 request, u16 value,
+			 ctrl_complete_t complete, void *context);
+int  st5481_setup_usb(struct st5481_adapter *adapter);
+void st5481_release_usb(struct st5481_adapter *adapter);
+void st5481_start(struct st5481_adapter *adapter);
+void st5481_stop(struct st5481_adapter *adapter);
+
+// ----------------------------------------------------------------------
+// debugging macros
+
+#define __debug_variable st5481_debug
+#include "hisax_debug.h"
+
+#ifdef CONFIG_HISAX_DEBUG
+
+extern int st5481_debug;
+
+#define DBG_ISO_PACKET(level,urb) \
+  if (level & __debug_variable) dump_iso_packet(__FUNCTION__,urb)
+
+static void __attribute__((unused))
+dump_iso_packet(const char *name,urb_t *urb)
+{
+	int i,j;
+	int len,ofs;
+	u_char *data;
+
+	printk(KERN_DEBUG "%s: packets=%d,errors=%d\n",
+	       name,urb->number_of_packets,urb->error_count);
+	for (i = 0; i  < urb->number_of_packets; ++i) {
+		if (urb->pipe & USB_DIR_IN) {
+			len = urb->iso_frame_desc[i].actual_length;
+		} else {
+			len = urb->iso_frame_desc[i].length;
+		}
+		ofs = urb->iso_frame_desc[i].offset;
+		printk(KERN_DEBUG "len=%.2d,ofs=%.3d ",len,ofs);
+		if (len) {
+			data = urb->transfer_buffer+ofs;
+			for (j=0; j < len; j++) {
+				printk ("%.2x", data[j]);
+			}
+		}
+		printk("\n");
+	}
+}
+
+static inline const char *ST5481_CMD_string(int evt)
+{
+	static char s[16];
+
+	switch (evt) {
+	case ST5481_CMD_DR: return "DR";
+	case ST5481_CMD_RES: return "RES";
+	case ST5481_CMD_TM1: return "TM1";
+	case ST5481_CMD_TM2: return "TM2";
+	case ST5481_CMD_PUP: return "PUP";
+	case ST5481_CMD_AR8: return "AR8";
+	case ST5481_CMD_AR10: return "AR10";
+	case ST5481_CMD_ARL: return "ARL";
+	case ST5481_CMD_PDN: return "PDN";
+	};
+	
+	sprintf(s,"0x%x",evt);
+	return s;
+}	
+
+#else
+
+#define DBG_ISO_PACKET(level,urb) do {} while (0)
+
+#endif
+
+
+
+#endif 
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/hisax/st5481_b.c linux/drivers/isdn/hisax/st5481_b.c
--- v2.4.9/linux/drivers/isdn/hisax/st5481_b.c	Wed Dec 31 16:00:00 1969
+++ linux/drivers/isdn/hisax/st5481_b.c	Sun Sep  9 10:45:43 2001
@@ -0,0 +1,367 @@
+/*
+ * Driver for ST5481 USB ISDN modem
+ *
+ * Author       Frode Isaksen
+ * Copyright    2001 by Frode Isaksen      <fisaksen@bewan.com>
+ *              2001 by Kai Germaschewski  <kai.germaschewski@gmx.de>
+ * 
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
+ *
+ */
+
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/usb.h>
+#include <linux/slab.h>
+#include <linux/netdevice.h>
+#include "st5481.h"
+
+static inline void B_L1L2(struct st5481_bcs *bcs, int pr, void *arg)
+{
+	struct hisax_if *ifc = (struct hisax_if *) &bcs->b_if;
+
+	ifc->l1l2(ifc, pr, arg);
+}
+
+/*
+ * Encode and transmit next frame.
+ */
+static void usb_b_out(struct st5481_bcs *bcs,int buf_nr)
+{
+	struct st5481_b_out *b_out = &bcs->b_out;
+	struct st5481_adapter *adapter = bcs->adapter;
+	struct urb *urb;
+	unsigned int packet_size,offset;
+	int len,buf_size,bytes_sent;
+	int i;
+	struct sk_buff *skb;
+	
+	if (test_and_set_bit(buf_nr, &b_out->busy)) {
+		DBG(4,"ep %d urb %d busy",(bcs->channel+1)*2,buf_nr);
+		return;
+	}
+	urb = b_out->urb[buf_nr];
+
+	// Adjust isoc buffer size according to flow state
+	if(b_out->flow_event & (OUT_DOWN | OUT_UNDERRUN)) {
+		buf_size = NUM_ISO_PACKETS_B*SIZE_ISO_PACKETS_B_OUT + B_FLOW_ADJUST;
+		packet_size = SIZE_ISO_PACKETS_B_OUT + B_FLOW_ADJUST;
+		DBG(4,"B%d,adjust flow,add %d bytes",bcs->channel+1,B_FLOW_ADJUST);
+	} else if(b_out->flow_event & OUT_UP){
+		buf_size = NUM_ISO_PACKETS_B*SIZE_ISO_PACKETS_B_OUT - B_FLOW_ADJUST;
+		packet_size = SIZE_ISO_PACKETS_B_OUT - B_FLOW_ADJUST;
+		DBG(4,"B%d,adjust flow,remove %d bytes",bcs->channel+1,B_FLOW_ADJUST);
+	} else {
+		buf_size = NUM_ISO_PACKETS_B*SIZE_ISO_PACKETS_B_OUT;
+		packet_size = 8;
+	}
+	b_out->flow_event = 0;
+
+	len = 0;
+	while (len < buf_size) {
+		if ((skb = b_out->tx_skb)) {
+			DBG_SKB(0x100, skb);
+			DBG(4,"B%d,len=%d",bcs->channel+1,skb->len);
+			
+			if (bcs->mode == L1_MODE_TRANS) {	
+				bytes_sent = buf_size - len;
+				if (skb->len < bytes_sent)
+					bytes_sent = skb->len;
+
+				memcpy(urb->transfer_buffer+len, skb->data, bytes_sent);
+				
+				len += bytes_sent;
+			} else {
+				len += hdlc_encode(&b_out->hdlc_state, 
+						   skb->data, skb->len, &bytes_sent,
+						   urb->transfer_buffer+len, buf_size-len);
+			}
+
+			skb_pull(skb, bytes_sent);
+			
+			if (!skb->len) {
+				// Frame sent
+				b_out->tx_skb = NULL;
+				B_L1L2(bcs, PH_DATA | CONFIRM, (void *) skb->truesize);
+				dev_kfree_skb_any(skb);
+				
+/* 				if (!(bcs->tx_skb = skb_dequeue(&bcs->sq))) { */
+/* 					st5481B_sched_event(bcs, B_XMTBUFREADY); */
+/* 				} */
+			}
+		} else {
+			if (bcs->mode == L1_MODE_TRANS) {
+				memset(urb->transfer_buffer+len, 0xff, buf_size-len);
+				len = buf_size;
+			} else {
+				// Send flags
+				len += hdlc_encode(&b_out->hdlc_state, 
+						   NULL, 0, &bytes_sent,
+						   urb->transfer_buffer+len, buf_size-len);
+			}
+		}	
+	}
+
+	// Prepare the URB
+	for (i = 0, offset = 0; offset < len; i++) {
+		urb->iso_frame_desc[i].offset = offset;
+		urb->iso_frame_desc[i].length = packet_size;
+		offset += packet_size;
+		packet_size = SIZE_ISO_PACKETS_B_OUT;
+	}
+	urb->transfer_buffer_length = len;
+	urb->number_of_packets = i;
+	urb->dev = adapter->usb_dev;
+
+	DBG_ISO_PACKET(0x200,urb);
+
+	SUBMIT_URB(urb);
+}
+
+/*
+ * Start transfering (flags or data) on the B channel, since
+ * FIFO counters has been set to a non-zero value.
+ */
+static void st5481B_start_xfer(void *context)
+{
+	struct st5481_bcs *bcs = context;
+
+	DBG(4,"B%d",bcs->channel+1);
+
+	// Start transmitting (flags or data) on B channel
+
+	usb_b_out(bcs,0);
+	usb_b_out(bcs,1);
+}
+
+/*
+ * If the adapter has only 2 LEDs, the green
+ * LED will blink with a rate depending
+ * on the number of channels opened.
+ */
+static void led_blink(struct st5481_adapter *adapter)
+{
+	u_char leds = adapter->leds;
+
+	// 50 frames/sec for each channel
+	if (++adapter->led_counter % 50) {
+		return;
+	}
+
+	if (adapter->led_counter % 100) {
+		leds |= GREEN_LED;
+	} else {
+		leds &= ~GREEN_LED;
+	}
+	
+	st5481_usb_device_ctrl_msg(adapter, GPIO_OUT, leds, NULL, NULL);
+}
+
+static void usb_b_out_complete(struct urb *urb)
+{
+	struct st5481_bcs *bcs = urb->context;
+	struct st5481_b_out *b_out = &bcs->b_out;
+	struct st5481_adapter *adapter = bcs->adapter;
+	int buf_nr;
+	
+	buf_nr = get_buf_nr(b_out->urb, urb);
+	test_and_clear_bit(buf_nr, &b_out->busy);
+
+	if (urb->status < 0) {
+		if (urb->status != USB_ST_URB_KILLED) {
+			WARN("urb status %d",urb->status);
+			if (b_out->busy == 0) {
+				st5481_usb_pipe_reset(adapter, (bcs->channel+1)*2 | USB_DIR_OUT, NULL, NULL);
+			}
+		} else {
+			DBG(1,"urb killed"); 
+			return; // Give up
+		}
+	}
+
+	usb_b_out(bcs,buf_nr);
+
+	if (adapter->number_of_leds == 2)
+		led_blink(adapter);
+}
+
+/*
+ * Start or stop the transfer on the B channel.
+ */
+static void st5481B_mode(struct st5481_bcs *bcs, int mode)
+{
+	struct st5481_b_out *b_out = &bcs->b_out;
+	struct st5481_adapter *adapter = bcs->adapter;
+
+	DBG(4,"B%d,mode=%d", bcs->channel + 1, mode);
+
+	if (bcs->mode == mode)
+		return;
+
+	bcs->mode = mode;
+
+	// Cancel all USB transfers on this B channel
+	usb_unlink_urb(b_out->urb[0]);
+	usb_unlink_urb(b_out->urb[1]);
+	b_out->busy = 0;
+
+	st5481_in_mode(&bcs->b_in, mode);
+	if (bcs->mode != L1_MODE_NULL) {
+		// Open the B channel
+		if (bcs->mode != L1_MODE_TRANS) {
+			hdlc_out_init(&b_out->hdlc_state, 0, bcs->mode == L1_MODE_HDLC_56K);
+		}
+		st5481_usb_pipe_reset(adapter, (bcs->channel+1)*2, NULL, NULL);
+	
+		// Enable B channel interrupts
+		st5481_usb_device_ctrl_msg(adapter, FFMSK_B1+(bcs->channel*2), 
+				    OUT_UP+OUT_DOWN+OUT_UNDERRUN, NULL, NULL);
+
+		// Enable B channel FIFOs
+		st5481_usb_device_ctrl_msg(adapter, OUT_B1_COUNTER+(bcs->channel*2), 32, st5481B_start_xfer, bcs);
+		if (adapter->number_of_leds == 4) {
+			if (bcs->channel == 0) {
+				adapter->leds |= B1_LED;
+			} else {
+				adapter->leds |= B2_LED;
+			}
+		}
+	} else {
+		// Disble B channel interrupts
+		st5481_usb_device_ctrl_msg(adapter, FFMSK_B1+(bcs->channel*2), 0, NULL, NULL);
+
+		// Disable B channel FIFOs
+		st5481_usb_device_ctrl_msg(adapter, OUT_B1_COUNTER+(bcs->channel*2), 0, NULL, NULL);
+
+		if (adapter->number_of_leds == 4) {
+			if (bcs->channel == 0) {
+				adapter->leds &= ~B1_LED;
+			} else {
+				adapter->leds &= ~B2_LED;
+			}
+		} else {
+			st5481_usb_device_ctrl_msg(adapter, GPIO_OUT, adapter->leds, NULL, NULL);
+		}
+		if (b_out->tx_skb) {
+			dev_kfree_skb_any(b_out->tx_skb);
+			b_out->tx_skb = NULL;
+		}
+		
+	}
+}
+
+static int __devinit st5481_setup_b_out(struct st5481_bcs *bcs)
+{
+	struct usb_device *dev = bcs->adapter->usb_dev;
+	struct usb_interface_descriptor *altsetting;
+	struct usb_endpoint_descriptor *endpoint;
+  	struct st5481_b_out *b_out = &bcs->b_out;
+
+	DBG(4,"");
+
+	altsetting = &(dev->config->interface[0].altsetting[3]);
+
+	// Allocate URBs and buffers for the B channel out
+	endpoint = &altsetting->endpoint[EP_B1_OUT - 1 + bcs->channel * 2];
+
+	DBG(4,"endpoint address=%02x,packet size=%d",
+	    endpoint->bEndpointAddress,endpoint->wMaxPacketSize);
+
+	// Allocate memory for 8000bytes/sec + extra bytes if underrun
+	return st5481_setup_isocpipes(b_out->urb, dev, 
+				      usb_sndisocpipe(dev, endpoint->bEndpointAddress),
+				      NUM_ISO_PACKETS_B, SIZE_ISO_PACKETS_B_OUT,
+				      NUM_ISO_PACKETS_B * SIZE_ISO_PACKETS_B_OUT + B_FLOW_ADJUST,
+				      usb_b_out_complete, bcs);
+}
+
+static void __devexit st5481_release_b_out(struct st5481_bcs *bcs)
+{
+	struct st5481_b_out *b_out = &bcs->b_out;
+
+	DBG(4,"");
+
+	st5481_release_isocpipes(b_out->urb);
+}
+
+int __devinit st5481_setup_b(struct st5481_bcs *bcs)
+{
+	int retval;
+
+	DBG(4,"");
+
+	retval = st5481_setup_b_out(bcs);
+	if (retval)
+		goto err;
+	bcs->b_in.bufsize = HSCX_BUFMAX;
+	bcs->b_in.num_packets = NUM_ISO_PACKETS_B;
+	bcs->b_in.packet_size = SIZE_ISO_PACKETS_B_IN;
+	bcs->b_in.ep = (bcs->channel ? EP_B2_IN : EP_B1_IN) | USB_DIR_IN;
+	bcs->b_in.counter = bcs->channel ? IN_B2_COUNTER : IN_B1_COUNTER;
+	bcs->b_in.adapter = bcs->adapter;
+	bcs->b_in.hisax_if = &bcs->b_if.ifc;
+	retval = st5481_setup_in(&bcs->b_in);
+	if (retval)
+		goto err_b_out;
+
+
+	return 0;
+
+ err_b_out:
+	st5481_release_b_out(bcs);
+ err:
+	return retval;
+}
+
+/*
+ * Release buffers and URBs for the B channels
+ */
+void __devexit st5481_release_b(struct st5481_bcs *bcs)
+{
+	DBG(4,"");
+
+	st5481_release_in(&bcs->b_in);
+	st5481_release_b_out(bcs);
+}
+
+/*
+ * st5481_b_l2l1 is the entry point for upper layer routines that want to
+ * transmit on the B channel.  PH_DATA | REQUEST is a normal packet that
+ * we either start transmitting (if idle) or queue (if busy).
+ * PH_PULL | REQUEST can be called to request a callback message
+ * (PH_PULL | CONFIRM)
+ * once the link is idle.  After a "pull" callback, the upper layer
+ * routines can use PH_PULL | INDICATION to send data.
+ */
+void st5481_b_l2l1(struct hisax_if *ifc, int pr, void *arg)
+{
+	struct st5481_bcs *bcs = ifc->priv;
+	struct sk_buff *skb = arg;
+	int mode;
+
+	DBG(4, "");
+
+	switch (pr) {
+	case PH_DATA | REQUEST:
+		if (bcs->b_out.tx_skb)
+			BUG();
+		
+		bcs->b_out.tx_skb = skb;
+		break;
+	case PH_ACTIVATE | REQUEST:
+		mode = (int) arg;
+		DBG(4,"B%d,PH_ACTIVATE_REQUEST %d", bcs->channel + 1, mode);
+		st5481B_mode(bcs, mode);
+		B_L1L2(bcs, PH_ACTIVATE | INDICATION, NULL);
+		break;
+	case PH_DEACTIVATE | REQUEST:
+		DBG(4,"B%d,PH_DEACTIVATE_REQUEST", bcs->channel + 1);
+		st5481B_mode(bcs, L1_MODE_NULL);
+		B_L1L2(bcs, PH_DEACTIVATE | INDICATION, NULL);
+		break;
+	default:
+		WARN("pr %#x\n", pr);
+	}
+}
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/hisax/st5481_d.c linux/drivers/isdn/hisax/st5481_d.c
--- v2.4.9/linux/drivers/isdn/hisax/st5481_d.c	Wed Dec 31 16:00:00 1969
+++ linux/drivers/isdn/hisax/st5481_d.c	Sun Sep  9 10:45:43 2001
@@ -0,0 +1,774 @@
+/*
+ * Driver for ST5481 USB ISDN modem
+ *
+ * Author       Frode Isaksen
+ * Copyright    2001 by Frode Isaksen      <fisaksen@bewan.com>
+ *              2001 by Kai Germaschewski  <kai.germaschewski@gmx.de>
+ * 
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
+ *
+ */
+
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/usb.h>
+#include <linux/slab.h>
+#include <linux/netdevice.h>
+#include "st5481.h"
+
+static void ph_connect(struct st5481_adapter *adapter);
+static void ph_disconnect(struct st5481_adapter *adapter);
+
+static struct Fsm l1fsm;
+
+static char *strL1State[] =
+{
+	"ST_L1_F3",
+	"ST_L1_F4",
+	"ST_L1_F6",
+	"ST_L1_F7",
+	"ST_L1_F8",
+};
+
+static char *strL1Event[] =
+{
+	"EV_IND_DP",  
+	"EV_IND_1",   
+	"EV_IND_2",   
+	"EV_IND_3",   
+	"EV_IND_RSY", 
+	"EV_IND_5",   
+	"EV_IND_6",   
+	"EV_IND_7",   
+	"EV_IND_AP",  
+	"EV_IND_9",   
+	"EV_IND_10",  
+	"EV_IND_11",  
+	"EV_IND_AI8",
+	"EV_IND_AI10",
+	"EV_IND_AIL",
+	"EV_IND_DI",  
+	"EV_PH_ACTIVATE_REQ",
+	"EV_PH_DEACTIVATE_REQ",
+	"EV_TIMER3",
+};
+
+static inline void D_L1L2(struct st5481_adapter *adapter, int pr, void *arg)
+{
+	struct hisax_if *ifc = (struct hisax_if *) &adapter->hisax_d_if;
+
+	ifc->l1l2(ifc, pr, arg);
+}
+
+static void
+l1_go_f3(struct FsmInst *fi, int event, void *arg)
+{
+	struct st5481_adapter *adapter = fi->userdata;
+
+	if (fi->state == ST_L1_F7)
+		ph_disconnect(adapter);
+	
+	FsmChangeState(fi, ST_L1_F3);
+	D_L1L2(adapter, PH_DEACTIVATE | INDICATION, NULL);
+}
+
+static void
+l1_go_f6(struct FsmInst *fi, int event, void *arg)
+{
+	struct st5481_adapter *adapter = fi->userdata;
+
+	if (fi->state == ST_L1_F7)
+		ph_disconnect(adapter);
+
+	FsmChangeState(fi, ST_L1_F6);
+}
+
+static void
+l1_go_f7(struct FsmInst *fi, int event, void *arg)
+{
+	struct st5481_adapter *adapter = fi->userdata;
+
+	FsmDelTimer(&adapter->timer, 0);
+	ph_connect(adapter);
+	FsmChangeState(fi, ST_L1_F7);
+	D_L1L2(adapter, PH_ACTIVATE | INDICATION, NULL);
+}
+
+static void
+l1_go_f8(struct FsmInst *fi, int event, void *arg)
+{
+	struct st5481_adapter *adapter = fi->userdata;
+
+	if (fi->state == ST_L1_F7)
+		ph_disconnect(adapter);
+
+	FsmChangeState(fi, ST_L1_F8);
+}
+
+static void
+l1_timer3(struct FsmInst *fi, int event, void *arg)
+{
+	struct st5481_adapter *adapter = fi->userdata;
+
+	st5481_ph_command(adapter, ST5481_CMD_DR);
+	FsmChangeState(fi, ST_L1_F3);
+	D_L1L2(adapter, PH_DEACTIVATE | INDICATION, NULL);
+}
+
+static void
+l1_ignore(struct FsmInst *fi, int event, void *arg)
+{
+}
+
+static void
+l1_activate(struct FsmInst *fi, int event, void *arg)
+{
+	struct st5481_adapter *adapter = fi->userdata;
+
+	st5481_ph_command(adapter, ST5481_CMD_DR);
+	st5481_ph_command(adapter, ST5481_CMD_PUP);
+	FsmRestartTimer(&adapter->timer, TIMER3_VALUE, EV_TIMER3, NULL, 2);
+	st5481_ph_command(adapter, ST5481_CMD_AR8);
+	FsmChangeState(fi, ST_L1_F4);
+}
+
+static struct FsmNode L1FnList[] __initdata =
+{
+	{ST_L1_F3, EV_IND_DP,            l1_ignore},
+	{ST_L1_F3, EV_IND_AP,            l1_go_f6},
+	{ST_L1_F3, EV_IND_AI8,           l1_go_f7},
+	{ST_L1_F3, EV_IND_AI10,          l1_go_f7},
+	{ST_L1_F3, EV_PH_ACTIVATE_REQ,   l1_activate},
+
+	{ST_L1_F4, EV_TIMER3,            l1_timer3},
+	{ST_L1_F4, EV_IND_DP,            l1_go_f3},
+	{ST_L1_F4, EV_IND_AP,            l1_go_f6},
+	{ST_L1_F4, EV_IND_AI8,           l1_go_f7},
+	{ST_L1_F4, EV_IND_AI10,          l1_go_f7},
+
+	{ST_L1_F6, EV_TIMER3,            l1_timer3},
+	{ST_L1_F6, EV_IND_DP,            l1_go_f3},
+	{ST_L1_F6, EV_IND_AP,            l1_ignore},
+	{ST_L1_F6, EV_IND_AI8,           l1_go_f7},
+	{ST_L1_F6, EV_IND_AI10,          l1_go_f7},
+	{ST_L1_F7, EV_IND_RSY,           l1_go_f8},
+
+	{ST_L1_F7, EV_IND_DP,            l1_go_f3},
+	{ST_L1_F7, EV_IND_AP,            l1_go_f6},
+	{ST_L1_F7, EV_IND_AI8,           l1_ignore},
+	{ST_L1_F7, EV_IND_AI10,          l1_ignore},
+	{ST_L1_F7, EV_IND_RSY,           l1_go_f8},
+
+	{ST_L1_F8, EV_TIMER3,            l1_timer3},
+	{ST_L1_F8, EV_IND_DP,            l1_go_f3},
+	{ST_L1_F8, EV_IND_AP,            l1_go_f6},
+	{ST_L1_F8, EV_IND_AI8,           l1_go_f8},
+	{ST_L1_F8, EV_IND_AI10,          l1_go_f8},
+	{ST_L1_F8, EV_IND_RSY,           l1_ignore},
+};
+
+static void l1m_debug(struct FsmInst *fi, char *fmt, ...)
+{
+	va_list args;
+	char buf[256];
+	
+	va_start(args, fmt);
+	vsprintf(buf, fmt, args);
+	printk("buf %s\n", buf);
+	DBG(8, "%s", buf);
+	va_end(args);
+}
+
+/* ======================================================================
+ * D-Channel out
+ */
+
+/*
+  D OUT state machine:
+  ====================
+
+  Transmit short frame (< 16 bytes of encoded data):
+
+  L1 FRAME    D_OUT_STATE           USB                  D CHANNEL
+  --------    -----------           ---                  ---------
+ 
+              FIXME
+
+ -> [xx..xx]  SHORT_INIT            -> [7Exx..xxC1C27EFF]
+              SHORT_WAIT_DEN        <> OUT_D_COUNTER=16 
+                                                 
+              END_OF_SHORT          <- DEN_EVENT         -> 7Exx
+                                                          xxxx 
+                                                          xxxx
+							  xxxx 
+							  xxxx
+							  xxxx
+							  C1C1 
+							  7EFF 
+              WAIT_FOR_RESET_IDLE   <- D_UNDERRUN        <- (8ms)                        
+              IDLE                  <> Reset pipe
+
+              
+
+  Transmit long frame (>= 16 bytes of encoded data):
+
+  L1 FRAME    D_OUT_STATE           USB                  D CHANNEL
+  --------    -----------           ---                  ---------
+
+ -> [xx...xx] IDLE
+              WAIT_FOR_STOP         <> OUT_D_COUNTER=0
+              WAIT_FOR_RESET        <> Reset pipe
+	      STOP
+	      INIT_LONG_FRAME       -> [7Exx..xx]
+              WAIT_DEN              <> OUT_D_COUNTER=16 
+              OUT_NORMAL            <- DEN_EVENT       -> 7Exx
+              END_OF_FRAME_BUSY     -> [xxxx]             xxxx 
+              END_OF_FRAME_NOT_BUSY -> [xxxx]             xxxx
+				    -> [xxxx]		  xxxx 
+				    -> [C1C2]		  xxxx
+				    -> [7EFF]		  xxxx
+							  xxxx 
+							  xxxx 
+                                                          ....
+							  xxxx
+							  C1C2
+							  7EFF
+	                 	    <- D_UNDERRUN      <- (> 8ms)                        
+              WAIT_FOR_STOP         <> OUT_D_COUNTER=0
+              WAIT_FOR_RESET        <> Reset pipe
+	      STOP
+
+*/          
+
+static struct Fsm dout_fsm;
+
+static char *strDoutState[] =
+{
+	"ST_DOUT_NONE",
+
+	"ST_DOUT_SHORT_INIT",
+	"ST_DOUT_SHORT_WAIT_DEN",
+
+	"ST_DOUT_LONG_INIT",
+	"ST_DOUT_LONG_WAIT_DEN",
+	"ST_DOUT_NORMAL",
+
+	"ST_DOUT_WAIT_FOR_UNDERRUN",
+        "ST_DOUT_WAIT_FOR_NOT_BUSY",
+	"ST_DOUT_WAIT_FOR_STOP",
+	"ST_DOUT_WAIT_FOR_RESET",
+};
+
+static char *strDoutEvent[] =
+{
+	"EV_DOUT_START_XMIT",
+	"EV_DOUT_COMPLETE",
+	"EV_DOUT_DEN",
+	"EV_DOUT_RESETED",
+	"EV_DOUT_STOPPED",
+	"EV_DOUT_COLL",
+	"EV_DOUT_UNDERRUN",
+};
+
+static void dout_debug(struct FsmInst *fi, char *fmt, ...)
+{
+	va_list args;
+	char buf[256];
+	
+	va_start(args, fmt);
+	vsprintf(buf, fmt, args);
+	DBG(0x2, "%s", buf);
+	va_end(args);
+}
+
+static void dout_stop_event(void *context)
+{
+	struct st5481_adapter *adapter = context;
+
+	FsmEvent(&adapter->d_out.fsm, EV_DOUT_STOPPED, NULL);
+}
+
+/*
+ * Start the transfer of a D channel frame.
+ */
+static void usb_d_out(struct st5481_adapter *adapter, int buf_nr)
+{
+	struct st5481_d_out *d_out = &adapter->d_out;
+	struct urb *urb;
+	unsigned int num_packets, packet_offset;
+	int len, buf_size, bytes_sent;
+	struct sk_buff *skb;
+	iso_packet_descriptor_t *desc;
+
+	if (d_out->fsm.state != ST_DOUT_NORMAL)
+		return;
+
+	if (test_and_set_bit(buf_nr, &d_out->busy)) {
+		DBG(2, "ep %d urb %d busy %#lx", EP_D_OUT, buf_nr, d_out->busy);
+		return;
+	}
+	urb = d_out->urb[buf_nr];
+
+	skb = d_out->tx_skb;
+
+	buf_size = NUM_ISO_PACKETS_D * SIZE_ISO_PACKETS_D_OUT;
+	
+	if (skb) {
+		len = hdlc_encode(&d_out->hdlc_state, 
+				  skb->data, skb->len, &bytes_sent,
+				  urb->transfer_buffer, buf_size);
+		skb_pull(skb,bytes_sent);
+	} else {
+		// Send flags or idle
+		len = hdlc_encode(&d_out->hdlc_state, 
+				  NULL, 0, &bytes_sent,
+				  urb->transfer_buffer, buf_size);
+	}
+	
+	if (len < buf_size) {
+		FsmChangeState(&d_out->fsm, ST_DOUT_WAIT_FOR_UNDERRUN);
+	}
+	if (skb && !skb->len) {
+		d_out->tx_skb = NULL;
+		D_L1L2(adapter, PH_DATA | CONFIRM, NULL);
+		dev_kfree_skb_any(skb);
+	}
+
+	// Prepare the URB
+	urb->transfer_buffer_length = len;
+	num_packets = 0;
+	packet_offset = 0;
+	while (packet_offset < len) {
+		desc = &urb->iso_frame_desc[num_packets];
+		desc->offset = packet_offset;
+		desc->length = SIZE_ISO_PACKETS_D_OUT;
+		if (len - packet_offset < desc->length)
+			desc->length = len - packet_offset;
+		num_packets++;
+		packet_offset += desc->length;
+	}
+	urb->number_of_packets = num_packets;
+
+	// Prepare the URB
+	urb->dev = adapter->usb_dev;
+	// Need to transmit the next buffer 2ms after the DEN_EVENT
+	urb->transfer_flags = 0;
+	urb->start_frame = usb_get_current_frame_number(adapter->usb_dev)+2;
+
+	DBG_ISO_PACKET(0x20,urb);
+
+	if (usb_submit_urb(urb) < 0) {
+		// There is another URB queued up
+		urb->transfer_flags = USB_ISO_ASAP;
+		SUBMIT_URB(urb);
+	}	
+}
+
+static void fifo_reseted(void *context)
+{
+	struct st5481_adapter *adapter = context;
+
+	FsmEvent(&adapter->d_out.fsm, EV_DOUT_RESETED, NULL);
+}
+
+static void usb_d_out_complete(struct urb *urb)
+{
+	struct st5481_adapter *adapter = urb->context;
+	struct st5481_d_out *d_out = &adapter->d_out;
+	int buf_nr;
+	
+	DBG(2, "");
+
+	buf_nr = get_buf_nr(d_out->urb, urb);
+	test_and_clear_bit(buf_nr, &d_out->busy);
+
+	if (urb->status < 0) {
+		if (urb->status != USB_ST_URB_KILLED) {
+			WARN("urb status %d",urb->status);
+			if (d_out->busy == 0) {
+				st5481_usb_pipe_reset(adapter, EP_D_OUT | USB_DIR_OUT, fifo_reseted, adapter);
+			}
+			return;
+		} else {
+			DBG(1,"urb killed"); 
+			return; // Give up
+		}
+	}
+
+	FsmEvent(&adapter->d_out.fsm, EV_DOUT_COMPLETE, (void *) buf_nr);
+}
+
+/* ====================================================================== */
+
+static void dout_start_xmit(struct FsmInst *fsm, int event, void *arg)
+{
+	// FIXME unify?
+	struct st5481_adapter *adapter = fsm->userdata;
+	struct st5481_d_out *d_out = &adapter->d_out;
+	struct urb *urb;
+	int len, bytes_sent;
+	struct sk_buff *skb;
+	int buf_nr = 0;
+
+	skb = d_out->tx_skb;
+
+	DBG(2,"len=%d",skb->len);
+
+	hdlc_out_init(&d_out->hdlc_state, 1, 0);
+
+	if (test_and_set_bit(buf_nr, &d_out->busy)) {
+		WARN("ep %d urb %d busy %#lx", EP_D_OUT, buf_nr, d_out->busy);
+		return;
+	}
+	urb = d_out->urb[buf_nr];
+
+	DBG_SKB(0x10, skb);
+	len = hdlc_encode(&d_out->hdlc_state, 
+			  skb->data, skb->len, &bytes_sent,
+			  urb->transfer_buffer, 16);
+	skb_pull(skb, bytes_sent);
+
+	if(len < 16)
+		FsmChangeState(&d_out->fsm, ST_DOUT_SHORT_INIT);
+	else
+		FsmChangeState(&d_out->fsm, ST_DOUT_LONG_INIT);
+
+	if (skb->len == 0) {
+		d_out->tx_skb = NULL;
+		D_L1L2(adapter, PH_DATA | CONFIRM, NULL);
+		dev_kfree_skb_any(skb);
+	}
+
+// Prepare the URB
+	urb->transfer_buffer_length = len;
+
+	urb->iso_frame_desc[0].offset = 0;
+	urb->iso_frame_desc[0].length = len;
+	urb->number_of_packets = 1;
+
+	// Prepare the URB
+	urb->dev = adapter->usb_dev;
+	urb->transfer_flags = USB_ISO_ASAP;
+
+	DBG_ISO_PACKET(0x20,urb);
+	SUBMIT_URB(urb);
+}
+
+static void dout_short_fifo(struct FsmInst *fsm, int event, void *arg)
+{
+	struct st5481_adapter *adapter = fsm->userdata;
+	struct st5481_d_out *d_out = &adapter->d_out;
+
+	FsmChangeState(&d_out->fsm, ST_DOUT_SHORT_WAIT_DEN);
+	st5481_usb_device_ctrl_msg(adapter, OUT_D_COUNTER, 16, NULL, NULL);
+}
+
+static void dout_end_short_frame(struct FsmInst *fsm, int event, void *arg)
+{
+	struct st5481_adapter *adapter = fsm->userdata;
+	struct st5481_d_out *d_out = &adapter->d_out;
+
+	FsmChangeState(&d_out->fsm, ST_DOUT_WAIT_FOR_UNDERRUN);
+}
+
+static void dout_long_enable_fifo(struct FsmInst *fsm, int event, void *arg)
+{
+	struct st5481_adapter *adapter = fsm->userdata;
+	struct st5481_d_out *d_out = &adapter->d_out;
+    
+	st5481_usb_device_ctrl_msg(adapter, OUT_D_COUNTER, 16, NULL, NULL);
+	FsmChangeState(&d_out->fsm, ST_DOUT_LONG_WAIT_DEN);
+}
+
+static void dout_long_den(struct FsmInst *fsm, int event, void *arg)
+{
+	struct st5481_adapter *adapter = fsm->userdata;
+	struct st5481_d_out *d_out = &adapter->d_out;
+
+	FsmChangeState(&d_out->fsm, ST_DOUT_NORMAL);
+	usb_d_out(adapter, 0);
+	usb_d_out(adapter, 1);
+}
+
+static void dout_reset(struct FsmInst *fsm, int event, void *arg)
+{
+	struct st5481_adapter *adapter = fsm->userdata;
+	struct st5481_d_out *d_out = &adapter->d_out;
+
+	FsmChangeState(&d_out->fsm, ST_DOUT_WAIT_FOR_RESET);
+	st5481_usb_pipe_reset(adapter, EP_D_OUT | USB_DIR_OUT, fifo_reseted, adapter);
+}
+
+static void dout_stop(struct FsmInst *fsm, int event, void *arg)
+{
+	struct st5481_adapter *adapter = fsm->userdata;
+	struct st5481_d_out *d_out = &adapter->d_out;
+
+	FsmChangeState(&d_out->fsm, ST_DOUT_WAIT_FOR_STOP);
+	st5481_usb_device_ctrl_msg(adapter, OUT_D_COUNTER, 0, dout_stop_event, adapter);
+}
+
+static void dout_underrun(struct FsmInst *fsm, int event, void *arg)
+{
+	struct st5481_adapter *adapter = fsm->userdata;
+	struct st5481_d_out *d_out = &adapter->d_out;
+
+	if (test_bit(0, &d_out->busy) || test_bit(1, &d_out->busy)) {
+		FsmChangeState(&d_out->fsm, ST_DOUT_WAIT_FOR_NOT_BUSY);
+	}  else {
+		dout_stop(fsm, event, arg);
+	}
+}
+
+static void dout_check_busy(struct FsmInst *fsm, int event, void *arg)
+{
+	struct st5481_adapter *adapter = fsm->userdata;
+	struct st5481_d_out *d_out = &adapter->d_out;
+
+	if (!test_bit(0, &d_out->busy) && !test_bit(1, &d_out->busy))
+		dout_stop(fsm, event, arg);
+}
+
+static void dout_reseted(struct FsmInst *fsm, int event, void *arg)
+{
+	struct st5481_adapter *adapter = fsm->userdata;
+	struct st5481_d_out *d_out = &adapter->d_out;
+
+	FsmChangeState(&d_out->fsm, ST_DOUT_NONE);
+	// FIXME locking
+	if (d_out->tx_skb)
+		FsmEvent(&d_out->fsm, EV_DOUT_START_XMIT, NULL);
+}
+
+static void dout_complete(struct FsmInst *fsm, int event, void *arg)
+{
+	struct st5481_adapter *adapter = fsm->userdata;
+	int buf_nr = (int) arg;
+
+	usb_d_out(adapter, buf_nr);
+}
+
+static void dout_ignore(struct FsmInst *fsm, int event, void *arg)
+{
+}
+
+static struct FsmNode DoutFnList[] __initdata =
+{
+	{ST_DOUT_NONE,                   EV_DOUT_START_XMIT,   dout_start_xmit},
+
+	{ST_DOUT_SHORT_INIT,             EV_DOUT_COMPLETE,     dout_short_fifo},
+
+	{ST_DOUT_SHORT_WAIT_DEN,         EV_DOUT_DEN,          dout_end_short_frame},
+	{ST_DOUT_SHORT_WAIT_DEN,         EV_DOUT_UNDERRUN,     dout_underrun},
+
+	{ST_DOUT_LONG_INIT,              EV_DOUT_COMPLETE,     dout_long_enable_fifo},
+
+	{ST_DOUT_LONG_WAIT_DEN,          EV_DOUT_DEN,          dout_long_den},
+	{ST_DOUT_LONG_WAIT_DEN,          EV_DOUT_UNDERRUN,     dout_underrun},
+
+	{ST_DOUT_NORMAL,                 EV_DOUT_UNDERRUN,     dout_underrun},
+	{ST_DOUT_NORMAL,                 EV_DOUT_COMPLETE,     dout_complete},
+
+	{ST_DOUT_WAIT_FOR_UNDERRUN,      EV_DOUT_UNDERRUN,     dout_underrun},
+	{ST_DOUT_WAIT_FOR_UNDERRUN,      EV_DOUT_COMPLETE,     dout_ignore},
+
+	{ST_DOUT_WAIT_FOR_NOT_BUSY,      EV_DOUT_COMPLETE,     dout_check_busy},
+
+	{ST_DOUT_WAIT_FOR_STOP,          EV_DOUT_STOPPED,      dout_reset},
+
+	{ST_DOUT_WAIT_FOR_RESET,         EV_DOUT_RESETED,      dout_reseted},
+};
+
+void st5481_d_l2l1(struct hisax_if *hisax_d_if, int pr, void *arg)
+{
+	struct st5481_adapter *adapter = hisax_d_if->priv;
+	struct sk_buff *skb = arg;
+
+	switch (pr) {
+	case PH_ACTIVATE | REQUEST:
+		FsmEvent(&adapter->l1m, EV_PH_ACTIVATE_REQ, NULL);
+		break;
+	case PH_DEACTIVATE | REQUEST:
+		FsmEvent(&adapter->l1m, EV_PH_DEACTIVATE_REQ, NULL);
+		break;
+	case PH_DATA | REQUEST:
+		DBG(2, "PH_DATA REQUEST len %d", skb->len);
+		if (adapter->d_out.tx_skb)
+			BUG();
+
+		adapter->d_out.tx_skb = skb;
+		FsmEvent(&adapter->d_out.fsm, EV_DOUT_START_XMIT, NULL);
+		break;
+	default:
+		WARN("pr %#x\n", pr);
+		break;
+	}
+}
+
+/* ======================================================================
+ */
+
+/*
+ * Start receiving on the D channel since entered state F7.
+ */
+static void ph_connect(struct st5481_adapter *adapter)
+{
+	struct st5481_d_out *d_out = &adapter->d_out;
+	struct st5481_in *d_in = &adapter->d_in;
+
+	DBG(8,"");
+		
+	FsmChangeState(&d_out->fsm, ST_DOUT_NONE);
+
+	//	st5481_usb_device_ctrl_msg(adapter, FFMSK_D, OUT_UNDERRUN, NULL, NULL);
+	st5481_usb_device_ctrl_msg(adapter, FFMSK_D, 0xfc, NULL, NULL);
+	st5481_in_mode(d_in, L1_MODE_HDLC);
+
+#if LOOPBACK
+	// Turn loopback on (data sent on B and D looped back)
+	st5481_usb_device_ctrl_msg(cs, LBB, 0x04, NULL, NULL);
+#endif
+
+	st5481_usb_pipe_reset(adapter, EP_D_OUT | USB_DIR_OUT, NULL, NULL);
+
+	// Turn on the green LED to tell that we are in state F7
+	adapter->leds |= GREEN_LED;
+	st5481_usb_device_ctrl_msg(adapter, GPIO_OUT, adapter->leds, NULL, NULL);
+}
+
+/*
+ * Stop receiving on the D channel since not in state F7.
+ */
+static void ph_disconnect(struct st5481_adapter *adapter)
+{
+	DBG(8,"");
+
+	st5481_in_mode(&adapter->d_in, L1_MODE_NULL);
+
+	// Turn off the green LED to tell that we left state F7
+	adapter->leds &= ~GREEN_LED;
+	st5481_usb_device_ctrl_msg(adapter, GPIO_OUT, adapter->leds, NULL, NULL);
+}
+
+static int __devinit st5481_setup_d_out(struct st5481_adapter *adapter)
+{
+	struct usb_device *dev = adapter->usb_dev;
+	struct usb_interface_descriptor *altsetting;
+	struct usb_endpoint_descriptor *endpoint;
+	struct st5481_d_out *d_out = &adapter->d_out;
+
+	DBG(2,"");
+
+	altsetting = &(dev->config->interface[0].altsetting[3]);
+
+	// Allocate URBs and buffers for the D channel out
+	endpoint = &altsetting->endpoint[EP_D_OUT-1];
+
+	DBG(2,"endpoint address=%02x,packet size=%d",
+	    endpoint->bEndpointAddress,endpoint->wMaxPacketSize);
+
+	return st5481_setup_isocpipes(d_out->urb, dev, 
+				      usb_sndisocpipe(dev, endpoint->bEndpointAddress),
+				      NUM_ISO_PACKETS_D, SIZE_ISO_PACKETS_D_OUT,
+				      NUM_ISO_PACKETS_D * SIZE_ISO_PACKETS_D_OUT,
+				      usb_d_out_complete, adapter);
+}
+
+static void __devexit st5481_release_d_out(struct st5481_adapter *adapter)
+{
+	struct st5481_d_out *d_out = &adapter->d_out;
+
+	DBG(2,"");
+
+	st5481_release_isocpipes(d_out->urb);
+}
+
+int __devinit st5481_setup_d(struct st5481_adapter *adapter)
+{
+	int retval;
+
+	DBG(2,"");
+
+	retval = st5481_setup_d_out(adapter);
+	if (retval)
+		goto err;
+	adapter->d_in.bufsize = MAX_DFRAME_LEN_L1;
+	adapter->d_in.num_packets = NUM_ISO_PACKETS_D;
+	adapter->d_in.packet_size = SIZE_ISO_PACKETS_D_IN;
+	adapter->d_in.ep = EP_D_IN | USB_DIR_IN;
+	adapter->d_in.counter = IN_D_COUNTER;
+	adapter->d_in.adapter = adapter;
+	adapter->d_in.hisax_if = &adapter->hisax_d_if.ifc;
+	retval = st5481_setup_in(&adapter->d_in);
+	if (retval)
+		goto err_d_out;
+
+	adapter->l1m.fsm = &l1fsm;
+	adapter->l1m.state = ST_L1_F3;
+	adapter->l1m.debug = 1;
+	adapter->l1m.userdata = adapter;
+	adapter->l1m.printdebug = l1m_debug;
+	FsmInitTimer(&adapter->l1m, &adapter->timer);
+
+	adapter->d_out.fsm.fsm = &dout_fsm;
+	adapter->d_out.fsm.state = ST_DOUT_NONE;
+	adapter->d_out.fsm.debug = 1;
+	adapter->d_out.fsm.userdata = adapter;
+	adapter->d_out.fsm.printdebug = dout_debug;
+
+	return 0;
+
+ err_d_out:
+	st5481_release_d_out(adapter);
+ err:
+	return retval;
+}
+
+void __devexit st5481_release_d(struct st5481_adapter *adapter)
+{
+	DBG(2,"");
+
+	st5481_release_in(&adapter->d_in);
+	st5481_release_d_out(adapter);
+}
+
+/* ======================================================================
+ * init / exit
+ */
+
+int __init st5481_d_init(void)
+{
+	int retval;
+
+	l1fsm.state_count = L1_STATE_COUNT;
+	l1fsm.event_count = L1_EVENT_COUNT;
+	l1fsm.strEvent = strL1Event;
+	l1fsm.strState = strL1State;
+	retval = FsmNew(&l1fsm, L1FnList, ARRAY_SIZE(L1FnList));
+	if (retval)
+		goto err;
+
+	dout_fsm.state_count = DOUT_STATE_COUNT;
+	dout_fsm.event_count = DOUT_EVENT_COUNT;
+	dout_fsm.strEvent = strDoutEvent;
+	dout_fsm.strState = strDoutState;
+	retval = FsmNew(&dout_fsm, DoutFnList, ARRAY_SIZE(DoutFnList));
+	if (retval)
+		goto err_l1;
+
+	return 0;
+
+ err_l1:
+	FsmFree(&l1fsm);
+ err:
+	return retval;
+}
+
+// can't be __exit
+void st5481_d_exit(void)
+{
+	FsmFree(&l1fsm);
+	FsmFree(&dout_fsm);
+}
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/hisax/st5481_hdlc.c linux/drivers/isdn/hisax/st5481_hdlc.c
--- v2.4.9/linux/drivers/isdn/hisax/st5481_hdlc.c	Wed Dec 31 16:00:00 1969
+++ linux/drivers/isdn/hisax/st5481_hdlc.c	Sun Sep  9 10:45:43 2001
@@ -0,0 +1,620 @@
+/*
+ * Driver for ST5481 USB ISDN modem
+ *
+ * Author       Frode Isaksen
+ * Copyright    2001 by Frode Isaksen      <fisaksen@bewan.com>
+ *              2001 by Kai Germaschewski  <kai.germaschewski@gmx.de>
+ * 
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
+ *
+ */
+
+#include "st5481_hdlc.h"
+
+static const unsigned short int crc16_tab[] = {
+	0x0000,0x1189,0x2312,0x329b,0x4624,0x57ad,0x6536,0x74bf,
+	0x8c48,0x9dc1,0xaf5a,0xbed3,0xca6c,0xdbe5,0xe97e,0xf8f7,
+	0x1081,0x0108,0x3393,0x221a,0x56a5,0x472c,0x75b7,0x643e,
+	0x9cc9,0x8d40,0xbfdb,0xae52,0xdaed,0xcb64,0xf9ff,0xe876,
+	0x2102,0x308b,0x0210,0x1399,0x6726,0x76af,0x4434,0x55bd,
+	0xad4a,0xbcc3,0x8e58,0x9fd1,0xeb6e,0xfae7,0xc87c,0xd9f5,
+	0x3183,0x200a,0x1291,0x0318,0x77a7,0x662e,0x54b5,0x453c,
+	0xbdcb,0xac42,0x9ed9,0x8f50,0xfbef,0xea66,0xd8fd,0xc974,
+	0x4204,0x538d,0x6116,0x709f,0x0420,0x15a9,0x2732,0x36bb,
+	0xce4c,0xdfc5,0xed5e,0xfcd7,0x8868,0x99e1,0xab7a,0xbaf3,
+	0x5285,0x430c,0x7197,0x601e,0x14a1,0x0528,0x37b3,0x263a,
+	0xdecd,0xcf44,0xfddf,0xec56,0x98e9,0x8960,0xbbfb,0xaa72,
+	0x6306,0x728f,0x4014,0x519d,0x2522,0x34ab,0x0630,0x17b9,
+	0xef4e,0xfec7,0xcc5c,0xddd5,0xa96a,0xb8e3,0x8a78,0x9bf1,
+	0x7387,0x620e,0x5095,0x411c,0x35a3,0x242a,0x16b1,0x0738,
+	0xffcf,0xee46,0xdcdd,0xcd54,0xb9eb,0xa862,0x9af9,0x8b70,
+	0x8408,0x9581,0xa71a,0xb693,0xc22c,0xd3a5,0xe13e,0xf0b7,
+	0x0840,0x19c9,0x2b52,0x3adb,0x4e64,0x5fed,0x6d76,0x7cff,
+	0x9489,0x8500,0xb79b,0xa612,0xd2ad,0xc324,0xf1bf,0xe036,
+	0x18c1,0x0948,0x3bd3,0x2a5a,0x5ee5,0x4f6c,0x7df7,0x6c7e,
+	0xa50a,0xb483,0x8618,0x9791,0xe32e,0xf2a7,0xc03c,0xd1b5,
+	0x2942,0x38cb,0x0a50,0x1bd9,0x6f66,0x7eef,0x4c74,0x5dfd,
+	0xb58b,0xa402,0x9699,0x8710,0xf3af,0xe226,0xd0bd,0xc134,
+	0x39c3,0x284a,0x1ad1,0x0b58,0x7fe7,0x6e6e,0x5cf5,0x4d7c,
+	0xc60c,0xd785,0xe51e,0xf497,0x8028,0x91a1,0xa33a,0xb2b3,
+	0x4a44,0x5bcd,0x6956,0x78df,0x0c60,0x1de9,0x2f72,0x3efb,
+	0xd68d,0xc704,0xf59f,0xe416,0x90a9,0x8120,0xb3bb,0xa232,
+	0x5ac5,0x4b4c,0x79d7,0x685e,0x1ce1,0x0d68,0x3ff3,0x2e7a,
+	0xe70e,0xf687,0xc41c,0xd595,0xa12a,0xb0a3,0x8238,0x93b1,
+	0x6b46,0x7acf,0x4854,0x59dd,0x2d62,0x3ceb,0x0e70,0x1ff9,
+	0xf78f,0xe606,0xd49d,0xc514,0xb1ab,0xa022,0x92b9,0x8330,
+	0x7bc7,0x6a4e,0x58d5,0x495c,0x3de3,0x2c6a,0x1ef1,0x0f78
+};
+
+
+
+enum {
+	HDLC_FAST_IDLE,HDLC_GET_FLAG_B0,HDLC_GETFLAG_B1A6,HDLC_GETFLAG_B7,
+	HDLC_GET_DATA,HDLC_FAST_FLAG
+};
+
+enum {
+	HDLC_SEND_DATA,HDLC_SEND_CRC1,HDLC_SEND_FAST_FLAG,
+	HDLC_SEND_FIRST_FLAG,HDLC_SEND_CRC2,HDLC_SEND_CLOSING_FLAG,
+	HDLC_SEND_IDLE1,HDLC_SEND_FAST_IDLE,HDLC_SENDFLAG_B0,
+	HDLC_SENDFLAG_B1A6,HDLC_SENDFLAG_B7,STOPPED
+};
+
+void 
+hdlc_rcv_init(struct hdlc_vars *hdlc, int do_adapt56)
+{
+   	hdlc->bit_shift = 0;
+	hdlc->hdlc_bits1 = 0;
+	hdlc->data_bits = 0;
+	hdlc->ffbit_shift = 0;
+	hdlc->data_received = 0;
+	hdlc->state = HDLC_GET_DATA;
+	hdlc->do_adapt56 = do_adapt56;
+	hdlc->dchannel = 0;
+	hdlc->crc = 0;
+	hdlc->cbin = 0;
+	hdlc->shift_reg = 0;
+	hdlc->ffvalue = 0;
+	hdlc->dstpos = 0;
+}
+
+void 
+hdlc_out_init(struct hdlc_vars *hdlc, int is_d_channel, int do_adapt56)
+{
+   	hdlc->bit_shift = 0;
+	hdlc->hdlc_bits1 = 0;
+	hdlc->data_bits = 0;
+	hdlc->ffbit_shift = 0;
+	hdlc->data_received = 0;
+	hdlc->do_closing = 0;
+	hdlc->ffvalue = 0;
+	if (is_d_channel) {
+		hdlc->dchannel = 1;
+		hdlc->state = HDLC_SEND_FIRST_FLAG;
+	} else {
+		hdlc->dchannel = 0;
+		hdlc->state = HDLC_SEND_FAST_FLAG;
+		hdlc->ffvalue = 0x7e;
+	} 
+	hdlc->cbin = 0x7e;
+	hdlc->bit_shift = 0;
+	if(do_adapt56){
+		hdlc->do_adapt56 = 1;		
+		hdlc->data_bits = 0;
+		hdlc->state = HDLC_SENDFLAG_B0;
+	} else {
+		hdlc->do_adapt56 = 0;		
+		hdlc->data_bits = 8;
+	}
+	hdlc->shift_reg = 0;
+}
+
+/*
+  hdlc_decode - decodes HDLC frames from a transparent bit stream.
+
+  The source buffer is scanned for valid HDLC frames looking for
+  flags (01111110) to indicate the start of a frame. If the start of
+  the frame is found, the bit stuffing is removed (0 after 5 1's).
+  When a new flag is found, the complete frame has been received
+  and the CRC is checked.
+  If a valid frame is found, the function returns the frame length 
+  excluding the CRC with the bit HDLC_END_OF_FRAME set.
+  If the beginning of a valid frame is found, the function returns
+  the length. 
+  If a framing error is found (too many 1s and not a flag) the function 
+  returns the length with the bit HDLC_FRAMING_ERROR set.
+  If a CRC error is found the function returns the length with the
+  bit HDLC_CRC_ERROR set.
+  If the frame length exceeds the destination buffer size, the function
+  returns the length with the bit HDLC_LENGTH_ERROR set.
+
+  src - source buffer
+  slen - source buffer length
+  count - number of bytes removed (decoded) from the source buffer
+  dst _ destination buffer
+  dsize - destination buffer size
+  returns - number of decoded bytes in the destination buffer and status
+  flag.
+ */
+int hdlc_decode(struct hdlc_vars *hdlc, const unsigned char *src,
+		int slen, int *count, unsigned char *dst, int dsize)
+{
+	int status=0;
+
+	static const unsigned char fast_flag[]={
+		0x00,0x00,0x00,0x20,0x30,0x38,0x3c,0x3e,0x3f
+	};
+
+	static const unsigned char fast_flag_value[]={
+		0x00,0x7e,0xfc,0xf9,0xf3,0xe7,0xcf,0x9f,0x3f
+	};
+
+	static const unsigned char fast_abort[]={
+		0x00,0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff
+	};
+
+	*count = slen;
+
+	while(slen > 0){
+		if(hdlc->bit_shift==0){
+			hdlc->cbin = *src++;
+			slen--;
+			hdlc->bit_shift = 8;
+			if(hdlc->do_adapt56){
+				hdlc->bit_shift --;
+			}
+		}
+
+		switch(hdlc->state){
+		case STOPPED:
+			return 0;
+		case HDLC_FAST_IDLE:
+			if(hdlc->cbin == 0xff){
+				hdlc->bit_shift = 0;
+				break;
+			}
+			hdlc->state = HDLC_GET_FLAG_B0;
+			hdlc->hdlc_bits1 = 0;
+			hdlc->bit_shift = 8;
+			break;
+		case HDLC_GET_FLAG_B0:
+			if(!(hdlc->cbin & 0x80)) {
+				hdlc->state = HDLC_GETFLAG_B1A6;
+				hdlc->hdlc_bits1 = 0;
+			} else {
+				if(!hdlc->do_adapt56){
+					if(++hdlc->hdlc_bits1 >=8 ) if(hdlc->bit_shift==1)
+						hdlc->state = HDLC_FAST_IDLE;
+				}
+			}
+			hdlc->cbin<<=1;
+			hdlc->bit_shift --;
+			break;
+		case HDLC_GETFLAG_B1A6:
+			if(hdlc->cbin & 0x80){
+				hdlc->hdlc_bits1++;
+				if(hdlc->hdlc_bits1==6){
+					hdlc->state = HDLC_GETFLAG_B7;
+				}
+			} else {
+				hdlc->hdlc_bits1 = 0;
+			}
+			hdlc->cbin<<=1;
+			hdlc->bit_shift --;
+			break;
+		case HDLC_GETFLAG_B7:
+			if(hdlc->cbin & 0x80) {
+				hdlc->state = HDLC_GET_FLAG_B0;
+			} else {
+				hdlc->state = HDLC_GET_DATA;
+				hdlc->crc = 0xffff;
+				hdlc->shift_reg = 0;
+				hdlc->hdlc_bits1 = 0;
+				hdlc->data_bits = 0;
+				hdlc->data_received = 0;
+			}
+			hdlc->cbin<<=1;
+			hdlc->bit_shift --;
+			break;
+		case HDLC_GET_DATA:
+			if(hdlc->cbin & 0x80){
+				hdlc->hdlc_bits1++;
+				switch(hdlc->hdlc_bits1){
+				case 6:
+					break;
+				case 7:
+					if(hdlc->data_received) {
+						// bad frame
+						status = -HDLC_FRAMING_ERROR;
+					}
+					if(!hdlc->do_adapt56){
+						if(hdlc->cbin==fast_abort[hdlc->bit_shift+1]){
+							hdlc->state = HDLC_FAST_IDLE;
+							hdlc->bit_shift=1;
+							break;
+						}
+					} else {
+						hdlc->state = HDLC_GET_FLAG_B0;
+					}
+					break;
+				default:
+					hdlc->shift_reg>>=1;
+					hdlc->shift_reg |= 0x80;
+					hdlc->data_bits++;
+					break;
+				}
+			} else {
+				switch(hdlc->hdlc_bits1){
+				case 5:
+					break;
+				case 6:
+					if(hdlc->data_received){
+						if (hdlc->dstpos < 2) {
+							status = -HDLC_FRAMING_ERROR;
+						} else if (hdlc->crc != 0xf0b8){
+							// crc error
+							status = -HDLC_CRC_ERROR;
+						} else {
+							// remove CRC
+							hdlc->dstpos -= 2;
+							// good frame
+							status = hdlc->dstpos;
+						}
+					}
+					hdlc->crc = 0xffff;
+					hdlc->shift_reg = 0;
+					hdlc->data_bits = 0;
+					if(!hdlc->do_adapt56){
+						if(hdlc->cbin==fast_flag[hdlc->bit_shift]){
+							hdlc->ffvalue = fast_flag_value[hdlc->bit_shift];
+							hdlc->state = HDLC_FAST_FLAG;
+							hdlc->ffbit_shift = hdlc->bit_shift;
+							hdlc->bit_shift = 1;
+						} else {
+							hdlc->state = HDLC_GET_DATA;
+							hdlc->data_received = 0;
+						}
+					} else {
+						hdlc->state = HDLC_GET_DATA;
+						hdlc->data_received = 0;
+					}
+					break;
+				default:
+					hdlc->shift_reg>>=1;
+					hdlc->data_bits++;
+					break;
+				}
+				hdlc->hdlc_bits1 = 0;
+			}
+			if (status) {
+				hdlc->dstpos = 0;
+				*count -= slen;
+				hdlc->cbin <<= 1;
+				hdlc->bit_shift--;
+				return status;
+			}
+			if(hdlc->data_bits==8){
+				unsigned cval;
+				
+				hdlc->data_bits = 0;
+				hdlc->data_received = 1;
+				cval = (hdlc->crc^hdlc->shift_reg) & 0xff;
+				hdlc->crc = (hdlc->crc>>8)^crc16_tab[cval];
+				// good byte received
+				if (dsize--) {
+					dst[hdlc->dstpos++] = hdlc->shift_reg;
+				} else {
+					// frame too long
+					status = -HDLC_LENGTH_ERROR;
+					hdlc->dstpos = 0;
+				}
+			}
+			hdlc->cbin <<= 1;
+			hdlc->bit_shift--;
+			break;
+		case HDLC_FAST_FLAG:
+			if(hdlc->cbin==hdlc->ffvalue){
+				hdlc->bit_shift = 0;
+				break;
+			} else {
+				if(hdlc->cbin == 0xff){
+					hdlc->state = HDLC_FAST_IDLE;
+					hdlc->bit_shift=0;
+				} else if(hdlc->ffbit_shift==8){
+					hdlc->state = HDLC_GETFLAG_B7;
+					break;
+				} else {
+					hdlc->shift_reg = fast_abort[hdlc->ffbit_shift-1];
+					hdlc->hdlc_bits1 = hdlc->ffbit_shift-2;
+					if(hdlc->hdlc_bits1<0)hdlc->hdlc_bits1 = 0;
+					hdlc->data_bits = hdlc->ffbit_shift-1;
+					hdlc->state = HDLC_GET_DATA;
+					hdlc->data_received = 0;
+				}
+			}
+			break;
+		default:
+			break;
+		}
+	}
+	*count -= slen;
+	return 0;
+}
+
+/*
+  hdlc_encode - encodes HDLC frames to a transparent bit stream.
+
+  The bit stream starts with a beginning flag (01111110). After
+  that each byte is added to the bit stream with bit stuffing added
+  (0 after 5 1's).
+  When the last byte has been removed from the source buffer, the
+  CRC (2 bytes is added) and the frame terminates with the ending flag.
+  For the dchannel, the idle character (all 1's) is also added at the end.
+  If this function is called with empty source buffer (slen=0), flags or
+  idle character will be generated.
+ 
+  src - source buffer
+  slen - source buffer length
+  count - number of bytes removed (encoded) from source buffer
+  dst _ destination buffer
+  dsize - destination buffer size
+  returns - number of encoded bytes in the destination buffer
+*/
+int hdlc_encode(struct hdlc_vars *hdlc, const unsigned char *src, 
+		unsigned short slen, int *count,
+		unsigned char *dst, int dsize)
+{
+	static const unsigned char xfast_flag_value[] = {
+		0x7e,0x3f,0x9f,0xcf,0xe7,0xf3,0xf9,0xfc,0x7e
+	};
+
+	int len = 0;
+
+	*count = slen;
+
+	while (dsize > 0) {
+		if(hdlc->bit_shift==0){	
+			if(slen && !hdlc->do_closing){
+				hdlc->shift_reg = *src++;
+				slen--;
+				if (slen == 0) 
+					hdlc->do_closing = 1;  /* closing sequence, CRC + flag(s) */
+				hdlc->bit_shift = 8;
+			} else {
+				if(hdlc->state == HDLC_SEND_DATA){
+					if(hdlc->data_received){
+						hdlc->state = HDLC_SEND_CRC1;
+						hdlc->crc ^= 0xffff;
+						hdlc->bit_shift = 8;
+						hdlc->shift_reg = hdlc->crc & 0xff;
+					} else if(!hdlc->do_adapt56){
+						hdlc->state = HDLC_SEND_FAST_FLAG;
+					} else {
+						hdlc->state = HDLC_SENDFLAG_B0;
+					}
+				}
+			  
+			}
+		}
+
+		switch(hdlc->state){
+		case STOPPED:
+			while (dsize--)
+				*dst++ = 0xff;
+		  
+			return dsize;
+		case HDLC_SEND_FAST_FLAG:
+			hdlc->do_closing = 0;
+			if(slen == 0){
+				*dst++ = hdlc->ffvalue;
+				len++;
+				dsize--;
+				break;
+			}
+			if(hdlc->bit_shift==8){
+				hdlc->cbin = hdlc->ffvalue>>(8-hdlc->data_bits);
+				hdlc->state = HDLC_SEND_DATA;
+				hdlc->crc = 0xffff;
+				hdlc->hdlc_bits1 = 0;
+				hdlc->data_received = 1;
+			}
+			break;
+		case HDLC_SENDFLAG_B0:
+			hdlc->do_closing = 0;
+			hdlc->cbin <<= 1;
+			hdlc->data_bits++;
+			hdlc->hdlc_bits1 = 0;
+			hdlc->state = HDLC_SENDFLAG_B1A6;
+			break;
+		case HDLC_SENDFLAG_B1A6:
+			hdlc->cbin <<= 1;
+			hdlc->data_bits++;
+			hdlc->cbin++;
+			if(++hdlc->hdlc_bits1 == 6)
+				hdlc->state = HDLC_SENDFLAG_B7;
+			break;
+		case HDLC_SENDFLAG_B7:
+			hdlc->cbin <<= 1;
+			hdlc->data_bits++;
+			if(slen == 0){
+				hdlc->state = HDLC_SENDFLAG_B0;
+				break;
+			}
+			if(hdlc->bit_shift==8){
+				hdlc->state = HDLC_SEND_DATA;
+				hdlc->crc = 0xffff;
+				hdlc->hdlc_bits1 = 0;
+				hdlc->data_received = 1;
+			}
+			break;
+		case HDLC_SEND_FIRST_FLAG:
+			hdlc->data_received = 1;
+			if(hdlc->data_bits==8){
+				hdlc->state = HDLC_SEND_DATA;
+				hdlc->crc = 0xffff;
+				hdlc->hdlc_bits1 = 0;
+				break;
+			}
+			hdlc->cbin <<= 1;
+			hdlc->data_bits++;
+			if(hdlc->shift_reg & 0x01)
+				hdlc->cbin++;
+			hdlc->shift_reg >>= 1;
+			hdlc->bit_shift--;
+			if(hdlc->bit_shift==0){
+				hdlc->state = HDLC_SEND_DATA;
+				hdlc->crc = 0xffff;
+				hdlc->hdlc_bits1 = 0;
+			}
+			break;
+		case HDLC_SEND_DATA:
+			hdlc->cbin <<= 1;
+			hdlc->data_bits++;
+			if(hdlc->hdlc_bits1 == 5){
+				hdlc->hdlc_bits1 = 0;
+				break;
+			}
+			if(hdlc->bit_shift==8){
+				unsigned cval;
+
+				cval = (hdlc->crc^hdlc->shift_reg) & 0xff;
+				hdlc->crc = (hdlc->crc>>8)^crc16_tab[cval];
+			}
+			if(hdlc->shift_reg & 0x01){
+				hdlc->hdlc_bits1++;
+				hdlc->cbin++;
+				hdlc->shift_reg >>= 1;
+				hdlc->bit_shift--;
+			} else {
+				hdlc->hdlc_bits1 = 0;
+				hdlc->shift_reg >>= 1;
+				hdlc->bit_shift--;
+			}
+			break;
+		case HDLC_SEND_CRC1:
+			hdlc->cbin <<= 1;
+			hdlc->data_bits++;
+			if(hdlc->hdlc_bits1 == 5){
+				hdlc->hdlc_bits1 = 0;
+				break;
+			}
+			if(hdlc->shift_reg & 0x01){
+				hdlc->hdlc_bits1++;
+				hdlc->cbin++;
+				hdlc->shift_reg >>= 1;
+				hdlc->bit_shift--;
+			} else {
+				hdlc->hdlc_bits1 = 0;
+				hdlc->shift_reg >>= 1;
+				hdlc->bit_shift--;
+			}
+			if(hdlc->bit_shift==0){
+				hdlc->shift_reg = (hdlc->crc >> 8);
+				hdlc->state = HDLC_SEND_CRC2;
+				hdlc->bit_shift = 8;
+			}
+			break;
+		case HDLC_SEND_CRC2:
+			hdlc->cbin <<= 1;
+			hdlc->data_bits++;
+			if(hdlc->hdlc_bits1 == 5){
+				hdlc->hdlc_bits1 = 0;
+				break;
+			}
+			if(hdlc->shift_reg & 0x01){
+				hdlc->hdlc_bits1++;
+				hdlc->cbin++;
+				hdlc->shift_reg >>= 1;
+				hdlc->bit_shift--;
+			} else {
+				hdlc->hdlc_bits1 = 0;
+				hdlc->shift_reg >>= 1;
+				hdlc->bit_shift--;
+			}
+			if(hdlc->bit_shift==0){
+				hdlc->shift_reg = 0x7e;
+				hdlc->state = HDLC_SEND_CLOSING_FLAG;
+				hdlc->bit_shift = 8;
+			}
+			break;
+		case HDLC_SEND_CLOSING_FLAG:
+			hdlc->cbin <<= 1;
+			hdlc->data_bits++;
+			if(hdlc->hdlc_bits1 == 5){
+				hdlc->hdlc_bits1 = 0;
+				break;
+			}
+			if(hdlc->shift_reg & 0x01){
+				hdlc->cbin++;
+			}
+			hdlc->shift_reg >>= 1;
+			hdlc->bit_shift--;
+			if(hdlc->bit_shift==0){
+				hdlc->ffvalue = xfast_flag_value[hdlc->data_bits];
+				if(hdlc->dchannel){
+					hdlc->ffvalue = 0x7e;
+					hdlc->state = HDLC_SEND_IDLE1;
+					hdlc->bit_shift = 8-hdlc->data_bits;
+					if(hdlc->bit_shift==0)
+						hdlc->state = HDLC_SEND_FAST_IDLE;
+				} else {
+					if(!hdlc->do_adapt56){
+						hdlc->state = HDLC_SEND_FAST_FLAG;
+						hdlc->data_received = 0;
+					} else {
+						hdlc->state = HDLC_SENDFLAG_B0;
+						hdlc->data_received = 0;
+					}
+					// Finished with this frame, send flags
+					if (dsize > 1) dsize = 1; 
+				}
+			}
+			break;
+		case HDLC_SEND_IDLE1:
+			hdlc->do_closing = 0;
+			hdlc->cbin <<= 1;
+			hdlc->cbin++;
+			hdlc->data_bits++;
+			hdlc->bit_shift--;
+			if(hdlc->bit_shift==0){
+				hdlc->state = HDLC_SEND_FAST_IDLE;
+				hdlc->bit_shift = 0;
+			}
+			break;
+		case HDLC_SEND_FAST_IDLE:
+			hdlc->do_closing = 0;
+			hdlc->cbin = 0xff;
+			hdlc->data_bits = 8;
+			if(hdlc->bit_shift == 8){
+				hdlc->cbin = 0x7e;
+				hdlc->state = HDLC_SEND_FIRST_FLAG;
+			} else {
+				*dst++ = hdlc->cbin;
+				hdlc->bit_shift = hdlc->data_bits = 0;
+				len++;
+				dsize = 0;
+			}
+			break;
+		default:
+			break;
+		}
+		if(hdlc->do_adapt56){
+			if(hdlc->data_bits==7){
+				hdlc->cbin <<= 1;
+				hdlc->cbin++;
+				hdlc->data_bits++;
+			}
+		}
+		if(hdlc->data_bits==8){
+			*dst++ = hdlc->cbin;
+			hdlc->data_bits = 0;
+			len++;
+			dsize--;
+		}
+	}
+	*count -= slen;
+
+	return len;
+}
+
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/hisax/st5481_hdlc.h linux/drivers/isdn/hisax/st5481_hdlc.h
--- v2.4.9/linux/drivers/isdn/hisax/st5481_hdlc.h	Wed Dec 31 16:00:00 1969
+++ linux/drivers/isdn/hisax/st5481_hdlc.h	Sun Sep  9 10:45:43 2001
@@ -0,0 +1,62 @@
+/*
+ * Driver for ST5481 USB ISDN modem
+ *
+ * Author       Frode Isaksen
+ * Copyright    2001 by Frode Isaksen      <fisaksen@bewan.com>
+ *              2001 by Kai Germaschewski  <kai.germaschewski@gmx.de>
+ * 
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
+ *
+ */
+
+#ifndef __ST5481_HDLC_H__
+#define __ST5481_HDLC_H__
+
+struct hdlc_vars {
+  	int bit_shift; 
+	int hdlc_bits1;
+	int data_bits;
+	int ffbit_shift; // encoding only
+	int state;
+	int dstpos;
+
+	int data_received:1; // set if transferring data
+	int dchannel:1; // set if D channel (send idle instead of flags)
+	int do_adapt56:1; // set if 56K adaptation
+        int do_closing:1; // set if in closing phase (need to send CRC + flag
+
+	unsigned short crc;
+
+	unsigned char cbin; 
+	unsigned char shift_reg;
+	unsigned char ffvalue;
+	
+};
+
+
+/*
+  The return value from hdlc_decode is
+  the frame length, 0 if no complete frame was decoded,
+  or a negative error number
+*/
+
+#define HDLC_FRAMING_ERROR     1
+#define HDLC_CRC_ERROR         2
+#define HDLC_LENGTH_ERROR      3
+
+void 
+hdlc_rcv_init(struct hdlc_vars *hdlc, int do_adapt56);
+
+int
+hdlc_decode(struct hdlc_vars *hdlc, const unsigned char *src, int slen,int *count, 
+	    unsigned char *dst, int dsize);
+
+void 
+hdlc_out_init(struct hdlc_vars *hdlc,int is_d_channel,int do_adapt56);
+
+int 
+hdlc_encode(struct hdlc_vars *hdlc,const unsigned char *src,unsigned short slen,int *count,
+	    unsigned char *dst,int dsize);
+
+#endif
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/hisax/st5481_init.c linux/drivers/isdn/hisax/st5481_init.c
--- v2.4.9/linux/drivers/isdn/hisax/st5481_init.c	Wed Dec 31 16:00:00 1969
+++ linux/drivers/isdn/hisax/st5481_init.c	Sun Sep  9 10:45:43 2001
@@ -0,0 +1,215 @@
+/*
+ * Driver for ST5481 USB ISDN modem
+ *
+ * Author       Frode Isaksen
+ * Copyright    2001 by Frode Isaksen      <fisaksen@bewan.com>
+ *              2001 by Kai Germaschewski  <kai.germaschewski@gmx.de>
+ * 
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
+ *
+ */
+
+/* 
+ * TODO:
+ *
+ * b layer1 delay?
+ * hdlc as module
+ * hotplug / unregister issues
+ * mod_inc/dec_use_count
+ * unify parts of d/b channel usb handling
+ * file header
+ * avoid copy to isoc buffer?
+ * improve usb delay?
+ * merge l1 state machines?
+ * clean up debug
+ */
+
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/usb.h>
+#include <linux/slab.h>
+#include "st5481.h"
+
+MODULE_AUTHOR("Frode Isaksen <fisaksen@bewan.com>");
+MODULE_DESCRIPTION("ST5481 USB ISDN modem driver");
+
+static int protocol = 2;       /* EURO-ISDN Default */
+MODULE_PARM(protocol, "i");
+
+static int number_of_leds = 2;       /* 2 LEDs on the adpater default */
+MODULE_PARM(number_of_leds, "i");
+
+#ifdef CONFIG_HISAX_DEBUG
+static int debug = 0x1;
+MODULE_PARM(debug, "i");
+int st5481_debug;
+#endif
+
+static LIST_HEAD(adapter_list);
+
+/* ======================================================================
+ * registration/deregistration with the USB layer
+ */
+
+/*
+ * This function will be called when the adapter is plugged
+ * into the USB bus.
+ */
+static void * __devinit probe_st5481(struct usb_device *dev,
+				     unsigned int ifnum,
+				     const struct usb_device_id *id)
+{
+	struct st5481_adapter *adapter;
+	struct hisax_b_if *b_if[2];
+	int retval, i;
+
+	printk(KERN_INFO "st541: found adapter VendorId %04x, ProductId %04x, LEDs %d\n",
+	     dev->descriptor.idVendor, dev->descriptor.idProduct,
+	     number_of_leds);
+
+	adapter = kmalloc(sizeof(struct st5481_adapter), GFP_KERNEL);
+	if (!adapter)
+		return NULL;
+
+	memset(adapter, 0, sizeof(struct st5481_adapter));
+
+	adapter->number_of_leds = number_of_leds;
+	adapter->usb_dev = dev;
+
+	SET_MODULE_OWNER(&adapter->hisax_d_if);
+	adapter->hisax_d_if.ifc.priv = adapter;
+	adapter->hisax_d_if.ifc.l2l1 = st5481_d_l2l1;
+
+	for (i = 0; i < 2; i++) {
+		adapter->bcs[i].adapter = adapter;
+		adapter->bcs[i].channel = i;
+		adapter->bcs[i].b_if.ifc.priv = &adapter->bcs[i];
+		adapter->bcs[i].b_if.ifc.l2l1 = st5481_b_l2l1;
+	}
+	list_add(&adapter->list, &adapter_list);
+
+	retval = st5481_setup_usb(adapter);
+	if (retval < 0)
+		goto err;
+
+	retval = st5481_setup_d(adapter);
+	if (retval < 0)
+		goto err_usb;
+
+	retval = st5481_setup_b(&adapter->bcs[0]);
+	if (retval < 0)
+		goto err_d;
+
+	retval = st5481_setup_b(&adapter->bcs[1]);
+	if (retval < 0)
+		goto err_b;
+
+	for (i = 0; i < 2; i++)
+		b_if[i] = &adapter->bcs[i].b_if;
+
+	hisax_register(&adapter->hisax_d_if, b_if, "st5481_usb", protocol);
+	st5481_start(adapter);
+
+	return adapter;
+
+ err_b:
+	st5481_release_b(&adapter->bcs[0]);
+ err_d:
+	st5481_release_d(adapter);
+ err_usb:
+	st5481_release_usb(adapter);
+ err:
+	return NULL;
+}
+
+/*
+ * This function will be called when the adapter is removed
+ * from the USB bus.
+ */
+static void __devexit disconnect_st5481(struct usb_device *dev, void *arg)
+{
+	struct st5481_adapter *adapter = arg;
+
+	DBG(1,"");
+
+	list_del(&adapter->list);
+
+	st5481_stop(adapter);
+	st5481_release_b(&adapter->bcs[1]);
+	st5481_release_b(&adapter->bcs[0]);
+	st5481_release_d(adapter);
+	// we would actually better wait for completion of outstanding urbs
+	mdelay(2);
+	st5481_release_usb(adapter);
+
+	hisax_unregister(&adapter->hisax_d_if);
+
+	kfree(adapter);
+}
+
+/*
+ * The last 4 bits in the Product Id is set with 4 pins on the chip.
+ */
+static struct usb_device_id st5481_ids[] = {
+	{ USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x0) },
+	{ USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x1) },
+	{ USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x2) },
+	{ USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x3) },
+	{ USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x4) },
+	{ USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x5) },
+	{ USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x6) },
+	{ USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x7) },
+	{ USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x8) },
+	{ USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x9) },
+	{ USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0xA) },
+	{ USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0xB) },
+	{ USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0xC) },
+	{ USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0xD) },
+	{ USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0xE) },
+	{ USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0xF) },
+	{ }
+};
+MODULE_DEVICE_TABLE (usb, st5481_ids);
+
+static struct usb_driver st5481_usb_driver = {
+	name: "st5481_usb",
+	probe: probe_st5481,
+	disconnect: disconnect_st5481,
+	id_table: st5481_ids,
+};
+
+static int __init st5481_usb_init(void)
+{
+	int retval;
+
+#ifdef CONFIG_HISAX_DEBUG
+	st5481_debug = debug;
+#endif
+
+	printk(KERN_INFO "hiax_st5481: ST5481 USB ISDN driver v0.1.0\n");
+
+	retval = st5481_d_init();
+	if (retval < 0)
+		goto out;
+
+	retval = usb_register(&st5481_usb_driver);
+	if (retval < 0)
+		goto out_d_exit;
+
+	return 0;
+
+ out_d_exit:
+	st5481_d_exit();
+ out:
+	return retval;
+}
+
+static void __exit st5481_usb_exit(void)
+{
+	usb_deregister(&st5481_usb_driver);
+}
+
+module_init(st5481_usb_init);
+module_exit(st5481_usb_exit);
diff -u --recursive --new-file v2.4.9/linux/drivers/isdn/hisax/st5481_usb.c linux/drivers/isdn/hisax/st5481_usb.c
--- v2.4.9/linux/drivers/isdn/hisax/st5481_usb.c	Wed Dec 31 16:00:00 1969
+++ linux/drivers/isdn/hisax/st5481_usb.c	Sun Sep  9 10:45:43 2001
@@ -0,0 +1,639 @@
+/*
+ * Driver for ST5481 USB ISDN modem
+ *
+ * Author       Frode Isaksen
+ * Copyright    2001 by Frode Isaksen      <fisaksen@bewan.com>
+ *              2001 by Kai Germaschewski  <kai.germaschewski@gmx.de>
+ * 
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
+ *
+ */
+
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/usb.h>
+#include <linux/slab.h>
+#include "st5481.h"
+
+/* ======================================================================
+ * control pipe
+ */
+
+/*
+ * Send the next endpoint 0 request stored in the FIFO.
+ * Called either by the completion or by usb_ctrl_msg.
+ */
+static void usb_next_ctrl_msg(struct urb *urb,
+			      struct st5481_adapter *adapter)
+{
+	struct st5481_ctrl *ctrl = &adapter->ctrl;
+	int r_index;
+
+	if (test_and_set_bit(0, &ctrl->busy)) {
+		return;
+	}
+
+	if ((r_index = fifo_remove(&ctrl->msg_fifo.f)) < 0) {
+		test_and_clear_bit(0,&ctrl->busy);
+		return;
+	} 
+	urb->setup_packet = 
+		(unsigned char *)&ctrl->msg_fifo.data[r_index];
+	
+	DBG(1,"request=0x%02x,value=0x%04x,index=%x",
+	    ((struct ctrl_msg *)urb->setup_packet)->dr.request,
+	    ((struct ctrl_msg *)urb->setup_packet)->dr.value,
+	    ((struct ctrl_msg *)urb->setup_packet)->dr.index);
+
+	// Prepare the URB
+	urb->dev = adapter->usb_dev;
+
+	SUBMIT_URB(urb);
+}
+
+/*
+ * Asynchronous endpoint 0 request (async version of usb_control_msg).
+ * The request will be queued up in a FIFO if the endpoint is busy.
+ */
+void usb_ctrl_msg(struct st5481_adapter *adapter,
+		  u8 request, u8 requesttype, u16 value, u16 index,
+		  ctrl_complete_t complete, void *context)
+{
+	struct st5481_ctrl *ctrl = &adapter->ctrl;
+	int w_index;
+	struct ctrl_msg *ctrl_msg;
+	
+	if ((w_index = fifo_add(&ctrl->msg_fifo.f)) < 0) {
+		WARN("control msg FIFO full");
+		return;
+	}
+	ctrl_msg = &ctrl->msg_fifo.data[w_index]; 
+   
+	ctrl_msg->dr.requesttype = requesttype;
+	ctrl_msg->dr.request = request;
+	ctrl_msg->dr.value = cpu_to_le16p(&value);
+	ctrl_msg->dr.index = cpu_to_le16p(&index);
+	ctrl_msg->dr.length = 0;
+	ctrl_msg->complete = complete;
+	ctrl_msg->context = context;
+
+	usb_next_ctrl_msg(ctrl->urb, adapter);
+}
+
+/*
+ * Asynchronous endpoint 0 device request.
+ */
+void st5481_usb_device_ctrl_msg(struct st5481_adapter *adapter,
+			 u8 request, u16 value,
+			 ctrl_complete_t complete, void *context)
+{
+	usb_ctrl_msg(adapter, request, 
+		     USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 
+		     value, 0, complete, context);
+}
+
+/*
+ * Asynchronous pipe reset (async version of usb_clear_halt).
+ */
+void st5481_usb_pipe_reset(struct st5481_adapter *adapter,
+		    u_char pipe,
+		    ctrl_complete_t complete, void *context)
+{
+	DBG(1,"pipe=%02x",pipe);
+
+	usb_ctrl_msg(adapter,
+		     USB_REQ_CLEAR_FEATURE, USB_DIR_OUT | USB_RECIP_ENDPOINT,
+		     0, pipe, complete, context);
+}
+
+
+/*
+  Physical level functions
+*/
+
+void st5481_ph_command(struct st5481_adapter *adapter, unsigned int command)
+{
+	DBG(8,"command=%s", ST5481_CMD_string(command));
+
+	st5481_usb_device_ctrl_msg(adapter, TXCI, command, NULL, NULL);
+}
+
+/*
+ * The request on endpoint 0 has completed.
+ * Call the user provided completion routine and try
+ * to send the next request.
+ */
+static void usb_ctrl_complete(struct urb *urb)
+{
+	struct st5481_adapter *adapter = urb->context;
+	struct st5481_ctrl *ctrl = &adapter->ctrl;
+	struct ctrl_msg *ctrl_msg;
+	
+	if (urb->status < 0) {
+		if (urb->status != USB_ST_URB_KILLED) {
+			WARN("urb status %d",urb->status);
+		} else {
+			DBG(1,"urb killed");
+			return; // Give up
+		}
+	}
+
+	ctrl_msg = (struct ctrl_msg *)urb->setup_packet;
+	
+	if (ctrl_msg->dr.request == USB_REQ_CLEAR_FEATURE) {
+	        /* Special case handling for pipe reset */
+		le16_to_cpus(&ctrl_msg->dr.index);
+		usb_endpoint_running(adapter->usb_dev,
+				     ctrl_msg->dr.index & ~USB_DIR_IN, 
+				     (ctrl_msg->dr.index & USB_DIR_IN) == 0);
+
+		/* toggle is reset on clear */
+		usb_settoggle(adapter->usb_dev, 
+			      ctrl_msg->dr.index & ~USB_DIR_IN, 
+			      (ctrl_msg->dr.index & USB_DIR_IN) == 0,
+			      0);
+
+
+	}
+	
+	if (ctrl_msg->complete)
+		ctrl_msg->complete(ctrl_msg->context);
+
+	clear_bit(0, &ctrl->busy);
+	
+	// Try to send next control message
+	usb_next_ctrl_msg(urb, adapter);
+	return;
+}
+
+/* ======================================================================
+ * interrupt pipe
+ */
+
+/*
+ * The interrupt endpoint will be called when any
+ * of the 6 registers changes state (depending on masks).
+ * Decode the register values and schedule a private event.
+ * Called at interrupt.
+ */
+static void usb_int_complete(struct urb *urb)
+{
+	u_char *data = urb->transfer_buffer;
+	u_char irqbyte;
+	struct st5481_adapter *adapter = urb->context;
+	int j;
+
+	if (urb->status < 0) {
+		if (urb->status != USB_ST_URB_KILLED) {
+			WARN("urb status %d",urb->status);
+			urb->actual_length = 0;
+		} else {
+			DBG(1,"urb killed");
+			return; // Give up
+		}
+	}
+	
+	DBG_PACKET(1, data, INT_PKT_SIZE);
+		
+	if (urb->actual_length == 0) {
+		return;
+	}
+
+	irqbyte = data[MPINT];
+	if (irqbyte & DEN_INT)
+		FsmEvent(&adapter->d_out.fsm, EV_DOUT_DEN, NULL);
+
+	if (irqbyte & DCOLL_INT)
+		FsmEvent(&adapter->d_out.fsm, EV_DOUT_COLL, NULL);
+
+	irqbyte = data[FFINT_D];
+	if (irqbyte & OUT_UNDERRUN)
+		FsmEvent(&adapter->d_out.fsm, EV_DOUT_UNDERRUN, NULL);
+
+	if (irqbyte & OUT_DOWN)
+;//		printk("OUT_DOWN\n");
+
+	irqbyte = data[MPINT];
+	if (irqbyte & RXCI_INT)
+		FsmEvent(&adapter->l1m, data[CCIST] & 0x0f, NULL);
+
+	for (j = 0; j < 2; j++)
+		adapter->bcs[j].b_out.flow_event |= data[FFINT_B1 + j];
+
+	urb->actual_length = 0;
+}
+
+/* ======================================================================
+ * initialization
+ */
+
+int __devinit st5481_setup_usb(struct st5481_adapter *adapter)
+{
+	struct usb_device *dev = adapter->usb_dev;
+	struct st5481_ctrl *ctrl = &adapter->ctrl;
+	struct st5481_intr *intr = &adapter->intr;
+	struct usb_interface_descriptor *altsetting;
+	struct usb_endpoint_descriptor *endpoint;
+	int status;
+	urb_t *urb;
+	u_char *buf;
+	
+	DBG(1,"");
+	
+	if ((status = usb_set_configuration (dev,dev->config[0].bConfigurationValue)) < 0) {
+		WARN("set_configuration failed,status=%d",status);
+		return status;
+	}
+
+	
+	altsetting = &(dev->config->interface[0].altsetting[3]);	
+
+	// Check if the config is sane
+	if ( altsetting->bNumEndpoints != 7 ) {
+		WARN("expecting 7 got %d endpoints!", altsetting->bNumEndpoints);
+		return -EINVAL;
+	}
+
+	// The descriptor is wrong for some early samples of the ST5481 chip
+	altsetting->endpoint[3].wMaxPacketSize = 32;
+	altsetting->endpoint[4].wMaxPacketSize = 32;
+
+	// Use alternative setting 3 on interface 0 to have 2B+D
+	if ((status = usb_set_interface (dev, 0, 3)) < 0) {
+		WARN("usb_set_interface failed,status=%d",status);
+		return status;
+	}
+
+	// Allocate URB for control endpoint
+	urb = usb_alloc_urb(0);
+	if (!urb) {
+		return -ENOMEM;
+	}
+	ctrl->urb = urb;
+	
+	// Fill the control URB
+	FILL_CONTROL_URB (urb, dev, 
+			  usb_sndctrlpipe(dev, 0),
+			  NULL, NULL, 0, usb_ctrl_complete, adapter);
+
+		
+	fifo_init(&ctrl->msg_fifo.f, ARRAY_SIZE(ctrl->msg_fifo.data));
+
+	// Allocate URBs and buffers for interrupt endpoint
+	urb = usb_alloc_urb(0);
+	if (!urb) { 
+		return -ENOMEM;
+	}
+	intr->urb = urb;
+	
+	buf = kmalloc(INT_PKT_SIZE, GFP_KERNEL);
+	if (!buf) {
+		return -ENOMEM;
+	}
+
+	endpoint = &altsetting->endpoint[EP_INT-1];
+				
+	// Fill the interrupt URB
+	FILL_INT_URB(urb, dev,
+		     usb_rcvintpipe(dev, endpoint->bEndpointAddress),
+		     buf, INT_PKT_SIZE,
+		     usb_int_complete, adapter,
+		     endpoint->bInterval);
+		
+	return 0;
+}
+
+/*
+ * Release buffers and URBs for the interrupt and control
+ * endpoint.
+ */
+void __devexit st5481_release_usb(struct st5481_adapter *adapter)
+{
+	struct st5481_intr *intr = &adapter->intr;
+	struct st5481_ctrl *ctrl = &adapter->ctrl;
+
+	DBG(1,"");
+
+	// Stop and free Control and Interrupt URBs
+	usb_unlink_urb(ctrl->urb);
+	if (ctrl->urb->transfer_buffer)
+		kfree(ctrl->urb->transfer_buffer);
+	usb_free_urb(ctrl->urb);
+
+	usb_unlink_urb(intr->urb);
+	if (intr->urb->transfer_buffer)
+		kfree(intr->urb->transfer_buffer);
+	usb_free_urb(intr->urb);
+}
+
+/*
+ *  Initialize the adapter.
+ */
+void __devinit st5481_start(struct st5481_adapter *adapter)
+{
+	static const u8 init_cmd_table[]={
+		SET_DEFAULT,0,
+		STT,0,
+		SDA_MIN,0x0d,
+		SDA_MAX,0x29,
+		SDELAY_VALUE,0x14,
+		GPIO_DIR,0x01,		
+		GPIO_OUT,RED_LED,
+//		FFCTRL_OUT_D,4,
+//		FFCTRH_OUT_D,12,
+		FFCTRL_OUT_B1,6,
+		FFCTRH_OUT_B1,20,
+		FFCTRL_OUT_B2,6,
+		FFCTRH_OUT_B2,20,
+		MPMSK,RXCI_INT+DEN_INT+DCOLL_INT,
+		0
+	};	
+	struct st5481_intr *intr = &adapter->intr;
+	int i = 0;
+	u8 request,value;
+
+	DBG(8,"");
+
+	adapter->leds = RED_LED; 
+
+	// Start receiving on the interrupt endpoint
+	SUBMIT_URB(intr->urb); 
+
+	while ((request = init_cmd_table[i++])) {
+		value = init_cmd_table[i++];
+		st5481_usb_device_ctrl_msg(adapter, request, value, NULL, NULL);
+	}
+	st5481_ph_command(adapter, ST5481_CMD_PUP);
+}
+
+/*
+ * Reset the adapter to default values.
+ */
+void __devexit st5481_stop(struct st5481_adapter *adapter)
+{
+	DBG(8,"");
+
+	st5481_usb_device_ctrl_msg(adapter, SET_DEFAULT, 0, NULL, NULL);
+}
+
+/* ======================================================================
+ * isochronous USB  helpers
+ */
+
+static void __devinit
+fill_isoc_urb(struct urb *urb, struct usb_device *dev,
+	      unsigned int pipe, void *buf, int num_packets, 
+	      int packet_size, usb_complete_t complete,
+	      -	if (count <i2c-adap-ite_msg(adapterned int counus = usb_set_configuration (dev,dev->c);
+	if msg(adapterned ined int counus = u4b_set_co.xiguration (dev,dev->c);
+	if msg(adapterned ined int counu	 = u4y? */
+	is idle.  After ado_adaft56:1; // set if 56K adaptcnion
}_M-----------daptcnion---------------7 @@
 	  ft5MIT_URB(intr->urb); 
+
+	while ((reque>urb->t(0x5f,QD_CONTter *adif (count     CONr *adif (count    *)(bus_to_bad6b46 (count    *)onst message
+	usb_next_ctrl_msg(urb, adapter);
+	rph_com32 (MACEPCI_ERROR(count    *)onst mnnel = st->T := $(shell md5su  eithds;
+	stransmix", EP_D_OUT, buf
- *ransmix",adif (count  *ra
 }
 
 
@@ -2253,28 +2  <> OUT_D_COUn---------------7 @@gisters & ini800x04U /* B2 channel out */
+#define EPi800x04U /* B2 channel		FFCTRL_OUT_D,4,
+//		FFCTRH_OUT_D,12,
+		FFCTer, the
+SD_INT      FFCTer, the FFCTer,-16K adaptcnif  /* I2C_ITE_H reg >>= 1;
+_DOWN)
+;//NULL);
+
+	fo;
+_DOWN)
+;//NULL);
+r)
+		kfree(intr->ueb->transfer_buffer);
+	dsb_free_urb(intr->urb);
+}
+
+/*
+ *  Initialize the adapter.
+(6/
+void __devinit st5481_start(struct st5481_adapter *cdapter)EEN_LED;
ENDOR_ID, ST5481_PROD* This allows the);
+	dsb_free_urb(intr->urb);
+}
+
+/*tate *cs)
+{
+	strunux/drivers/char/joystick/gameport.c
--- v2.4.9/linux/drivers/char/joystick/gameport.c	Fri Feb  9 11:30:23 2001
+++ linux/drivers/char/joystick/gameport.c	Wed Sep 12 15:34: B_RCVBUFREADY 0
 #def5 eb_free_ur6+			}
+			elkb);
+				
+/* 		issue command\n");rq
 
-sta5481_adapter *adapter = fsm->userdata;h>
+#inclu*
+  hdlc_do long
+					status =  NULL, NULL);
+	FsmChangeState(&d_out->fsm, ST 19:44:23 kai Exp $
  7xt frame.
+ */
+pshw.b_if;
+
+	s*dev,
+	     3ewakSun Sep  9 10:45:43 2001
@@ -0';
+		actr++;
+	}
+	ifed long",status);
--recursive --newai Exp $
  7fed55Ae --newai Exp $
  7fed55Ae --newai (256<<20, 256<<20, BOOT_MEM_ee(intr->ue<<20, BOOT_MEM_ee(intr->de)<20, BOOT_MEM_ee(intr->de------+
+//tr->de)<20, BOOT_MEM_ee(intr->de------+
+//tr-> l1 state machine_complete, adaptertatic void hisax_bc_clall a3d_init);
 module#ifndef _2CFDR);
+				buf[rdcounturation (dev,dev->c)+++ linee_urb(intr->_ee(intr->de--{
+			if (bcs->channel ==+			if (bcs->channellinee_urb(intr->_ee(intr->dewhere);
+void FsmRestartTimer(struct FsmTimeatus);
--recursive --newai Exp $
  7feait f=(intrt st5481_adapter *adaptCONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is ENSE("GPL");
}GDrified) */
-sO_PACKETS_B_OmeporNTER		0x36 /* D receive channel fifo counter */nt retval = 0;
+
+	while (retval < mandt) {
+
+		}t (copy_f.#de, 130, 275 },  /* WDC AC2540			*/1_F6);
+}
+
+static vo *)urb->sint fifo_add(stru.%afifo f the GNU General Publd5,0xa96a,0->dewhere);
+void FsmRchannel		FFCTRL_OUT_D,4,
+//		FFC+			}
+			eatic vo *)urb->si5t fifo_add(stru.%afifo f the 1NU Glneral Publd5,0xa96a,0->dewhere);
+void FsmRchannel		FFCTLC_OUTDD,4,
+//		FFC+			}
+			eatic vo *)urb->si5t fifo_add(stru.%afifo f the 1NU Glneral Publd5,0xa96a,0->dewhere);
+void FsmRöhannel		F‘	_isa.c
--- v2.4.9001
@1_b.c	Wed Dec	ST_DOUT_Lrun */
+intk("azt= hdlc_encode--- v2.4.9001+481_ctrl NULL;
+				B_L1L2(bcs, PH_DATA | CONFIRM, (void *) skb->treturn -ENOMEM;
+	}
+	intr->urb = urb;
+	
+	bayd_DOUTloc(INT_PKT_SIZE,2*			if (bcs->channef CONFIG_B \
+        	next = entry->next; \
   	0x20 /* In)PPC | PPCnext; \
   	0x20 /*eot_detecte Place, So *)urb->sint fifoDOUT_LONG_WAIT_DEN,  - v2.4.90ACEPCI_ERROG1        <> OU= -1"EV_DOUT_STOPrequest will be queuedxf687,0xc41c,0xd595,hxa12a,0xb0a3,0x8238,0x93b1,
+	0x6b46,0x7acf,0x4854,0x59dd,0x2d62,0x3ceb,0x0e70,0x1ff9,
+	0xf78f,0xe606,0xd49d,0xc514,0xb1ab,0xa022,0x9>b9,0x8330,
+	0x7bc7,0x6a4e,0x58d5,0x495c,0x3de3,0x2c6}]0x1ef1,0x0f78
+}:
+
+=0
+         apter *ada urb;
+	
+		lc->stat
+}
+
+int DBG(2,"");
board
+	 *  3:_adapter *adapter)
}zn);
+ESS?
+	blu1ab,0xa022,2_shift-1;
+
+	}	hdlc->state = HDLC_GET_DATA;
+					hdlc->data_received = 0;
+					
}			}
+			break;
+		dreceived = 5nt i = 4=
}d n);
+ESS?
+	blfdf+
+	if (!fi
+	}
+	intr->st, int dsize)
+{
 		nt st6C2540			*/	Wed Sep 12 15: = &adapter->intapter->d_out;
}d n);
+ESS?
+			eat-44				hdlc->d1_rel dsi_out;
}d n);
+9tatic vo */isdnl1.c	Ta	if (bcs->cha8:19 2001
+++ linux/drivers/isdn/hisax/isdnl1.c	Sun Se45 9 13+45:43 2001
@@ -1,4 +1,4 @@
-/* $Id: isdnl1.c,v 2.41.6.3 2001/05/26 15:19:57 kai Exp $
+/* $Id: isdnl1.c,v 2.41.6.4 2001/08/23 19:44:23 kai Exp $
  *
  * isdnl1.c     common low level stuff for Siemens Chipsetbased isdn cards
  *              based on the teles driver from A:001/08/23 19:44:23 kai er from A:001/08/23_free_ur6+			}
-= +285,6 @@
 changes fr6taVista Sofc7bc7,0x6a4e={
+		SET_DEFARista Sofc7bnput devicid hisax_b)           END_OFsax_b)        t;
+
+	terned ined int counus = u4b_set_co.xiate_count, event_--- v2.4.9/lin**ate, void *arg)
+{
+iso_packet_deutState[] =,"");
+
+	ada_encode--- e--nges fr6taVista Sn);
+9tatic v
+9tatic v
+9tatic v
+ kai   mplete_tf_nr(struct urb *");
+
+	ada_encodazel;
 		struct w");
+
+	ada_rbs[0]=03rb ? 0 : 15		break;
 
t devicid		  NU          vent, **skb->data, rated
+	 * baon low level stufst on endpoinrl stufst on endpo1
@@ -639,9 +void FsmRcm2a,0xb0a3,0x8238,:19 2001
+++ linux/drive0x04);
-			in         --sm->userdat");
+/* FF: This
+/* $Id: fsm)changes fr6taVist895b = b_out->tx_ level s:= $(shell md5su  eithatus);
+		ret7da_encodaVist895b = b_ree(ctrl+			}
-= +285,6 @E	dsb_free_ur6 +285,6 @,
+		int slen, in       based o*arg)
+{
+isoDE_HDLC_56K 4SI#define L1_MODE_MODEM	7
+#define L1_MODE_V32	}rcedffin6K 4SI#define Lg->dr.index &)Ued_DMBNe L1_SODE_V4bindfin6_out->tx_ l L1_SODE_V4bin1
@@ -6390) {
+		led>;
@@ -1378,long locX, r->st, int dsize)            bevel stuff fort
 CONFIG_Dn6K 4SI#define8T1rnative setting 3from A:001/6K 4SI#defi7+
+static vrt
 CONFIG_Dn6K 4id __attribled when anree_ur6 +285,6 @,1);
+
+	ada_
+static vrtcontrol
+ 
 
t devicid	r6 5
+static vrtcontr4->channel+1)s);
--recursinux/netltmp.len);
-		rfdbe queuedxfcase MOXA_LOAD_CODE:
-		if(cop?_from_user(&dl4mT 2
+#define SIZE vent, **sk_struct st54F__buffer;
+	G_Dn6K 4SI#defin- of 0x00e0,-6,e8T1rnativec);
+	if msg(adaf(cop?_from_user kai Exp $
  *
  ibled when anree_6K 4id __attrib4y? */
+	is ink
+ */
+
+vrial.o
 
 i96<<20, 25d1_rel dsi_tic int   mcd_irqee_6K 4id __a4id (adaf(cop?AD_CODE:
-	->busy);
+ndif /* CONFIG_BLK_< 0) 9Énderrun}+	G_Dn6K 4SI#defi %s not ava
  *
  * isdnl1c vrtcontr4->chan08/23_free_ur1ODE:
-		if(uffers and URBs4ne OUT_D_COE#define SIZ/* D transmiE#define hi_7751se.h:4B_user kai Exp $
-:001/08/23_f¾Æ²k
+ *t);
+void st	is ink
+ */
+msg(ial.8  	if (bcs->mwbd 4id __attr void hisax0xf78f,0xe61* D channel out *ct hdlc_var9 /* CONFIG_BLK_<  4SI#defi7+
 i96<<20, 6 +285,6_PUP		 0x7 /* Power UD
+}
+I_Atatic vo *),Bb->en anree_ur6 =%8Hel+1)s);
--recurs_:_:_rel dsi_ti<S	if(uffers ai Exp $
  ftGive up
+	+)s);
--recu-639,9 +void Fvrtcontrol
+ 1997 Simon G.  hisax0xf78f,0xe61* D channel out *ct hdlc_var9 /* CONFIG_BLK_<  4SI#defi7+
 i96<<20, 6 +285,6_PUP		 0x7 /* Power UD
+}
+I_Atatic vo *),Bb->en anree_ur6 =%8Hel+1)s);
--recurs_:_:
+
 		kill_f